Chandra X-Ray Observatory
Skip to the navigation links
Last modified: December 2015

Jump to: Description · Example · Bugs · See Also

AHELP for CIAO 4.9


Context: crates


Create a virtual column.


create_virtual_column(source, colname, cptnames, transform)


Argument Description
source The CrateData object containing the data to which the transform will be applied.
colname The name of the virtual column.
cptnames A list of the component names, if the source is a vector column (the number of names should match), otherwise None.
transform The transform used to create the virtual column values. It must be one of the support pytransform types: LINEARTransform, LINEAR2DTransform, or WCSTANTransform.

The create_virtual_column command creates a virtual column; that is a column whose values are calculated by applying a transform to an existing column. It can create single or vector columns. See also the create_vector_column command.


>>> cr = TABLECrate()
>>> tf = CrateData()
>>> = 'Tf'
>>> tf.unit = 'deg F'
>>> tf.desc = 'Simulated temperature'
>>> tf.values = np.random.normal(60.1, 12.2, size=10)
>>> from pytransform import LINEARTransform
>>> tr = LINEARTransform()
>>> tr.get_parameter('SCALE').set_value(5/9.0)
>>> tr.get_parameter('OFFSET').set_value(-5*32/9.0)
>>> tc = create_virtual_component(tf, 'Tc', None, tr)
>>> tc.unit = 'deg C'
>>> cr.add_column(tf)
>>> cr.add_column(tc)
>>> cr.write('tbl.fits')

This example shows how to create a 10-row file with a 'Tf' column - in degrees Farenheit - and an associated virtual column 'Tc', in degrees Centigrade. For example:

>>> print(tf.values[0:5])
[ 70.37663997 68.14952196 40.58894648 65.96498007 56.25287882]
>>> print(tc.values[0:5])
[ 21.32035554 20.08306776 4.77163694 18.86943337 13.47382157]


See the bug pages on the CIAO website for an up-to-date listing of known bugs.

Refer to the CIAO bug pages for an up-to-date listing of known issues.

See Also

add_col, add_piximg, cratedata, create_vector_column, get_col, get_colvals, get_piximg

Last modified: December 2015
Smithsonian Institute Smithsonian Institute

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