About Chandra Archive Proposer Instruments & Calibration Newsletters Data Analysis HelpDesk Calibration Database NASA Archives & Centers Chandra Science Links

Skip the navigation links
Last modified: 12 December 2008

URL: http://cxc.harvard.edu/chips4.1/concepts/setget.html

Concepts: Set and Get

There are various methods of accessing and modifying attribute values in ChIPS, ranging from general commands to attribute-specific methods. In general, these are known as "set" (modify an attribute value) and "get" (obtain an attribute value) commands. The attributes concept document has general information on configuring object properties and the values document lists the ranges of common attributes, such as color and line style.


General Accessors

The generic set_attribute and get_attribute commands may be used to access attributes of any type of ChIPS object.

The set_attribute command sets one or more attribute values.

# Python
   set_attribute([ChipsId|id], object_type, values)
      
% S-Lang
   set_attribute([ChipsId|id], object_type, values);
      

The routine takes an optional ChipsId structure containing values to modify the currency state for the command. The object_type tells ChIPS what type of object to modify, such as chips_window or chips_curve. The values parameter is a list containing attribute value pairs or an attribute object.

Examples of using set_attribute

# Python
   set_attribute("reg1", chips_region, ["fill.color", "blue"]) 
   set_attribute(chips_label, ["angle", 45, "font", "greek"]) 
      
% S-Lang
   set_attribute("reg1", chips_region, ["fill.color", "blue"]); 
   set_attribute(chips_label, ["angle", 45, "font", "greek"]); 
      

The get_attribute command retrieves the value of a specific attribute. If an attribute is not specified, the values of all attributes of the specified object are returned.

# Python
   get_attribute([ChipsId|id], object_type, [attribute])
      
% S-Lang
   get_attribute([ChipsId|id], object_type, [attribute]);
      

The routine takes an optional ChipsId structure containing values to modify the currency state for the command. The object_type tells ChIPS what type of object to query, such as chips_window or chips_curve. The attribute parameter is a single object attribute from which to obtain the value.

Examples of using get_attribute

# Python
   get_attribute("lbl1", chips_label)
   get_attribute("crv1",chips_curve,"symbol.size")
      
% S-Lang
   get_attribute("lbl1", chips_label);
   get_attribute("crv1",chips_curve,"symbol.size");
      

Object Accessors

Object accessors act on specific ChIPS objects. The function name contains the object_type value.

# Python
   set_window([ChipsId|id] values)
   set_frame([ChipsId|id] values)
   set_plot([ChipsId|id] values)
   set_axis([ChipsId|id] values)
   set_curve([ChipsId|id] values)
   set_contour([ChipsId|id] values)
   set_histogram([ChipsId|id] values)
   set_label([ChipsId|id] values)
   set_line([ChipsId|id] values)
   set_point([ChipsId|id] values)
   set_region([ChipsId|id] values)
      
% S-Lang
   set_window([ChipsId|id] values);
   set_frame([ChipsId|id] values);
   set_plot([ChipsId|id] values);
   set_axis([ChipsId|id] values);
   set_curve([ChipsId|id] values);
   set_contour([ChipsId|id] values);
   set_histogram([ChipsId|id] values);
   set_label([ChipsId|id] values);
   set_line([ChipsId|id] values);
   set_point([ChipsId|id] values);
   set_region([ChipsId|id] values);
      

The get_<object> accessors return all the attribute values of the object type. To retrieve the value of a specific attribute, provide the attribute name and the id or ChipsId of the object.

# Python
   get_window([ChipsId|id [,attribute])
   get_frame([ChipsId|id [,attribute])
   get_plot([ChipsId|id [,attribute])
   get_axis([ChipsId|id [,attribute])
   get_curve([ChipsId|id [,attribute])
   get_contour([ChipsId|id [,attribute])
   get_histogram([ChipsId|id [,attribute])
   get_label([[ChipsId|id [,attribute])
   get_line([ChipsId|id [,attribute])
   get_point([ChipsId|id [,attribute])
   get_region([ChipsId|id [,attribute]])
      
% S-Lang
   get_window([ChipsId|id [,attribute]);
   get_frame([ChipsId|id [,attribute]);
   get_plot([ChipsId|id [,attribute]);
   get_axis([ChipsId|id [,attribute]);
   get_curve([ChipsId|id [,attribute]);
   get_contour([ChipsId|id [,attribute]);
   get_histogram([ChipsId|id [,attribute]);
   get_label([[ChipsId|id [,attribute]);
   get_line([ChipsId|id [,attribute]);
   get_point([ChipsId|id [,attribute]);
   get_region([ChipsId|id [,attribute]]);
      

Examples of using get accessors

# Python
   get_line("line2")
   get_label(None, "font")
      
% S-Lang
   get_line("line2");
   get_label(NULL, "font");
      

Attribute-specific Accessors

[Updated] The module of advanced ChIPS functions contains attribute-specific accessor methods which may be used to retrieve and modify the values of individual object attributes. An accessor exists for every attribute of each ChIPS object; refer to "ahelp chips" for information on loading the module. For example:

# Python
   set_curve_linecolor([ChipsId,] color)
   set_label_font([ChipsId,] font)
   set_histogram_depth([ChipsId,] depth)

   get_axis_tickformat([ChipsId])
   get_window_bgcolor([ChipsId])
   get_axis_color([ChipsId])
      
% S-Lang
   set_curve_linecolor([ChipsId,] color);
   set_label_font([ChipsId,] font);
   set_histogram_depth([ChipsId,] depth);

   get_axis_tickformat([ChipsId]);
   get_window_bgcolor([ChipsId]);
   get_axis_color([ChipsId]);
      

The get routines can only operate on a single object. An error is returned if currency is set to "all".

Examples of using attribute-specific accessors

# Python
   from pychips.advanced import *
   set_curve_linecolor("red")
   set_frame_bgcolor("frm1","8f40af")

   get_axis_major_mode("ax1")
   get_curve_symbolstyle()
      
% S-Lang
   require("chips_advanced");
   set_curve_linecolor("red");
   set_frame_bgcolor("frm1","8f40af");

   get_axis_major_mode("ax1");
   get_curve_symbolstyle();
      
Last modified: 12 December 2008


The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory.
60 Garden Street, Cambridge, MA 02138 USA.    Email: cxcweb@head.cfa.harvard.edu
Smithsonian Institution, Copyright © 1998-2004. All rights reserved.