6.3.2. Data class structure¶
6.3.2.1. Spectral & response data¶
- class pyspex.data.Data[source]¶
Main data class used to set and get observed data.
- Variables:
ninst (int) – Number of instruments loaded.
inst (list of objects) – Python list of instrument objects.
- delete(ins)[source]¶
Delete instrument with number ins.
- Parameters:
ins (int) – Instrument number to delete.
- load(resfile, spofile)[source]¶
Add a new set of spectrum and response file to the dataset. Provide the full filename including extension!
- class pyspex.data.Instrument[source]¶
Properties of an instrument.
- Variables:
nsector (int) – Number of sectors in instrument.
nregion – Number of data regions in response.
nreg (int) – Number of regions in data.
ncomp (int) – Number of response components.
index (int) – Index number of this instrument.
sponame (str) – Filename of .spo file.
resname (str) – Filename of .res file
reg (list of objects) – List of regions for this instrument.
- class pyspex.data.Region[source]¶
Properties of one region.
- Variables:
index (int) – Region number.
emin (float) – Min data energy range (keV).
emax (float) – Max data energy range (keV).
srccount (float) – Net source counts.
srccerr (float) – Net source count error.
bkgcount (float) – Subtracted background counts.
bkgcerr (float) – Error subtracted background counts.
srcrate (float) – Net source count rate (counts/s).
srcrerr (float) – Net source count rate error (counts/s).
bkgrate (float) – Background count rate subtracted.
bkgrerr (float) – Error background count rate subtracted.
mbkgrate (float) – Model background count rate.
tintmin (float) – Minimum integration time per channel.
tintmax (float) – Maximum integration time per channel.
tintaver (float) – Average integration time per channel.
6.3.2.2. Spectral binning and data selection¶
- class pyspex.data.Bins[source]¶
Class containing the binning methods.
- bin(inst, reg, elow, ehigh, factor, unit=None)[source]¶
Bin the spectrum using a fixed factor.
- Parameters:
inst (int) – Instrument number.
reg (int) – Region number.
elow (float) – Start point of energy/channel interval.
ehigh (float) – End point of energy/channel interval.
factor (int) – Binning factor
unit (str) – Unit of the energy/channel range, for example: ‘kev’, ‘ev’, ‘ryd’, ‘j’, ‘hz’, ‘ang’, ‘nm’
- ignore(inst, reg, elow, ehigh, unit=None)[source]¶
Ignore the bins given by the energy/channel range.
- obin(inst, reg, elow, ehigh, unit=None)[source]¶
Bin the spectrum optimally given the instrument resolution and statistics.
- rbin(inst, reg, elow, ehigh, unit=None)[source]¶
Bin the spectrum and the response optimally given the instrument resolution and statistics.
- syserr(inst, reg, elow, ehigh, src, bkg, unit=None)[source]¶
Add an additional error to the source and background spectrum.
- Parameters:
inst (int) – Instrument number.
reg (int) – Region number.
elow (float) – Start point of energy/channel interval.
ehigh (float) – End point of energy/channel interval.
src (float) – Error value to be quadratically added to the current error bar of the source spectrum.
bkg (float) – Error value to be quadratically added to the current error bar of the background spectrum.
unit (str) – Unit of the energy/channel range, for example: ‘kev’, ‘ev’, ‘ryd’, ‘j’, ‘hz’, ‘ang’, ‘nm’
- vbin(inst, reg, elow, ehigh, factor, snr, unit=None)[source]¶
Bin the spectrum using a variable bin size, given a minimum bin factor and a minimum signal to noise ratio.
- Parameters:
inst (int) – Instrument number.
reg (int) – Region number.
elow (float) – Start point of energy/channel interval.
ehigh (float) – End point of energy/channel interval.
factor (int) – Minimal binning factor
snr (float) – Minimal signal to noise for a data point after binning.
unit (str) – Unit of the energy/channel range, for example: ‘kev’, ‘ev’, ‘ryd’, ‘j’, ‘hz’, ‘ang’, ‘nm’
6.3.2.3. Simulate spectra¶
- class pyspex.data.Simulate[source]¶
Class to simulate spectra.
- set_bnoise(status)[source]¶
Add Poisson noise to the background spectrum (status is True or False).
- Parameters:
status (bool) – Add Poisson noise to the simulated background spectrum.
- set_instrument(irange)[source]¶
Define the range of instruments to simulate.
- Parameters:
irange (str) – Instrument range to simulate (default all)
- set_noise(status)[source]¶
Add Poisson noise to the source spectrum (status is True or False).
- Parameters:
status (bool) – Add Poisson noise to the simulated source spectrum.
- set_random_seed(seed)[source]¶
Set the random seed to an integer value.
- Parameters:
seed (int) – Set the random seed for the simulation.
- set_region(rrange)[source]¶
Define the range of regions to simulate.
- Parameters:
rrange (str) – Region range to simulate (default all)
- set_syserr(src, bkg)[source]¶
Add a systematic error to the source spectrum (src) and to the background spectrum (bkg).
- simulate(extime, inst=None, reg=None, ssys=None, bsys=None, noise=None, bnoise=None, seed=None)[source]¶
Simulate a spectrum for exposure time extime and optionally with a number of options.
- Parameters:
extime (float) – Exposure time to simulate.
inst (str) – (Optional) Instrument range to simulate (default all)
reg (str) – (Optional) Region range to simulate (default all)
ssys (float) – (Optional) Add a systematic error to the source spectrum (Default 0).
bsys (float) – (Optional) Add a systematic error to the background spectrum (Default 0).
noise (bool) – (Optional) Add Poisson noise to the simulated source spectrum (Default True).
bnoise (bool) – (Optional) Add Poisson noise to the simulated background spectrum (Default False).
seed (int) – (Optional) Set the random seed for the simulation (Default: system clock).