Utility Scripts

nustar_gen.utils.energy_to_chan(keV)

Convert keV to NuSTAR PI channels: PI = (keV - 1.6) / 0.04

Parameters:

keV (float) – Unitless float giving the energy you want to convert to channels.

Example

>>> from nustar_gen.utils import energy_to_chan
>>> chan = energy_to_chan(10.)
>>> np.isclose(chan, 210)
True
nustar_gen.utils.chan_to_energy(chan)

Convert NuSTAR PI channels to keV: keV = PI * 0.04 + 1.6

Parameters:

channel (int) – Integer PI channel to be converted into keV

Example

>>> from nustar_gen.utils import chan_to_energy
>>> chan = chan_to_energy(210)
>>> np.isclose(chan, 10.)
True
nustar_gen.utils.make_usr_gti(input_gtis, outfile='usrgti.fits', **kwargs)

Utility script to make a usrgti file. Uses the template distributed with the repo.

Parameters:
  • gtis (dict) – Dictionary assumed to have a ‘START’ and ‘STOP’ keys. Can be an array of dicts.

  • outfile (str) – Full path to desired outfile location. Default is ‘usrgti.fits’ in current working directory

nustar_gen.utils.append_fits_entry(base_rec, new_entry)

Helper script to append an entry to a FITS_rec object. Based on astropy documentation here: https://docs.astropy.org/en/stable/io/fits/usage/table.html