6.3.5. Plot functions

6.3.5.1. Model spectrum plots

class pyspex.plot.PlotModel[source]

Class containing the model spectra for plotting purposes.

Variables:
  • nsector (int) – Number of sectors available.

  • sector (list of objects) – List of plot objects for each sector.

adum_xspec_qdp(isect, qdpfile, overwrite=False)[source]

Write the model to a QDP file in Xspec output format. This is useful to use SPEX models as input for various simulation programs, like SIMX, SIXTE and HEASIM.

Parameters:
  • isect (int) – Sector number to write (Usually 1).

  • qdpfile (str) – File name of the QDP file to write.

  • overwrite (bool) – Overwrite existing files (default=False).

plot(xlog=False, ylog=False, wave=False, title='SPEX Model Spectrum', show=True)[source]

Plot the model spectrum for all sectors.

Parameters:
  • xlog (bool) – (Optional) Set the X-axis to be logarithmic.

  • ylog (bool) – (Optional) Set the Y-axis to be logarithmic.

  • wave (bool) – (Optional) Plot in wavelength (Angstrom)

  • title (str) – (Optional) Set the title of the plot.

  • show (bool) – (Optional) Show the plot (True) or return the plot object (False).

Returns:

Matplotlib plt object.

Return type:

matplotlib.pyplot

update(wave=False)[source]

Update the model spectrum information for all sectors.

class pyspex.plot.PlotModelSector[source]

Class containing the spectral model for a particular sector for plotting purposes.

Variables:
  • xc (astropy.units.quantity.Quantity) – Central bin energy (keV).

  • xb (astropy.units.quantity.Quantity) – Upper boundary of bin energy (keV).

  • m (astropy.units.quantity.Quantity) – Model spectrum (Photons/m**2/s/keV).

  • n (int) – Number of bins.

  • tabmodel (astropy.table.table.QTable) – Astropy QTable containing the model spectrum

update(isect, wave=False)[source]

Update the values of the model spectrum for this sector.

Parameters:

isect (int) – Sector number.

6.3.5.2. Data plots

class pyspex.plot.PlotData[source]

Class containing the observed spectrum and the convolved model spectrum for plotting.

Variables:
  • ninst (int) – Number of instruments

  • inst (list) – List of instruments with data plot information

  • colors (tuple) – List of colors.

chiplot(xlog=False, ylog=False, chi='dchi', wave=False, title='SPEX', show=True)[source]

Plot the observed data, model and background spectra for all instruments, and include a subwindow with the residuals. Chi options are ‘dchi’: (observed - model)/error and ‘rel’: (observed - model)/model.

Parameters:
  • xlog (bool) – (Optional) Set the X-axis to be logarithmic.

  • ylog (bool) – (Optional) Set the Y-axis to be logarithmic.

  • chi (str) – (Optional) Type of residual. Either ‘dchi’ (data-model)/error or ‘rel’ (data-model)/model.

  • wave (bool) – (Optional) Plot residuals as a function of wavelength (Angstrom)

  • title (str) – (Optional) Set the title of the plot.

  • show (bool) – (Optional) Show the plot (True) or return the plot object (False).

Returns:

Matplotlib plt object.

Return type:

matplotlib.pyplot

plot(xlog=False, ylog=False, wave=False, title='SPEX', show=True)[source]

Plot the observed data, model and background spectra for all instruments.

Parameters:
  • xlog (bool) – (Optional) Set the X-axis to be logarithmic.

  • ylog (bool) – (Optional) Set the Y-axis to be logarithmic.

  • wave (bool) – (Optional) Plot the data on a wavelength scale (Angstrom).

  • title (str) – (Optional) Set the title of the plot.

  • show (bool) – (Optional) Show the plot (True) or return the plot object (False).

Returns:

Matplotlib plt object.

Return type:

matplotlib.pyplot

plot_chi(ax)[source]

Generate plot data for a plot of the residuals.

Parameters:

ax (matplotlib.axes.Axes) – Axis object from Matplotlib.

plot_comp(xlog=False, ylog=False, wave=False, title='SPEX', show=True)[source]

Plot the total spectrum and the individual additive model components.

Parameters:
  • xlog (bool) – (Optional) Set the X-axis to be logarithmic.

  • ylog (bool) – (Optional) Set the Y-axis to be logarithmic.

  • wave (bool) – (Optional) Plot as function of wavelenght (Angstrom).

  • title (str) – (Optional) Set the title of the plot.

  • show (bool) – (Optional) Show the plot (True) or return the plot object (False).

Returns:

Matplotlib plt object.

Return type:

matplotlib.pyplot

