BatPha¶
- class gdt.missions.swift.bat.pha.BatPha[source]¶
Bases:
PhaAttributes 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.
open(file_path, **kwargs)Open a BAT Pha FITS file and return the BatPha 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])Write the file to disk.
Attributes Documentation
- channel_mask¶
A Boolean array representing the valid channels
- Type:
(np.array)
- data¶
The PHA data
- Type:
(
EnergyBins)
- ebounds¶
The energy bounds
- Type:
(
Ebounds)
- 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)
- gti¶
The good time intervals
- Type:
(
Gti)
- 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.missions.swift.bat.headers.PhaHeaders'>, **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 defined
- 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)
- classmethod open(file_path, **kwargs)[source]¶
Open a BAT Pha FITS file and return the BatPha object
- Parameters:
file_path (str) – The file path of the FITS file
- Returns:
(
BatPha)
- rebin_energy(method, *args, energy_range=(None, None), **kwargs)¶
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)
- slice_energy(energy_ranges, **kwargs)¶
Slice the PHA by one or more energy ranges. Produces a new PHA object.
- Parameters:
energy_ranges ([(float, float), ...]) – The energy ranges to slice the data to.
- Returns:
(
Pha)
- write(directory: Union[str, Path], filename: str = None, **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.