Alexandria 2.32.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Euclid::Table::FitsReader Class Reference

TableReader implementation for reading FITS tables. More...

#include <FitsReader.h>

Inheritance diagram for Euclid::Table::FitsReader:
Collaboration diagram for Euclid::Table::FitsReader:

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
FitsReaderoperator= (FitsReader &&)=default
 FitsReader (const FitsReader &)=delete
FitsReaderoperator= (const FitsReader &)=delete
virtual ~FitsReader ()=default
 Destructor.
FitsReaderfixColumnNames (std::vector< std::string > column_names)
 Overrides the column names of the table.
const ColumnInfogetInfo () 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.
Public Member Functions inherited from Euclid::Table::TableReader
 TableReader ()=default
 TableReader (TableReader &&)=default
TableReaderoperator= (TableReader &&)=default
 TableReader (const TableReader &)=delete
TableReaderoperator= (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::stringm_column_names {}
std::shared_ptr< ColumnInfom_column_info

Detailed Description

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:

  • Aw (Character) : std::string
  • Iw (Decimal integer) : int64_t
  • Fw.d (Floating-point, fixed decimal notation) : double
  • Ew.d (Floating-point, fixed exponential notation) : double
  • Dw.d (Floating-point, fixed exponential notation) : double

In the case of binary table, the format mapping is the following (note that a subset of formats is only supported):

  • L (Logical) : bool
  • X (Bit) : NOT SUPPORTED
  • B (Unsigned byte) : int32_t
  • I (16-bit integer) : int32_t
  • J (32-bit integer) : int32_t
  • K (64-bit integer) : int64_t
  • A (Character) : std::string
  • E (Single precision floating point) : float
  • D (Double precision floating point) : double
  • C (Single precision complex) : NOT SUPPORTED
  • M (Double precision complex) : NOT SUPPORTED
  • P (Array Descriptor 32-bit) : NOT SUPPORTED
  • Q (Array Descriptor 64-bit) : NOT 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.

Constructor & Destructor Documentation

◆ FitsReader() [1/5]

Euclid::Table::FitsReader::FitsReader ( const CCfits::HDU & hdu)
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.

Parameters
hduA reference to the CCfits::HDU to read the table from

Definition at line 44 of file FitsReader.cpp.

References m_hdu.

Referenced by FitsReader(), FitsReader(), fixColumnNames(), operator=(), operator=(), and ~FitsReader().

◆ FitsReader() [2/5]

Euclid::Table::FitsReader::FitsReader ( const std::string & filename,
int hdu_index = 1 )
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.

References Euclid::Table::_readKeys(), m_fits, m_hdu, and Euclid::make_unique().

Here is the call graph for this function:

◆ FitsReader() [3/5]

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.

References Euclid::Table::_readKeys(), m_fits, m_hdu, and Euclid::make_unique().

Here is the call graph for this function:

◆ FitsReader() [4/5]

Euclid::Table::FitsReader::FitsReader ( FitsReader && )
default

References FitsReader().

Here is the call graph for this function:

◆ FitsReader() [5/5]

Euclid::Table::FitsReader::FitsReader ( const FitsReader & )
delete

References FitsReader().

Here is the call graph for this function:

◆ ~FitsReader()

virtual Euclid::Table::FitsReader::~FitsReader ( )
virtualdefault

Destructor.

References FitsReader().

Here is the call graph for this function:

Member Function Documentation

◆ fixColumnNames()

FitsReader & Euclid::Table::FitsReader::fixColumnNames ( std::vector< std::string > column_names)

Overrides the column names of the table.

Parameters
column_namesThe names of the columns or empty for auto-detection
Returns
A reference to the FitsReader instance
Exceptions
Elements::Exceptionif there are duplicate column names
Elements::Exceptionif any of the given column names is empty or contains whitespace characters
Elements::Exceptionif the FitsReader instance has already been used for reading

Definition at line 52 of file FitsReader.cpp.

References FitsReader(), std::set< K >::insert(), m_column_names, m_reading_started, and std::move().

Here is the call graph for this function:

◆ getComment()

std::string Euclid::Table::FitsReader::getComment ( )
overridevirtual
Returns
Returns the comment associated to the table

Implements Euclid::Table::TableReader.

Definition at line 111 of file FitsReader.cpp.

References m_hdu.

◆ getInfo()

const ColumnInfo & Euclid::Table::FitsReader::getInfo ( )
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.

Returns
The description of the table columns
Exceptions
Elements::ExceptionIf 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().

Here is the call graph for this function:

◆ hasMoreRows()

bool Euclid::Table::FitsReader::hasMoreRows ( )
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().

Here is the call graph for this function:

◆ operator=() [1/2]

FitsReader & Euclid::Table::FitsReader::operator= ( const FitsReader & )
delete

References FitsReader().

Here is the call graph for this function:

◆ operator=() [2/2]

FitsReader & Euclid::Table::FitsReader::operator= ( FitsReader && )
default

References FitsReader().

Here is the call graph for this function:

◆ readColumnInfo()

◆ readImpl()

Table Euclid::Table::FitsReader::readImpl ( long rows)
overrideprotectedvirtual

◆ rowsLeft()

std::size_t Euclid::Table::FitsReader::rowsLeft ( )
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().

Here is the call graph for this function:

◆ skip()

void Euclid::Table::FitsReader::skip ( long rows)
overridevirtual

Implements the TableReader::skip() contract.

Implements Euclid::Table::TableReader.

Definition at line 162 of file FitsReader.cpp.

References m_current_row, and readColumnInfo().

Here is the call graph for this function:

Member Data Documentation

◆ m_column_info

std::shared_ptr<ColumnInfo> Euclid::Table::FitsReader::m_column_info
private

Definition at line 167 of file FitsReader.h.

Referenced by getInfo(), readColumnInfo(), and readImpl().

◆ m_column_names

std::vector<std::string> Euclid::Table::FitsReader::m_column_names {}
private

Definition at line 166 of file FitsReader.h.

Referenced by fixColumnNames(), and readColumnInfo().

◆ m_current_row

long Euclid::Table::FitsReader::m_current_row = 1
private

Definition at line 165 of file FitsReader.h.

Referenced by hasMoreRows(), readImpl(), rowsLeft(), and skip().

◆ m_fits

std::unique_ptr<CCfits::FITS> Euclid::Table::FitsReader::m_fits {nullptr}
private

Definition at line 161 of file FitsReader.h.

Referenced by FitsReader(), and FitsReader().

◆ m_hdu

std::reference_wrapper<const CCfits::HDU> Euclid::Table::FitsReader::m_hdu
private

Definition at line 162 of file FitsReader.h.

Referenced by FitsReader(), FitsReader(), FitsReader(), getComment(), readColumnInfo(), and readImpl().

◆ m_reading_started

bool Euclid::Table::FitsReader::m_reading_started = false
private

Definition at line 163 of file FitsReader.h.

Referenced by fixColumnNames(), and readColumnInfo().

◆ m_total_rows

long Euclid::Table::FitsReader::m_total_rows = -1
private

Definition at line 164 of file FitsReader.h.

Referenced by hasMoreRows(), readColumnInfo(), readImpl(), and rowsLeft().


The documentation for this class was generated from the following files: