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


C++ GFits::close方法代码示例

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


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

示例1: 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

示例2: 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

示例3: test_time_reference

/***********************************************************************//**
 * @brief Test GTimeReference
 ***************************************************************************/
void TestGObservation::test_time_reference(void)
{
    // Test void constructor
    test_try("Void constructor");
    try {
        GTimeReference reference;
        test_try_success();
    }
    catch (std::exception &e) {
        test_try_failure(e);
    }

    // Test copy constructor
    test_try("Copy constructor");
    try {
        GTimeReference reference;
        GTimeReference reference2(reference);
        test_try_success();
    }
    catch (std::exception &e) {
        test_try_failure(e);
    }

    // Test reference constructor
    test_try("Reference constructor");
    try {
        GTimeReference reference(55197.0, "s", "TT", "LOCAL");
        test_try_success();
        test_value(reference.mjdref(), 55197.0);
        test_assert(reference.timeunit() == "s",
                    "Time unit was \""+reference.timeunit()+"\", expected \"s\"");
        test_assert(reference.timesys() == "TT",
                    "Time system was \""+reference.timesys()+"\", expected \"TT\"");
        test_assert(reference.timeref() == "LOCAL",
                    "Time reference was \""+reference.timeref()+"\", expected \"LOCAL\"");
    }
    catch (std::exception &e) {
        test_try_failure(e);
    }

    // Test reference constructor
    test_try("Reference constructor (split reference)");
    try {
        GTimeReference reference(55197, 0.000766018518519, "s", "TT", "LOCAL");
        test_try_success();
        test_value(reference.mjdref(), 55197.000766018518519);
        test_assert(reference.timeunit() == "s",
                    "Time unit was \""+reference.timeunit()+"\", expected \"s\"");
        test_assert(reference.timesys() == "TT",
                    "Time system was \""+reference.timesys()+"\", expected \"TT\"");
        test_assert(reference.timeref() == "LOCAL",
                    "Time reference was \""+reference.timeref()+"\", expected \"LOCAL\"");
    }
    catch (std::exception &e) {
        test_try_failure(e);
    }

    // Test FITS file writing
    GTimeReference reference(55197.000766018518519, "s", "TT", "LOCAL");
    GFits          fits;
    GFitsBinTable  table;
    reference.write(table);
    fits.append(table);
    fits.saveto("test_time_reference.fits", true);
    fits.close();

    // Read back from FITS file and check values
    fits.open("test_time_reference.fits");
    const GFitsTable& hdu = *fits.table(1);
    GTimeReference value(hdu);
    fits.close();
    test_value(value.mjdref(),  reference.mjdref());
    test_value(value.mjdrefi(), reference.mjdrefi());
    test_value(value.mjdreff(), reference.mjdreff());
    test_assert(value.timeunit() == reference.timeunit(),
                "Time unit was \""+value.timeunit()+"\", expected "+reference.timeunit()+".");
    test_assert(value.timesys() == reference.timesys(),
                "Time system was \""+value.timesys()+"\", expected "+reference.timesys()+".");
    test_assert(value.timeref() == reference.timeref(),
                "Time reference was \""+value.timeref()+"\", expected "+reference.timeref()+".");

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

示例4: load_nodes


//.........这里部分代码省略.........
 * Load the light curve nodes from a FITS file. The light curve nodes are
 * expected in the first extension of the FITS file, containing two mandatory
 * columns with names "TIME" and "NORM".
 ***************************************************************************/
void GModelTemporalLightCurve::load_nodes(const GFilename& filename)
{
    // Set maximum light curve normalization value, including a small margin
    const double max_norm = 1.0 + 1.0e-8;

    // Clear nodes and values
    m_nodes.clear();
    m_values.clear();

    // Set filename
    m_filename = filename;

    // Load FITS file
    GFits fits = GFits(filename);

    // Extract binary table (so far always load extension 1 as table)
    GFitsTable* table = fits.table(1);

    // Read time reference from binary table
    m_timeref.read(*table);

    // Extract columns
    GFitsTableCol* time_col = (*table)["TIME"];
    GFitsTableCol* norm_col = (*table)["NORM"];

    // Check that there are at least two nodes in table
    if (time_col->nrows() < 2) {
        std::string msg = "\"TIME\" column contains "+
                          gammalib::str(time_col->nrows())+" rows but at "
                          "least two rows are required. Please specify a valid "
                          "temporal file function.";
        throw GException::invalid_value(G_LOAD_NODES, msg);
    }

    // Check that both columns are consistent
    if (time_col->nrows() != norm_col->nrows()) {
        std::string msg = "\"TIME\" and \"NORM\" columns have inconsistent "
                          "number of rows ("+
                          gammalib::str(time_col->nrows())+", "+
                          gammalib::str(norm_col->nrows())+"). Please "
                          "specify a valid temporal file function.";
        throw GException::invalid_value(G_LOAD_NODES, msg);
    }

    // Set number of nodes
    int nodes = time_col->nrows();

    // Check that time values are in ascending order and that no node is
    // larger than 1
    double last_time = -1.0;
    for (int i = 0; i < nodes; ++i) {

        // Check if time has increased
        if (last_time >= 0.0 && time_col->real(i) <= last_time) {
            std::string msg = "Time "+gammalib::str(time_col->real(i))+
                              " in row "+gammalib::str(i+1)+" of \"TIME\" "
                              "column is equal to or smaller than preceeding "
                              "value. Please provide a light curve file with "
                              "monotonically increasing times.";
            throw GException::invalid_value(G_LOAD_NODES, msg);
        }

        // Check if value is smaller than maximum allowed normalisation
        if (norm_col->real(i) > max_norm) {
            std::string msg = "Value "+gammalib::str(norm_col->real(i))+" at "
                              "time "+gammalib::str(time_col->real(i))+" is "
                              "larger than 1. Please provide a light curve file "
                              "with normalizations not exceeding 1.";
            throw GException::invalid_value(G_LOAD_NODES, msg);
        }
        
    } // endfor: looped over nodes

    // Extract nodes
    for (int i = 0; i < nodes; ++i) {
        m_nodes.append(time_col->real(i));
        m_values.push_back(norm_col->real(i));
    }

    // Make sure that no node exceeds 1
    for (int i = 0; i < m_values.size(); ++i) {
        if (m_values[i] > 1.0) {
            m_values[i] = 1.0;
        }
    }

    // Set minimum and maximum times (assumes that times are ordered)
    m_tmin.set(time_col->real(0), m_timeref);
    m_tmax.set(time_col->real(time_col->nrows()-1), m_timeref);

    // Close FITS file
    fits.close();

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


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