Loading...
Searching...
No Matches
casacore::ArrayMeasColumn< M > Class Template Reference
measures package (libcasa_measures) » TableMeasures_module

More...

`#include <ArrayMeasColumn.h>`

## Public Member Functions

| ArrayMeasColumn ()
| The default constructor creates a null object.
| ArrayMeasColumn (const Table &tab, const String &columnName)
| Create the ArrayMeasColumn from the table and column Name.
| ArrayMeasColumn (const ArrayMeasColumn< M > &that)
| Copy constructor (copy semantics).
virtual | ~ArrayMeasColumn ()
void | reference (const ArrayMeasColumn< M > &that)
| Change the reference to another column.
void | attach (const Table &tab, const String &columnName)
| Attach a column to the object.
void | get (rownr_t rownr, Array< M > &meas, Bool resize=False) const
| Get the Measure array in the specified row.
Array< M > | operator() (rownr_t rownr) const
Array< M > | convert (rownr_t rownr, const M &meas) const
| Get the Measure array contained in the specified row and convert it to the reference and offset found in the given measure.
Array< M > | convert (rownr_t rownr, const MeasRef< M > &measRef) const
| Get the Measure array contained in the specified row and convert it to the given reference.
Array< M > | convert (rownr_t rownr, uInt refCode) const
const MeasRef< M > & | getMeasRef () const
| Get the column's reference.
void | setDescRefCode (uInt refCode, Bool tableMustBeEmpty=True)
| Reset the refCode, offset, or units.
void | setDescOffset (const Measure &offset, Bool tableMustBeEmpty=True)
void | setDescUnits (const Vector< Unit > &units, Bool tableMustBeEmpty=True)
void | put (rownr_t rownr, const Array< M > &)
| Add a Measure array to the specified row.
Public Member Functions inherited from casacore::TableMeasColumn
| TableMeasColumn ()
| The default constructor creates a null object.
| TableMeasColumn (const Table &tab, const String &columnName)
| Create the ScalarMeasColumn from the table and column Name.
| TableMeasColumn (const TableMeasColumn &that)
| Copy constructor (copy semantics).
virtual | ~TableMeasColumn ()
void | reference (const TableMeasColumn &that)
| Change the reference to another column.
void | attach (const Table &tab, const String &columnName)
| Attach another column to the object.
Bool | isDefined (rownr_t rownr) const
| Tests if a row contains a Measure (i.e., if the row has a defined value).
const TableMeasDescBase & | measDesc () const
| Get access to the TableMeasDescBase describing the column.
TableMeasDescBase & | measDesc ()
Bool | isNull () const
| Test if the object is null.
void | throwIfNull () const
| Throw an exception if the object is null.
const String & | columnName () const
| Get the name of the column.
Table | table () const
| Get the Table object this column belongs to.
Bool | isScalar () const
| Is the column a scalar measures column?

## Protected Attributes

MeasRef< M > | itsMeasRef
Protected Attributes inherited from casacore::TableMeasColumn
uInt | itsNvals
std::shared_ptr< TableMeasDescBase > | itsDescPtr
TableColumn | itsTabDataCol
Bool | itsVarRefFlag
Bool | itsVarOffFlag

## Private Member Functions

ArrayMeasColumn & | operator= (const ArrayMeasColumn< M > &that)
| Assignment makes no sense in a read only class.
void | cleanUp ()
| Deletes allocated memory etc.
Array< M > | doConvert (rownr_t rownr, typename M::Convert &conv) const
| Get the data and convert using conversion engine.

## Private Attributes

ArrayColumn< Double > * | itsDataCol
ScalarColumn< Int > * | itsRefIntCol
ArrayColumn< Int > * | itsArrRefIntCol
ScalarColumn< String > * | itsRefStrCol
ArrayColumn< String > * | itsArrRefStrCol
ScalarMeasColumn< M > * | itsOffsetCol
ArrayMeasColumn< M > * | itsArrOffsetCol

## Detailed Description

