当前位置: 首页>>代码示例>>C++>>正文


C++ GFits类代码示例

本文整理汇总了C++中GFits的典型用法代码示例。如果您正苦于以下问题:C++ GFits类的具体用法?C++ GFits怎么用?C++ GFits使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GFits类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: clear

/***********************************************************************//**
 * @brief Read exposure cube from FITS object
 *
 * @param[in] fits FITS object.
 *
 * Read the exposure cube from a FITS object.
 ***************************************************************************/
void GCTACubeExposure::read(const GFits& fits)
{
    // Clear object
    clear();

    // Get HDUs
    const GFitsImage& hdu_expcube = *fits.image("Primary");
    const GFitsTable& hdu_ebounds = *fits.table("EBOUNDS");
    const GFitsTable& hdu_gti     = *fits.table("GTI");

    // Read cube
    m_cube.read(hdu_expcube);

    // Read cube attributes
    read_attributes(hdu_expcube);

    // Read energy boundaries
    m_ebounds.read(hdu_ebounds);

    // Read GTIs
    m_gti.read(hdu_gti);

    // Set energy node array
    set_eng_axis();

    // Return
    return;
}
开发者ID:TarekHC,项目名称:gammalib,代码行数:35,代码来源:GCTACubeExposure.cpp

示例2: write

/***********************************************************************//**
 * @brief Write CTA event cube into FITS file.
 *
 * @param[in] fits FITS file.
 *
 * Writes CTA event cube into a FITS file. The following HDUs will be written
 *
 *      COUNTS - Counts cube
 *      WEIGHTS - Weights for each counts cube bin
 *      EBOUNDS - Energy boundaries
 *      GTI - Good Time Intervals
 *
 * The counts cube will be written as a double precision sky map. The
 * weighing cube contains the weight for each counts cube, computed as the
 * fraction of the event bin that has been selected in filling the counts
 * cube. This allows to account for proper stacking of observations with
 * different energy thresholds, or different regions of interest. The energy
 * boundaries for all counts cube layers are also written, as well as the
 * Good Time Intervals that have been used in generating the counts cube.
 ***************************************************************************/
void GCTAEventCube::write(GFits& fits) const
{
    // Remove HDUs if they exist already
    if (fits.contains("GTI")) {
        fits.remove("GTI");
    }
    if (fits.contains("EBOUNDS")) {
        fits.remove("EBOUNDS");
    }
    if (fits.contains("WEIGHTS")) {
        fits.remove("WEIGHTS");
    }
    if (fits.contains("COUNTS")) {
        fits.remove("COUNTS");
    }
    if (fits.contains("Primary")) {
        fits.remove("Primary");
    }

    // Write counts cube
    m_map.write(fits, "COUNTS");

    // Write cube weighting
    m_weights.write(fits, "WEIGHTS");

    // Write energy boundaries
    ebounds().write(fits);

    // Write Good Time intervals
    gti().write(fits);

    // Return
    return;
}
开发者ID:,项目名称:,代码行数:54,代码来源:

示例3: clear

/***********************************************************************//**
 * @brief Read spectrum from FITS file
 *
 * @param[in] fits FITS file.
 * @param[in] extno Extension number of spectrum.
 *
 * @exception GMWLException::file_open_error
 *            No table found in file.
 *
 * Read the spectrum from a FITS table found in the specified extension.
 * In no extension number if specified (or if extno=0) then the spectrum
 * is loaded from the first table extension that is found in the file.
 ***************************************************************************/
void GMWLSpectrum::read(const GFits& fits, const int& extno)
{
    // Clear object
    clear();

    // Initialise extension number
    int extension = extno;

    // If the extension number is 0 then load first FITS table in file.
    if (extension == 0) {
        for (int i = 0; i < fits.size(); ++i) {
            if (fits.at(i)->exttype() == GFitsHDU::HT_ASCII_TABLE ||
                fits.at(i)->exttype() == GFitsHDU::HT_BIN_TABLE) {
                extension = i;
                break;
            }
        }
    }

    // If we found no table then throw an exception
    if (extension == 0) {
        throw GMWLException::file_open_error(G_READ, fits.filename().url(),
                                             "No table found in file.");
    }

    // Get table pointer
    const GFitsTable& table = *fits.table(extension);

    // Read spectrum from table
    read_fits(table);

    // Return
    return;
}
开发者ID:gammalib,项目名称:gammalib,代码行数:47,代码来源:GMWLSpectrum.cpp

