EleFits  5.0.0
A modern C++ API on top of CFITSIO

◆ readTo() [2/2]

void readTo ( ColumnKey  key,
TColumn &  column 
) const

Read the column with given name or index into an existing Column.

Parameters
keyThe name or 0-based index of the column to be read
columnThe Column object to which data should be written (column.info().name is not used by the method and can be different from the name parameter)
keyThe name or 0-based index of the column to be read

There are several ways to read a column, which can be specified either by its name or 0-based index. The simplest way is to read the whole column as a new VecColumn with methods read(). In this case, the value type is given as the template parameter. In order to store the column data in an existing Column (e.g. PtrColumn), similar methods readTo() should be used. In this case, the value type is deduced and should not be specified.

Example usages:

// Create a new Column
auto fromName = columns.read<float>("RA");
auto fromIndex = columns.read<float>(1);
// Concatenate two columns into an existing Column
long rowCount = readRowCount();
std::vector<float> values(rowCount * 2);
PtrColumn<float> ra({"RA", "deg", 1}, rowCount, &values[0]);
PtrColumn<float> dec({"DEC", "deg", 1}, rowCount, &values[rowCount]);
columns.readTo("RA", ra);
columns.readTo("DEC", dec);
long readRowCount() const
Get the current number of rows.
T dec(T... args)
Warning
Methods readTo() do not allocate memory: the user must ensure that enough space has been allocated previously.