plot_data(ax, xlog=False, ylog=False)[source]

Generate plot of the data, model and background spectrum. This is a subfunction of plot() and chiplot().

Parameters:
  • ax (matplotlib.axes.Axes) – Axis object from Matplotlib.

  • xlog (bool) – (Optional) Set the X-axis to be logarithmic.

  • ylog (bool) – (Optional) Set the Y-axis to be logarithmic.

update(chi='dchi', wave=False)[source]

Update data plot information for this instrument.

Parameters:

chi (str) – (Optional) Type of residual. Either ‘dchi’ (data-model)/error or ‘rel’ (data-model)/model.

class pyspex.plot.PlotDataInst[source]

Class containing the data plot information for this instrument.

Variables:
  • nreg (int) – Number of regions.

  • reg (list) – List of regions with data plot information

update(inst, tchi='dchi', wave=False)[source]

Update the data plot information for this instrument.

Parameters:
  • inst (int) – Instrument number.

  • tchi (str) – (Optional) Type of residual. Either ‘dchi’ (data-model)/error or ‘rel’ (data-model)/model.

class pyspex.plot.PlotDataReg[source]

Class containing the data plot information for a region.

Variables:
  • n (int) – Number of bins

  • elow (astropy.units.quantity.Quantity) – Bin lower boundary (keV)

  • ectr (astropy.units.quantity.Quantity) – Bin center value (keV)

  • eupp (astropy.units.quantity.Quantity) – Bin upper boundary (keV)

  • ewid (astropy.units.quantity.Quantity) – Bin width (keV)

  • pdata (astropy.units.quantity.Quantity) – Data value (Counts/s/keV)

  • pmodel (astropy.units.quantity.Quantity) – Model value (Counts/s/keV)

  • pback (astropy.units.quantity.Quantity) – Background value (Counts/s/keV)

  • perror (astropy.units.quantity.Quantity) – Error value

  • tints (astropy.units.quantity.Quantity) – Exposure time (s)

  • tarea (astropy.units.quantity.Quantity) – Inverse of the effective area value (1/m**2)

  • comp (list) – List of model components for a component plot

  • ncomp (int) – Number of model components

  • tabdata (astropy.table.QTable) – Astropy QTable containing the plot data

  • chi (numpy.ndarray) – Residual value

  • chierr (numpy.ndarray) – Residual error

chitype(tchi, wave=False)[source]

Calculate the residuals for the chi plot window.

Parameters:

tchi (str) – (Optional) Type of residual. Either ‘dchi’ (data-model)/error or ‘rel’ (data-model)/model.

update(inst, reg, tchi='dchi', wave=False)[source]

Update the data plot information for this region.

Parameters:
  • inst (int) – Instrument number.

  • reg (int) – Region number.

  • tchi (str) – (Optional) Type of residual. Either ‘dchi’ (data-model)/error or ‘rel’ (data-model)/model.

6.3.5.3. Effective area plots

class pyspex.plot.PlotArea[source]

Class for plotting effective area.

Variables:
  • ninst (int) – Number of instruments.

  • inst (list of objects) – List of instrument objects.

plot(xlog=False, ylog=False, wave=False, title='Effective Area', show=True)[source]

Plot the effective area.

Parameters:
  • xlog (bool) – (Optional) Set the X-axis to be logarithmic.

  • ylog (bool) – (Optional) Set the Y-axis to be logarithmic.

  • wave (bool) – (Optional) Plot the effective area as a function of wavelength.

  • title (str) – (Optional) Set the title of the plot.

  • show (bool) – (Optional) Show the plot (True) or return the plot object (False).

Returns:

Matplotlib plt object.

Return type:

matplotlib.pyplot

update(wave=False)[source]

Update the effective area information for the plot.

class pyspex.plot.PlotAreaInst[source]

Instrument definition and region list for area plots.

Variables:
  • nreg (int) – Number of regions.

  • reg (list) – List of region area plots.

update(inst, wave)[source]

Update the area information in the regions of this instrument.

Parameters:

inst (int) – Instrument number to update.

class pyspex.plot.PlotAreaReg[source]

Effective area information for each region.

Variables:
  • xc (astropy.units.quantity.Quantity) – Energy bin center value (keV)

  • xb (astropy.units.quantity.Quantity) – Energy bin upper boundary value (keV)

  • area (astropy.units.quantity.Quantity) – Effective area (m^2)

  • tabarea (astropy.table.QTable) – Astropy QTable containing the effective area plot

update(inst, reg, wave=False)[source]

Update effective area information for this region (reg) in instrument (inst).

Parameters:
  • inst (int) – Instrument number.

  • reg (int) – Region number.