Ctime

class gdt.missions.gifts.phaii.Ctime[source]

Bases: GiftsPhaii

Class for GIFTS CTIME data.

Attributes Summary

data

The PHAII data

detector

The detector name

ebounds

The energy-channel mapping.

energy_range

The energy range of the data.

filename

The filename

gti

The good time intervals

hdulist

The list of Header Data Units

headers

The headers

num_chans

The number of energy channels

num_hdus

The number of HDUs

time_range

The time range of the data

trigtime

The trigger time of the data, if available.

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 PHAII object from a TimeEnergyBins data object.

get_column_names(hdu_num)

Get the column names in a HDU.

get_exposure([time_ranges])

Calculate the total exposure of a time range or time ranges of data.

merge(phaii_list)

Merge a list of Phaii objects into a new Phaii object.

open(file_path, **kwargs)

Open a GIFTS PHAII FITS file and return the GiftsPhaii object

rebin_energy(method, *args[, energy_range])

Rebin the PHAII in energy given a rebinning method.

rebin_time(method, *args[, time_range])

Rebin the PHAII in time given a rebinning method.

set_ebounds(ebounds)

Set the energy calibration (ebounds) of the data.

slice_energy(energy_ranges, **kwargs)

Slice the PHAII by one or more energy range.

slice_time(time_ranges, **kwargs)

Slice the PHAII by one or more time range.

to_lightcurve([time_range, energy_range, ...])

Integrate the PHAII data over energy to produce a lightcurve.

to_pha([time_ranges, energy_range, ...])

Integrate the PHAII data over time to produce a PHA object.

to_spectrum([time_range, energy_range, ...])

Integrate the PHAII data over time to produce a count spectrum

write(directory[, filename])

Write the file to disk.

Attributes Documentation

data

The PHAII data

Type:

(TimeEnergyBins)

detector

The detector name

Type:

(str)

ebounds

The energy-channel mapping. If data does not have an ebounds, returns None.

Type:

(Ebounds)

energy_range

The energy range of the data. If data does not have an ebounds, returns None.

Type:

(float, 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:

(FileHeaders)

num_chans

The number of energy channels

Type:

(int)

num_hdus

The number of HDUs

Type:

(int)

time_range

The time range of the data

Type:

(float, float)

trigtime

The trigger time of the data, if available.

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)

classmethod from_data(data, gti=None, trigger_time=None, filename=None, headers=None, **kwargs)

Create a PHAII object from a TimeEnergyBins data object.

Parameters:
  • data (TimeEnergyBins) – The PHAII data

  • gti (Gti, optional) – The Good Time Intervals object. If omitted, the GTI spans (tstart, tstop)

  • trigger_time (float, optional) – The trigger time, if applicable. If provided, the data times will be shifted relative to the trigger time.

  • filename (str, optional) – The name of the file

  • headers (FileHeaders) – The file headers

Returns:

(Phaii)

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)

get_exposure(time_ranges=None)

Calculate the total exposure of a time range or time ranges of data.

Parameters:

time_ranges ([(float, float), ...], optional) – The time range or time ranges over which to calculate the exposure. If omitted, calculates the total exposure of the data.

Returns:

(float)

classmethod merge(phaii_list)

Merge a list of Phaii objects into a new Phaii object. The header from the first Phaii in the list is used in the new Phaii and appropriately updated.

Parameters:

phaii_list (list) – The list of Phaii objects to merge

Returns:

(Phaii)

classmethod open(file_path, **kwargs)

Open a GIFTS PHAII FITS file and return the GiftsPhaii object

Parameters:

file_path (str) – The file path of the FITS file

Returns:

(GiftsPhaii)

rebin_energy(method, *args, energy_range=(None, None), **kwargs)

Rebin the PHAII in energy given a rebinning method. Produces a new PHAII object.

Note::

If the data does not have an energy calibration (ebounds), then this function will bin by energy channels, and therefore the energy_range argument should be a range of energy channels instead of energies.

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 (or channel) to rebin. If omitted, uses the full range of data. Setting start or end to None will use the data from the beginning or end of the data, respectively.

Returns

(Phaii)

rebin_time(method, *args, time_range=(None, None), **kwargs)

Rebin the PHAII in time given a rebinning method. Produces a new PHAII object.

Parameters:
  • method (<function>) – The rebinning function

  • *args – Arguments to be passed to the rebinning function

  • time_range ((float, float), optional) – The starting and ending time to rebin. If omitted, uses the full range of data. Setting start or end to None will use the data from the beginning or end of the data, respectively.

Returns

(Phaii)

set_ebounds(ebounds)

Set the energy calibration (ebounds) of the data. If the data are not yet energy calibrated, this will convert the data object from TimeChannelBins to TimeEnergyBins`. If the data already has an energy calibration, this method will update the calibration to with the new ebounds. The number of channels in ebounds must equal the number of channels of the data.

Parameters:

ebounds (Ebounds) – The ebounds

slice_energy(energy_ranges, **kwargs)

Slice the PHAII by one or more energy range. Produces a new PHAII object.

Note::

If the data does not have an energy calibration (ebounds), then this function will slice by energy channels, and therefore the energy_ranges argument should be a range(s) of energy channels instead of energies.

Parameters:

energy_ranges ([(float, float), ...]) – The energy ranges to slice the data to.

Returns:

(Phaii)

slice_time(time_ranges, **kwargs)

Slice the PHAII by one or more time range. Produces a new PHAII object. The GTI will be automatically update to match the new time range(s).

Parameters:

time_ranges ([(float, float), ...]) – The time ranges to slice the data to.

Returns:

(Phaii)

to_lightcurve(time_range=None, energy_range=None, channel_range=None)

Integrate the PHAII data over energy to produce a lightcurve.

Note::

If the data has not energy calibration, then energy_range is ignored, and only channel_range is used.

Parameters:
  • time_range ((float, float), optional) – The time range of the lightcurve. If omitted, uses the entire time range of the data.

  • energy_range ((float, float), optional) – The energy range of the lightcurve. If omitted, uses the entire energy range of the data.

  • channel_range ((int, int), optional) – The channel range of the lightcurve. If omitted, uses the entire energy range of the data.

Returns:

(TimeBins)

to_pha(time_ranges=None, energy_range=None, channel_range=None, **kwargs)

Integrate the PHAII data over time to produce a PHA object.

Note::

If the data does not have an energy calibration (ebounds), then a PHA object cannot be created and calling this method will raise an exception.

Parameters:
  • time_ranges ([(float, float), ...], optional) – The time range of the spectrum. If omitted, uses the entire time range of the data.

  • energy_range ((float, float), optional) – The energy range of the spectrum. If omitted, uses the entire energy range of the data.

  • channel_range ((int, int), optional) – The channel range of the spectrum. If omitted, uses the entire energy range of the data.

  • **kwargs – Options passed to pha.Pha.from_data()

Returns:

(Pha)

to_spectrum(time_range=None, energy_range=None, channel_range=None)

Integrate the PHAII data over time to produce a count spectrum

Note::

If the data has not energy calibration, then energy_range is ignored, and only channel_range is used.

Parameters:
  • time_range ((float, float), optional) – The time range of the spectrum. If omitted, uses the entire time range of the data.

  • energy_range ((float, float), optional) – The energy range of the spectrum. If omitted, uses the entire energy range of the data.

  • channel_range ((int, int), optional) – The channel range of the spectrum. If omitted, uses the entire energy range of the data.

Returns:

(EnergyBins)

write(directory: 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.