next up previous contents
Next: Toolbox Up: CFITSIO Table Row Selection Previous: Basic Table Row Selection   Contents

Advanced Table Row Selection

There are three functions that may be used in the algebraic expression that are borrowed from the SAO region filtering syntax. They return a boolean true or false depending on whether a two dimensional point is in the region or not:

``point in a circular region''
circle(xcntr,ycntr,radius,Xcolumn,Ycolumn)
``point in an elliptical region''
ellipse(xcntr,ycntr,xhlf_wdth,yhlf_wdth,rotation,Xcolumn,Ycolumn)
``point in a rectangular region''
box(xcntr,ycntr,xfll_wdth,yfll_wdth,rotation,Xcolumn,Ycolumn)
where
(xcntr,ycntr) are the (x,y) position of the center of the region
(xhlf_wdth,yhlf_wdth) are the (x,y) half widths of the region
(xfll_wdth,yfll_wdth) are the (x,y) full widths of the region
(radius) is half the diameter of the circle
(rotation) is the angle(degrees) that the region is rotated with respect to (xcntr,ycntr)
(Xcoord,Ycoord) are the (x,y) coordinates to test, usually column names
NOTE: each parameter can itself be an expression, not merely a column name or constant.

There is also a function for testing if two data values are close to each other, i.e., if they are ``near'' each other to within a user specified tolerance. The arguments value 1 and value 2 can be integer or real, and represent the two data values whose proximity is being tested to be within the specified tolerance - also integer or real:

near(value_1, value_2, tolerance)
When a NULL, or undefined, value is encountered in the table element, the expression will evaluate to NULL unless the undefined value is not actually required for evaluation, e.g., ``TRUE .or. NULL'' evaluates to TRUE. The following two functions allow some NULL detection and handling: ISNULL(x) and DEFNULL(x,y). The former returns a boolean value of TRUE if the argument x is NULL. The latter defines a value to be substituted for NULL values; it returns the value of x, if x is not NULL, otherwise it returns the value of y.

The following type casting operators are available, where the enclosing parentheses are required and taken from the C language usage. Also, the integer to real casts values to double precision:

"real to integer" (int) x (INT) x
"integer to real" (float) i (FLOAT) i

Bit masks can be used to select out rows from table columns of DAL data type DAL_BIT. To represent the mask, binary, octal, and hex formats are allowed:

binary: b0110xx1010000101xxxx0001
octal: o720x1 -> (b111010000xxx001)
hex: h0FxD -> (b00001111xxxx1101)

In all the representations, an x or X is allowed in the mask as a wild card. Note that the x represents a different number of wild card bits in each representation. All representations are case insensitive.

To construct the boolean expression using the mask as the boolean equal operator described above on a bit table column. For example, if you had a 7 bit table column with name ``FLAGS'' and wanted all rows having the bit pattern 0010011, the selection expression would be:

flags == b0010011
or
flags .eq. b10011

It is also possible to test if a range of bits is less than, less than equal, greater than and greater than equal to a particular boolean value:

flags <= bxxx010xx
flags .gt. bxxx100xx
flags .le. b1xxxxxxx

Notice the use of the x bit value to limit the range of bits being compared. It is not necessary to specify the leading (most significant) zero (0) bits in the mask, as shown in the second expression above. Bit wise AND, OR and NOT operations are also possible on two or more bit fields using the `&' (AND), ` |' (OR), and `!' (NOT) operators. All of these operators result in a bit field which can then be used with the ``equal'' operator. For example:

(!flags) == b1101100
(flags & b1000001) == bx000001

Bit fields can be appended as well using the `+'operator. Strings can be concatenated this way, too.


next up previous contents
Next: Toolbox Up: CFITSIO Table Row Selection Previous: Basic Table Row Selection   Contents
inthelp@sciops.esa.int