30 #include <boost/regex.hpp>
32 using boost::regex_match;
53 : m_fits(Euclid::
make_unique<CCfits::FITS>(filename)), m_hdu(
_readKeys(m_fits->extension(hduIndex))) {}
56 : m_fits(Euclid::
make_unique<CCfits::FITS>(filename)), m_hdu(
_readKeys(m_fits->extension(hduName))) {}
61 <<
"has started is not allowed";
67 regex whitespace{
".*\\s.*"};
72 if (regex_match(name, whitespace)) {
74 <<
"whitespace characters";
76 if (!set.insert(name).second) {
95 const CCfits::Table& table_hdu =
dynamic_cast<const CCfits::Table&
>(
m_hdu.
get());
103 throw Elements::Exception() <<
"Columns number in HDU (" << table_hdu.numCols() <<
") does not match the column names number ("
118 const CCfits::Table& table_hdu =
dynamic_cast<const CCfits::Table&
>(
m_hdu.
get());
119 return table_hdu.comment();
134 const CCfits::Table& table_hdu =
dynamic_cast<const CCfits::Table&
>(
m_hdu.
get());
139 for (
int i = 1; i <= table_hdu.numCols(); ++i) {
148 for (
int i = 0; i < rows; ++i) {
150 for (
const auto& column_data : data) {
156 return Table{row_list};
static CCfits::HDU & _readKeys(CCfits::HDU &hdu)
const ColumnInfo & getInfo() override
Returns the column information of the table.
std::shared_ptr< ColumnInfo > m_column_info
FitsReader & fixColumnNames(std::vector< std::string > column_names)
Overrides the column names of the table.
Table readImpl(long rows) override
Implements the TableReader::readImpl() contract.
std::shared_ptr< ColumnInfo > createColumnInfo(const std::vector< std::string > &names, const std::vector< std::type_index > &types, const std::vector< std::string > &units, const std::vector< std::string > &descriptions)
Creates a ColumnInfo object from the given names and types.
std::reference_wrapper< const CCfits::HDU > m_hdu
FitsReader(const CCfits::HDU &hdu)
Creates a FitsReader that reads from the given HDU.
std::size_t rowsLeft() override
Implements the TableReader::rowsLeft() contract.
std::vector< std::string > m_column_names
std::map< std::string, ColumnDescription > autoDetectColumnDescriptions(std::istream &in, const std::string &comment)
Reads the column descriptions of the given stream.
Represents one row of a Table.
Provides information about the columns of a Table.
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::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...
void skip(long rows) override
Implements the TableReader::skip() contract.
TableReader implementation for reading FITS tables.
bool hasMoreRows() override
Implements the TableReader::hasMoreRows() contract.
std::vector< std::string > autoDetectColumnUnits(const CCfits::Table &table_hdu)
Reads the column units based on the TUNITn keyword.
std::vector< std::type_index > autoDetectColumnTypes(const CCfits::Table &table_hdu)
Reads the column types of the given table HDU.
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::string getComment() override