# Events API¶

soxs.events.make_exposure_map(event_file, expmap_file, energy, weights=None, asol_file=None, normalize=True, overwrite=False, reblock=1, nhistx=16, nhisty=16, order=1)[source]

Make an exposure map for a SOXS event file, and optionally write an aspect solution file. The exposure map will be created by binning an aspect histogram over the range of the aspect solution.

Parameters: event_file (string) – The path to the event file to use for making the exposure map. expmap_file (string) – The path to write the exposure map file to. energy (float, (value, unit) tuple, or Quantity, or NumPy array) – The energy in keV to use when computing the exposure map, or a set of energies to be used with the weights parameter. If providing a set, it must be in keV. weights (array-like, optional) – The weights to use with a set of energies given in the energy parameter. Used to create a more accurate exposure map weighted by a range of energies. Default: None asol_file (string, optional) – The path to write the aspect solution file to, if desired. Default: None normalize (boolean, optional) – If True, the exposure map will be divided by the exposure time so that the map’s units are cm**2. Default: True overwrite (boolean, optional) – Whether or not to overwrite an existing file. Default: False reblock (integer, optional) – Supply an integer power of 2 here to make an exposure map with a different binning. Default: 1 nhistx (integer, optional) – The number of bins in the aspect histogram in the DETX direction. Default: 16 nhisty (integer, optional) – The number of bins in the aspect histogram in the DETY direction. Default: 16 order (integer, optional) – The interpolation order to use when making the exposure map. Default: 1
soxs.events.plot_spectrum(specfile, plot_energy=True, lw=2, xmin=None, xmax=None, ymin=None, ymax=None, xscale=None, yscale=None, label=None, fontsize=18, fig=None, ax=None, plot_counts=False, **kwargs)[source]

Make a quick Matplotlib plot of a convolved spectrum from a file. A Matplotlib figure and axis is returned.

Parameters: specfile (string) – The file to be opened for plotting. figsize (tuple of integers, optional) – The size of the figure on both sides in inches. Default: (10,10) plot_energy (boolean, optional) – Whether to plot in energy or channel space. Default is to plot in energy, unless the RMF for the spectrum cannot be found. lw (float, optional) – The width of the lines in the plots. Default: 2.0 px. xmin (float, optional) – The left-most energy (in keV) or channel to plot. Default is the minimum value in the spectrum. xmax (float, optional) – The right-most energy (in keV) or channel to plot. Default is the maximum value in the spectrum. ymin (float, optional) – The lower extent of the y-axis. By default it is set automatically. ymax (float, optional) – The upper extent of the y-axis. By default it is set automatically. xscale (string, optional) – The scaling of the x-axis of the plot. Default: “log” yscale (string, optional) – The scaling of the y-axis of the plot. Default: “log” label (string, optional) – The label of the spectrum. Default: None fontsize (int) – Font size for labels and axes. Default: 18 fig (Figure, optional) – A Figure instance to plot in. Default: None, one will be created if not provided. ax (Axes, optional) – An Axes instance to plot in. Default: None, one will be created if not provided. plot_counts (boolean, optional) – If set to True, the counts instead of the count rate will be plotted. Default: False A tuple of the Figure and the Axes objects.
soxs.events.write_image(evt_file, out_file, coord_type='sky', emin=None, emax=None, overwrite=False, expmap_file=None, reblock=1)[source]

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

Parameters: evt_file (string) – The name of the input event file to read. out_file (string) – The name of the image file to write. coord_type (string, optional) – The type of coordinate to bin into an image. Can be “sky” or “det”. Default: “sky” emin (float, (value, unit) tuple, or Quantity, optional) – The minimum energy of the photons to put in the image, in keV. emax (float, (value, unit) tuple, or Quantity, optional) – The maximum energy of the photons to put in the image, in keV. overwrite (boolean, optional) – Whether or not to overwrite an existing file with the same name. Default: False expmap_file (string, optional) – Supply an exposure map file to divide this image by to get a flux map. Default: None reblock (integer, optional) – Change this value to reblock the image to larger pixel sizes (reblock >= 1). Only supported for sky coordinates. Default: 1
soxs.events.write_radial_profile(evt_file, out_file, ctr, rmin, rmax, nbins, ctr_type='celestial', emin=None, emax=None, expmap_file=None, overwrite=False)[source]

Bin up events into a radial profile and write them to a FITS table.

Parameters: evt_file (string) – Input event file. out_file (string) – The output file to write the profile to. ctr (array-like) – The central coordinate of the profile. Can either be in celestial coordinates (the default) or “physical” pixel coordinates. If the former, the ctr_type keyword argument must be explicity set to “physical”. rmin (float, (value, unit) tuple, or Quantity) – The minimum radius of the profile, in arcseconds. rmax (float, (value, unit) tuple, or Quantity) – The maximum radius of the profile, in arcseconds. nbins (integer) – The number of bins in the profile. ctr_type (string, optional) – The type of center coordinate. Either “celestial” for (RA, Dec) coordinates (the default), or “physical” for pixel coordinates. emin (float, (value, unit) tuple, or Quantity, optional) – The minimum energy of the events to be binned in keV. Default is the lowest energy available. emax (float, (value, unit) tuple, or Quantity, optional) – The maximum energy of the events to be binned in keV. Default is the highest energy available. overwrite (boolean, optional) – Whether or not to overwrite an existing file with the same name. Default: False expmap_file (string, optional) – Supply an exposure map file to determine fluxes. Default: None
soxs.events.write_spectrum(evtfile, specfile, overwrite=False)[source]

Bin event energies into a spectrum and write it to a FITS binary table. Does not do any grouping of channels, and will automatically determine PI or PHA.

Parameters: evtfile (string) – The name of the event file to read the events from. specfile (string) – The name of the spectrum file to be written. overwrite (boolean, optional) – Whether or not to overwrite an existing file with the same name. Default: False