Position ImplIterator2D::col_size ( Position row ) const { return col_back(row) - col_front(row) + 1; }
Iterator2D::const_iterator ImplIterator2D::col_end ( Position row ) const { return const_iterator( col_back(row) + 1); }
/***********************************************************************//** * @brief Write Pulse Height Analyzer spectrum * * @param[in] fits FITS file. * * Writes the Pulse Height Analyzer spectrum into `SPECTRUM` and `EBOUNDS` * extensions of the FITS file. Extensions with these names will be removed * from the FITS file before writing. * * The columns `CHANNEL`, `COUNTS`, `STAT_ERR`, `SYS_ERR`, `QUALITY`, * `GROUPING`, `AREASCAL`, and `BACKSCAL` will be written into the `SPECTRUM` * extension, but only the `CHANNEL` and `COUNTS` columns will be filled with * values. Note that the channels start from 1 in the Pulse Height Analyzer * spectrum. * * See * https://heasarc.gsfc.nasa.gov/docs/heasarc/ofwg/docs/spectra/ogip_92_007/node5.html * for details about the PHA file format. ***************************************************************************/ void GPha::write(GFits& fits) const { // Remove extensions if they exist already if (fits.contains("EBOUNDS")) { fits.remove("EBOUNDS"); } if (fits.contains("SPECTRUM")) { fits.remove("SPECTRUM"); } // 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 GFitsTableShortCol col_chan("CHANNEL", length); GFitsTableFloatCol col_data("COUNTS", length); GFitsTableFloatCol col_stat("STAT_ERR", length); GFitsTableFloatCol col_syst("SYS_ERR", length); GFitsTableShortCol col_qual("QUALITY", length); GFitsTableShortCol col_grpg("GROUPING", length); GFitsTableFloatCol col_area("AREASCAL", length); GFitsTableFloatCol col_back("BACKSCAL", length); // Fill columns for (int i = 0; i < length; ++i) { col_chan(i) = i+1; // Channels start at 1 col_data(i) = float(m_counts[i]); } // Set table attributes hdu.extname("SPECTRUM"); // Append columns to table hdu.append(col_chan); hdu.append(col_data); hdu.append(col_stat); hdu.append(col_syst); hdu.append(col_qual); hdu.append(col_grpg); hdu.append(col_area); hdu.append(col_back); // Write keywords hdu.card("EXPOSURE", m_exposure, "[s] Deadtime corrected exposure time"); // Append HDU to FITS file fits.append(hdu); // Optionally append energy boundaries if (m_ebounds.size() > 0) { m_ebounds.write(fits); } } // endif: there were data to write // Return return; }