6.3.1. Session class structure

The PYSPEX session class is the top-level class for PYSPEX and the most important class managing user interaction. When the class is initialized, a SPEX session is started for the duration of the Python session. All subsequent commands communicate with this SPEX session in the background.

The start of a SPEX session is managed by the __init__ method. At the same time, objects are created to contain much of the internal SPEX data that pyspex can access. These objects are instances of the Data, Model, Optimization, Ascdump and Log classes that are explained later in this Chapter.

class pyspex.spex.Session(*args, **kwargs)[source]

This class contains all the classes and commands that are available in a pySPEX session.

__init__()[source]

Function to initialize the PYSPEX session. It starts an instance of SPEX in the background. Furthermore, it initializes a set of objects containing information about the loaded data, model values, optimization and logs.

Variables:
  • version (str) – The SPEX version number

  • dataset (data.Data) – Class containing the data information

  • mod_abundance (model.Abundance) – Model class for the abundance setting

  • mod_distance (model.Distance) – Model class containing distance tools

  • mod_egrid (model.Egrid) – Model class for the definition of energy grids

  • mod_flux (model.Fluxes) – Model class containing flux and luminosity information

  • mod_ibal (model.Ibal) – Model class for the ionisation balance setting

  • mod_ions (model.Ions) – Model class for setting the used ions

  • mod_var (model.Var) – Model class for plasma model settings

  • mod_dem (model.Dem) – Model class for DEM modeling

  • mod_spectrum (model.Spectrum) – Model class containing commands to extract model results from SPEX

  • mod (model.Model) – Model class containing sectors, components and parameters.

  • opt_fit (optimize.Fit) – Initialize the Fit class for spectral fitting

  • asc (ascdump.Ascdump) – Class for the Ascdump output

  • logs (log.Log) – Class for Log saving and execution

During the SPEX session, the object variables can be used to obtain values from the SPEX session in the background. Please note that for most of these there are existing PYSPEX commands to retrieve the information safely.

Descriptions of the classes behind the object variables in __init__ can be found by clicking the link behind the variable.

Warning

You can only start one PYSPEX session during a python session. Unfortunately, the Fortran to Python interface that we use cannot handle multiple sessions properly.

6.3.1.1. Session class commands

The Session class also contains the main PYSPEX commands listed in Basic PYSPEX commands.