26 #include <boost/regex.hpp> 29 #include <CCfits/CCfits> 39 using boost::regex_match;
50 if (dataset_name.empty()){
56 return (dataset_name);
62 std::ifstream sfile(file);
70 std::unique_ptr<CCfits::FITS> fits {
new CCfits::FITS(file, CCfits::RWmode::Read)};
71 CCfits::ExtHDU& table_hdu = fits->extension(1);
73 table_hdu.readAllKeys();
74 auto keyword_map = table_hdu.keyWord();
75 auto iter=keyword_map.find(key_word);
76 if (iter != keyword_map.end()) {
77 iter->second->value(value);
88 std::unique_ptr<XYDataset> dataset_ptr {};
89 std::ifstream sfile(file);
91 CCfits::FITS::setVerboseMode(
true);
95 std::unique_ptr<CCfits::FITS> fits {
new CCfits::FITS(file, CCfits::RWmode::Read)};
97 const CCfits::ExtHDU& table_hdu = fits->extension(1);
102 std::vector<std::pair<double, double>> vector_pair;
103 for (
auto row : table) {
104 vector_pair.push_back(std::make_pair( boost::get<double>(row[0]), boost::get<double>(row[1]) ));
106 dataset_ptr = std::unique_ptr<XYDataset> {
new XYDataset(vector_pair) };
108 catch (CCfits::FitsException& fits_except){
120 bool is_a_dataset_file =
true;
122 std::unique_ptr<CCfits::FITS> fits {
new CCfits::FITS(file, CCfits::RWmode::Read)};
123 const CCfits::ExtHDU& table_hdu = fits->extension(1);
124 ELEMENTS_UNUSED auto& temp =
dynamic_cast<const CCfits::Table&
>(table_hdu);
126 catch (CCfits::FitsException& fits_except){
127 is_a_dataset_file =
false;
129 return is_a_dataset_file;
std::string removeAllBeforeLastSlash(const std::string &input_str)
bool isDatasetFile(const std::string &file) override
Check that the FITS file is a dataset file(with at least one HDU table)
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::string m_name_keyword
Table read(long rows=-1)
Reads next rows as a table.
std::string removeExtension(const std::string &input_str)
This module provides an interface for accessing two dimensional datasets (pairs of (X...
TableReader implementation for reading FITS tables.
std::string getName(const std::string &file) override
Get the dataset name of a FITS file.
std::unique_ptr< XYDataset > getDataset(const std::string &file) override
Get a XYDataset object reading data from an FITS file.