casa
$Rev:20696$
|
Definition of a Measure column in a Table. More...
#include <TableMeasDesc.h>
Public Member Functions | |
TableMeasDesc (const TableMeasValueDesc &) | |
Constructor with measure value descriptor. | |
TableMeasDesc (const TableMeasValueDesc &, const Vector< Unit > &) | |
Constructor with measure value descriptor and Vector of Units. | |
TableMeasDesc (const TableMeasValueDesc &, const TableMeasRefDesc &) | |
Constructor with value and reference descriptors. | |
TableMeasDesc (const TableMeasValueDesc &, const TableMeasRefDesc &, const Vector< Unit > &) | |
Constructor with value and reference descriptors and Vector of Units. | |
virtual TableMeasDescBase * | clone () const |
Clone the object. | |
TableMeasDesc (const TableMeasDesc< M > &that) | |
Copy constructor (copy semantics). | |
~TableMeasDesc () | |
TableMeasDesc< M > & | operator= (const TableMeasDesc< M > &that) |
Assignment operator (copy semantics) |
Definition of a Measure column in a Table.
Public interface
The TableMeasures system was created to add support for Measure columns to the AIPS++ Table system. Measures are not a fundamental type of the Tables system and hence cannot be represented directly. Instead a Measure column can be created with the aid of the TableMeasDesc class hierarchy. The TableMeasDesc class hierarchy creates a Measure column by associating some number of fundamental data type Table columns into a unit. The associations between these columns is represented in the column keywords of each of the columns which make up a specific Measure column.
Creating and using Measure columns is a three step process:
Defining a Measure column (that is, steps 1 and 2 above) is the more complex operation. However, for each Measure column it is a once only operation. After a Measure column has been created its subsequent use is not much different to using "ordinary" Table columns. For information on how to use a Measure column see the (RO)ScalarMeasColumns and (RO)ArrayMeasColumns classes.
The TableMeasDesc class hierarchy contains classes for defining each component of the Measures to be contained in column. A TableMeasOffsetDesc is used to specify the offset component, a TableMeasRefDesc to set up the reference code component and a TableMeasValueDesc names the column used as the main Measure column through which the Measure column is subsequently accessed.
The final step needed to create a Measure column is the creation of a TableMeasDesc object whose constructor takes a TableMeasValueDesc and (optionally) a TableMeasRefDesc. After construction the TableMeasDesc object's write() member is used to make the the Measure column persistent within the Table.
The following examples demonstrate the creation of Measure columns using the above components. Further details about each of these components is available with each class description.
All examples write the measure description into a TableDesc object, i.e. the argument used in the TableMeasDesc::write function is a TableDesc object. It is, however, also possible to write them into a Table object which is useful if measure columns are added to an already existing table (see example 2).
The following creates a MEpoch column with a fixed reference.
// Need a table to work with. TableDesc td("measureTable_desc", "1", TableDesc::New); td.comment() = "A test of TableMeasures class."; // Define a column and add it to the table // The main measure column is always an Array column of type Double ArrayColumnDesc<Double> cdTime("Time", "An MEpoch column"); td.addColumn(cdtime); // Create the Measure column for an MEpoch. The MEpoch in // the column has reference code MEpoch::TAI TableMeasRefDesc measRef(MEpoch::TAI); TableMeasValueDesc measVal(td, "Time"); TableMeasDesc<MEpoch> mepochCol(measVal, measRef); // write makes the Measure column persistent. mepochCol.write(td); // create the table with 5 rows SetupNewTable newtab("MeasuresTable", td, Table::New); Table tab(newtab, 5);
Same as example above, but for an already existing table.
// Need a table to work with. TableDesc td("measureTable_desc", "1", TableDesc::New); td.comment() = "A test of TableMeasures class."; // Define a column and add it to the table // The main measure column is always an Array column of type Double ArrayColumnDesc<Double> cdTime("Time", "An MEpoch column"); td.addColumn(cdtime); // create the table with 5 rows SetupNewTable newtab("MeasuresTable", td, Table::New); Table tab(newtab, 5); // Create the Measure column for an MEpoch. The MEpoch in // the column has reference code MEpoch::TAI TableMeasRefDesc measRef(MEpoch::TAI); TableMeasValueDesc measVal(tab.tableDesc(), "Time"); TableMeasDesc<MEpoch> mepochCol(measVal, measRef); // write makes the Measure column persistent. mepochCol.write(tab);
An MEpoch column with a variable reference code with a fixed offset:
// The following three columns will be used to set up a Scalar MEpoch // column with variable references and offsets. 3 columns are needed. // The "main" column where the MEpoch will be stored ArrayColumnDesc<Double> cdTime("Time", "An MEpoch column"); // Variable (i.e., per row) reference code storage needs a column. // The column type is either Int or String (Int is faster but String // may be useful when browsing the table). Either a Scalar column or // Array column can be used here dependent on whether a Scalar or // Array Measure column is used and whether in case of an Array Measure // column the reference code has to be variable per array element. ScalarColumnDesc<Int> cdRef("TimeRef", "Reference column for Time"); // add the columns to the Table decriptor td.addColumn(cdTime); td.addColumn(cdRef); // now create the MEpoch column. // want a fixed offset. Offsets are Measures MEpoch offset(MVEpoch(MVTime(1996, 5, 17), MEpoch::UTC); TableMeasOffsetDesc offsetDesc(offset); // the reference TableMeasRefDesc measRef(td, "TimeRef", offsetDesc); // the value descriptor, create and write the column TableMeasValueDesc measVal(td, "Time"); TableMeasDesc<MEpoch> mepochCol(measVal, measRef); mepochCol.write(); // create the table, etc ..\.
// Variable (per row storage of) offsets needs its own column. Measure // offsets are Measures therefore a Measure column is needed. ArrayColumnDesc<Double> cdOffset("OffsetCol", "Variable Offset col"); // A column for the variable reference code ScalarColumnDesc<String> cdRef("RefCol", "Variable reference column"); // The main (value) column for the Measure column ArrayColumnDesc<Double> cdTime("Time", "MEpoch column"); // add the column descriptors to the table td.addColumn(cdOffset); td.addColumn(cdRef); td.addColumn(cdTime); // Create the Measure column // The offset column is itself a Measure column, but write() is not // called TableMeasValueDesc offsetVal(td, "OffsetCol"); TableMeasDesc<MEpoch> offset(offsetVal); TableMeasOffsetDesc offsetDesc(offset); // the reference TableMeasRefDesc ref(td, "RefCol", offsetDesc); // create the Measure column TableMeasValueDesc val(td, "Time"); TableMeasDesc<MEpoch> mepochCol(val, ref); mepochCol.write(); // create the table, etc ..\.
Creating the required keyword for the definition of a Measure in a Table is somewhat complicated. This class assists in that process.
Definition at line 258 of file TableMeasDesc.h.
casa::TableMeasDesc< M >::TableMeasDesc | ( | const TableMeasValueDesc & | ) |
casa::TableMeasDesc< M >::TableMeasDesc | ( | const TableMeasValueDesc & | , |
const Vector< Unit > & | |||
) |
casa::TableMeasDesc< M >::TableMeasDesc | ( | const TableMeasValueDesc & | , |
const TableMeasRefDesc & | |||
) |
Constructor with value and reference descriptors.
Units for the column will be the default for Measure type.
casa::TableMeasDesc< M >::TableMeasDesc | ( | const TableMeasValueDesc & | , |
const TableMeasRefDesc & | , | ||
const Vector< Unit > & | |||
) |
casa::TableMeasDesc< M >::TableMeasDesc | ( | const TableMeasDesc< M > & | that | ) |
Copy constructor (copy semantics).
casa::TableMeasDesc< M >::~TableMeasDesc | ( | ) |
virtual TableMeasDescBase* casa::TableMeasDesc< M >::clone | ( | ) | const [virtual] |
Clone the object.
Reimplemented from casa::TableMeasDescBase.
TableMeasDesc<M>& casa::TableMeasDesc< M >::operator= | ( | const TableMeasDesc< M > & | that | ) |
Assignment operator (copy semantics)