Changeset 12618 for trunk/FACT++/src


Ignore:
Timestamp:
11/22/11 23:39:34 (13 years ago)
Author:
tbretz
Message:
Implemented Time::UnixDate and use this instead of UnixTime when writing TSTART and TSTOP in FITS header -- units there are days not seconds.
Location:
trunk/FACT++/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/DataWriteFits.cc

    r12615 r12618  
    246246        const Time stop (fTstop[0],  fTstop[1]);
    247247
    248         fFile.WriteKey("TSTARTI",  floor(start.UnixTime()),
     248        fFile.WriteKey("TSTARTI",  uint32_t(floor(start.UnixDate())),
    249249                       "Time when first event received (integral part)");
    250         fFile.WriteKey("TSTARTF",  fmod(start.UnixTime(), 1),
     250        fFile.WriteKey("TSTARTF",  fmod(start.UnixDate(), 1),
    251251                       "Time when first event received (fractional part)");
    252         fFile.WriteKey("TSTOPI",   floor(stop.UnixTime()),
     252        fFile.WriteKey("TSTOPI",   uint32_t(floor(stop.UnixDate())),
    253253                       "Time when last event received (integral part)");
    254         fFile.WriteKey("TSTOPF",   fmod(stop.UnixTime(), 1),
     254        fFile.WriteKey("TSTOPF",   fmod(stop.UnixDate(), 1),
    255255                       "Time when last event received (fractional part)");
    256256        fFile.WriteKey("DATE-OBS", start.Iso(),
  • trunk/FACT++/src/Fits.cc

    r12616 r12618  
    322322        const double doubleValue = *reinterpret_cast<double*>(fStandardPointers[0]);
    323323
    324         const double start = Time(doubleValue).UnixTime();
    325         const double stop  = Time(fEndMjD).UnixTime();
    326 
    327         fFile->WriteKeyNT("TSTARTI", floor(start),  "Time when first event received (integral part)");
    328         fFile->WriteKeyNT("TSTARTF", fmod(start, 1), "Time when first event received (fractional part)");
    329         fFile->WriteKeyNT("TSTOPI",  floor(stop),    "Time when last event received (integral part)");
    330         fFile->WriteKeyNT("TSTOPF",  fmod(stop, 1),  "Time when last event received (fractional part)");
     324        const double start = Time(doubleValue).UnixDate();
     325        const double stop  = Time(fEndMjD).UnixDate();
     326
     327        fFile->WriteKeyNT("TSTARTI", uint32_t(floor(start)), "Time when first event received (integral part)");
     328        fFile->WriteKeyNT("TSTARTF", fmod(start, 1),         "Time when first event received (fractional part)");
     329        fFile->WriteKeyNT("TSTOPI",  uint32_t(floor(stop)),  "Time when last event received (integral part)");
     330        fFile->WriteKeyNT("TSTOPF",  fmod(stop, 1),          "Time when last event received (fractional part)");
    331331
    332332        fFile->WriteKeyNT("DATE-OBS", Time(doubleValue).Iso(),
     
    353353    if (fFile->IsOpen() && fFile->IsOwner())
    354354    {
    355         const double stop = Time(fEndMjD).UnixTime();
     355        const double stop = Time(fEndMjD).UnixDate();
    356356
    357357        // FIMXE: Check for error? (It is allowed that fFile is NULL)
    358         fFile->WriteKeyNT("TSTOPI", floor(stop),   "Time when last event received (integral part)");
    359         fFile->WriteKeyNT("TSTOPF", fmod(stop, 1), "Time when last event received (fractional part)");
     358        fFile->WriteKeyNT("TSTOPI", uint32_t(floor(stop)),   "Time when last event received (integral part)");
     359        fFile->WriteKeyNT("TSTOPF", fmod(stop, 1),           "Time when last event received (fractional part)");
    360360
    361361        fFile->WriteKeyNT("DATE-END", Time(fEndMjD).Iso(),
  • trunk/FACT++/src/Time.cc

    r11440 r12618  
    186186// --------------------------------------------------------------------------
    187187//
     188// @returns days since 1970/1/1
     189//
     190double Time::UnixDate() const
     191{
     192    return (date().modjulian_day()-40587) + SecondsOfDay()/(24*60*60);
     193}
     194
     195// --------------------------------------------------------------------------
     196//
    188197// @returns seconds since 1970/1/1
    189198//
  • trunk/FACT++/src/Time.h

    r11439 r12618  
    9898    time_t Time_t() const;
    9999    double UnixTime() const;
     100    double UnixDate() const;
    100101    double RootTime() const;
    101102
Note: See TracChangeset for help on using the changeset viewer.