Bak¶
- class gdt.core.pha.Bak[source]¶
Bases:
PhaClass for a PHA background spectrum.
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 BAK object from an
BackgroundSpectrumobject.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[, emin, emax])Not Implemented
slice_energy(method, *args[, emin, emax])Not Implemented
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, **kwargs)[source]¶
Create a BAK object from an
BackgroundSpectrumobject.- Parameters:
data (
BackgroundSpectrum) – The background 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.
- Returns:
(
Bak)
- 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)¶
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)
- write(directory, filename=None, rates=False, poisson_errs=False, **kwargs)¶
Write the file to disk.
- Parameters:
directory (str) – The directory to write the file.
filename (str, optional) – The filename. If omitted, attempts to use the
filenameif set.