本文整理汇总了C++中GFits::open方法的典型用法代码示例。如果您正苦于以下问题:C++ GFits::open方法的具体用法?C++ GFits::open怎么用?C++ GFits::open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GFits
的用法示例。
在下文中一共展示了GFits::open方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例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;
}