示例4: connect

/***********************************************************************//**
 * @brief Publish FITS HDU
 *
 * @param[in] hdu FITS HDU
 *
 * Publishes a FITS HDU.           
 ***************************************************************************/
void GVOClient::publish(const GFitsHDU& hdu)
{
    // Signal that client should be disconnected after sending the image
    // to Hub
    bool disconnected = !is_connected();

    // Make sure that the client is connected to a Hub
    if (disconnected) {
        connect();
    }

    // Save FITS HDU into a temporary file
    std::string samp_share = std::tmpnam(NULL);
    GFits fits;
    fits.append(hdu);
    fits.saveto(samp_share, true);

    // Get FITS extension name
    std::string extname = hdu.extname();
    if (extname.empty()) {
        extname = "FITS Image";
    }

    // Compose notification to be passed to the Hub
    std::string hub_command = "";
    hub_command.append("<?xml version=\"1.0\"?>\n");
    hub_command.append("<methodCall>\n");
    hub_command.append("  <methodName>samp.hub.notifyAll</methodName>\n");
    hub_command.append("  <params>\n");
    hub_command.append("    <param><value>image.load.fits</value></param>\n");
    hub_command.append("    <param><value>"+m_secret+"</value></param>\n");
    hub_command.append("    <param><value><struct>\n");
    hub_command.append("      <member><name>samp.params</name><value><struct>\n");
    hub_command.append("        <member><name>name</name><value>"+extname+"</value></member>\n");
    hub_command.append("        <member><name>url</name><value>file://localhost"+samp_share+"</value></member>\n");
    hub_command.append("        <member><name>image-id</name><value>Gammalib Data</value></member>\n");
    hub_command.append("      </struct></value></member>\n");
    hub_command.append("      <member><name>samp.mtype</name><value>image.load.fits</value></member>\n");
    hub_command.append("    </struct></value></param>\n");
    hub_command.append("  </params>\n");
    hub_command.append("</methodCall>\n");

    // Send notification
    execute(hub_command);

    // Disconnect client from Hub
    if (disconnected) {
        disconnect();
    }

    // Return
    return;
}
开发者ID:,项目名称:,代码行数:60,代码来源:

示例5: save

/***********************************************************************//**
 * @brief Save CTA event cube into FITS file
 *
 * @param[in] filename FITS filename.
 * @param[in] clobber Overwrite existing FITS file (default=false).
 *
 * Save the CTA event cube into FITS file.
 ***************************************************************************/
void GCTAEventCube::save(const std::string& filename, bool clobber) const
{
    // Create empty FITS file
    GFits fits;

    // Write event cube
    write(fits);
    
    // Save FITS file
    fits.saveto(filename, clobber);

    // Return
    return;
}
开发者ID:adonath,项目名称:gammalib,代码行数:22,代码来源:GCTAEventCube.cpp

示例6: save

/***********************************************************************//**
 * @brief Save LAT event cube into FITS file
 *
 * @param[in] filename FITS file name.
 * @param[in] clobber Overwrite existing FITS file? (default: false)
 *
 * Save the LAT event cube into FITS file.
 ***************************************************************************/
void GLATEventCube::save(const GFilename& filename,
                         const bool&      clobber) const
{
    // Create empty FITS file
    GFits fits;

    // Write event cube into FITS file
    write(fits);
    
    // Save FITS file
    fits.saveto(filename, clobber);

    // Return
    return;
}
开发者ID:,项目名称:,代码行数:23,代码来源:

示例7: save

