29#include <CCfits/CCfits>
30#include <boost/filesystem.hpp>
46 static constexpr int BPIX = BYTE_IMG;
51 static constexpr int BPIX = SHORT_IMG;
56 static constexpr int BPIX = LONG_IMG;
61 static constexpr int BPIX = LONGLONG_IMG;
66 static constexpr int BPIX = FLOAT_IMG;
71 static constexpr int BPIX = DOUBLE_IMG;
96template <
typename... AxesTypes>
105 auto& axis = std::get<I - 1>(axes_tuple);
114 for (
size_t i = 0; i < axis.size(); ++i) {
116 row_list.push_back(
Table::Row{{(int)i, fits_value}, column_info});
122 .
setHduName(axis.name() +
"_" + array_hdu_name)
130template <
typename GridCellManager,
typename... AxesTypes>
133 auto& axes = grid.getAxesTuple();
138 CCfits::FITS fits(filename.string(), CCfits::Write);
146 fits.addImage(hdu_name, bpix, ext_ax);
149 for (
auto value : grid) {
153 fits.currentExtension().write(1, grid.size(), data);
160template <
typename Gr
idType>
166 template <
int I,
typename =
void>
185 auto axis_name = hdu.name().substr(0, hdu.name().size() - grid_name.
size() - 1);
188 auto& column = hdu.column(
"Value");
189 column.read(data, 1, column.rows());
190 }
catch (CCfits::FitsException e) {
203 auto axis =
readAxis<I>(grid_name, fits.extension(hdu_index));
214 auto name = fits.extension(hdu_index).name();
215 return readAxesTuple(fits, name, hdu_index + GridType::axisNumber(),
220template <
typename Gr
idType>
222 CCfits::FITS fits(filename.string(), CCfits::Read);
229 fits.extension(hdu_index).read(data);
232 for (
auto iter = grid.begin(); iter != grid.end(); ++iter, ++i) {
static AxesTupleType< I >::type readAxesTuple(CCfits::FITS &fits, const std::string &grid_name, int hdu_index, const TemplateLoopCounter< I > &)
static std::tuple readAxesTuple(CCfits::FITS &, const std::string &, int, const TemplateLoopCounter<-1 > &)
typename std::remove_reference< decltype(std::declval< GridType >().template getAxis< I >())>::type AxisType
static GridAxisType< I > readAxis(const std::string &grid_name, CCfits::ExtHDU &hdu)
typename std::remove_reference< decltype(std::declval< GridType >().template getAxis< I >())>::type GridAxisType
static AxesTupleType< GridType::axisNumber() -1 >::type readAllAxes(CCfits::FITS &fits, int hdu_index)
Provides information related with an axis of a GridContainer.
static std::vector< size_t > createAxesSizesVector(const std::tuple< GridAxis< Axes >... > &axes, const TemplateLoopCounter< I > &)
Creates a vector which contains the sizes of the given axes.
Representation of a multi-dimensional grid which contains axis information.
Provides information about the columns of a Table.
ColumnDescription info_type
TableWriter implementation for writing tables in FITS format.
FitsWriter & setFormat(Format format)
Set the FITS table format.
@ BINARY
FITS binary table HDU format.
FitsWriter & setHduName(const std::string &name)
Set the HDU name where the table is written.
Represents one row of a Table.
void addData(const Table &table)
Appends the contents of the given table to the output.
Represents a name qualified with a set of groups.
const std::string & qualifiedName() const
Returns the qualified name as a string.
GridType gridFitsImport(const boost::filesystem::path &filename, int hdu_index)
Imports a Grid from a FITS file.
void gridFitsExport(const boost::filesystem::path &filename, const std::string &hdu_name, const GridContainer< GridCellManager, AxesTypes... > &grid)
Exports a Grid as a FITS file.
static constexpr int BPIX
static constexpr int BPIX
static constexpr int BPIX
static constexpr int BPIX
static constexpr int BPIX
static constexpr int BPIX
static void addGridAxesToFitsFile(const boost::filesystem::path &filename, const std::string &array_hdu_name, const std::tuple< GridAxis< AxesTypes >... > &axes_tuple, const TemplateLoopCounter< I > &)
static void addGridAxesToFitsFile(const boost::filesystem::path &, const std::string &, const std::tuple< GridAxis< AxesTypes >... > &, const TemplateLoopCounter< 0 > &)
decltype(std::tuple_cat(std::declval< previous >(), std::declval< std::tuple< AxisType< I > > >())) type
typename AxesTupleType< I - 1 >::type previous
static XYDataset::QualifiedName FitsToAxis(const FitsType &value)
static FitsType axisToFits(const XYDataset::QualifiedName &value)
static T FitsToAxis(const FitsType &value)
static FitsType axisToFits(const T &value)
GridCellManager::data_type data_type
The type of the data kept by the GridCellManager.