template<class M>
class casacore::ArrayMeasColumn< M >

Access table array Measure columns.

### Intended use:

Public interface

### Review Status

Reviewed By:
  Bob Garwood
Date Reviewed:
  1999/12/23
Test programs:
  tTableMeasures

### Prerequisite

- Measures
- Tables
- TableMeasDesc

### Synopsis

ArrayMeasColumn objects can be used to access array Measure Columns in tables, both for reading and writing (if the table is writable).

Before a column can be accessed it must have previously been defined as a Measure column by use of the TableMeasDesc object.

The ArrayMeasColumn class is templated on Measure type and MeasValue type but typedefs exist for making declaration less long winded. The Measure classes (like MEpoch) have typedefs ArrayColumn to assist in creating ArrayMeasColumn objects.

Constructing array Measure column objects using these typedefs looks like this:

// Read/write MEpoch array column
MEpoch::ArrayColumn ec(table, "ColumnName);
casacore::MEpoch::ArrayColumn
ArrayMeasColumn< MEpoch > ArrayColumn
Definition MEpoch.h:158
casacore::TableMeasColumn::table
Table table() const
Get the Table object this column belongs to.

### Reading and writing Measures

The reading and writing of Measures columns is very similar to reading and writing of "ordinary" Table columns. get() and operator() exist for reading Measures and the put() member for adding Measures to a column. (put() is obviously not defined for ScalarMeasColumn objects.) Each of these members accepts a row number as an argument.

Care needs to be taken when adding Measures to a column. The user needs to be aware that Measures are not checked for consistency, with respect to a Measure's reference, between the Measures being added to a column and the column's predefined Measure reference. This is only an issue if the Measure column was defined to have a fixed reference. For such columns the reference component of Measures added to a column is silently ignored, that is, there is no warning nor is there any sort of conversion to the column's reference should the reference of the added Measure be different from the column's reference. The functions

TableMeasDescBase::isRefVariable() and

ArrayMeasColumn::getMeasRef() can be used to discover a Measure column's Measure reference characteristics.

### Example

// create an MEpoch array column object
ArrayMeasColumn<MEpoch> arrayCol;
// should be null. Can test this and attach a real MEpoch column
// The column Time1Arr should exist in the table and would have been
// defined by using a TableMeasDesc
if (arrayCol.isNull()) {
arrayCol.attach(tab, "Time1Arr");
}
// This would throw an Exception if the object is still null....but
// hopefully won't
arrayCol.throwIfNull();
// create a vector of MEpochs
MEpoch last(Quantity(13.45, "h"), MEpoch::Ref(MEpoch::TAI));
Vector<MEpoch> ev(10);
for (uInt i=0; i<10; i++) {
last.set(Quantity(13.45 + i, "h"));
ev(i) = last;
}
// before adding something check the isDefined() member
if (!arrayCol.isDefined(0)) {
cout << "PASS - nothing in the measure array column row yet\n";
} else {
cout << "FAIL - there shouldn't be a valid value in the row!\n";
}
// add the MEpoch vector to the array Measure column at row 0
arrayCol.put(0, ev);
// now read the array from the row. Could use same object to do this
// but here we'll create a ArrayMeasColumn<MEpoch> to do this
ArrayMeasColumn<MEpoch> roArrCol(tab, "Time1Arr");
// need a vector to put the MEpochs into
Vector<MEpoch> ew;
// setting the resize parameter to True automatically sets ew to the
// same shape as the array contained in the row
arrayCol.get(0, ew, True);
casacore::ArrayMeasColumn::ArrayMeasColumn
ArrayMeasColumn()
The default constructor creates a null object.
casacore::ArrayMeasColumn::attach
void attach(const Table &tab, const String &columnName)
Attach a column to the object.
casacore::ArrayMeasColumn::get
void get(rownr_t rownr, Array< M > &meas, Bool resize=False) const
Get the Measure array in the specified row.
casacore::ArrayMeasColumn::put
void put(rownr_t rownr, const Array< M > &)
Add a Measure array to the specified row.
casacore::MEpoch
Definition MEpoch.h:101
casacore::MEpoch::TAI
@ TAI
Definition MEpoch.h:126
casacore::MEpoch::Ref
MeasRef< MEpoch > Ref
Measure reference (i.e.
Definition MEpoch.h:153
casacore::TableMeasColumn::isDefined
Bool isDefined(rownr_t rownr) const
Tests if a row contains a Measure (i.e., if the row has a defined value).
casacore::TableMeasColumn::throwIfNull
void throwIfNull() const
Throw an exception if the object is null.
casacore::TableMeasColumn::isNull
Bool isNull() const
Test if the object is null.
Definition TableMeasColumn.h:134
casacore::Vector
Definition Vector.h:82
casacore::uInt
unsigned int uInt
Definition aipstype.h:49
casacore::Quantity
Quantum< Double > Quantity
Definition Quantum.h:39
casacore::True
const Bool True
Definition aipstype.h:41

### Motivation

The standard Casacore Table system does not support array Measure columns. This class overcomes this limitation.

### Thrown Exceptions

- ArrayConformanceError during get() if supplied array is the wrong shape.

Definition at line 168 of file ArrayMeasColumn.h.

## Constructor & Destructor Documentation

## ArrayMeasColumn() [1/3]

template<class M>

casacore::ArrayMeasColumn< M >::ArrayMeasColumn | ( |  | ) |

The default constructor creates a null object.

Useful for creating arrays of ArrayMeasColumn objects. Attempting to use a null object will produce a segmentation fault so care needs to be taken to initialise the objects by using the attach() member before any attempt is made to use the object. A ArrayMeasColumn object can be tested if it is null by using the isNull() member.

## ArrayMeasColumn() [2/3]

template<class M>

casacore::ArrayMeasColumn< M >::ArrayMeasColumn | ( | const Table & | tab,
|  | const String & | columnName )

Create the ArrayMeasColumn from the table and column Name.

## ArrayMeasColumn() [3/3]

template<class M>

casacore::ArrayMeasColumn< M >::ArrayMeasColumn | ( | const ArrayMeasColumn< M > & | that | ) |

Copy constructor (copy semantics).

## ~ArrayMeasColumn()

template<class M>

virtual casacore::ArrayMeasColumn< M >::~ArrayMeasColumn | ( |  | ) |

virtual

## Member Function Documentation

## attach()

template<class M>

void casacore::ArrayMeasColumn< M >::attach | ( | const Table & | tab,
|  | const String & | columnName )

Attach a column to the object.

## cleanUp()

template<class M>

void casacore::ArrayMeasColumn< M >::cleanUp | ( |  | ) |

private

Deletes allocated memory etc.

Called by ~tor and any member which needs to reallocate data.

## convert() [1/3]

template<class M>

Array< M > casacore::ArrayMeasColumn< M >::convert | ( | rownr_t | rownr,
|  | const M & | meas ) const

inline

Get the Measure array contained in the specified row and convert it to the reference and offset found in the given measure.

Definition at line 202 of file ArrayMeasColumn.h.

Referenced by casacore::ArrayMeasColumn< MBaseline >::convert().

## convert() [2/3]

template<class M>

Array< M > casacore::ArrayMeasColumn< M >::convert | ( | rownr_t | rownr,
|  | const MeasRef< M > & | measRef ) const

Get the Measure array contained in the specified row and convert it to the given reference.

## convert() [3/3]

template<class M>

Array< M > casacore::ArrayMeasColumn< M >::convert | ( | rownr_t | rownr,
|  | uInt | refCode ) const

## doConvert()

template<class M>

Array< M > casacore::ArrayMeasColumn< M >::doConvert | ( | rownr_t | rownr,
|  | typename M::Convert & | conv ) const

private

Get the data and convert using conversion engine.

## get()

template<class M>

void casacore::ArrayMeasColumn< M >::get | ( | rownr_t | rownr,
|  | Array< M > & | meas,
|  | Bool | resize = False ) const

Get the Measure array in the specified row.

For get() the supplied array's shape should match the shape in the row unless resize is True.

## getMeasRef()

template<class M>

const MeasRef< M > & casacore::ArrayMeasColumn< M >::getMeasRef | ( |  | ) | const

inline

Get the column's reference.

Definition at line 213 of file ArrayMeasColumn.h.

## operator()()

template<class M>

Array< M > casacore::ArrayMeasColumn< M >::operator() | ( | rownr_t | rownr | ) | const

## operator=()

template<class M>

ArrayMeasColumn & casacore::ArrayMeasColumn< M >::operator= | ( | const ArrayMeasColumn< M > & | that | ) |

private

Assignment makes no sense in a read only class.

Declaring this operator private makes it unusable.

## put()

template<class M>

void casacore::ArrayMeasColumn< M >::put | ( | rownr_t | rownr,
|  | const Array< M > & | )

Add a Measure array to the specified row.

## reference()

template<class M>

void casacore::ArrayMeasColumn< M >::reference | ( | const ArrayMeasColumn< M > & | that | ) |

Change the reference to another column.

## setDescOffset()

template<class M>

void casacore::ArrayMeasColumn< M >::setDescOffset | ( | const Measure & | offset,
|  | Bool | tableMustBeEmpty = True )

## setDescRefCode()

template<class M>

void casacore::ArrayMeasColumn< M >::setDescRefCode | ( | uInt | refCode,
|  | Bool | tableMustBeEmpty = True )

Reset the refCode, offset, or units.

It overwrites the value used when defining the TableMeasDesc. Resetting the refCode and offset can only be done if they were defined as fixed in the description.
Tip: In principle the functions can only be used if the table is empty, otherwise already written values have thereafter the incorrect reference, offset, or unit; However, it is possible that part of the table is already written and that the entire measure column is filled in later; In that case the reference, offset, or units can be set by using a False tableMustBeEmpty argument;

## setDescUnits()

template<class M>

void casacore::ArrayMeasColumn< M >::setDescUnits | ( | const Vector< Unit > & | units,
|  | Bool | tableMustBeEmpty = True )

## Member Data Documentation

## itsArrOffsetCol

template<class M>

ArrayMeasColumn<M>* casacore::ArrayMeasColumn< M >::itsArrOffsetCol

private

Definition at line 256 of file ArrayMeasColumn.h.

## itsArrRefIntCol

template<class M>

ArrayColumn<Int>* casacore::ArrayMeasColumn< M >::itsArrRefIntCol

private

Definition at line 249 of file ArrayMeasColumn.h.

## itsArrRefStrCol

template<class M>

ArrayColumn<String>* casacore::ArrayMeasColumn< M >::itsArrRefStrCol

private

Definition at line 252 of file ArrayMeasColumn.h.

## itsDataCol

template<class M>

ArrayColumn<Double>* casacore::ArrayMeasColumn< M >::itsDataCol

private

Definition at line 246 of file ArrayMeasColumn.h.

## itsMeasRef

template<class M>

MeasRef<M> casacore::ArrayMeasColumn< M >::itsMeasRef

protected

Definition at line 242 of file ArrayMeasColumn.h.

## itsOffsetCol

template<class M>

ScalarMeasColumn<M>* casacore::ArrayMeasColumn< M >::itsOffsetCol

private

Definition at line 255 of file ArrayMeasColumn.h.

## itsRefIntCol

template<class M>

ScalarColumn<Int>* casacore::ArrayMeasColumn< M >::itsRefIntCol

private

Definition at line 248 of file ArrayMeasColumn.h.

## itsRefStrCol

template<class M>

ScalarColumn<String>* casacore::ArrayMeasColumn< M >::itsRefStrCol

private

Definition at line 251 of file ArrayMeasColumn.h.

The documentation for this class was generated from the following files:

- measures/Measures/MBaseline.h
- measures/TableMeasures/ArrayMeasColumn.h