Pha¶
- class gdt.core.pha.Pha[source]¶
Bases:
FitsFileContextManagerPHA class for count spectra.
Attributes Summary
A Boolean array representing the valid channels
The PHA data
The energy bounds
The energy range of the spectrum
The exposure of the PHA data
The filename
The good time intervals
The list of Header Data Units
The headers
The number of energy channels
The number of HDUs
The center time of the data
The time range of the spectrum
The trigger time of the data, if available
The channel indices that are valid
Methods Summary
close()Close the file
column(hdu_num, col_name)Return a column from an HDU as an array.
columns_as_array(hdu_num, col_names[, dtype])Return a list of columns from an HDU as an array.
from_data(data[, gti, trigger_time, ...])Create a PHA object from an
EnergyBinsobject.get_column_names(hdu_num)Get the column names in a HDU.
hdu_index_from_name(ext_name)Returns the index into the HDU list based on the extension name.
open(file_path, **kwargs)Open a PHA FITS file and return the PHA object
rebin_energy(method, *args[, energy_range])Rebin the PHA in energy given a rebinning method.
slice_energy(energy_ranges, **kwargs)Slice the PHA by one or more energy ranges.
write(directory[, filename, rates, poisson_errs])Write the file to disk.
Attributes Documentation
- channel_mask¶
A Boolean array representing the valid channels
- Type:
(np.array)
- data¶
The PHA data
- Type:
- energy_range¶
The energy range of the spectrum
- Type:
(float, float)
- exposure¶
The exposure of the PHA data
- Type:
(float)
- filename¶
The filename
- Type:
(str)
- hdulist¶
The list of Header Data Units
- Type:
(astropy.io.fits.hdu.HDUList)
- headers¶
The headers
- Type:
- num_chans¶
The number of energy channels
- Type:
(int)
- num_hdus¶
The number of HDUs
- Type:
(int)
- tcent¶
The center time of the data
- Type:
(float)
- time_range¶
The time range of the spectrum
- Type:
(float, float)
- trigtime¶
The trigger time of the data, if available
- Type:
(float)
- valid_channels¶
The channel indices that are valid
- Type:
(np.array)
Methods Documentation
- close()¶
Close the file
- column(hdu_num: int, col_name: str) array¶
Return a column from an HDU as an array.
- Parameters:
hdu_num (int) – The HDU number
col_name (str) – The name of the column
- Returns:
(np.array)
- columns_as_array(hdu_num: int, col_names: List[str], dtype: dtype = None) array¶
Return a list of columns from an HDU as an array.
- Parameters:
hdu_num (int) – The HDU number
col_names (list of str) – The names of the columns
dtype (np.dtype, optional) – The custom dtype of the output array
- Returns:
(np.array)
- classmethod from_data(data, gti=None, trigger_time=None, filename=None, headers=None, channel_mask=None, header_type=<class 'gdt.core.pha.PhaHeaders'>, valid_channels=None, **kwargs)[source]¶
Create a PHA object from an
EnergyBinsobject.- Parameters:
data (
EnergyBins) – The PHA count spectrum datagti (
Gti), optional) – The good time intervals of the pectrum data. If omitted, then assumes the range (0, exposure).trigger_time (float, optional) – The trigger time, if applicable. If provided, the data times will be shifted relative to the trigger time. Default is zero.
headers (
FileHeaders) – The file headerschannel_mask (np.array(dtype=bool)) – A boolean array representing the valid channels. If omitted, assumes all non-zero count channels are valid.
header_type (
FileHeaders) – Default file header class. Only used ifheadersis not definedvalid_channels (np.array(dtype=int)) – An integer array indicating which channels are valid. This is overriden if channel_mask is set.
- Returns:
(
Pha)
- get_column_names(hdu_num: int)¶
Get the column names in a HDU. Returns empty if there is no data extension in the HDU.
- Parameters:
hdu_num (int) – The HDU number
- Returns:
(tuple)
- hdu_index_from_name(ext_name)¶
Returns the index into the HDU list based on the extension name. If there is no match, returns None.
- Parameters:
ext_name (str) – The extension name
- Returns:
(int)
- classmethod open(file_path, **kwargs)[source]¶
Open a PHA FITS file and return the PHA object
If this class is inherited, this method may be over-written if a non-standard file is being parsed, or if there is extra header information/data that needs to be stored.
- Parameters:
file_path (str) – The file path of the FITS file
- Returns:
(
Pha)
- rebin_energy(method, *args, energy_range=(None, None), **kwargs)[source]¶
Rebin the PHA in energy given a rebinning method.
- Parameters:
method (<function>) – The rebinning function
*args – Arguments to be passed to the rebinning function
energy_range ((float, float), optional) – The starting and ending energy to rebin. If omitted, uses the full range of data. Setting start or end to
Nonewill use the data from the beginning or end of the data, respectively.
- Returns
(
Pha)