示例#1
0
/***********************************************************************//**
 * @brief Write time reference into FITS header
 *
 * @param[in] hdu FITS extension.
 *
 * Writes or updates the time reference information in a FITS header.
 * Depending of whether the keyword "MJDREF" or the pair of keywords "MJDREFI"
 * and "MJDREFF" exist already in the header, the method either writes the
 * reference MJD as floating point value, or split into an integer and a
 * fractional part. If nothing has been written yet, splitting into an
 * integer and fractional part will be used as this preserves the highest
 * possible accuracy.
 *
 * The following additional keywords are written:
 *     TIMEUNIT
 *     TIMESYS
 *     TIMEREF
 *
 * Nothing is done if the HDU pointer is NULL.
 ***************************************************************************/
void GTimeReference::write(GFitsHDU* hdu) const
{
    // Continue only if HDU is valid
    if (hdu != NULL) {

        // Case A: use floating point reference MJD
        if (hdu->hascard("MJDREF")) {
            hdu->card("MJDREF",   mjdref(),   "[days] Time reference MJD");
            hdu->card("TIMEUNIT", timeunit(), "Time unit");
            hdu->card("TIMESYS",  timesys(),  "Time system");
            hdu->card("TIMEREF",  timeref(),  "Time reference");
        }

        // Case B: use fractional reference MJD
        else {
            hdu->card("MJDREFI",  mjdrefi(),  "[days] Integer part of time reference MJD");
            hdu->card("MJDREFF",  mjdreff(),  "[days] Fractional part of time reference MJD");
            hdu->card("TIMEUNIT", timeunit(), "Time unit");
            hdu->card("TIMESYS",  timesys(),  "Time system");
            hdu->card("TIMEREF",  timeref(),  "Time reference");
        }


    } // endif: HDU was valid

    // Return
    return;
}
示例#2
0
/***********************************************************************//**
 * @brief Read LAT events from FITS file.
 *
 * @param[in] file FITS file.
 *
 * This method read the LAT event list from a FITS file.
 *
 * The method clears the object before loading, thus any events residing in
 * the object before loading will be lost.
 ***************************************************************************/
void GLATEventList::read(const GFits& file)
{
    // Clear object
    clear();

    // Get HDU (pointer is always valid)
    const GFitsTable& hdu = *file.table("EVENTS");

    // Read event data
    read_events(hdu);

    // Read data selection keywords
    read_ds_keys(hdu);

    // If we have a GTI extension, then read Good Time Intervals from that
    // extension
    if (file.contains("GTI")) {
        const GFitsTable& gti = *file.table("GTI");
        m_gti.read(gti);
    }

    // ... otherwise build GTI from TSTART and TSTOP
    else {

        // Read start and stop time
        double tstart = hdu.real("TSTART");
        double tstop  = hdu.real("TSTOP");

        // Create time reference from header information
        GTimeReference timeref(hdu);
        
        // Set start and stop time
        GTime start(tstart);
        GTime stop(tstop);

        // Append start and stop time as single time interval to GTI
        m_gti.append(start, stop);

        // Set GTI time reference
        m_gti.reference(timeref);

    } // endelse: GTI built from TSTART and TSTOP

    // Return
    return;
}
示例#3
0
/***********************************************************************//**
 * @brief Print time reference
 *
 * @return String containing the time reference.
 ***************************************************************************/
std::string GTimeReference::print(void) const
{
    // Initialise result string
    std::string result;

    // Append header
    result.append("=== GTimeReference ===\n");

    // Append information
    result.append(parformat("MJD reference time")+str(mjdref())+"\n");
    result.append(parformat("Time unit")+timeunit()+"\n");
    result.append(parformat("Time system")+timesys()+"\n");
    result.append(parformat("Time reference")+timeref()+"\n");

    // Return
    return result;
}