/***********************************************************************//**
 * @brief Save Good Time Intervals intervals to FITS file
 *
 * @param[in] filename FITS filename.
 * @param[in] clobber Overwrite any existing GTI extension?
 * @param[in] extname GTI extension name (defaults to "GTI")
 *
 * Saves Good Time Intervals into extension @p extname of a FITS file. If the
 * file does not exist it is created. If the file exists the GTI is appended
 * as extension. If another GTI exists already it is overwritten if
 * @p clobber=true.
 ***************************************************************************/
void GGti::save(const std::string& filename, const bool& clobber,
                const std::string& extname) const
{
    // Allocate FITS file
    GFits file;

    // Write GTI to FITS file
    write(file, extname);

    // Save to file
    file.saveto(filename, clobber);

    // Return
    return;
}
开发者ID:TarekHC,项目名称:gammalib,代码行数:27,代码来源:GGti.cpp

示例8: GFitsTableDoubleCol

/***********************************************************************//**
 * @brief Write energy boundaries into FITS object
 *
 * @param[in] file FITS file.
 * @param[in] extname Energy boundary extension name (defaults to "EBOUNDS")
 * @param[in] unit Energy units (defaults to "keV")
 *
 * Writes the energy boundaries into a FITS object. The @p unit parameter
 * specifies in which unit the energies are written. By default, the energy
 * units are keV.
 *
 * @todo Write header keywords.
 ***************************************************************************/
void GEbounds::write(GFits&             file,
                     const std::string& extname,
                     const std::string& unit) const
{
    // Create energy boundary columns
    GFitsTableDoubleCol cemin = GFitsTableDoubleCol("E_MIN", m_num);
    GFitsTableDoubleCol cemax = GFitsTableDoubleCol("E_MAX", m_num);

    // Fill energy boundary columns
    for (int i = 0; i < m_num; ++i) {
        cemin(i) = m_min[i](unit);
        cemax(i) = m_max[i](unit);
    }

    // Set energy units
    cemin.unit(unit);
    cemax.unit(unit);

    // Create binary table
    GFitsBinTable* table = new GFitsBinTable(m_num);
    table->append(cemin);
    table->append(cemax);
    table->extname(extname);

    // Write to FITS file
    file.append(*table);

    // Free table
    delete table;

    // Return
    return;
}
开发者ID:TarekHC,项目名称:gammalib,代码行数:46,代码来源:GEbounds.cpp

示例9: GFitsTableDoubleCol

/***********************************************************************//**
 * @brief Write Good Time Intervals and time reference into FITS object
 *
 * @param[in] file FITS file.
 * @param[in] extname GTI extension name (defaults to "GTI")
 *
 * Saves Good Time Intervals and time reference into a FITS object. If the
 * file does not exist it is created. If the file exists the GTI is appended
 * as extension. If another GTI exists already it is overwritten if
 * @p clobber=true.
 *
 * @todo Implement clobber method for overwriting of existing GTIs.
 ***************************************************************************/
void GGti::write(GFits& file, const std::string& extname) const
{
    // Create GTI columns
    GFitsTableDoubleCol cstart = GFitsTableDoubleCol("START", m_num);
    GFitsTableDoubleCol cstop  = GFitsTableDoubleCol("STOP", m_num);

    // Fill GTI columns in specified time reference
    for (int i = 0; i < m_num; ++i) {
        cstart(i) = m_start[i].convert(m_reference);
        cstop(i)  = m_stop[i].convert(m_reference);
    }

    // Create GTI table
    GFitsBinTable* table = new GFitsBinTable(m_num);
    table->append(cstart);
    table->append(cstop);
    table->extname(extname);

    // Write time reference
    m_reference.write(*table);

    // Write to FITS file
    file.append(*table);

    // Free table
    delete table;

    // Return
    return;
}
开发者ID:TarekHC,项目名称:gammalib,代码行数:43,代码来源:GGti.cpp

示例10: save

