elisa.data.ogip#
- class Data(erange: list | tuple, specfile: str, backfile: str | None = None, respfile: str | None = None, ancrfile: str | None = None, name: str | None = None, group: str | None = None, scale: float | None = None, preserve_data_group: bool = False, spec_poisson: bool | None = None, back_poisson: bool | None = None, ignore_bad: bool = True, keep_channel_info: bool = False, sparse_response: bool = False)[source]#
Bases:
ObservationDataHandle observation data in OGIP standards [1] [2].
Load the observation spectrum, the telescope response and the possible background, and handle the grouping of spectrum and response.
- Parameters:
- erangearray_like
Energy range of interest in keV, e.g.,
erange=[(0.5, 2), (5, 200)].- specfile
str Spectrum file path. For type II pha file, the row specifier must be given in the end of path, e.g.,
specfile='spec.pha2{1}'.- backfile
strorNone, optional Background file path. Read from the specfile header if None. For type II pha file, the row specifier must be given in the end of path, e.g.,
backfile='back.pha2{1}'.- respfile
strorNone, optional Response file path. Read from the specfile header if None. The path must be given if
RESPFILEis undefined in the header.- ancrfile
strorNone, optional Ancillary response path. Read from the specfile header if None.
Attributes
area_scaleArea scaling factor.
back_countsBackground counts of grouped measuring channels.
back_dataThe background data of the observation.
back_errorsUncertainty of background counts of grouped measuring channels.
back_exposureBackground exposure.
back_poissonWhether background data follows Poisson counting statistics.
back_ratioRatio of spectrum to background effective exposure.
ceGrouped net counts per second per keV.
ce_errorsUncertainty of grouped net counts per second per keV.
channelGrouped channel information.
channel_emaxRight edge of the grouped measurement channel energy grid.
channel_emeanGeometric mean of the grouped measurement channel energy grid.
channel_emidMidpoint of the grouped measurement channel energy grid.
channel_eminLeft edge of the grouped measurement channel energy grid.
channel_errorsWidth between left/right edge and geometric mean of channel grid.
channel_widthWidth of the grouped measurement channel energy grid.
erangeEnergy range of interest.
good_qualityFlags indicating which measurement channel to be used.
groupingCurrent grouping flags of the observation data.
has_backWhether the observation has background.
keep_channel_infoWhether to keep channel information when grouping the data.
nameName of the observation data.
net_countsNet counts of grouped measuring channels.
net_errorsUncertainty of net counts of grouped measuring channels.
resp_dataThe response matrix data of the observation.
response_matrixGrouped response matrix.
sparse_matrixGrouped response matrix in sparse representation.
spec_countsSpectrum counts of grouped measuring channels.
spec_dataThe spectrum data of the observation.
spec_errorsUncertainty of grouped spectrum counts.
spec_exposureSpectrum exposure.
spec_poissonWhether spectrum data follows Poisson counting statistics.
Methods
get_fixed_data()Return a fixed data object.
group(method[, scale, preserve_data_group])Group the spectrum.
plot_effective_area([hatch, ylog])Plot the effective area.
plot_matrix([hatch, norm])Plot the response matrix.
plot_spec([xlog, data_ylog, sig_ylog])Plot the spectrum.
set_erange(erange)Set energy range of interest.
set_grouping(grouping)Set grouping flags.
- Other Parameters:
- name
strorNone, optional Data name. Read from the specfile header if None. The name must be given if
DETNAM,INSTRUMEandTELESCOPare all undefined in the header.- group
strorNone, optional Method to group spectrum and background adaptively, these options are available so that each channel group has:
'const': scale number channels'min': total (source + background) counts >= scale'sig': source significance >= scale sigma'bmin': background counts >= scale, used to avoid bias when usingwstatto simultaneously fit the source and background'bsig': background significance >= scale sigma, used to avoid bias when usingpgstatto simultaneously fit the source and background'opt': optimal binning, see Kaastra & Bleeker (2016) [3]'optmin': optimal binning with total counts >= scale'optsig': optimal binning with source significance >= scale sigma'optbmin': optimal binning with background counts >= scale'optbsig': optimal binning with background significance >= scale sigma
The default is None.
- scale
floatorNone, optional Grouping scale for the method specified in group.
- preserve_data_groupbool, optional
Whether to preserve the grouping flags stored in specfile. If true, will first group the data based on the grouping flags stored in specfile, then apply the grouping method specified in group. If false, will directly apply the grouping method specified in group to the data, ignoring the grouping flags stored in specfile. The default is False.
- spec_poissonbool or
None, optional Whether the spectrum data follows counting statistics, reading from the specfile header. This value must be set if
POISSERRis undefined in the header.- back_poissonbool or
None, optional Whether the background data follows counting statistics, reading from the backfile header. This value must be set if
POISSERRis undefined in the header.- ignore_badbool, optional
Whether to ignore channels with
QUALITYbeing 2 or 5. The default is True. The possible values for spectralQUALITYare0: good1: defined bad by software2: defined dubious by software5: defined bad by user-1: reason for bad flag unknown
- keep_channel_infobool, optional
Whether to keep channel information in the label of grouped channel. Takes effect only if group is not None or spectral data has
GROUPINGdefined. The default is False.- sparse_responsebool, optional
Whether the response matrix is sparse. The default is False.
- name
Notes
Reading and applying correction to data is not yet supported.
References
- class Spectrum(specfile: str, poisson: bool | None = None)[source]#
Bases:
SpectrumDataLoad spectrum data in OGIP standards [1].
- Parameters:
- specfile
str Spectrum file path. For type II pha file, the row specifier must be given at the end of path, e.g.,
specfile='spec.pha2{1}'.- poissonbool or
None, optional Whether the spectrum data follows counting statistics, reading from the specfile header. This value must be set if
POISSERRis undefined in the header.
- specfile
Attributes
The ancillary response file path.
area_scaleArea scaling factor.
back_scaleBackground scaling factor.
The background file path.
countsSpectrum counts in each measuring channel.
errorsUncertainty of spectrum counts.
exposureSpectrum exposure.
groupingGrouping flags of the spectrum.
The spectrum header.
The name of the observation instrument.
poissonWhether spectrum data follows counting statistics.
qualityData quality of each spectrum channel.
The response file path.
The spectrum file path.
Methods
group(grouping[, quality])Group the spectrum.
References
- property header: Header#
The spectrum header.
- class Response(respfile: str, ancrfile: str | None = None, sparse: bool = False)[source]#
Bases:
ResponseDataLoad telescope response data in OGIP standards [1].
- Parameters:
Attributes
The ancillary response file path.
channelMeasurement channel information.
channel_emaxRight edge of measurement energy grid.
channel_eminLeft edge of measurement energy grid.
channel_fwhmEstimated Full Width at Half Maximum (FWHM) in channel energy space.
channel_numberNumber of channels.
channel_typeMeasurement channel type.
fwhmEstimated Full Width at Half Maximum (FWHM) in photon energy space.
matrixResponse matrix.
photon_egridPhoton energy grid of response matrix.
The response file path.
sparseWhether the response matrix is sparse.
sparse_matrixSparse response matrix.
Methods
group(grouping[, quality, keep_channel_info])Group the response matrix.
group_energy(grouping[, quality, ...])Get grouped channels' energy grid information.
plot_effective_area([noticed_range, ...])Plot the response matrix.
plot_matrix([noticed_range, good_quality, norm])Plot the response matrix.
References
- exception PoissonFlagNotFoundError[source]#
Bases:
RuntimeErrorIssued by
POISSERRnot found in spectrum header.