Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Euclid::XYDataset::FitsParser Class Reference

Tool for reading FITS tables from streams. More...

#include <FitsParser.h>

Inheritance diagram for Euclid::XYDataset::FitsParser:
Inheritance graph
[legend]
Collaboration diagram for Euclid::XYDataset::FitsParser:
Collaboration graph
[legend]

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< XYDatasetgetDataset (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)
 
- Public Member Functions inherited from Euclid::XYDataset::FileParser
virtual ~FileParser ()=default
 Default destructor.
 

Private Attributes

std::string m_name_keyword
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ FitsParser()

Euclid::XYDataset::FitsParser::FitsParser ( const std::string keyword = "")
inline

Constructor Tool for reading FITS tables from streams.

Parameters
keywordThe 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.

Member Function Documentation

◆ getDataset()

std::unique_ptr< XYDataset > Euclid::XYDataset::FitsParser::getDataset ( const std::string file)
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.

Parameters
fileFilename of the FITS file to be read (including the absolute path).
Returns
A unique pointer to a XYDatatset object or null pointer.
Exceptions
Elements::ExceptionA 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().

Here is the call graph for this function:

◆ getName()

std::string Euclid::XYDataset::FitsParser::getName ( const std::string file)
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.

Parameters
fileFilename of the file to be read including absolute path
Returns
The name of the datatset
Exceptions
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().

Here is the call graph for this function:

◆ getParameter()

std::string Euclid::XYDataset::FitsParser::getParameter ( const std::string file,
const std::string key_word 
)
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.

Parameters
fileFilename of the file to be read including absolute path
key_wordkey word identifying the parameter
Returns
The name of the datatset
Exceptions
ElementException: File not found

Implements Euclid::XYDataset::FileParser.

Definition at line 53 of file FitsParser.cpp.

Referenced by getName().

◆ isDatasetFile()

bool Euclid::XYDataset::FitsParser::isDatasetFile ( const std::string file)
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.

Parameters
fileFilename of the FITS file to be read including the absolute path.
Returns
true if it is a FITS file with dataset(at least with one HDU table)

Implements Euclid::XYDataset::FileParser.

Definition at line 111 of file FitsParser.cpp.

References ELEMENTS_UNUSED.

Member Data Documentation

◆ m_name_keyword

std::string Euclid::XYDataset::FitsParser::m_name_keyword
private

Definition at line 127 of file FitsParser.h.

Referenced by getName().


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