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.

plot(xlog=False, ylog=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.

  • 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()[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 (numpy.ndarray) – Central bin energy.

  • xb (numpy.ndarray) – Upper boundary of bin energy.

  • m (numpy.ndarray) – Model spectrum.

  • n (int) – Number of bins.

update(isect)[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', 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.

  • 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, 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.

  • 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, 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.

  • 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')[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')[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 (numpy.ndarray) – Bin lower boundary

  • ectr (numpy.ndarray) – Bin center value

  • eupp (numpy.ndarray) – Bin upper boundary

  • pdata (numpy.ndarray) – Data value

  • pmodel (numpy.ndarray) – Model value

  • pback (numpy.ndarray) – Background value

  • perror (numpy.ndarray) – Error value

  • tints (numpy.ndarray) – Exposure time

  • tarea (numpy.ndarray) – Area value

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

  • ncomp (int) – Number of model components

  • chi (numpy.ndarray) – Residual value

  • chierr (numpy.ndarray) – Residual error

chitype(tchi)[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')[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, 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.

  • 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()[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)[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 (numpy.ndarray) – Energy bin center value (keV)

  • xb (numpy.ndarray) – Energy bin upper boundary value (keV)

  • area (numpy.ndarray) – Effective area (m^2)

update(inst, reg)[source]

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

Parameters
  • inst (int) – Instrument number.

  • reg (int) – Region number.