Event Lists API

Classes for generating lists of detected events

class pyxsim.event_list.EventList(filespec)[source]
write_fits_file(fitsfile, fov, nx, overwrite=False)[source]

Write events to a FITS binary table file. The result is an “event file” which can be opened in ds9, binned into a spectrum, etc., but NOTE that this does NOT represent an actual observation since no instrumental effects are included.

Parameters
  • fitsfile (string) – The name of the event file to write.

  • fov (float, (value, unit) tuple, YTQuantity, or Quantity) – The field of view of the event file. If units are not provided, they are assumed to be in arcminutes.

  • nx (integer) – The resolution of the image (number of pixels on a side).

  • overwrite (boolean, optional) – Set to True to overwrite a previous file.

write_fits_image(imagefile, fov, nx, emin=None, emax=None, overwrite=False)[source]

Generate a image by binning X-ray counts and write it to a FITS file.

Parameters
  • imagefile (string) – The name of the image file to write.

  • fov (float, (value, unit) tuple, YTQuantity, or Quantity) – The field of view of the image. If units are not provided, they are assumed to be in arcminutes.

  • nx (integer) – The resolution of the image (number of pixels on a side).

  • emin (float, optional) – The minimum energy of the photons to put in the image, in keV.

  • emax (float, optional) – The maximum energy of the photons to put in the image, in keV.

  • overwrite (boolean, optional) – Set to True to overwrite a previous file.

write_spectrum(specfile, emin, emax, nchan, overwrite=False)[source]

Bin event energies into a spectrum and write it to a FITS binary table. This is for an unconvolved spectrum.

Parameters
  • specfile (string) – The name of the FITS file to be written.

  • emin (float) – The minimum energy of the spectral bins in keV.

  • emax (float) – The maximum energy of the spectral bins in keV.

  • nchan (integer) – The number of channels.

  • overwrite (boolean, optional) – Set to True to overwrite a previous file.

write_to_simput(prefix, overwrite=False)[source]

Write events to a SIMPUT catalog that may be utilized by various instrument simulators.

Parameters
  • prefix (string) – The filename prefix. The files to be written have the signature: f”{prefix}_simput.fits”, f”{prefix}_phlist.fits”, etc.

  • overwrite (boolean, optional) – Set to True to overwrite previous files.

pyxsim.utils.merge_files(input_files, output_file, overwrite=False, add_exposure_times=False)[source]

Helper function for merging PhotonList or EventList HDF5 files. :param input_files: List of filenames that will be merged together. :type input_files: list of strings :param output_file: Name of the merged file to be outputted. :type output_file: string :param overwrite: If a the output file already exists, set this to True to

overwrite it.

Parameters

add_exposure_times (boolean, default False) – If set to True, exposure times will be added together. Otherwise, the exposure times of all of the files must be the same.

Examples

>>> from pyxsim import merge_files
>>> merge_files(["events_0.h5","events_1.h5","events_3.h5"], "events.h5",
...             overwrite=True, add_exposure_times=True)

Notes

Currently, to merge files it is mandated that all of the parameters have the same values, with the exception of the exposure time parameter “exp_time”. If add_exposure_times=False, the maximum exposure time will be used.