|
Description
Description of libpyrap and bindings to casacore libraries.
Featured Introductionpyrap is the python binding to the radio-astronomical casacore package. It consists of 2 parts:
libpyrapAs described in AIPS++ note 259, casacore Array objects are stored in Fortran order. During the conversion to numpy array objects, the array axes are reversed to get C-ordering in python. Although numpy supports Fortran order, that support is only superficial. When, for example, adding 0 to a Fortran array the result is in C-order. It means that a possibly expensive transpose operation is done. See for example the following python code: from numpy import * a=array([[1,2,3],[4,5,6]],order='FORTRAN') a.strides Out[5]: (8, 16) b=a+0 b.strides Out[7]: (24, 8) # transposed!! libpyrap can be used by other packages needing a python binding. pyrap.quantaQuanta are numbers or vectors of numbers with physical units. This binding is different from the glish binding to quanta. In the python binding each quantum is a proper python object, while in glish each quantum resides in the server only. pyrap.measuresMeasures are quanta with a reference frame. The frame tells how, when, and where it was measured.
pyrap.functionalsA binding to the casacore Functionals library supporting N-dimensional arbitrary functions. pyrap.fittingA binding to the casacore Fitting library supporting linear and non-linear fitting using the Levenberg-Marquardt method. pyrap.tablesThis binding is a superset of the glish binding and Harro Verkouter's pycasa binding (http://www.jive.nl/~verkout/pycasa.html). Note that Harro's pycasa does not reverse the Array axes and requires some array resizing to get things right. All glish functions (as described on http://www.astron.nl/aips++/docs/user/Utility/node454.html#table) are available in python with the same function and argument names. It is useful to remark that put functionality is fully supported; for example, a non-contiguous numpy array slice is handled correctly. It has full support of the tableindex, tableiter, tablerow, and the new tablecolumn classes. Furthermore some extra functionality is available to make it really pythonic.
t=table("mytable",readonly=False) # open an existing table for update
tc=tablecolumn(t,'COLNAME'); # create object
mylist=tc[0:10:2]; # get row 0,2,4,6,8 and return in a list
tc[0:10:2]=3; # put 3 in these rows
t.close()Closing the table is not really needed, as the destructor automatically closes the table(and flushes written data if needed). A la python it is possible to give negative values for start and stop (thus counting from the end) and for step (thus reversed order).
tix=tableindex(t,'COLNAME') # form an index on the given column(s) rows=tix[key] # find all rows containing the key value
for tab in tableiter(t,'COLNAME'): Each step in the iteration gives a table object representing a subset of the original table in which the values in the given iteration column(s) are the same. Such a table object references the rows in the original table, thus writing to this subset changes the original table. The glish-python differences are reflected in the versatile Table Query Language (see http://www.astron.nl/aips++/docs/notes/199/199.html). TaQL can have different styles, so it can be used in Glish mode or in Python mode. By default pyrap uses the Python mode. Apart from using 0-base and C-order, this mode also uses a non-inclusive stop value in array indexing (a la python indexing). TaQL does not support negative start,stop,step values though. For example: t1=t.query("ANTENNA1 in [0:6:2]")selects ANTENNA1 0, 2 and 4 (NOT 6 as end is exclusive). Just like the table iterator, it creates a table object which references the rows in the original table. All table functionality is available on this subset. pyrap.imagesA binding the the casacore Images module, the module handling astronomical images. It can:
|