Alexandria 2.31.0
SDC-CH common library for the Euclid project
|
Tool for reading FITS tables from streams. More...
#include <FitsParser.h>
Public Member Functions | |
FitsParser (const std::string &keyword="") | |
Constructor Tool for reading FITS tables from streams. | |
std::string | getName (const std::string &file) override |
Get the dataset name of a FITS file. | |
std::string | getParameter (const std::string &file, const std::string &key_word) override |
Get the parameter identified by a given key_word value from a file. | |
std::unique_ptr< XYDataset > | getDataset (const std::string &file) override |
Get a XYDataset object reading data from an FITS file. | |
bool | isDatasetFile (const std::string &file) override |
Check that the FITS file is a dataset file(with at least one HDU table) | |
![]() | |
virtual | ~FileParser ()=default |
Default destructor. | |
Private Attributes | |
std::string | m_name_keyword |
Tool for reading FITS tables from streams.
The FitsParser reads FITS file which contains a primary HDU and one binary extension. The extension must contain two columns of double types. The first column contains the X data and the second the Y data. The name of the dataset is extracted from one of the keywords stored in the first extension. The name of this keyword can be specified in the constructor. If the keyword does not exist, the dataset name is extracted from the FITS filename itself removing the path and extension (.fits).
Definition at line 51 of file FitsParser.h.
|
inline |
Constructor Tool for reading FITS tables from streams.
keyword | The keyword name where the dataset name is stored in the FITS file. The default is the empty string. |
Definition at line 60 of file FitsParser.h.
|
overridevirtual |
Get a XYDataset object reading data from an FITS file.
It reads data in the first extension of a FITS file and put the data into a XYDataset object. It makes the assumption that the file only contains two columns of double values.
file | Filename of the FITS file to be read (including the absolute path). |
Elements::Exception | A FITS exception occured |
Implements Euclid::XYDataset::FileParser.
Definition at line 79 of file FitsParser.cpp.
References std::vector< T >::begin(), std::move(), Euclid::Table::TableReader::read(), and std::transform().
|
overridevirtual |
Get the dataset name of a FITS file.
This function gets the dataset name. It tries first to get the dataset name from the keyword stored in the binary extension. The keyword name to look for is specified at the constructor level. If no keyword specified or found, the dataset name is extracted from the filename removing the path and the extension.
file | Filename of the file to be read including absolute path |
ElementException | : File not found |
Implements Euclid::XYDataset::FileParser.
Definition at line 41 of file FitsParser.cpp.
References std::string::empty(), getParameter(), m_name_keyword, Euclid::XYDataset::removeAllBeforeLastSlash(), and Euclid::XYDataset::removeExtension().
|
overridevirtual |
Get the parameter identified by a given key_word value from a file.
This function gets the the parameter if present in the fits HDU keyword. Return an empty string if the key word is not present.
file | Filename of the file to be read including absolute path |
key_word | key word identifying the parameter |
ElementException | : File not found |
Implements Euclid::XYDataset::FileParser.
Definition at line 53 of file FitsParser.cpp.
Referenced by getName().
|
overridevirtual |
Check that the FITS file is a dataset file(with at least one HDU table)
This checking should avoid reading any files which do not contain any dataset.
file | Filename of the FITS file to be read including the absolute path. |
Implements Euclid::XYDataset::FileParser.
Definition at line 111 of file FitsParser.cpp.
References ELEMENTS_UNUSED.
|
private |
Definition at line 127 of file FitsParser.h.
Referenced by getName().