39 #define G_NAXIS "GSPIEventCube::naxis(int)"
40 #define G_MODEL_COUNTS "GSPIEventCube::model_counts(int&)"
41 #define G_SET_ENERGIES "GSPIEventCube::set_energies()"
42 #define G_SET_TIMES "GSPIEventCube::set_times()"
43 #define G_SET_BIN "GSPIEventCube::set_bin(int&)"
44 #define G_READ_FITS "GSPIEventCube::read(GFits&)"
45 #define G_READ_EBDS "GSPIEventCube::read_ebds(GFitsTable*)"
46 #define G_READ_PNT "GSPIEventCube::read_pnt(GFitsTable*, GFitsTable*)"
47 #define G_READ_MODELS "GSPIEventCube::read_models(GFits&)"
48 #define G_PTID "GSPIEventCube::ptid(int&)"
49 #define G_DIR "GSPIEventCube::dir(int&, int&)"
50 #define G_SPI_X "GSPIEventCube::spi_x(int&)"
51 #define G_SPI_Z "GSPIEventCube::spi_z(int&)"
263 #if defined(G_RANGE_CHECK)
264 if (axis < 0 || axis >=
dim()) {
274 int naxis = *ptr[axis];
291 #pragma omp critical(GSPIEventCube_load)
297 GFits fits(filename);
328 fits.
saveto(filename, clobber);
375 std::string msg =
"Extension \"SPI.-EBDS-SET\" not found in "
376 "Observation Group FITS file \""+
378 "valid Observation Group.";
382 std::string msg =
"Extension \"SPI.-OBS.-PNT\" not found in "
383 "Observation Group FITS file \""+
385 "valid Observation Group.";
389 std::string msg =
"Extension \"SPI.-OBS.-GTI\" not found in "
390 "Observation Group FITS file \""+
392 "valid Observation Group.";
396 std::string msg =
"Extension \"SPI.-OBS.-DSP\" not found in "
397 "Observation Group FITS file \""+
399 "valid Observation Group.";
403 std::string msg =
"Extension \"SPI.-OBS.-DTI\" not found in "
404 "Observation Group FITS file \""+
406 "valid Observation Group.";
441 if (ebds != NULL)
delete ebds;
442 if (pnt != NULL)
delete pnt;
443 if (gti != NULL)
delete gti;
444 if (dsp != NULL)
delete dsp;
445 if (dti != NULL)
delete dti;
493 return int(number+0.5);
512 for (
int ipt = 0; ipt <
m_num_pt; ++ipt) {
516 double mean_ontime = 0.0;
517 double num_active_det = 0.0;
520 for (
int idet = 0; idet <
m_num_det; ++idet) {
523 int irow = ipt * m_num_det + idet;
529 num_active_det += 1.0;
535 if (num_active_det > 0.0) {
536 mean_ontime /= num_active_det;
543 ontime += mean_ontime;
567 for (
int ipt = 0; ipt <
m_num_pt; ++ipt) {
571 double mean_livetime = 0.0;
572 double num_active_det = 0.0;
575 for (
int idet = 0; idet <
m_num_det; ++idet) {
578 int irow = ipt * m_num_det + idet;
584 num_active_det += 1.0;
590 if (num_active_det > 0.0) {
591 mean_livetime /= num_active_det;
598 livetime += mean_livetime;
627 #if defined(G_RANGE_CHECK)
628 if (index < 0 || index >= num_models) {
637 counts +=
m_models[i*num_models + index];
660 #if defined(G_RANGE_CHECK)
688 #if defined(G_RANGE_CHECK)
719 #if defined(G_RANGE_CHECK)
745 #if defined(G_RANGE_CHECK)
772 result.append(
"=== GSPIEventCube ===");
809 result.append(
tstart().utc()+
" - ");
810 result.append(
tstop().utc());
900 for (
int i = 0; i <
m_num_pt; ++i) {
997 if (m_num_ebin > 0) {
1011 for (
int i = 0; i <
m_num_pt; ++i) {
1079 std::string msg =
"Number of energy bins "+
1081 "\"SPI.-EBDS-SET\" extension differes from value "+
1083 "in \"SPI.-OBS.-DSP\" extension. Please specify a "
1084 "valid Observation Group.";
1089 for (
int iebin = 0; iebin <
m_num_ebin; ++iebin) {
1119 if (pnt != NULL && gti != NULL) {
1131 for (
int ipt = 0; ipt <
m_num_pt; ++ipt) {
1145 for (
int idet = 0; idet <
m_num_det; ++idet) {
1148 int irow = ipt * m_num_det + idet;
1153 std::string msg =
"PITD_SPI \""+pnt_ptid->
string(ipt)+
"\" in "
1154 "\"SPI.-OBS.-PNT\" differs from \""+
1155 gti_ptid->
string(irow)+
"\" in "
1156 "\"SPI.-OBS.-GTI\" extension for detector "+
1158 "specify a valid Observation Group.";
1196 for (
int ipt = 0; ipt <
m_num_pt; ++ipt) {
1201 double t_start = 0.0;
1202 double t_stop = 0.0;
1205 for (
int idet = 0; idet <
m_num_det; ++idet) {
1208 int irow = ipt * m_num_det + idet;
1214 double ijd = 0.5 * (tstart->
real(irow) + tstop->
real(irow));
1219 if (ontime->
real(irow) > 0.0) {
1220 if (t_start == 0.0 || (tstart->
real(irow) < t_start)) {
1221 t_start = tstart->
real(irow);
1223 if (t_stop == 0.0 || (tstop->
real(irow) > t_stop)) {
1224 t_stop = tstop->
real(irow);
1231 if (t_start != 0.0 && t_stop != 0.0) {
1262 for (
int ipt = 0; ipt <
m_num_pt; ++ipt) {
1265 for (
int idet = 0; idet <
m_num_det; ++idet) {
1268 int irow = ipt * m_num_det + idet;
1306 for (
int ipt = 0; ipt <
m_num_pt; ++ipt) {
1309 for (
int idet = 0; idet <
m_num_det; ++idet) {
1312 int irow = ipt * m_num_det + idet;
1318 for (
int iebin = 0; iebin <
m_num_ebin; ++iebin, ++index) {
1352 for (
int i = 0; i <
m_num_sky; ++i, ++imodel) {
1358 if (model == NULL) {
1359 std::string msg =
"Extension \"SPI.-SDET-SPE\" version "+
1362 "\". Please specify a valid Observation Group.";
1369 name = model->
string(
"SOURCEID");
1377 for (
int ipt = 0; ipt <
m_num_pt; ++ipt) {
1380 for (
int idet = 0; idet <
m_num_det; ++idet) {
1383 int irow = ipt * m_num_det + idet;
1389 for (
int iebin = 0; iebin <
m_num_ebin; ++iebin, ++index) {
1390 m_models[index*num_models + imodel] = counts->
real(irow, iebin);
1400 for (
int i = 0; i <
m_num_bgm; ++i, ++imodel) {
1406 if (model == NULL) {
1407 std::string msg =
"Extension \"SPI.-BMOD-DSP\" version "+
1410 "\". Please specify a valid Observation Group.";
1417 name = model->
string(
"BKGNAME");
1425 for (
int ipt = 0; ipt <
m_num_pt; ++ipt) {
1428 for (
int idet = 0; idet <
m_num_det; ++idet) {
1431 int irow = ipt * m_num_det + idet;
1437 for (
int iebin = 0; iebin <
m_num_ebin; ++iebin, ++index) {
1438 m_models[index*num_models + imodel] = counts->
real(irow, iebin);
1501 #if defined(G_RANGE_CHECK)
1502 if (index < 0 || index >=
size()) {
GEnergy * m_energy
Pointer to energy of bin.
const GGti & gti(void) const
Return Good Time Intervals.
GSPIInstDir * m_dir
Pointer to direction of bin.
virtual void read(const GFits &file)
Read INTEGRAL/SPI event cube from Observation Group FITS file.
void init_members(void)
Initialise class members.
bool has_card(const int &cardno) const
Check existence of header card.
double * m_livetime
Livetime array.
const GSkyDir & spi_z(const int &ipt) const
Return SPI Z direction.
double * m_models
Models array.
Energy value class definition.
const GSkyDir & spi_x(const int &ipt) const
Return SPI X direction (pointing direction)
virtual std::string print(const GChatter &chatter=NORMAL) const
Print INTEGRAL/SPI event cube information.
double * m_livetime
Pointer to livetime of bin.
int m_num_pt
Number of pointings.
const GSPIInstDir & dir(const int &ipt, const int &idet) const
Return instrument direction.
Sky direction class interface definition.
virtual GSPIEventCube * clone(void) const
Clone event cube.
GSPIInstDir * m_dir
Event direction array.
int size(void) const
Return number of energy boundaries.
GTime * m_time
Time array.
void init_members(void)
Initialise class members.
void free_members(void)
Delete class members.
GSPIEventCube(void)
Void constructor.
const GFilename & filename(void) const
Return FITS filename.
virtual GEventCube & operator=(const GEventCube &cube)
Assignment operator.
void read_models(const GFits &file)
Read models from INTEGRAL/SPI Observation Group.
void init_bin(void)
Initialise event bin.
virtual void clear(void)
Clear INTEGRAL/SPI instrument direction.
const GTime & tstop(void) const
Return stop time.
int m_num_bgm
Number of background models.
int m_model_size
Size of model arrays.
void clear(void)
Clear time.
GEbounds m_ebounds
Energy boundaries covered by events.
GSPIEventBin m_bin
Actual event bin.
int m_idir
Direction index.
INTEGRAL/SPI event bin container class definition.
double MeV(void) const
Return energy in MeV.
void read(const GFitsTable &table)
Read energy boundaries from FITS table.
void detid(const int &detid)
Set detector identifier.
double * m_counts
Counts array.
int spi_num_hdus(const GFits &fits, const std::string &extname)
Return number of HDU versions.
void read_dsp(const GFitsTable *dsp)
Read data from INTEGRAL/SPI "SPI.-OBS.-DSP" extension.
GEnergy emean(const int &index) const
Returns mean energy for a given energy interval.
virtual void clear(void)
Clear INTEGRAL/SPI event bin.
virtual void load(const GFilename &filename)
Load INTEGRAL/SPI event cube from Observation Group.
int m_dsp_size
Size of DSP arrays.
void dir(const GSkyDir &dir)
Set pointing direction.
int m_index
Dataspace index.
GEnergy * m_ewidth
Energy bin width array.
GEnergy ewidth(const int &index) const
Returns energy interval width.
void append(const GTime &tstart, const GTime &tstop)
Append Good Time Interval.
void copy_members(const GSPIEventCube &cube)
Copy class members.
INTEGRAL/SPI instrument direction class.
int m_gti_size
Size of GTI arrays.
virtual std::string string(const int &row, const int &inx=0) const =0
GTime spi_ijd2time(const double &ijd)
Convert IJD to GTime.
void free_members(void)
Delete class members.
INTEGRAL/SPI event bin container class.
void saveto(const GFilename &filename, const bool &clobber=false)
Saves to specified FITS file.
void free_members(void)
Delete class members.
double * m_ontime
Pointer to ontime of bin.
void read_gti(const GFitsTable *gti)
Read data from INTEGRAL/SPI "SPI.-OBS.-GTI" extension.
void read_pnt(const GFitsTable *pnt, const GFitsTable *gti)
Read pointing information.
GSkyDir * m_spix
SPI X axis array.
virtual GSPIEventBin * operator[](const int &index)
Event bin access operator.
void free_members(void)
Delete class members.
Abstract interface for FITS table column.
void read_ebds(const GFitsTable *ebds)
Read data from INTEGRAL/SPI "SPI.-EBDS-SET" extension.
const GFitsTable * spi_hdu(const GFits &fits, const std::string &extname, const int &extver=1)
Return FITS table.
std::vector< std::string > m_modnames
Model names.
virtual void clear(void)
Clear INTEGRAL/SPI event cube.
Abstract interface for FITS table.
double livetime(void) const
Return total livetime.
GGti m_gti
Good time intervals covered by events.
virtual void save(const GFilename &filename, const bool &clobber=false) const
Save INTEGRAL/SPI event cube into FITS file.
virtual GSPIEventCube & operator=(const GSPIEventCube &cube)
Assignment operator.
int integer(const std::string &keyname) const
Return card value as integer.
double * m_size
Event bin size array.
virtual int size(void) const
Return event cube size.
double * m_size
Pointer to size of bin.
void radec_deg(const double &ra, const double &dec)
Set equatorial sky direction (degrees)
double * m_ontime
Ontime array.
void init_members(void)
Initialise class members.
void read_dti(const GFitsTable *dti)
Read data from INTEGRAL/SPI "SPI.-OBS.-DTI" extension.
const std::string & ptid(const int &ipt) const
Return pointing identifier.
std::string url(void) const
Return Uniform Resource Locator (URL)
void clear(void)
Clear sky direction.
double * m_models
Pointer to models of bin.
virtual int integer(const int &row, const int &inx=0) const =0
GSkyDir * m_spiz
SPI Z axis array.
virtual double real(const int &row, const int &inx=0) const =0
void alloc_data(void)
Allocate data.
const GEnergy & emin(void) const
Return minimum energy.
virtual void write(GFits &file) const
Write INTEGRAL/SPI event cube into FITS file.
int m_num_sky
Number of sky models.
GTime * m_time
Pointer to time of bin.
double * m_counts
Pointer to number of counts.
std::string string(const std::string &keyname) const
Return card value as string.
int m_iebin
Energy bin index.
INTEGRAL/SPI event bin class.
double ontime(void) const
Return total ontime.
std::string * m_ptid
Pointing identifiers.
virtual int naxis(const int &axis) const
Return number of bins in axis.
GEnergy * m_energy
Energy array.
int m_num_ebin
Number of energy bins.
virtual int number(void) const
Return number of events in cube.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
virtual ~GSPIEventCube(void)
Destructor.
const GTime & tstart(void) const
Return start time.
Abstract event bin container class.
void close(void)
Close FITS file.
void set_bin(const int &index)
Set event bin.
Time class interface definition.
const GEnergy & emax(void) const
Return maximum energy.
INTEGRAL/SPI instrument direction class definition.
double * m_stat_err
Statistical error array.
void clear(void)
Clear instance.
int m_num_models
Number of models in bin.
int m_num_det
Number of detectors.
double model_counts(const int &index) const
Return number of events in model.
virtual int dim(void) const
Return event cube dimension.
Class that handles energies in a unit independent way.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.