39#define G_NAXIS "GSPIEventCube::naxis(int)"
40#define G_MODEL_COUNTS "GSPIEventCube::model_counts(int&)"
41#define G_MODEL_NAME "GSPIEventCube::model_name(int&)"
42#define G_SET_ENERGIES "GSPIEventCube::set_energies()"
43#define G_SET_TIMES "GSPIEventCube::set_times()"
44#define G_SET_BIN "GSPIEventCube::set_bin(int&)"
45#define G_READ_FITS "GSPIEventCube::read(GFits&)"
46#define G_READ_EBDS "GSPIEventCube::read_ebds(GFitsTable*)"
47#define G_READ_PNT "GSPIEventCube::read_pnt(GFitsTable*, GFitsTable*)"
48#define G_READ_MODELS "GSPIEventCube::read_models(GFits&)"
49#define G_PTID "GSPIEventCube::ptid(int&)"
50#define G_DIR "GSPIEventCube::dir(int&, int&)"
51#define G_SPI_X "GSPIEventCube::spi_x(int&)"
52#define G_SPI_Z "GSPIEventCube::spi_z(int&)"
53#define G_EVENT_SIZE "GSPIEventCube::event_size(int&)"
54#define G_EVENT_MODEL "GSPIEventCube::event_model(int&, int&)"
266 #if defined(G_RANGE_CHECK)
267 if (axis < 0 || axis >=
dim()) {
277 int naxis = *ptr[axis];
294 #pragma omp critical(GSPIEventCube_load)
300 GFits fits(filename);
331 fits.
saveto(filename, clobber);
378 std::string msg =
"Extension \"SPI.-EBDS-SET\" not found in "
379 "Observation Group FITS file \""+
381 "valid Observation Group.";
385 std::string msg =
"Extension \"SPI.-OBS.-PNT\" not found in "
386 "Observation Group FITS file \""+
388 "valid Observation Group.";
392 std::string msg =
"Extension \"SPI.-OBS.-GTI\" not found in "
393 "Observation Group FITS file \""+
395 "valid Observation Group.";
399 std::string msg =
"Extension \"SPI.-OBS.-DSP\" not found in "
400 "Observation Group FITS file \""+
402 "valid Observation Group.";
406 std::string msg =
"Extension \"SPI.-OBS.-DTI\" not found in "
407 "Observation Group FITS file \""+
409 "valid Observation Group.";
444 if (ebds != NULL)
delete ebds;
445 if (pnt != NULL)
delete pnt;
446 if (
gti != NULL)
delete gti;
447 if (dsp != NULL)
delete dsp;
448 if (dti != NULL)
delete dti;
513 for (
int ipt = 0; ipt <
m_num_pt; ++ipt) {
517 double mean_ontime = 0.0;
518 double num_active_det = 0.0;
521 for (
int idet = 0; idet <
m_num_det; ++idet) {
530 num_active_det += 1.0;
536 if (num_active_det > 0.0) {
537 mean_ontime /= num_active_det;
568 for (
int ipt = 0; ipt <
m_num_pt; ++ipt) {
572 double mean_livetime = 0.0;
573 double num_active_det = 0.0;
576 for (
int idet = 0; idet <
m_num_det; ++idet) {
585 num_active_det += 1.0;
591 if (num_active_det > 0.0) {
592 mean_livetime /= num_active_det;
628 #if defined(G_RANGE_CHECK)
629 if (index < 0 || index >= num_models) {
638 counts +=
m_models[i*num_models + index];
664 #if defined(G_RANGE_CHECK)
665 if (index < 0 || index >= num_models) {
690 #if defined(G_RANGE_CHECK)
718 #if defined(G_RANGE_CHECK)
749 #if defined(G_RANGE_CHECK)
775 #if defined(G_RANGE_CHECK)
801 #if defined(G_RANGE_CHECK)
802 if (ievent < 0 || ievent >=
size()) {
830 #if defined(G_RANGE_CHECK)
831 if (ievent < 0 || ievent >=
size()) {
835 #if defined(G_RANGE_CHECK)
836 if (imodel < 0 || imodel >= nmodels) {
842 return (
m_models[imodel+ievent*nmodels]);
861 result.append(
"=== GSPIEventCube ===");
898 result.append(
tstart().utc()+
" - ");
899 result.append(
tstop().utc());
990 for (
int i = 0; i <
m_num_pt; ++i) {
1109 for (
int i = 0; i <
m_num_pt; ++i) {
1185 std::string msg =
"Number of energy bins "+
1187 "\"SPI.-EBDS-SET\" extension differes from value "+
1189 "in \"SPI.-OBS.-DSP\" extension. Please specify a "
1190 "valid Observation Group.";
1195 for (
int iebin = 0; iebin <
m_num_ebin; ++iebin) {
1225 if (pnt != NULL &&
gti != NULL) {
1237 for (
int ipt = 0; ipt <
m_num_pt; ++ipt) {
1251 for (
int idet = 0; idet <
m_num_det; ++idet) {
1259 std::string msg =
"PITD_SPI \""+pnt_ptid->
string(ipt)+
"\" in "
1260 "\"SPI.-OBS.-PNT\" differs from \""+
1261 gti_ptid->
string(irow)+
"\" in "
1262 "\"SPI.-OBS.-GTI\" extension for detector "+
1264 "specify a valid Observation Group.";
1282 " for pointing \""+pnt_ptid->
string(ipt)+
1284 " for pointing \""+pnt_ptid->
string(0)+
1285 "\". Please specify a valid Observation Group.";
1327 for (
int ipt = 0; ipt <
m_num_pt; ++ipt) {
1332 double t_start = 0.0;
1333 double t_stop = 0.0;
1336 for (
int idet = 0; idet <
m_num_det; ++idet) {
1345 double ijd = 0.5 * (
tstart->real(irow) +
tstop->real(irow));
1350 if (
ontime->real(irow) > 0.0) {
1351 if (t_start == 0.0 || (
tstart->real(irow) < t_start)) {
1352 t_start =
tstart->real(irow);
1354 if (t_stop == 0.0 || (
tstop->real(irow) > t_stop)) {
1355 t_stop =
tstop->real(irow);
1362 if (t_start != 0.0 && t_stop != 0.0) {
1396 for (
int ipt = 0; ipt <
m_num_pt; ++ipt) {
1399 for (
int idet = 0; idet <
m_num_det; ++idet) {
1440 for (
int ipt = 0; ipt <
m_num_pt; ++ipt) {
1443 for (
int idet = 0; idet <
m_num_det; ++idet) {
1452 for (
int iebin = 0; iebin <
m_num_ebin; ++iebin, ++index) {
1486 for (
int i = 0; i <
m_num_sky; ++i, ++imodel) {
1492 if (model == NULL) {
1493 std::string msg =
"Extension \"SPI.-SDET-SPE\" version "+
1496 "\". Please specify a valid Observation Group.";
1503 name = model->
string(
"SOURCEID");
1511 for (
int ipt = 0; ipt <
m_num_pt; ++ipt) {
1514 for (
int idet = 0; idet <
m_num_det; ++idet) {
1523 for (
int iebin = 0; iebin <
m_num_ebin; ++iebin, ++index) {
1524 m_models[index*num_models + imodel] = counts->
real(irow, iebin);
1534 for (
int i = 0; i <
m_num_bgm; ++i, ++imodel) {
1540 if (model == NULL) {
1541 std::string msg =
"Extension \"SPI.-BMOD-DSP\" version "+
1544 "\". Please specify a valid Observation Group.";
1551 name = model->
string(
"BKGNAME");
1559 for (
int ipt = 0; ipt <
m_num_pt; ++ipt) {
1562 for (
int idet = 0; idet <
m_num_det; ++idet) {
1571 for (
int iebin = 0; iebin <
m_num_ebin; ++iebin, ++index) {
1572 m_models[index*num_models + imodel] = counts->
real(irow, iebin);
1635 #if defined(G_RANGE_CHECK)
1636 if (index < 0 || index >=
size()) {
Energy value class definition.
INTEGRAL/SPI event bin container class definition.
INTEGRAL/SPI instrument direction class definition.
Sky direction class interface definition.
Time class interface definition.
GEnergy ewidth(const int &index) const
Returns energy interval width.
void read(const GFitsTable &table)
Read energy boundaries from FITS table.
GEnergy emean(const int &index) const
Returns mean energy for a given energy interval.
int size(void) const
Return number of energy boundaries.
Class that handles energies in a unit independent way.
double MeV(void) const
Return energy in MeV.
void clear(void)
Clear instance.
Abstract event bin container class.
void free_members(void)
Delete class members.
void init_members(void)
Initialise class members.
virtual GEventCube & operator=(const GEventCube &cube)
Assignment operator.
void free_members(void)
Delete class members.
GGti m_gti
Good time intervals covered by events.
const GTime & tstart(void) const
Return start time.
GEbounds m_ebounds
Energy boundaries covered by events.
const GGti & gti(void) const
Return Good Time Intervals.
void init_members(void)
Initialise class members.
const GTime & tstop(void) const
Return stop time.
const GEnergy & emax(void) const
Return maximum energy.
const GEnergy & emin(void) const
Return minimum energy.
std::string url(void) const
Return Uniform Resource Locator (URL)
bool has_card(const int &cardno) const
Check existence of header card.
std::string string(const std::string &keyname) const
Return card value as string.
int integer(const std::string &keyname) const
Return card value as integer.
Abstract interface for FITS table column.
virtual int integer(const int &row, const int &inx=0) const =0
virtual double real(const int &row, const int &inx=0) const =0
virtual std::string string(const int &row, const int &inx=0) const =0
Abstract interface for FITS table.
void saveto(const GFilename &filename, const bool &clobber=false)
Saves to specified FITS file.
void close(void)
Close FITS file.
const GFilename & filename(void) const
Return FITS filename.
void append(const GTime &tstart, const GTime &tstop)
Append Good Time Interval.
INTEGRAL/SPI event bin class.
virtual void clear(void)
Clear INTEGRAL/SPI event bin.
int m_index
Dataspace index.
GSPIInstDir * m_dir
Pointer to direction of bin.
GTime * m_time
Pointer to time of bin.
GEnergy * m_energy
Pointer to energy of bin.
double * m_counts
Pointer to number of counts.
int m_num_models
Number of models in bin.
int m_iebin
Energy bin index.
void free_members(void)
Delete class members.
double * m_ontime
Pointer to ontime of bin.
int m_idir
Direction index.
double * m_livetime
Pointer to livetime of bin.
double * m_size
Pointer to size of bin.
double * m_models
Pointer to models of bin.
INTEGRAL/SPI event bin container class.
void copy_members(const GSPIEventCube &cube)
Copy class members.
virtual void clear(void)
Clear INTEGRAL/SPI event cube.
void init_members(void)
Initialise class members.
void read_pnt(const GFitsTable *pnt, const GFitsTable *gti)
Read pointing information.
GSkyDir * m_spiz
SPI Z axis array.
GSkyDir * m_spix
SPI X axis array.
int m_model_size
Size of model arrays.
const GSPIInstDir & dir(const int &ipt, const int &idet) const
Return instrument direction.
const double & event_model(const int &ievent, const int &imodel) const
Return value of model for event bin.
const GSkyDir & spi_z(const int &ipt) const
Return SPI Z direction.
const double & event_size(const int &ievent) const
Return size of event bin.
double * m_livetime
Livetime array.
int models(void) const
Return number of models.
virtual double number(void) const
Return number of events in cube.
GSPIEventBin m_bin
Actual event bin.
void read_models(const GFits &file)
Read models from INTEGRAL/SPI Observation Group.
GTime * m_time
Time array.
virtual ~GSPIEventCube(void)
Destructor.
void read_dti(const GFitsTable *dti)
Read data from INTEGRAL/SPI "SPI.-OBS.-DTI" extension.
virtual int dim(void) const
Return event cube dimension.
void read_dsp(const GFitsTable *dsp)
Read data from INTEGRAL/SPI "SPI.-OBS.-DSP" extension.
virtual void save(const GFilename &filename, const bool &clobber=false) const
Save INTEGRAL/SPI event cube into FITS file.
virtual int naxis(const int &axis) const
Return number of bins in axis.
void free_members(void)
Delete class members.
double livetime(void) const
Return total livetime.
virtual int size(void) const
Return event cube size.
void init_bin(void)
Initialise event bin.
GEnergy * m_energy
Energy array.
int m_num_pt
Number of pointings.
std::vector< std::string > m_modnames
Model names.
const std::string & ptid(const int &ipt) const
Return pointing identifier.
void set_bin(const int &index)
Set event bin.
virtual GSPIEventCube & operator=(const GSPIEventCube &cube)
Assignment operator.
double ontime(void) const
Return total ontime.
virtual void load(const GFilename &filename)
Load INTEGRAL/SPI event cube from Observation Group.
virtual void write(GFits &file) const
Write INTEGRAL/SPI event cube into FITS file.
const std::string & model_name(const int &index) const
Return model name.
double * m_size
Event bin size array.
GSPIInstDir * m_dir
Event direction array.
void read_gti(const GFitsTable *gti)
Read data from INTEGRAL/SPI "SPI.-OBS.-GTI" extension.
void alloc_data(void)
Allocate data.
int m_gti_size
Size of GTI arrays.
int m_num_sky
Number of sky models.
int * m_detid
Detector ID of event cube ADD!!!!
int m_num_ebin
Number of energy bins.
virtual GSPIEventBin * operator[](const int &index)
Event bin access operator.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print INTEGRAL/SPI event cube information.
int m_num_det
Number of detectors.
int m_num_bgm
Number of background models.
double * m_counts
Counts array.
double * m_stat_err
Statistical error array.
double * m_ontime
Ontime array.
std::string * m_ptid
Pointing identifiers.
GSPIEventCube(void)
Void constructor.
virtual GSPIEventCube * clone(void) const
Clone event cube.
int m_dsp_size
Size of DSP arrays.
virtual void read(const GFits &file)
Read INTEGRAL/SPI event cube from Observation Group FITS file.
GEnergy * m_ewidth
Energy bin width array.
double * m_models
Models array.
double model_counts(const int &index) const
Return number of events in model.
const GSkyDir & spi_x(const int &ipt) const
Return SPI X direction (pointing direction)
void read_ebds(const GFitsTable *ebds)
Read data from INTEGRAL/SPI "SPI.-EBDS-SET" extension.
INTEGRAL/SPI instrument direction class.
virtual void clear(void)
Clear INTEGRAL/SPI instrument direction.
void dir(const GSkyDir &dir)
Set pointing direction.
void detid(const int &detid)
Set detector identifier.
void radec_deg(const double &ra, const double &dec)
Set equatorial sky direction (degrees)
void clear(void)
Clear sky direction.
void clear(void)
Clear time.
void append(const GTime &time)
Append time to container.
void reserve(const int &num)
Reserve memory for times in container.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
int spi_num_hdus(const GFits &fits, const std::string &extname)
Return number of HDU versions.
GTime spi_ijd2time(const double &ijd)
Convert IJD to GTime.
const GFitsTable * spi_hdu(const GFits &fits, const std::string &extname, const int &extver=1)
Return FITS table.