/***********************************************************************//**
 * @brief Save exposure cube into FITS file
 *
 * @param[in] filename Exposure cube FITS file name.
 * @param[in] clobber Overwrite existing file? (true=yes)
 *
 * Save the exposure cube into a FITS file.
 *
 * @todo Implement method
 ***************************************************************************/
void GCTACubeExposure::save(const std::string& filename, const bool& clobber) const
{
    // Create empty FITS file
    GFits fits;

    // Write exposure cube
    write(fits);

    // Save FITS file
    fits.saveto(filename, clobber);

    // Store filename
    m_filename = filename;

    // Return
    return;
}
开发者ID:TarekHC,项目名称:gammalib,代码行数:27,代码来源:GCTACubeExposure.cpp

示例11: save

/***********************************************************************//**
 * @brief Save energy boundaries into FITS file
 *
 * @param[in] filename FITS filename.
 * @param[in] clobber Overwrite any existing file  (defaults to false)?
 * @param[in] extname Energy boundary extension name (defaults to "EBOUNDS").
 * @param[in] unit Energy units (defaults to "keV")
 *
 * Saves the energy boundaries into extension @p extname of a FITS file.
 ***************************************************************************/
void GEbounds::save(const std::string& filename,
                    const bool&        clobber,
                    const std::string& extname,
                    const std::string& unit) const
{
    // Allocate FITS file
    GFits file;

    // Write energy boundaries to FITS file
    write(file, extname, unit);

    // Save to file
    file.saveto(filename, clobber);

    // Return
    return;
}
开发者ID:TarekHC,项目名称:gammalib,代码行数:27,代码来源:GEbounds.cpp

示例12: write

/***********************************************************************//**
 * @brief Save PSF table into FITS file
 *
 * @param[in] filename PSF table FITS file name.
 * @param[in] clobber Overwrite existing file? (true=yes)
 *
 * Save the PSF table into a FITS file.
 ***************************************************************************/
void GCTAPsf2D::save(const std::string& filename, const bool& clobber) const
{
    // Create binary table
    GFitsBinTable table;
    table.extname("POINT SPREAD FUNCTION");

    // Write the PSF table
    write(table);

    // Create FITS file, append table, and write into the file
    GFits fits;
    fits.append(table);
    fits.saveto(filename, clobber);

    // Return
    return;
}
开发者ID:TarekHC,项目名称:gammalib,代码行数:25,代码来源:GCTAPsf2D.cpp

示例13: clear

/***********************************************************************//**
 * @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;
}
开发者ID:hsiejkowski,项目名称:gammalib,代码行数:56,代码来源:GLATEventList.cpp

示例14: load

/***********************************************************************//**
 * @brief Load energy boundaries from FITS file
 *
 * @param[in] filename FITS filename.
 * @param[in] extname FITS extension name (defaults to "EBOUNDS").
 *
 * Loads the energy boundaries from FITS file.
 ***************************************************************************/
void GEbounds::load(const std::string& filename, const std::string& extname)
{
    // Allocate FITS file
    GFits file;

    // Open FITS file
    file.open(filename);

    // Get energy boundary table
    const GFitsTable& table = *file.table(extname);

    // Read energy boundaries from table
    read(table);

    // Close FITS file
    file.close();

    // Return
    return;
}
开发者ID:TarekHC,项目名称:gammalib,代码行数:28,代码来源:GEbounds.cpp

示例15: load

/***********************************************************************//**
 * @brief Load Good Time Intervals from FITS file
 *
 * @param[in] filename FITS filename.
 * @param[in] extname GTI extension name (defaults to "GTI")
 *
 * Loads the Good Time Intervals from FITS file.
 ***************************************************************************/
void GGti::load(const std::string& filename, const std::string& extname)
{
    // Allocate FITS file
    GFits file;

    // Open FITS file
    file.open(filename);

    // Get GTI table
    const GFitsTable& table = *file.table(extname);

    // Read GTI from table
    read(table);

    // Close FITS file
    file.close();

    // Return
    return;
}
开发者ID:TarekHC,项目名称:gammalib,代码行数:28,代码来源:GGti.cpp


注:本文中的GFits类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。