Last modified: December 2015

URL: https://cxc.cfa.harvard.edu/ciao/ahelp/create_virtual_column.html
Jump to: Description · Example · Bugs · See Also


AHELP for CIAO 4.15

create_virtual_column

Context: crates

Synopsis

Create a virtual column.

Syntax

create_virtual_column(source, colname, cptnames, transform)

Description

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.


Example

>>> cr = TABLECrate()
>>> tf = CrateData()
>>> tf.name = '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]

Bugs

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

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