EleFits  5.3.1
A modern C++ API on top of CFITSIO
Loading...
Searching...
No Matches

◆ read()

VecColumn< T, N > read ( ColumnKey  key) const

Read the column with given name or index.

Parameters
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 read_to() should be used. In this case, the value type is deduced and should not be specified.

Example usages:

// Create a new Column
auto from_name = columns.read<float>("RA");
auto from_index = columns.read<float>(1);
// Concatenate two columns into an existing Column
long row_count = read_row_count();
std::vector<float> values(row_count * 2);
PtrColumn<float> ra({"RA", "deg", 1}, row_count, &values[0]);
PtrColumn<float> dec({"DEC", "deg", 1}, row_count, &values[row_count]);
columns.read_to("RA", ra);
columns.read_to("DEC", dec);
long read_row_count() const
Get the current number of rows.
Binary table column data and metadata.
Definition: Column.h:69
Warning
Methods read_to() do not allocate memory: the user must ensure that enough space has been allocated previously.
Examples
EleFitsBintableExample.cpp, and EleFitsTutorial.cpp.