Alexandria 2.31.0
SDC-CH common library for the Euclid project
|
TableReader implementation for reading FITS tables. More...
#include <FitsReader.h>
Public Member Functions | |
FitsReader (const CCfits::HDU &hdu) | |
Creates a FitsReader that reads from the given HDU. | |
FitsReader (const std::string &filename, int hdu_index=1) | |
FitsReader (const std::string &filename, const std::string &hduName) | |
FitsReader (FitsReader &&)=default | |
FitsReader & | operator= (FitsReader &&)=default |
FitsReader (const FitsReader &)=delete | |
FitsReader & | operator= (const FitsReader &)=delete |
virtual | ~FitsReader ()=default |
Destructor. | |
FitsReader & | fixColumnNames (std::vector< std::string > column_names) |
Overrides the column names of the table. | |
const ColumnInfo & | getInfo () override |
Returns the column information of the table. | |
std::string | getComment () override |
void | skip (long rows) override |
Implements the TableReader::skip() contract. | |
bool | hasMoreRows () override |
Implements the TableReader::hasMoreRows() contract. | |
std::size_t | rowsLeft () override |
Implements the TableReader::rowsLeft() contract. | |
![]() | |
TableReader ()=default | |
TableReader (TableReader &&)=default | |
TableReader & | operator= (TableReader &&)=default |
TableReader (const TableReader &)=delete | |
TableReader & | operator= (const TableReader &)=delete |
virtual | ~TableReader ()=default |
Table | read (long rows=-1) |
Reads next rows as a table. | |
Protected Member Functions | |
Table | readImpl (long rows) override |
Implements the TableReader::readImpl() contract. | |
Private Member Functions | |
void | readColumnInfo () |
Private Attributes | |
std::unique_ptr< CCfits::FITS > | m_fits {nullptr} |
std::reference_wrapper< const CCfits::HDU > | m_hdu |
bool | m_reading_started = false |
long | m_total_rows = -1 |
long | m_current_row = 1 |
std::vector< std::string > | m_column_names {} |
std::shared_ptr< ColumnInfo > | m_column_info |
TableReader implementation for reading FITS tables.
This class can read both binary and ASCII table HDUs. In the case of ASCII table, the format mapping is the following:
In the case of binary table, the format mapping is the following (note that a subset of formats is only supported):
Note that repeat counts (which create arrays) in the binary table formats are translated to vectors, with exception the "A" format, which is translated to a string.
The (non standard) keywords TDESCn are considered to contain the text description of the column. The unit is retrieved by using the standard TUNITn keyword. The names of the columns can be overridden by using the method fixColumnNames().
Definition at line 75 of file FitsReader.h.
|
explicit |
Creates a FitsReader that reads from the given HDU.
This constructor delegates the lifetime management of the CCfits::HDU object to the user. The given reference must be valid for all the lifetime of the FitsReader object. This constructor is meant to be used for more advanced use cases (like optimization). If you just want to read a table from a file you should first consider the other constructors.
hdu | A reference to the CCfits::HDU to read the table from |
Definition at line 44 of file FitsReader.cpp.
|
explicit |
Creates a FitsReader that reads a table from a FITS file, based on the HDU index
Definition at line 46 of file FitsReader.cpp.
Euclid::Table::FitsReader::FitsReader | ( | const std::string & | filename, |
const std::string & | hduName | ||
) |
Creates a FitsReader that reads a table from a FITS file, based on the HDU name
Definition at line 49 of file FitsReader.cpp.
|
default |
|
delete |
|
virtualdefault |
Destructor.
FitsReader & Euclid::Table::FitsReader::fixColumnNames | ( | std::vector< std::string > | column_names | ) |
Overrides the column names of the table.
column_names | The names of the columns or empty for auto-detection |
Elements::Exception | if there are duplicate column names |
Elements::Exception | if any of the given column names is empty or contains whitespace characters |
Elements::Exception | if the FitsReader instance has already been used for reading |
Definition at line 52 of file FitsReader.cpp.
References m_column_names, m_reading_started, and std::move().
|
overridevirtual |
Implements Euclid::Table::TableReader.
Definition at line 111 of file FitsReader.cpp.
References std::reference_wrapper::get(), and m_hdu.
|
overridevirtual |
Returns the column information of the table.
For more details of the column info definition in the FITS file, see the documentation of the class.
Elements::Exception | If automatic column type or name detection is overridden and the HDU contains a different number of columns |
Implements Euclid::Table::TableReader.
Definition at line 106 of file FitsReader.cpp.
References m_column_info, and readColumnInfo().
|
overridevirtual |
Implements the TableReader::hasMoreRows() contract.
Implements Euclid::Table::TableReader.
Definition at line 167 of file FitsReader.cpp.
References m_current_row, m_total_rows, and readColumnInfo().
|
delete |
|
default |
|
private |
Definition at line 78 of file FitsReader.cpp.
References Euclid::Table::autoDetectColumnDescriptions(), Euclid::Table::autoDetectColumnNames(), Euclid::Table::autoDetectColumnTypes(), Euclid::Table::autoDetectColumnUnits(), Euclid::Table::createColumnInfo(), ELEMENTS_UNUSED, std::vector< T >::empty(), std::reference_wrapper::get(), m_column_info, m_column_names, m_hdu, m_reading_started, m_total_rows, and std::vector< T >::size().
Referenced by getInfo(), hasMoreRows(), readImpl(), rowsLeft(), and skip().
|
overrideprotectedvirtual |
Implements the TableReader::readImpl() contract.
Implements Euclid::Table::TableReader.
Definition at line 116 of file FitsReader.cpp.
References std::vector< T >::emplace_back(), std::reference_wrapper::get(), m_column_info, m_current_row, m_hdu, m_total_rows, std::min(), std::move(), readColumnInfo(), std::vector< T >::reserve(), std::vector< T >::size(), and Euclid::Table::translateColumn().
|
overridevirtual |
Implements the TableReader::rowsLeft() contract.
Implements Euclid::Table::TableReader.
Definition at line 172 of file FitsReader.cpp.
References m_current_row, m_total_rows, and readColumnInfo().
|
overridevirtual |
Implements the TableReader::skip() contract.
Implements Euclid::Table::TableReader.
Definition at line 162 of file FitsReader.cpp.
References m_current_row, and readColumnInfo().
|
private |
Definition at line 167 of file FitsReader.h.
Referenced by getInfo(), readColumnInfo(), and readImpl().
|
private |
Definition at line 166 of file FitsReader.h.
Referenced by fixColumnNames(), and readColumnInfo().
|
private |
Definition at line 165 of file FitsReader.h.
Referenced by hasMoreRows(), readImpl(), rowsLeft(), and skip().
|
private |
Definition at line 161 of file FitsReader.h.
|
private |
Definition at line 162 of file FitsReader.h.
Referenced by getComment(), readColumnInfo(), and readImpl().
|
private |
Definition at line 163 of file FitsReader.h.
Referenced by fixColumnNames(), and readColumnInfo().
|
private |
Definition at line 164 of file FitsReader.h.
Referenced by hasMoreRows(), readColumnInfo(), readImpl(), and rowsLeft().