46#define G_OPERATOR "GCOSSpaceCraft::operator[](int&)"
47#define G_LOAD_ORI "GCOSSpaceCraft::load_ori(GFilename&)"
140 if (
this != &spacecraft) {
172 #if defined(G_RANGE_CHECK)
173 if (index < 0 || index >=
size()) {
197 #if defined(G_RANGE_CHECK)
198 if (index < 0 || index >=
size()) {
257 for (
int i = 0; i <
size(); ++i) {
265 double earth_radius = std::asin(6378.0 / (6378.0 + pointing.
altitude()));
272 if (distance > earth_radius) {
303 std::vector<GSkyDir> dirs;
305 for (
int k = 0; k < npix; ++k) {
306 dirs.push_back(
livetime.inx2dir(k));
310 for (
int i = 0; i <
size(); ++i) {
318 double earth_radius = std::asin(6378.0 / (6378.0 + pointing.
altitude()));
321 for (
int k = 0; k < npix; ++k) {
329 if (distance > earth_radius) {
381 fits.
saveto(filename, clobber);
463 result.append(
"=== GCOSSpaceCraft ===");
564 FILE* fptr = std::fopen(fname.c_str(),
"r");
566 std::string msg =
"Unable to open file \""+fname+
"\" for read access. "
567 "Please specify a readable file.";
574 double altitude = 0.0;
576 double gti_livetime = 0.0;
579 while (std::fgets(line, n, fptr) != NULL) {
586 if (sline.length() == 0) {
592 for (
int i = 0; i < elements.size(); ++i) {
597 if (elements.size() != 10) {
613 GSkyDir earth_nadir(earth_zenith);
618 if ((gti_livetime == 0.0) && (
livetime > 0.0)) {
628 if ((gti_livetime > 0.0) && (
livetime == 0.0)) {
674 if ((gti_livetime > 0.0) && (time > tstart)) {
710 GFits fits(filename);
736 int num = table.
nrows();
751 const GFitsTableCol* col_earth_zenith_glon = table[
"EARTH_ZENITH_GLON"];
752 const GFitsTableCol* col_earth_zenith_glat = table[
"EARTH_ZENITH_GLAT"];
756 for (
int i = 0; i < num; ++i) {
764 earth_zenith.
lb_deg(col_earth_zenith_glon->
real(i), col_earth_zenith_glat->
real(i));
767 GSkyDir earth_nadir(earth_zenith);
806 int num = table.
nrows();
818 for (
int i = 0; i < num; ++i) {
858 col_sc_x_glon.
unit(
"deg");
859 col_sc_x_glat.
unit(
"deg");
860 col_sc_z_glon.
unit(
"deg");
861 col_sc_z_glat.
unit(
"deg");
862 col_altitude.
unit(
"km");
863 col_earth_zenith_glon.
unit(
"deg");
864 col_earth_zenith_glat.
unit(
"deg");
865 col_livetime.
unit(
"s");
868 for (
int i = 0; i <
size(); ++i) {
875 col_earth_zenith_glon(i) =
m_pointings[i].earth_zenith().l_deg();
876 col_earth_zenith_glat(i) =
m_pointings[i].earth_zenith().b_deg();
882 table.
append(col_sc_x_glon);
883 table.
append(col_sc_x_glat);
884 table.
append(col_sc_z_glon);
885 table.
append(col_sc_z_glat);
886 table.
append(col_altitude);
887 table.
append(col_earth_zenith_glon);
888 table.
append(col_earth_zenith_glat);
889 table.
append(col_livetime);
897 table.
card(
"DEADC",
m_deadc,
"Deadtime correction factor");
932 col_livetime.
unit(
"s");
935 for (
int i = 0; i < num; ++i) {
940 table.
append(col_livetime);
948 table.
card(
"DEADC",
m_deadc,
"Deadtime correction factor");
COSI space craft class definition.
Exception handler interface definition.
Filename class interface definition.
FITS binary table class definition.
FITS table column abstract base class definition.
FITS table double column class interface definition.
FITS table abstract base class interface definition.
FITS file class interface definition.
Sky direction class interface definition.
Sky map class definition.
const double & livetime(void) const
Return livetime.
const GSkyDir & sc_z(void) const
Return space craft Z-axis.
const GSkyDir & earth_nadir(void) const
Return direction of Earth's nadir at space craft location.
const double & altitude(void) const
Return space craft altitude in km.
const GSkyDir & sc_x(void) const
Return space craft X-axis.
const GTime & time(void) const
Return time stamp.
const GSkyDir & earth_zenith(void) const
Return direction of Earth's zenith at space craft location.
const GGti & gti(void) const
Return Good Time Intervals.
std::vector< double > m_livetimes
Livetimes for each Good Time Interval (sec)
void load_fits(const GFilename &filename)
Load COSI space craft file from FITS file.
double m_livetime
Livetime (sec)
void load_ori(const GFilename &filename)
Load COSI space craft file from ORI file.
int size(void) const
Return number of pointing entries.
void read_livetimes(const GFits &fits)
Read livetimes from FITS file.
void write_livetimes(GFits &fits) const
Write livetimes into FITS file.
GCOSSpaceCraft(void)
Void constructor.
GCOSSpaceCraft & operator=(const GCOSSpaceCraft &spacecraft)
Assignment operator.
double m_deadc
Deadtime correction.
GGti m_gti
Good Time Intervals.
double m_ontime
Ontime (sec)
void clear(void)
Clear space craft.
void free_members(void)
Delete class members.
std::string print(const GChatter &chatter=NORMAL) const
Print space craft information.
void copy_members(const GCOSSpaceCraft &spacecraft)
Copy class members.
void read(const GFits &fits)
Read COSI space craft FITS file.
const double & ontime(void) const
Return ontime in seconds.
void load(const GFilename &filename)
Load COSI space craft file.
void write(GFits &fits) const
Write COSI space craft into FITS file.
std::vector< GCOSPointing > m_pointings
Pointings.
void read_pointings(const GFits &fits)
Read pointings from FITS file.
void write_pointings(GFits &fits) const
Write pointings into FITS file.
virtual ~GCOSSpaceCraft(void)
Destructor.
void save(const GFilename &filename, const bool &clobber=false) const
Save COSI space craft FITS file.
GCOSSpaceCraft * clone(void) const
Clone space craft.
void init_members(void)
Initialise class members.
GCOSPointing & operator[](const int &index)
Return reference to COSI pointing.
const double & livetime(void) const
Return livetime in seconds.
bool is_fits(void) const
Checks whether file is a FITS file.
std::string url(void) const
Return Uniform Resource Locator (URL)
const std::string & extname(void) const
Return extension name.
double real(const std::string &keyname) const
Return card value as double precision.
GFitsHeaderCard & card(const int &cardno)
Return header card.
Abstract interface for FITS table column.
virtual double real(const int &row, const int &inx=0) const =0
void unit(const std::string &unit)
Set column unit.
FITS table double column.
Abstract interface for FITS table.
GFitsTableCol * append(const GFitsTableCol &column)
Append column to the table.
const int & nrows(void) const
Return number of rows in table.
void saveto(const GFilename &filename, const bool &clobber=false)
Saves to specified FITS file.
GFitsHDU * append(const GFitsHDU &hdu)
Append HDU to FITS file.
void close(void)
Close FITS file.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
std::string print(const GChatter &chatter=NORMAL) const
Print Good Time Intervals.
void write(GFits &fits, const std::string &extname=gammalib::extname_gti) const
Write Good Time Intervals and time reference into FITS object.
void read(const GFitsTable &table)
Read Good Time Intervals and time reference from FITS table.
void append(const GTime &tstart, const GTime &tstop)
Append Good Time Interval.
void clear(void)
Clear Good Time Intervals.
void lb_deg(const double &l, const double &b)
Set galactic sky direction (degrees)
void rotate(const double &phi, const double &theta)
Rotate sky direction by zenith and azimuth angle.
double dist(const GSkyDir &dir) const
Compute angular distance between sky directions in radians.
GSkyMap extract(const int &map, const int &nmaps=1) const
Extract maps into a new sky map object.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
double cos_seconds(const GTime &time)
Convert GammaLib time to COSI seconds.
GTime cos_time(const double &seconds)
Convert COSI seconds to GammaLib time.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
double todouble(const std::string &arg)
Convert string into double precision value.
std::string strip_whitespace(const std::string &arg)
Strip leading and trailing whitespace from string.
std::string expand_env(const std::string &arg)
Expand environment variables in string.
GChatter reduce(const GChatter &chatter)
Reduce chattiness by one level.
const std::string extname_gti
std::vector< std::string > split(const std::string &s, const std::string &sep)
Split string.
std::string strip_chars(const std::string &arg, const std::string &chars)
Strip leading and trailing character from string.