# 3.1.7. DEM: differential emission measure analysis¶

## 3.1.7.1. Overview¶

SPEX offers the opportunity to do a differential emission measure analysis. This is an effective way to model multi-temperature plasmas in the case of continuous temperature distributions or a large number of discrete temperature components.

The spectral model can only have one additive component: the DEM component that corresponds to a multi-temperature structure. There are no restrictions to the number of multiplicative components. For a description of the DEM analysis method see document SRON/SPEX/TRPB05 (in the documentation for version 1.0 of SPEX), Mewe et al. (1994), Mewe et al. (1995) and Kaastra et al. (1996).

SPEX has 5 different dem analysis methods implemented, as listed shortly below. We refer to the above papers for more details.

reg – Regularization method (minimizes second order derivative of the DEM; advantage: produces error bars; disadvantage: needs fine-tuning with a regularization parameter and can produce negative emission measures.

clean – Clean method: uses the clean method that is widely used in radio astronomy. Useful for “spiky emission measure distributions.

poly – Polynomial method: approximates the DEM by a polynomial in the plane, where is the emission measure. Works well if the DEM is smooth.

mult – Multi-temperature method: tries to fit the DEM to the sum of Gaussian components as a function of . Good for discrete and slightly broadened components, but may not always converge.

gene – Genetic algorithm: using a genetic algorithm try to find the best solution. Advantage: rather robust for avoiding local subminima.Disadvantage: may require a lot of cpu time, and each run produces slightly different results (due to randomization).

In practice to use the DEM methods the user should do the following steps:

Read and prepare the spectral data that should be analysed

Define the dem model with the “comp dem” command

Define any multiplicative models (absorption, redshifts, etc.) that should be applied to the additive model

Define the parameters of the dem model: number of temperature bins, temperature range, abundances etc.

Give the “dem lib” command to create a library of isothermal spectra.

Do the dem method of choice (each one of the five methods outlined above)

For different abundances or parameters of any of the spectral components, first the “dem lib” command must be re-issued!

## 3.1.7.2. Syntax¶

The following syntax rules apply:

`dem lib`

: Create the basic DEM library of isothermal spectra`dem reg auto`

: Do DEM analysis using the regularization method,
using an automatic search of the optimum regularization parameter. It
determines the regularisation parameter in such a way that
where the scaling factor
, is the number of spectral bins in the data set
and is the number of temperature components in
the DEM library.`dem reg auto #r`

: As above, but for the scaling factor
set to #r.`dem reg #r`

: Do DEM analysis using the regularization method,
using a fixed regularization parameter #r.`dem chireg #r1:#r2 #i`

: Do a grid search over the regularization
parameter , with #i steps and distributed
logarithmically between #r1 and #r2. Useful to scan the
curve whenever it is complicated and to see how much
“penalty’ (negative DEM values) there are for each value of .`dem clean`

: Do DEM analysis using the clean method`dem poly #i`

: Do DEM analysis using the polynomial method, where
#i is the degree of the polynomial`dem mult #i`

: Do DEM analysis using the multi-temperature method,
where #i is the number of broad components`dem gene #i1 #i2`

: Do DEM analysis using the genetic algorithm,
using a population size given by #i1 (maximum value 1024) and #i2 is
the number of generations (no limit, in practice after
100 generations not much change in the solution.
Experiment with these numbers for your practical case.`dem read #a`

: Read a DEM distribution from a file named #a which
automatically gets the extension “.dem”. It is an ascii file with at
least two columns, the first column is the temperature in keV and the
second column the differential emission measure, in units of
m:math:^{-3} keV:math:^{-1}. The maximum number of
data points in this file is 8192. Temperature should be in increasing
order. The data will be interpolated to match the temperature grid
defined in the dem model (which is set by the user).`dem save #a`

: Save the DEM to a file #a with extension “.dem”. The
same format as above is used for the file. A third column has the
corresponding error bars on the DEM as determined by the DEM method
used (not always relevant or well defined, exept for the
regularization method).`dem smooth #r`

: Smoothes a DEM previously determined by any DEM
method using a block filter/ Here #r is the full width of the filter
expressed in . Note that this smoothing will in
principle worsen the of the solution, but it is
sometimes useful to “wash out” some residual noise in the DEM
distribution, preserving total emission measure.## 3.1.7.3. Examples¶

`dem lib`

: create the DEM library`dem reg auto`

: use the automatic regularization method`dem reg 10.`

: use a regularization parameter of in
the regularization method`dem chireg 1.e-5:1.e5 11`

: do a grid search using 11
regularisation parameters given by ,
, 0.001, 0.01, 0.1, 1, 10, 100, 1000, ,
.`dem clean`

: use the clean method`dem poly 7`

: use a 7th degree polynomial method`dem gene 512 128`

: use the genetic algorithm with a population of
512 and 128 generations`dem save mydem`

: save the current dem on a file named mydem.dem`dem read modeldem`

: read the dem from a file named modeldem.dem`dem smooth 0.3`

: smooth the DEM to a temperature width of 0.3 in
(approximately a factor of 2 in temperature
range).