28 #include "ElementsKernel/Exception.h"
29 #include "ElementsKernel/Unused.h"
54 throw Elements::Exception() <<
"Fixing the column names after reading "
55 <<
"has started is not allowed";
64 throw Elements::Exception() <<
"Empty string column names are not allowed";
66 if (regex_match(name, whitespace)) {
67 throw Elements::Exception() <<
"Column name '" << name <<
"' contains "
68 <<
"whitespace characters";
70 if (!set.insert(name).second) {
71 throw Elements::Exception() <<
"Duplicate column name " << name;
85 ELEMENTS_UNUSED
auto& temp =
dynamic_cast<const CCfits::Table&
>(
m_hdu.
get());
87 throw Elements::Exception() <<
"Given HDU is not a table";
89 const CCfits::Table& table_hdu =
dynamic_cast<const CCfits::Table&
>(
m_hdu.
get());
97 throw Elements::Exception() <<
"Columns number in HDU (" << table_hdu.numCols()
112 const CCfits::Table& table_hdu =
dynamic_cast<const CCfits::Table&
>(
m_hdu.
get());
113 return table_hdu.comment();
128 const CCfits::Table& table_hdu =
dynamic_cast<const CCfits::Table&
>(
m_hdu.
get());
133 data.
reserve(table_hdu.numCols());
134 for (
int i = 1; i <= table_hdu.numCols(); ++i) {
150 for (
int i = 0; i < rows; ++i) {
153 for (
auto& column_data : data) {
Provides information about the columns of a Table.
TableReader implementation for reading FITS tables.
void skip(long rows) override
Implements the TableReader::skip() contract.
std::vector< std::string > m_column_names
FitsReader(const CCfits::HDU &hdu)
Creates a FitsReader that reads from the given HDU.
bool hasMoreRows() override
Implements the TableReader::hasMoreRows() contract.
const ColumnInfo & getInfo() override
Returns the column information of the table.
Table readImpl(long rows) override
Implements the TableReader::readImpl() contract.
std::reference_wrapper< const CCfits::HDU > m_hdu
std::shared_ptr< ColumnInfo > m_column_info
std::size_t rowsLeft() override
Implements the TableReader::rowsLeft() contract.
std::string getComment() override
FitsReader & fixColumnNames(std::vector< std::string > column_names)
Overrides the column names of the table.
T emplace_back(T... args)
std::map< std::string, ColumnDescription > autoDetectColumnDescriptions(std::istream &in, const std::string &comment)
Reads the column descriptions of the given stream.
std::vector< std::string > autoDetectColumnUnits(const CCfits::Table &table_hdu)
Reads the column units based on the TUNITn keyword.
std::vector< std::string > autoDetectColumnNames(std::istream &in, const std::string &comment, size_t columns_number)
Reads the column names of the given stream.
std::vector< Row::cell_type > translateColumn(CCfits::Column &column, std::type_index type)
Returns a vector representing the given FITS table column data, converted to the requested type.
std::vector< std::pair< std::type_index, std::size_t > > autoDetectColumnTypes(const CCfits::Table &table_hdu)
Reads the column types of the given table HDU.
static CCfits::HDU & _readKeys(CCfits::HDU &hdu)
std::shared_ptr< ColumnInfo > createColumnInfo(const std::vector< std::string > &names, const std::vector< std::pair< std::type_index, std::size_t >> &types, const std::vector< std::string > &units, const std::vector< std::string > &descriptions)
Creates a ColumnInfo object from the given names and types.
std::unique_ptr< T > make_unique(Args &&... args)
Constructs an object of type T and wraps it in a std::unique_ptr using args as the parameter list for...