예제 #1
0
/***********************************************************************//**
 * @brief Save point spread function table into FITS file
 *
 * @param[in] filename FITS file name.
 * @param[in] clobber Overwrite existing file? (default: false)
 *
 * Saves point spread function into a FITS file. If a file with the given
 * @p filename does not yet exist it will be created, otherwise the method
 * opens the existing file. The method will create a (or replace an existing)
 * point spread function extension. The extension name can be specified as
 * part of the @p filename, or if no extension name is given, is assumed to
 * be "POINT SPREAD FUNCTION".
 *
 * An existing file will only be modified if the @p clobber flag is set to
 * true.
 ***************************************************************************/
void GCTAPsfTable::save(const GFilename& filename, const bool& clobber) const
{
    // Get extension name
    std::string extname = filename.extname("POINT SPREAD FUNCTION");

    // Open or create FITS file (without extension name since the requested
    // extension may not yet exist in the file)
    GFits fits(filename.url(), true);

    // Remove extension if it exists already
    if (fits.contains(extname)) {
        fits.remove(extname);
    }

    // Create binary table
    GFitsBinTable table;

    // Write the background table
    write(table);

    // Set binary table extension name
    table.extname(extname);

    // Append table to FITS file
    fits.append(table);

    // Save to file
    fits.save(clobber);

    // Return
    return;
}
예제 #2
0
/***********************************************************************//**
 * @brief Load spectrum
 *
 * @param[in] filename File name.
 *
 * This method loads a spectrum from a variety of file types. The method
 * analyses the format of the file that is presented and choses then the
 * appropriate method to load the specific format. The following file
 * formats are supported: FITS, TBW ...
 *
 * @todo So far only FITS file support is implemented.
 ***************************************************************************/
void GMWLSpectrum::load(const GFilename& filename)
{
    // Clear object
    clear();

    // Open FITS file
    GFits fits(filename);

    // Read spectrum
    if (filename.has_extno()) {
        read(fits, filename.extno());
    }
    else if (filename.has_extname()) {
        read(fits, filename.extname());
    }
    else {
        read(fits);
    }

    // Close FITS file
    fits.close();

    // Return
    return;
}
예제 #3
0
/***********************************************************************//**
 * @brief Load point spread function from FITS file
 *
 * @param[in] filename FITS file name.
 *
 * Loads the point spread function from a FITS file.
 *
 * If no extension name is provided, the point spread function will be loaded
 * from the "POINT SPREAD FUNCTION" extension.
 ***************************************************************************/
void GCTAPsfTable::load(const GFilename& filename)
{
    // Open FITS file
    GFits fits(filename);

    // Get PSF table
    const GFitsTable& table = *fits.table(filename.extname("POINT SPREAD FUNCTION"));

    // Read PSF from table
    read(table);

    // Close FITS file
    fits.close();

    // Store filename
    m_filename = filename;

    // Return
    return;
}
예제 #4
0
/***********************************************************************//**
 * @brief Load point spread function from FITS file
 *
 * @param[in] filename FITS file name.
 *
 * Loads the point spread function from a FITS file.
 *
 * If no extension name is provided, the point spread function will be loaded
 * from the `POINT SPREAD FUNCTION` extension.
 ***************************************************************************/
void GCTAPsfTable::load(const GFilename& filename)
{
    // Open FITS file
    GFits fits(filename);

    // Get PSF table
    const GFitsTable& table =
          *fits.table(filename.extname(gammalib::extname_cta_psftable));

    // Read PSF from table
    read(table);

    // Close FITS file
    fits.close();

    // Store filename
    m_filename = filename;

    // Return
    return;
}