Last modified: December 2015

Jump to: Description · Example · Bugs · See Also

AHELP for CIAO 4.16


Context: crates


Create a vector column.


create_vector_column(colname, cptnames, source=None)


Argument Description
colname The name of the vector column.
cptnames A list of the component names.
source If not None, then the new vector column will be a virtual column for the source column (which should also be a vector column); see also create_virtual_column().

The create_vector_column command creates a vector column, as well as the component vectors, and returns it as a CrateData object. The values attribute of the returned object can be used to set the row values.


>>> cr = TABLECrate()
>>> sky = create_vector_column('sky', ['x', 'y'])
>>> sky.unit = 'pixel'
>>> sky.desc = 'Simulated Sky coordinate'
>>> nrows = 1000
>>> x = np.random.normal(4723.42, 2, size=nrows)
>>> y = np.random.normal(3888.21, 2, size=nrows)
>>> sky.values = np.column_stack((x, y))
>>> cr.add_column(sky)
>>> cr.write('tbl.fits')
>>> cr.write('tbl.dat[opt kernel=text/simple]')

This example shows how to create a 200-row file with a single vector called "sky". The components of "sky" are "x" and "y" and contain random numbers normally distributed around 4723.42 and 3888.21 respectively, both with a standard deviation of 2. The file is written out both as a FITS table (tbl.fits) and an ascii file (tbl.dat).


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_virtual_column, get_col, get_colvals, get_piximg