本文整理汇总了C++中GFits::append方法的典型用法代码示例。如果您正苦于以下问题:C++ GFits::append方法的具体用法?C++ GFits::append怎么用?C++ GFits::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GFits
的用法示例。
在下文中一共展示了GFits::append方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write
/***********************************************************************//**
* @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;
}
示例2: write
/***********************************************************************//**
* @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;
}
示例3: publish
/***********************************************************************//**
* @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;
}
示例4: GFitsTableFloatCol
/***********************************************************************//**
* @brief Write point spread function into FITS file
*
* @param[in] file FITS file.
*
* Writes the PSF into the extension "RPSF" of a FITS file. This method
* does not check if a "RPSF" extension exists so far, it simply adds one
* each time it is called.
*
* Nothing is done if the PSF size is 0.
*
* @todo Check if a RPSF extension exists already in FITS file
***************************************************************************/
void GLATPsfV3::write(GFits& file) const
{
// Continue only if there are bins
int size = m_rpsf_bins.size();
if (size > 0) {
// Create new binary table
GFitsBinTable* hdu_rpsf = new GFitsBinTable;
// Set table attributes
hdu_rpsf->extname("RPSF");
// Write boundaries into table
m_rpsf_bins.write(hdu_rpsf);
// Allocate floating point vector columns
GFitsTableFloatCol col_ncore = GFitsTableFloatCol("NCORE", 1, size);
GFitsTableFloatCol col_ntail = GFitsTableFloatCol("NTAIL", 1, size);
GFitsTableFloatCol col_score = GFitsTableFloatCol("SCORE", 1, size);
GFitsTableFloatCol col_stail = GFitsTableFloatCol("STAIL", 1, size);
GFitsTableFloatCol col_gcore = GFitsTableFloatCol("GCORE", 1, size);
GFitsTableFloatCol col_gtail = GFitsTableFloatCol("GTAIL", 1, size);
// Fill columns
for (int i = 0; i < size; ++i) {
col_ncore(0,i) = m_ncore[i];
col_ntail(0,i) = m_ntail[i];
col_score(0,i) = m_score[i];
col_stail(0,i) = m_stail[i];
col_gcore(0,i) = m_gcore[i];
col_gtail(0,i) = m_gtail[i];
}
// Append columns to table
hdu_rpsf->append_column(col_ncore);
hdu_rpsf->append_column(col_ntail);
hdu_rpsf->append_column(col_score);
hdu_rpsf->append_column(col_stail);
hdu_rpsf->append_column(col_gcore);
hdu_rpsf->append_column(col_gtail);
// Append HDU to FITS file
file.append(*hdu_rpsf);
// Free binary table
delete hdu_rpsf;
} // endif: there were data to write
// Return
return;
}
示例5: 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;
}
示例6: write_scale
/***********************************************************************//**
* @brief Write PSF scale factors
*
* @param[in] file FITS file.
*
* Writes the PSF scale factors in the extension "PSF_SCALING_PARAMS". This
* method appends an extension "PSF_SCALING_PARAMS" to the FITS file,
* irrespectively of whether the extension exists already or not.
* The scale facors are written into the column "PSFSCALE".
*
* @todo Check if PSF_SCALING_PARAMS exists already in FITS file
***************************************************************************/
void GLATPsfBase::write_scale(GFits& file) const
{
// Create new binary table
GFitsBinTable* hdu_scale = new GFitsBinTable;
// Set table attributes
hdu_scale->extname("PSF_SCALING_PARAMS");
// Allocate floating point vector column
GFitsTableFloatCol col_scale = GFitsTableFloatCol("PSFSCALE", 1, 5);
// Fill columns
if (front()) {
col_scale(0,0) = m_scale_par1;
col_scale(0,1) = m_scale_par2;
col_scale(0,2) = 0.0;
col_scale(0,3) = 0.0;
}
else {
col_scale(0,0) = 0.0;
col_scale(0,1) = 0.0;
col_scale(0,2) = m_scale_par1;
col_scale(0,3) = m_scale_par2;
}
col_scale(0,4) = m_scale_index;
// Append column to table
hdu_scale->append(col_scale);
// Append HDU to FITS file
file.append(*hdu_scale);
// Free binary table
delete hdu_scale;
// Return
return;
}
示例7: write_aeff
/***********************************************************************//**
* @brief Write effective area into FITS file
*
* @param[in] file FITS file.
*
* This method does not write anything if the instance is empty.
***************************************************************************/
void GLATAeff::write_aeff(GFits& file) const
{
// Continue only if there are bins
int size = m_aeff_bins.size();
if (size > 0) {
// Create new binary table
GFitsBinTable* hdu_aeff = new GFitsBinTable;
// Set table attributes
hdu_aeff->extname("EFFECTIVE AREA");
// Write boundaries into table
m_aeff_bins.write(*hdu_aeff);
// Allocate floating point vector columns
GFitsTableFloatCol col_aeff = GFitsTableFloatCol("EFFAREA", 1, size);
// Fill columns
for (int i = 0; i < size; ++i) {
col_aeff(0,i) = m_aeff[i];
}
// Append columns to table
hdu_aeff->append(col_aeff);
// Append HDU to FITS file
file.append(*hdu_aeff);
// Free binary table
delete hdu_aeff;
} // endif: there were data to write
// Return
return;
}
示例8: 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;
}
示例9: write
/***********************************************************************//**
* @brief Write Auxiliary Response File
*
* @param[in] fits FITS file.
*
* Writes the Auxiliary Response File into the `SPECRESP` extension of the
* FITS file. An existing extension with the same name will be removed from
* the FITS file before writing.
*
* The method writes the boundaries of the true energy bins into the
* `ENERG_LO` and `ENERG_HI` columns, response information will be written
* into the `SPECRESP` column.
*
* See
* http://heasarc.gsfc.nasa.gov/docs/heasarc/caldb/docs/memos/cal_gen_92_002/cal_gen_92_002.html#tth_sEc4
* for details about the Auxiliary Response File format.
***************************************************************************/
void GArf::write(GFits& fits) const
{
// If the FITS object contains already an extension with the same
// name then remove now this extension
if (fits.contains("SPECRESP")) {
fits.remove("SPECRESP");
}
// Set column length
int length = size();
// Continue only if there are bins
if (length > 0) {
// Create new binary table
GFitsBinTable hdu;
// Allocate floating point vector columns
GFitsTableFloatCol energy_lo("ENERG_LO", length);
GFitsTableFloatCol energy_hi("ENERG_HI", length);
GFitsTableFloatCol specresp("SPECRESP", length);
// Fill columns
for (int i = 0; i < length; ++i) {
energy_lo(i) = (float)m_ebounds.emin(i).keV();
energy_hi(i) = (float)m_ebounds.emax(i).keV();
specresp(i) = (float)m_specresp[i];
}
// Set column units
energy_lo.unit("keV");
energy_hi.unit("keV");
specresp.unit("cm^2");
// Set table attributes
hdu.extname("SPECRESP");
// Append columns to table
hdu.append(energy_lo);
hdu.append(energy_hi);
hdu.append(specresp);
// Append any additional columns
for (int icol = 0; icol < columns(); ++icol) {
// Allocate floating point vector columns
GFitsTableFloatCol column(m_colnames[icol], length);
// Fill columns
for (int i = 0; i < length; ++i) {
column(i) = (float)m_coldata[icol][i];
}
// Append columns to table
hdu.append(column);
} // endfor: looped over all additional columns
// Append HDU to FITS file
fits.append(hdu);
} // endif: there were data to write
// Return
return;
}