Commit e7137bed036aaccb45c43f6c8f6b8f415ed6acce
1 parent
1fc91b4a
Add optional DRW binary table to be written into FITS file
Showing
2 changed files
with
27 additions
and
9 deletions
inst/com/include/GCOMDri.hpp
... | ... | @@ -33,6 +33,7 @@ |
33 | 33 | #include "GSkyMap.hpp" |
34 | 34 | #include "GEbounds.hpp" |
35 | 35 | #include "GGti.hpp" |
36 | +#include "GFitsBinTable.hpp" | |
36 | 37 | #include "GCOMSelection.hpp" |
37 | 38 | |
38 | 39 | /* __ Forward declarations _______________________________________________ */ |
... | ... | @@ -167,12 +168,13 @@ protected: |
167 | 168 | int m_num_used_superpackets; //!< Number of used superpackets |
168 | 169 | int m_num_skipped_superpackets; //!< Number of skipped superpackets |
169 | 170 | |
170 | - // Optional DRW parameters | |
171 | - std::string m_drw_method; //!< DRW method | |
172 | - std::string m_drw_status; //!< DRW fitting status | |
173 | - double m_drw_fprompt; //!< DRW fitted fprompt parameter | |
174 | - double m_drw_e_fprompt; //!< DRW fprompt parameter error | |
175 | - int m_drw_iter; //!< DRW fitting iterations | |
171 | + // Optional DRW members | |
172 | + std::string m_drw_method; //!< DRW method | |
173 | + GFitsBinTable m_drw_table; //!< DRW binary table to append to the FITS file | |
174 | + std::string m_drw_status; //!< DRW fitting status | |
175 | + double m_drw_fprompt; //!< DRW fitted fprompt parameter | |
176 | + double m_drw_e_fprompt; //!< DRW fprompt parameter error | |
177 | + int m_drw_iter; //!< DRW fitting iterations | |
176 | 178 | |
177 | 179 | // Selection parameters |
178 | 180 | bool m_has_selection; //!< Signal that selection was applied | ... | ... |
inst/com/src/GCOMDri.cpp
1 | 1 | /*************************************************************************** |
2 | 2 | * GCOMDri.cpp - COMPTEL Data Space class * |
3 | 3 | * ----------------------------------------------------------------------- * |
4 | - * copyright (C) 2017-2022 by Juergen Knoedlseder * | |
4 | + * copyright (C) 2017-2023 by Juergen Knoedlseder * | |
5 | 5 | * ----------------------------------------------------------------------- * |
6 | 6 | * * |
7 | 7 | * This program is free software: you can redistribute it and/or modify * |
... | ... | @@ -900,6 +900,15 @@ void GCOMDri::load(const GFilename& filename) |
900 | 900 | // Read DRI file |
901 | 901 | read(hdu); |
902 | 902 | |
903 | + // If FITS file contains binary table then copy table into member | |
904 | + for (int i = 0; i < fits.size(); ++i) { | |
905 | + const GFitsBinTable* table = dynamic_cast<const GFitsBinTable*>(fits[i]); | |
906 | + if (table != NULL) { | |
907 | + m_drw_table = *table; | |
908 | + break; | |
909 | + } | |
910 | + } | |
911 | + | |
903 | 912 | // Close FITS file |
904 | 913 | fits.close(); |
905 | 914 | |
... | ... | @@ -922,6 +931,11 @@ void GCOMDri::save(const GFilename& filename, const bool& clobber) const |
922 | 931 | // Write data space into FITS file |
923 | 932 | write(fits, filename.extname(gammalib::extname_dri)); |
924 | 933 | |
934 | + // If DRI contains filled DRW binary table then append table to FITS file | |
935 | + if (m_drw_table.nrows() > 0) { | |
936 | + fits.append(m_drw_table); | |
937 | + } | |
938 | + | |
925 | 939 | // Save FITS file |
926 | 940 | fits.saveto(filename, clobber); |
927 | 941 | |
... | ... | @@ -1091,8 +1105,9 @@ void GCOMDri::init_members(void) |
1091 | 1105 | // Initialise statistics |
1092 | 1106 | init_statistics(); |
1093 | 1107 | |
1094 | - // Initialise optional DRW parameters | |
1108 | + // Initialise optional DRW members | |
1095 | 1109 | m_drw_method.clear(); |
1110 | + m_drw_table.clear(); | |
1096 | 1111 | m_drw_status.clear(); |
1097 | 1112 | m_drw_fprompt = 0.0; |
1098 | 1113 | m_drw_e_fprompt = 0.0; |
... | ... | @@ -1132,8 +1147,9 @@ void GCOMDri::copy_members(const GCOMDri& dri) |
1132 | 1147 | m_num_used_superpackets = dri.m_num_used_superpackets; |
1133 | 1148 | m_num_skipped_superpackets = dri.m_num_skipped_superpackets; |
1134 | 1149 | |
1135 | - // Copy optional DRW parameters | |
1150 | + // Copy optional DRW members | |
1136 | 1151 | m_drw_method = dri.m_drw_method; |
1152 | + m_drw_table = dri.m_drw_table; | |
1137 | 1153 | m_drw_status = dri.m_drw_status; |
1138 | 1154 | m_drw_fprompt = dri.m_drw_fprompt; |
1139 | 1155 | m_drw_e_fprompt = dri.m_drw_e_fprompt; | ... | ... |