Spex 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.

PYSPEX sessions

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.

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.

Since SPEX version 4, it is possible to run multiple instances of SPEX simultaneously, like:

s=Spex()
t=Spex()

Now both s and t are two different SPEX runs, so you can load different models and/or data in each:

s.com('cie')
You have defined    1 component.
t.com('po')
You have defined    1 component.

s.par_show()
---------------------------------------------------------------------------------------------------
sect comp mod  acro parameter with unit      value     status    minimum   maximum lsec lcom lpar

1    1 cie  norm norm                     1.00000   thawn         0.0   1.0E+20
1    1 cie  t    t                        1.00000   thawn     1.0E-05   1.0E+03
1    1 cie  sig  sig                      0.00000   frozen        0.0   1.0E+04

...

1    1 cie  x1   x1                       1.00000   frozen        1.0   1.0E+10
1    1 cie  y1   y1                       0.00000   frozen        0.0   1.0E+10
1    1 cie  b    b                        0.00000   frozen        0.0   1.0E+05


---------------------------------------------------------------------------------------------------
Fluxes and restframe luminosities between     2.00000 keV and     10.0000 keV

sect comp mod   photon flux   energy flux   nr of photons  luminosity
                (phot/m**2/s) (W/m**2)      (photons/s)    (W)
1    1 cie       0.00000       0.00000       0.00000        0.00000


t.par_show()
---------------------------------------------------------------------------------------------------
sect comp mod  acro parameter with unit      value     status    minimum   maximum lsec lcom lpar

1    1 pow  norm norm                     1.00000   thawn         0.0   1.0E+20
1    1 pow  gamm gamm                     2.00000   thawn        -10.       10.
1    1 pow  dgam dgam                     0.00000   frozen       -10.       10.
1    1 pow  e0   e0                   1.00000E+10   frozen        0.0   1.0E+20
1    1 pow  b    b                        0.00000   frozen        0.0       10.
1    1 pow  type type                     0.00000   frozen        0.0       1.0
1    1 pow  elow elow                     2.00000   frozen    1.0E-20   1.0E+10
1    1 pow  eupp eupp                     10.0000   frozen    1.0E-20   1.0E+10
1    1 pow  lum  lum                      1.00000   frozen        0.0   1.0E+20


---------------------------------------------------------------------------------------------------
Fluxes and restframe luminosities between     2.00000 keV and     10.0000 keV

sect comp mod   photon flux   energy flux   nr of photons  luminosity
                (phot/m**2/s) (W/m**2)      (photons/s)    (W)
1    1 pow       0.00000       0.00000       0.00000        0.00000

Warning

The individual sessions are not (yet) fully thread safe. Commands sent to the separate instances are still executed one-by-one. If you want to run SPEX threads in parallel, then please use separate processes for each SPEX instance.

Spex class commands

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