Commit 9243fc5b1393075e0004e4d27fb584017e345b46

Authored by Jürgen Knödlseder
1 parent fa1d8f0c

Write TSTART and TSTOP in correct reference and write correct time reference to event list header.

Makes use of the GTimeReference class to convert the start and stop times into the correct reference.
inst/cta/src/GCTAObservation.cpp
@@ -1016,11 +1016,14 @@ void GCTAObservation::write_attributes(GFitsHDU* hdu) const @@ -1016,11 +1016,14 @@ void GCTAObservation::write_attributes(GFitsHDU* hdu) const
1016 // Continue only if HDU is valid 1016 // Continue only if HDU is valid
1017 if (hdu != NULL) { 1017 if (hdu != NULL) {
1018 1018
  1019 + // Get time reference
  1020 + GTimeReference timeref = events()->gti().reference();
  1021 +
1019 // Compute some attributes 1022 // Compute some attributes
1020 double ra_pnt = (m_pointing != NULL) ? m_pointing->dir().ra_deg() : 0.0; 1023 double ra_pnt = (m_pointing != NULL) ? m_pointing->dir().ra_deg() : 0.0;
1021 double dec_pnt = (m_pointing != NULL) ? m_pointing->dir().dec_deg() : 0.0; 1024 double dec_pnt = (m_pointing != NULL) ? m_pointing->dir().dec_deg() : 0.0;
1022 - double tstart = events()->tstart().secs();  
1023 - double tstop = events()->tstop().secs(); 1025 + double tstart = events()->tstart().convert(timeref);
  1026 + double tstop = events()->tstop().convert(timeref);
1024 double telapse = events()->gti().telapse(); 1027 double telapse = events()->gti().telapse();
1025 double ontime = events()->gti().ontime(); 1028 double ontime = events()->gti().ontime();
1026 double deadc = (ontime > 0.0) ? livetime() / ontime : 0.0; 1029 double deadc = (ontime > 0.0) ? livetime() / ontime : 0.0;
@@ -1037,11 +1040,7 @@ void GCTAObservation::write_attributes(GFitsHDU* hdu) const @@ -1037,11 +1040,7 @@ void GCTAObservation::write_attributes(GFitsHDU* hdu) const
1037 // Set observation time information 1040 // Set observation time information
1038 hdu->card("TSTART", tstart, "[s] Mission time of start of observation"); 1041 hdu->card("TSTART", tstart, "[s] Mission time of start of observation");
1039 hdu->card("TSTOP", tstop, "[s] Mission time of end of observation"); 1042 hdu->card("TSTOP", tstop, "[s] Mission time of end of observation");
1040 - hdu->card("MJDREFI", 51910, "[days] Integer part of mission time reference MJD");  
1041 - hdu->card("MJDREFF", 7.428703703703703e-14, "[days] Fractional part of mission time reference MJD");  
1042 - hdu->card("TIMEUNIT", "s", "Time unit");  
1043 - hdu->card("TIMESYS", "TT", "Time system");  
1044 - hdu->card("TIMEREF", "LOCAL", "Time reference"); 1043 + timeref.write(hdu);
1045 hdu->card("TELAPSE", telapse, "[s] Mission elapsed time"); 1044 hdu->card("TELAPSE", telapse, "[s] Mission elapsed time");
1046 hdu->card("ONTIME", ontime, "[s] Total good time including deadtime"); 1045 hdu->card("ONTIME", ontime, "[s] Total good time including deadtime");
1047 hdu->card("LIVETIME", livetime(), "[s] Total livetime"); 1046 hdu->card("LIVETIME", livetime(), "[s] Total livetime");