BatseRsp

class gdt.missions.cgro.batse.response.BatseRsp[source]

Bases: Rsp

Class for BATSE single-DRM response files

Attributes Summary

detector

The name of the detector this response is associated with

drm

The response matrix

ebounds

The energy channel bounds

filename

The filename

hdulist

The list of Header Data Units

headers

The headers

num_chans

Number of energy channels

num_ebins

Number of photon energy bins

num_hdus

The number of HDUs

tcent

The center time of the interval over which the DRMs is valid

trigtime

The trigger time, if applicable

tstart

The start time of the interval over which the DRM is valid

tstop

The end time of the interval over which the DRM is 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.

fold_spectrum(function, params[, ...])

Fold a photon spectrum through a DRM to get a count spectrum.

from_data(drm[, filename, start_time, ...])

Create a Rsp object from a ResponseMatrix object.

get_column_names(hdu_num)

Get the column names in a HDU.

open(file_path, **kwargs)

Read a single-DRM response file from disk.

rebin([factor, edge_indices])

Rebins the channel energy axis of a DRM and returns a new response object.

resample([num_photon_bins, ...])

Resamples the incident photon axis of a DRM and returns a new ResponseMatrix object.

write(directory[, filename])

Write the file to disk.

Attributes Documentation

detector

The name of the detector this response is associated with

Type:

(str)

drm

The response matrix

Type:

(ResponseMatrix)

ebounds

The energy channel bounds

Type:

(Ebounds)

filename

The filename

Type:

(str)

hdulist

The list of Header Data Units

Type:

(astropy.io.fits.hdu.HDUList)

headers

The headers

Type:

(FileHeaders)

num_chans

Number of energy channels

Type:

(int)

num_ebins

Number of photon energy bins

Type:

(int)

num_hdus

The number of HDUs

Type:

(int)

tcent

The center time of the interval over which the DRMs is valid

Type:

(float)

trigtime

The trigger time, if applicable

Type:

(float)

tstart

The start time of the interval over which the DRM is valid

Type:

(float)

tstop

The end time of the interval over which the DRM is valid

Type:

(float)

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)

fold_spectrum(function, params, channel_mask=None, exposure=1.0)

Fold a photon spectrum through a DRM to get a count spectrum. This function differs from fold_spectrum() by taking in an optional exposure and returning an EnergyBins containing the count spectrum.

Parameters:
  • function (<function>) – A photon spectrum function. The function must accept a list of function parameters as its first argument and an array of photon energies as its second argument. The function must return the evaluation of the photon model in units of ph/s-cm^2-keV.

  • params (list of float) – A list of parameter values to be passed to the photon spectrum function

  • channel_mask (np.array, optional) – A Boolean mask where True indicates the channel is to be used for folding and False indicates the channel is to not be used for folding. If omitted, all channels are used.

  • exposure (float, optional) – The exposure in seconds. Default is 1.

Returns:

(EnergyBins)

classmethod from_data(drm, filename=None, start_time=None, stop_time=None, trigger_time=None, headers=None, detector=None)

Create a Rsp object from a ResponseMatrix object.

Parameters:
  • drm (ResponseMatrix) – The DRM

  • filename (str, optional) – The filename of the object

  • start_time (float, optional) – The start time for the response

  • stop_time (float, optional) – The stop time for the response

  • trigger_time (float, optional) – The trigger time, if applicable.

  • headers (FileHeaders) – The file headers

  • detector (str, optional) – The detector name

Returns:

(Rsp)

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]

Read a single-DRM response file from disk.

Parameters:

file_path (str) – The file path

Returns:

(BatseRsp)

rebin(factor=None, edge_indices=None)

Rebins the channel energy axis of a DRM and returns a new response object. Rebinning can only be used to downgrade the channel resolution and is constrained to the channel edges of the current DRM.

Rebinning can be performed by either defining an integral factor of the number of current energy channels to combine (e.g. factor=4 for 128 energy channels would result in 32 energy channels), or by defining an index array into the current channel edges that will define the new set of edges.

Parameters:
  • factor (int, optional) – The rebinning factor. Must set either this or edge_indices.

  • edge_indices (np.array, optional) – The index array that represents which energy edges should remain in the rebinned DRM.

Returns:

(Rsp)

resample(num_photon_bins=None, photon_bin_edges=None, num_interp_points=20, interp_kind='linear')

Resamples the incident photon axis of a DRM and returns a new ResponseMatrix object. Resampling can be used to downgrade the photon energy resolution, upgrade the resolution, and/or redefine the edges of the incident photon bins. By definition, the resampling can only be performed within the photon energy range of the current object.

The process for resampling is to create a high-resolution grid for each new photon bin, interpolate the differential effective area onto that grid (interpolation is performed on log10(effective area)), and then integrate the differential effective area over the grid points in each bin. The final effective area is then scaled by the ratio of the initial number of photon bins to the requested number of photon bins.

Parameters:
  • num_photon_bins (int, optional) – The number of photon bins in the new DRM. The bin edges will be generated logarithmically. Only set this or photon_bin_edges.

  • photon_bin_edges (np.array, optional) – The array of photon bin edges. Only set this or num_photon_bins.

  • num_interp_points (int, optional) – The number of interpolation points used to integrate over for each new photon bin. Default is 20.

  • interp_kind (str, optional) – The kind of interpolation to be passed to scipy.interp1d. Default is ‘linear’.

Returns:

(Rsp)

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 filename if set.