Skip to content

Additive models

APEC

Bases: AdditiveComponent

Collisionally ionized plasma emission from AtomDB 3.1.3.

This component represents the XSPEC apec, bapec, vapec, bvapec, vvapec and bvvapec variants. Lines and the pseudo-continuum are thermally broadened; setting broadening=True adds turbulent velocity broadening.

Parameters

  • \(kT\) (kT) \(\left[\text{keV}\right]\) : Plasma temperature
  • \(A\) (abund) \(\left[\text{dimensionless}\right]\) : Abundance of the 12 vapec metals relative to solar; available when abundances="fixed"
  • \(A_Z\) (He, C, N, O, Ne, Mg, Al, Si, S, Ar, Ca, Fe, Ni) \(\left[\text{dimensionless}\right]\) : Individual abundances relative to solar; available when abundances="free"
  • \(A_Z\) (H, He, ..., Zn) \(\left[\text{dimensionless}\right]\) : All 30 individual abundances relative to solar; available when abundances="all"
  • \(v\) (velocity) \(\left[\text{km s}^{-1}\right]\) : Gaussian turbulent velocity broadening; available when broadening=True
  • \(z\) (redshift) \(\left[\text{dimensionless}\right]\) : Redshift
  • \(K\) (norm) : Normalization \(\frac{10^{-14}}{4\pi \left[D_A (1+z)\right]^2} \int n_e n_H dV\) (XSPEC convention)

Constructor arguments

  • broadening : add the velocity parameter
  • abundances : "fixed" for one metal abundance, "free" for the 13 vapec abundances, or "all" for all 30 elements
  • abundance_table : solar abundance scale from abundance_table
  • energy_band : optional observed (e_min, e_max) band in keV; flux outside this band is unavailable
  • k_window : number of nearby output bins receiving each line. "auto" (default) sizes it from the energy grid at the first evaluation, for kT ≤ 15 keV and v ≤ 500 km/s; pass an integer for broader lines. A grid that is only ever traced (for instance shifted by an instrument model) falls back to 128 until a concrete grid has been seen
  • line_chunks : static line batch count; None selects it automatically
  • z_max : largest redshift covered by energy_band

Warning

Constructor arguments are static; changing them requires a new component and JIT compilation. The evaluation is compiled once per energy grid shape and window; the tables are device arrays shared by every replica and passed as arguments of that compiled function. Enable JAX float64 for full table precision.

Table coverage

The table covers 0.1–15 keV in the rest frame. Emissivities clip to its temperature range, 0.0813–38.5 keV.

Source code in src/jaxspec/model/_additive/apec.py
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
class APEC(AdditiveComponent):
    r"""Collisionally ionized plasma emission from AtomDB 3.1.3.

    This component represents the XSPEC `apec`, `bapec`, `vapec`, `bvapec`, `vvapec` and
    `bvvapec` variants. Lines and the pseudo-continuum are thermally broadened; setting
    ``broadening=True`` adds turbulent velocity broadening.

    !!! abstract "Parameters"
        * $kT$ (`kT`) $\left[\text{keV}\right]$ : Plasma temperature
        * $A$ (`abund`) $\left[\text{dimensionless}\right]$ : Abundance of the 12 vapec metals
          relative to solar; available when ``abundances="fixed"``
        * $A_Z$ (`He`, `C`, `N`, `O`, `Ne`, `Mg`, `Al`, `Si`, `S`, `Ar`, `Ca`, `Fe`, `Ni`)
          $\left[\text{dimensionless}\right]$ : Individual abundances relative to solar;
          available when ``abundances="free"``
        * $A_Z$ (`H`, `He`, ..., `Zn`) $\left[\text{dimensionless}\right]$ : All 30 individual
          abundances relative to solar; available when ``abundances="all"``
        * $v$ (`velocity`) $\left[\text{km s}^{-1}\right]$ : Gaussian turbulent velocity
          broadening; available when ``broadening=True``
        * $z$ (`redshift`) $\left[\text{dimensionless}\right]$ : Redshift
        * $K$ (`norm`) : Normalization
          $\frac{10^{-14}}{4\pi \left[D_A (1+z)\right]^2} \int n_e n_H dV$ (XSPEC convention)

    !!! abstract "Constructor arguments"
        * `broadening` : add the ``velocity`` parameter
        * `abundances` : ``"fixed"`` for one metal abundance, ``"free"`` for the 13 vapec
          abundances, or ``"all"`` for all 30 elements
        * `abundance_table` : solar abundance scale from
          [`abundance_table`][jaxspec.util.abundance.abundance_table]
        * `energy_band` : optional observed ``(e_min, e_max)`` band in keV; flux outside this
          band is unavailable
        * `k_window` : number of nearby output bins receiving each line. ``"auto"`` (default)
          sizes it from the energy grid at the first evaluation, for kT ≤ 15 keV and
          v ≤ 500 km/s; pass an integer for broader lines. A grid that is only ever traced
          (for instance shifted by an instrument model) falls back to 128 until a concrete grid
          has been seen
        * `line_chunks` : static line batch count; ``None`` selects it automatically
        * `z_max` : largest redshift covered by ``energy_band``

    !!! warning
        Constructor arguments are static; changing them requires a new component and JIT
        compilation. The evaluation is compiled once per energy grid shape and window; the
        tables are device arrays shared by every replica and passed as arguments of that
        compiled function. Enable JAX float64 for full table precision.

    !!! warning "Table coverage"
        The table covers 0.1–15 keV in the rest frame. Emissivities clip to its temperature
        range, 0.0813–38.5 keV.
    """

    def __init__(
        self,
        broadening: bool = False,
        abundances: Literal["fixed", "free", "all"] = "fixed",
        abundance_table: str = "angr",
        energy_band: tuple[float, float] | None = None,
        k_window: int | Literal["auto"] = "auto",
        line_chunks: int | None = None,
        z_max: float = 0.3,
    ):
        self.kT = nnx.Param(1.0)
        self.redshift = nnx.Param(0.0)
        self.norm = nnx.Param(1.0)

        if broadening:
            self.velocity = nnx.Param(0.0)

        if abundances == "fixed":
            self.abund = nnx.Param(1.0)
        elif abundances == "free":
            for symbol in VAPEC_SYMBOLS:
                setattr(self, symbol, nnx.Param(1.0))
        elif abundances == "all":
            for symbol in ELEMENT_SYMBOLS:
                setattr(self, symbol, nnx.Param(1.0))
        else:
            raise ValueError(f"abundances must be 'fixed', 'free' or 'all', got {abundances!r}")

        if isinstance(k_window, str):
            if k_window != "auto":
                raise ValueError(f"k_window must be a positive integer or 'auto', got {k_window!r}")
            self._k_window = None
        else:
            self._k_window = int(k_window)
            if self._k_window < 1:
                raise ValueError(f"k_window must be a positive integer or 'auto', got {k_window!r}")

        self._broadening = bool(broadening)
        self._abundances = abundances
        self._line_chunks = None if line_chunks is None else max(int(line_chunks), 1)
        self._k_window_checked = False
        # Grid of the last automatic window sizing (bins, first edge, last edge) and its result.
        self._auto_n_bins = -1
        self._auto_e_min = 0.0
        self._auto_e_max = 0.0
        self._auto_k = DEFAULT_K_WINDOW

        self._tables = _ApecTables(
            restricted_table(*energy_band, z_max=z_max)
            if energy_band is not None
            else runtime_table()
        )

        if abundance_table == "angr":
            self._ab_ratio = np.ones(len(ELEMENT_SYMBOLS))
        else:
            from ...util.abundance import abundance_table as abundance_df

            valid_tables = [column for column in abundance_df.columns if column != "Element"]
            if abundance_table not in valid_tables:
                raise ValueError(
                    f"Unknown abundance table {abundance_table!r}, expected one of {valid_tables}"
                )
            self._ab_ratio = np.asarray(abundance_df[abundance_table], dtype=float) / np.asarray(
                abundance_df["angr"], dtype=float
            )

    def _suggest_k_window(self, e_low, e_high, **kwargs) -> int:
        """Suggest a safe `k_window` for this component and energy grid."""
        arrays = self._tables.arrays
        kwargs.setdefault(
            "table", {"E0": np.asarray(arrays["E0"]), "Amass": np.asarray(arrays["Amass"])}
        )
        return suggest_k_window(e_low, e_high, **kwargs)

    def _resolve_k_window(self, e_low, e_high) -> int:
        """Return the static window for this grid: the explicit value, or one sized from it."""
        traced = isinstance(e_low, jax.core.Tracer)

        if self._k_window is not None:
            if not traced and not self._k_window_checked:
                self._k_window_checked = True
                needed = self._suggest_k_window(np.asarray(e_low), np.asarray(e_high))
                if needed > self._k_window:
                    warnings.warn(
                        f"APEC k_window={self._k_window} is smaller than the {needed} suggested "
                        "for this energy grid (sized for kT <= 15 keV, v <= 500 km/s): line "
                        "wings will be silently truncated. Pass k_window=... at construction.",
                        stacklevel=3,
                    )
            return self._k_window

        n_bins = int(e_low.shape[0])
        if traced:
            if self._auto_n_bins != n_bins:
                warnings.warn(
                    f"APEC k_window='auto' met a traced energy grid of {n_bins} bins before any "
                    f"concrete one; using k_window={DEFAULT_K_WINDOW}. Evaluate the component "
                    "once on concrete energies first, or pass k_window=... at construction.",
                    stacklevel=3,
                )
                return DEFAULT_K_WINDOW
            return self._auto_k

        # Host copies first: indexing a concrete array inside a trace would yield a tracer.
        lo, hi = np.asarray(e_low), np.asarray(e_high)
        e_min, e_max = float(lo[0]), float(hi[-1])
        if (n_bins, e_min, e_max) != (self._auto_n_bins, self._auto_e_min, self._auto_e_max):
            self._auto_k = self._suggest_k_window(lo, hi)
            self._auto_n_bins, self._auto_e_min, self._auto_e_max = n_bins, e_min, e_max
        return self._auto_k

    def _abund_vector(self):
        """Return per-element abundances relative to AG89 solar."""
        if self._abundances == "fixed":
            vector = jnp.where(METAL_MASK, jnp.asarray(self.abund), 1.0)
        elif self._abundances == "free":
            values = jnp.stack([jnp.asarray(getattr(self, symbol)) for symbol in VAPEC_SYMBOLS])
            vector = jnp.ones(len(ELEMENT_SYMBOLS)).at[VAPEC_IDX].set(values)
        else:
            vector = jnp.stack([jnp.asarray(getattr(self, symbol)) for symbol in ELEMENT_SYMBOLS])
        return vector * self._ab_ratio

    def integrated_continuum(self, e_low, e_high):
        sigma_v = jnp.asarray(self.velocity) if self._broadening else 0.0
        return _apec_flux_jit(
            e_low,
            e_high,
            jnp.asarray(self.kT),
            self._abund_vector(),
            sigma_v,
            jnp.asarray(self.redshift),
            jnp.asarray(self.norm),
            k_window=self._resolve_k_window(e_low, e_high),
            line_chunks=self._line_chunks,
            **self._tables.arrays,
        )

Additiveconstant

Bases: AdditiveComponent

A constant model

\[\mathcal{M}\left( E \right) = K\]

Parameters

  • \(K\) (norm) \(\left[\frac{\text{photons}}{\text{keV}\text{cm}^2\text{s}}\right]\) : Normalization
Source code in src/jaxspec/model/additive.py
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
class Additiveconstant(AdditiveComponent):
    r"""
    A constant model

    $$\mathcal{M}\left( E \right) = K$$

    !!! abstract "Parameters"
        * $K$ (`norm`) $\left[\frac{\text{photons}}{\text{keV}\text{cm}^2\text{s}}\right]$ : Normalization
    """

    def __init__(self):
        self.norm = nnx.Param(1.0)

    def integrated_continuum(self, e_low, e_high):
        return (e_high - e_low) * self.norm

Agauss

Bases: AdditiveComponent

A simple Gaussian line profile in wavelength space. If the width is \(\leq 0\) then it is treated as a delta function. The Zagauss variant computes a redshifted Gaussian.

\[\mathcal{M}\left( \lambda \right) = \frac{K}{\sigma \sqrt{2 \pi}} \exp\left(\frac{-(\lambda - \lambda_L)^2}{2 \sigma^2}\right)\]

Parameters

  • \(\lambda_L\) (lambdal) \(\left[\unicode{x212B}\right]\) : Wavelength of the line in Angström
  • \(\sigma\) (sigma) \(\left[\unicode{x212B}\right]\) : Width of the line width in Angström
  • \(K\) (norm) \(\left[\frac{\unicode{x212B}~\text{photons}}{\text{keV}\text{cm}^2\text{s}}\right]\): Normalization
Source code in src/jaxspec/model/additive.py
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
class Agauss(AdditiveComponent):
    r"""
    A simple Gaussian line profile in wavelength space.
    If the width is $\leq 0$ then it is treated as a delta function.
    The `Zagauss` variant computes a redshifted Gaussian.

    $$\mathcal{M}\left( \lambda \right) =
    \frac{K}{\sigma \sqrt{2 \pi}} \exp\left(\frac{-(\lambda - \lambda_L)^2}{2 \sigma^2}\right)$$

    !!! abstract "Parameters"
        * $\lambda_L$ (`lambdal`) $\left[\unicode{x212B}\right]$ : Wavelength of the line in Angström
        * $\sigma$ (`sigma`) $\left[\unicode{x212B}\right]$ : Width of the line width in Angström
        * $K$ (`norm`) $\left[\frac{\unicode{x212B}~\text{photons}}{\text{keV}\text{cm}^2\text{s}}\right]$: Normalization
    """

    def __init__(self):
        self.lambdal = nnx.Param(12.0)
        self.sigma = nnx.Param(1e-2)
        self.norm = nnx.Param(1.0)

    def continuum(self, energy) -> (jax.Array, jax.Array):
        hc = (astropy.constants.h * astropy.constants.c).to(u.angstrom * u.keV).value

        return self.norm * jsp.stats.norm.pdf(
            hc / energy,
            loc=jnp.asarray(self.lambdal, dtype=jnp.float64),
            scale=jnp.asarray(self.sigma, dtype=jnp.float64),
        )

Band

Bases: AdditiveComponent

A Band function model

\[ \mathcal{M}(E) = \begin{cases} K \left( \frac{E}{100 \, \text{keV}}\right)^{\alpha_1}\exp(-\frac{E}{E_c}) & \text{if $E < E_c (\alpha_1 - \alpha_2)$} \\ K \left[ (\alpha_1 - \alpha_2) \frac{E_c}{100 \, \text{keV}} \right]^{\alpha_1-\alpha_2} \left( \frac{E}{100 \, \text{keV}}\right)^{\alpha_2} \exp(-(\alpha_1 - \alpha_2)) & \text{if $E > E_c (\alpha_1 - \alpha_2)$} \end{cases} \]

Parameters

  • \(\alpha_1\) (alpha1) \(\left[\text{dimensionless}\right]\) : First powerlaw index
  • \(\alpha_2\) (alpha2) \(\left[\text{dimensionless}\right]\) : Second powerlaw index
  • \(E_c\) (Ec) \(\left[\text{keV}\right]\) : Radius at infinity (modulated by gravitational effects)
  • norm (norm) \(\left[\frac{\text{photons}}{\text{keV}\text{cm}^2\text{s}}\right]\) : Normalization at the reference energy (100 keV)
Source code in src/jaxspec/model/additive.py
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
class Band(AdditiveComponent):
    r"""
    A Band function model

    $$
    \mathcal{M}(E) = \begin{cases} K \left( \frac{E}{100 \, \text{keV}}\right)^{\alpha_1}\exp(-\frac{E}{E_c})  &
    \text{if $E < E_c (\alpha_1 - \alpha_2)$} \\
    K \left[ (\alpha_1 - \alpha_2) \frac{E_c}{100 \, \text{keV}} \right]^{\alpha_1-\alpha_2} \left( \frac{E}{100 \, \text{keV}}\right)^{\alpha_2} \exp(-(\alpha_1 - \alpha_2))  & \text{if $E > E_c (\alpha_1 - \alpha_2)$}
    \end{cases}
    $$

    !!! abstract "Parameters"
        * $\alpha_1$ (`alpha1`) $\left[\text{dimensionless}\right]$ : First powerlaw index
        * $\alpha_2$  (`alpha2`) $\left[\text{dimensionless}\right]$ : Second powerlaw index
        * $E_c$  (`Ec`) $\left[\text{keV}\right]$ : Radius at infinity (modulated by gravitational effects)
        * norm (`norm`) $\left[\frac{\text{photons}}{\text{keV}\text{cm}^2\text{s}}\right]$ : Normalization at the reference energy (100 keV)
    """

    def __init__(self):
        self.alpha1 = nnx.Param(-1.0)
        self.alpha2 = nnx.Param(-2.0)
        self.Ec = nnx.Param(200.0)
        self.norm = nnx.Param(1e-4)

    def continuum(self, energy):
        Epivot = 100.0
        alpha_diff = jnp.asarray(self.alpha1) - jnp.asarray(self.alpha2)

        spectrum = jnp.where(
            energy < self.Ec * (alpha_diff),
            (energy / Epivot) ** self.alpha1 * jnp.exp(-energy / self.Ec),
            (alpha_diff * (self.Ec / Epivot)) ** (alpha_diff)
            * (energy / 100) ** self.alpha2
            * jnp.exp(-alpha_diff),
        )

        return self.norm * spectrum

Blackbody

Bases: AdditiveComponent

A black body model

\[\mathcal{M}\left( E \right) = \frac{K \times 8.0525 E^{2}}{(k_B T)^{4}\left(\exp(E/k_BT)-1\right)}\]

Parameters

  • \(k_B T\) (kT) \(\left[\text{keV}\right]\) : Temperature
  • \(K\) (norm) \(\left[\text{dimensionless}\right]\) : \(L_{39}/D_{10}^{2}\), where \(L_{39}\) is the source luminosity [\(10^{39} \frac{\text{erg}}{\text{s}}\)] and \(D_{10}\) is the distance to the source [\(10 \text{kpc}\)]
Source code in src/jaxspec/model/additive.py
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
class Blackbody(AdditiveComponent):
    r"""
    A black body model

    $$\mathcal{M}\left( E \right) = \frac{K \times 8.0525 E^{2}}{(k_B T)^{4}\left(\exp(E/k_BT)-1\right)}$$

    !!! abstract "Parameters"
        * $k_B T$ (`kT`) $\left[\text{keV}\right]$ : Temperature
        * $K$ (`norm`) $\left[\text{dimensionless}\right]$ : $L_{39}/D_{10}^{2}$, where $L_{39}$ is the source luminosity [$10^{39} \frac{\text{erg}}{\text{s}}$]
        and $D_{10}$ is the distance to the source [$10 \text{kpc}$]
    """

    # TODO : rewrite constant as a astropy unit stuff

    def __init__(self):
        self.kT = nnx.Param(0.5)
        self.norm = nnx.Param(1.0)

    def continuum(self, energy):
        return self.norm * 8.0525 * energy**2 / ((self.kT**4) * jnp.expm1(energy / self.kT))

Blackbodyrad

Bases: AdditiveComponent

A black body model in radius normalization

\[\mathcal{M}\left( E \right) = \frac{K \times 1.0344\times 10^{-3} E^{2}}{\left(\exp (E/k_BT)-1\right)}\]

Parameters

  • \(k_B T\) (kT) \(\left[\text{keV}\right]\) : Temperature
  • \(K\) (norm) [dimensionless] : \(R^2_{km}/D_{10}^{2}\), where \(R_{km}\) is the source radius [\(\text{km}\)] and \(D_{10}\) is the distance to the source [\(10 \text{kpc}\)]
Source code in src/jaxspec/model/additive.py
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
class Blackbodyrad(AdditiveComponent):
    r"""
    A black body model in radius normalization

    $$\mathcal{M}\left( E \right) = \frac{K \times 1.0344\times 10^{-3} E^{2}}{\left(\exp (E/k_BT)-1\right)}$$

    !!! abstract "Parameters"
        * $k_B T$ (`kT`) $\left[\text{keV}\right]$ : Temperature
        * $K$ (`norm`) [dimensionless] : $R^2_{km}/D_{10}^{2}$, where $R_{km}$ is the source radius [$\text{km}$]
        and $D_{10}$ is the distance to the source [$10 \text{kpc}$]
    """

    def __init__(self):
        self.kT = nnx.Param(0.5)
        self.norm = nnx.Param(1.0)

    def continuum(self, energy):
        return self.norm * 1.0344e-3 * energy**2 / jnp.expm1(energy / self.kT)

Cutoffpl

Bases: AdditiveComponent

A power law model with high energy exponential cutoff

\[\mathcal{M}\left( E \right) = K \left( \frac{E}{E_0} \right)^{-\alpha} \exp(-E/\beta)\]

Parameters

  • \(\alpha\) (alpha) \(\left[\text{dimensionless}\right]\) : Photon index of the power law
  • \(\beta\) (beta) \(\left[\text{keV}\right]\) : Folding energy of the exponential cutoff
  • \(E_0\) \(\left[ \mathrm{keV}\right]\) : Reference energy fixed at 1 keV
  • \(K\) (norm) \(\left[\frac{\text{photons}}{\text{keV}\text{cm}^2\text{s}}\right]\) : Normalization
Source code in src/jaxspec/model/additive.py
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
class Cutoffpl(AdditiveComponent):
    r"""
    A power law model with high energy exponential cutoff

    $$\mathcal{M}\left( E \right) = K \left( \frac{E}{E_0} \right)^{-\alpha} \exp(-E/\beta)$$

    !!! abstract "Parameters"
        * $\alpha$ (`alpha`) $\left[\text{dimensionless}\right]$ : Photon index of the power law
        * $\beta$ (`beta`) $\left[\text{keV}\right]$ : Folding energy of the exponential cutoff
        * $E_0$ $\left[ \mathrm{keV}\right]$ : Reference energy fixed at 1 keV
        * $K$ (`norm`) $\left[\frac{\text{photons}}{\text{keV}\text{cm}^2\text{s}}\right]$ : Normalization
    """

    def __init__(self):
        self.alpha = nnx.Param(1.7)
        self.beta = nnx.Param(15.0)
        self.norm = nnx.Param(1e-4)

    def continuum(self, energy):
        return self.norm * energy ** (-self.alpha) * jnp.exp(-energy / self.beta)

Diskbb

Bases: AdditiveComponent

Multicolor disk blackbody with radial exponent fixed at \(p=0.75\).

\[\mathcal{M}(E)=\frac{K}{\Phi(T_{\rm in})}\, \frac{2.78\times10^{-3}}{T_{\rm in}} \int_0^{T_{\rm in}}\left(\frac{T}{T_{\rm in}}\right)^{-11/3} \frac{E^2}{\exp(E/T)-1}\,\mathrm{d}T.\]

norm is the unabsorbed photon flux over flux_band. Fits publish the XSPEC normalization \(\cos i\,(r_{\rm in}/d)^2\) as the derived quantity norm_xspec.

Parameters

  • \(T_{\rm in}\) (Tin) \([\mathrm{keV}]\): inner-disk temperature
  • \(K\) (norm) \([\mathrm{photons\,cm^{-2}\,s^{-1}}]\): photon flux over flux_band

Constructor arguments

  • flux_band: normalization band in keV; defaults to 0.5--10 keV
Source code in src/jaxspec/model/_additive/disk.py
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
class Diskbb(AdditiveComponent):
    r"""Multicolor disk blackbody with radial exponent fixed at $p=0.75$.

    $$\mathcal{M}(E)=\frac{K}{\Phi(T_{\rm in})}\,
    \frac{2.78\times10^{-3}}{T_{\rm in}}
    \int_0^{T_{\rm in}}\left(\frac{T}{T_{\rm in}}\right)^{-11/3}
    \frac{E^2}{\exp(E/T)-1}\,\mathrm{d}T.$$

    ``norm`` is the unabsorbed photon flux over ``flux_band``. Fits publish the XSPEC
    normalization $\cos i\,(r_{\rm in}/d)^2$ as the derived quantity ``norm_xspec``.

    !!! abstract "Parameters"
        * $T_{\rm in}$ (``Tin``) $[\mathrm{keV}]$: inner-disk temperature
        * $K$ (``norm``) $[\mathrm{photons\,cm^{-2}\,s^{-1}}]$: photon flux over
          ``flux_band``

    !!! abstract "Constructor arguments"
        * ``flux_band``: normalization band in keV; defaults to 0.5--10 keV
    """

    """Energy band, in keV, over which ``norm`` is the photon flux."""
    _flux_band: tuple[float, float]

    def __init__(self, flux_band: tuple[float, float] = DEFAULT_FLUX_BAND):
        self._flux_band = _validate_flux_band(flux_band)
        self.Tin = nnx.Param(1.0)
        self.norm = nnx.Param(1e-4)

    def continuum(self, energy):
        return _normalized_disk_continuum(
            energy,
            jnp.asarray(self.Tin),
            STANDARD_RADIAL_EXPONENT,
            jnp.asarray(self.norm),
            self._flux_band,
        )

    def derived_quantities(self):
        return {
            "norm_xspec": _xspec_normalization(
                jnp.asarray(self.Tin),
                STANDARD_RADIAL_EXPONENT,
                jnp.asarray(self.norm),
                self._flux_band,
            )
        }

Diskpbb

Bases: AdditiveComponent

Multicolor disk blackbody with \(T(r)\propto r^{-p}\).

\[\mathcal{M}(E)=\frac{K}{\Phi(T_{\rm in},p)}\, \frac{2.78\times10^{-3}}{T_{\rm in}}\left(\frac{0.75}{p}\right) \int_0^{T_{\rm in}}\left(\frac{T}{T_{\rm in}}\right)^{-2/p-1} \frac{E^2}{\exp(E/T)-1}\,\mathrm{d}T.\]

norm is the unabsorbed photon flux over flux_band. Fits publish the XSPEC normalization \(\cos i\,(r_{\rm in}/d)^2\) as the derived quantity norm_xspec.

Parameters

  • \(T_{\rm in}\) (Tin) \([\mathrm{keV}]\): inner-disk temperature
  • \(p\) (p): radial temperature exponent
  • \(K\) (norm) \([\mathrm{photons\,cm^{-2}\,s^{-1}}]\): photon flux over flux_band

Constructor arguments

  • flux_band: normalization band in keV; defaults to 0.5--10 keV
Source code in src/jaxspec/model/_additive/disk.py
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
class Diskpbb(AdditiveComponent):
    r"""Multicolor disk blackbody with $T(r)\propto r^{-p}$.

    $$\mathcal{M}(E)=\frac{K}{\Phi(T_{\rm in},p)}\,
    \frac{2.78\times10^{-3}}{T_{\rm in}}\left(\frac{0.75}{p}\right)
    \int_0^{T_{\rm in}}\left(\frac{T}{T_{\rm in}}\right)^{-2/p-1}
    \frac{E^2}{\exp(E/T)-1}\,\mathrm{d}T.$$

    ``norm`` is the unabsorbed photon flux over ``flux_band``. Fits publish the XSPEC
    normalization $\cos i\,(r_{\rm in}/d)^2$ as the derived quantity ``norm_xspec``.

    !!! abstract "Parameters"
        * $T_{\rm in}$ (``Tin``) $[\mathrm{keV}]$: inner-disk temperature
        * $p$ (``p``): radial temperature exponent
        * $K$ (``norm``) $[\mathrm{photons\,cm^{-2}\,s^{-1}}]$: photon flux over
          ``flux_band``

    !!! abstract "Constructor arguments"
        * ``flux_band``: normalization band in keV; defaults to 0.5--10 keV
    """

    """Energy band, in keV, over which ``norm`` is the photon flux."""
    _flux_band: tuple[float, float]

    def __init__(self, flux_band: tuple[float, float] = DEFAULT_FLUX_BAND):
        self._flux_band = _validate_flux_band(flux_band)
        self.Tin = nnx.Param(1.0)
        self.p = nnx.Param(STANDARD_RADIAL_EXPONENT)
        self.norm = nnx.Param(1e-4)

    def continuum(self, energy):
        return _normalized_disk_continuum(
            energy,
            jnp.asarray(self.Tin),
            jnp.asarray(self.p),
            jnp.asarray(self.norm),
            self._flux_band,
        )

    def derived_quantities(self):
        return {
            "norm_xspec": _xspec_normalization(
                jnp.asarray(self.Tin),
                jnp.asarray(self.p),
                jnp.asarray(self.norm),
                self._flux_band,
            )
        }

Gauss

Bases: AdditiveComponent

A Gaussian line profile. If the width is \(\leq 0\) then it is treated as a delta function. The Zgauss variant computes a redshifted Gaussian.

\[\mathcal{M}\left( E \right) = \frac{K}{\sigma \sqrt{2 \pi}}\exp\left(\frac{-(E-E_L)^2}{2\sigma^2}\right)\]

Parameters

  • \(E_L\) (El) \(\left[\text{keV}\right]\) : Energy of the line
  • \(\sigma\) (sigma) \(\left[\text{keV}\right]\) : Width of the line
  • \(K\) (norm) \(\left[\frac{\text{photons}}{\text{cm}^2\text{s}}\right]\) : Normalization
Source code in src/jaxspec/model/additive.py
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
class Gauss(AdditiveComponent):
    r"""
    A Gaussian line profile. If the width is $\leq 0$ then it is treated as a delta function.
    The `Zgauss` variant computes a redshifted Gaussian.

    $$\mathcal{M}\left( E \right) = \frac{K}{\sigma \sqrt{2 \pi}}\exp\left(\frac{-(E-E_L)^2}{2\sigma^2}\right)$$

    !!! abstract "Parameters"
        * $E_L$ (`El`) $\left[\text{keV}\right]$ : Energy of the line
        * $\sigma$ (`sigma`) $\left[\text{keV}\right]$ : Width of the line
        * $K$ (`norm`) $\left[\frac{\text{photons}}{\text{cm}^2\text{s}}\right]$ : Normalization
    """

    def __init__(self):
        self.El = nnx.Param(2.0)
        self.sigma = nnx.Param(1e-2)
        self.norm = nnx.Param(1.0)

    def integrated_continuum(self, e_low, e_high):
        upper = jsp.stats.norm.cdf(
            e_high,
            loc=jnp.asarray(self.El),
            scale=jnp.asarray(self.sigma),
        )

        lower = jsp.stats.norm.cdf(
            e_low,
            loc=jnp.asarray(self.El),
            scale=jnp.asarray(self.sigma),
        )

        factor = 2 / (1 - jsp.special.erf(-self.El / (self.sigma * jnp.sqrt(2))))

        return self.norm * (upper - lower) * factor

Logparabola

Bases: AdditiveComponent

A LogParabola model

\[ \mathcal{M}\left( E \right) = K \left( \frac{E}{E_{\text{Pivot}}} \right) ^{-(\alpha - \beta ~ \log (E/E_{\text{Pivot}})) } \]

Parameters

  • \(a\) (a) \(\left[\text{dimensionless}\right]\) : Slope of the LogParabola at the pivot energy
  • \(b\) (b) \(\left[\text{dimensionless}\right]\) : Curve parameter of the LogParabola
  • \(E_{\text{Pivot}}\) \(\left[ \mathrm{keV}\right]\) : Pivot energy fixed at 1 keV
  • \(K\) (norm) \(\left[\frac{\text{photons}}{\text{keV}\text{cm}^2\text{s}}\right]\) : Normalization
Source code in src/jaxspec/model/additive.py
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
class Logparabola(AdditiveComponent):
    r"""
    A LogParabola model

    $$
    \mathcal{M}\left( E \right) = K  \left( \frac{E}{E_{\text{Pivot}}} \right)
    ^{-(\alpha - \beta ~ \log (E/E_{\text{Pivot}})) }
    $$

    !!! abstract "Parameters"
        * $a$ (`a`) $\left[\text{dimensionless}\right]$ : Slope of the LogParabola at the pivot energy
        * $b$ (`b`) $\left[\text{dimensionless}\right]$ : Curve parameter of the LogParabola
        * $E_{\text{Pivot}}$ $\left[ \mathrm{keV}\right]$ : Pivot energy fixed at 1 keV
        * $K$ (`norm`) $\left[\frac{\text{photons}}{\text{keV}\text{cm}^2\text{s}}\right]$ : Normalization
    """

    def __init__(self):
        self.a = nnx.Param(1.0)
        self.b = nnx.Param(1.0)
        self.norm = nnx.Param(1.0)

    def continuum(self, energy):
        return self.norm * energy ** (-(self.a - self.b * jnp.log(energy)))

Lorentz

Bases: AdditiveComponent

A Lorentzian line profile

\[\mathcal{M}\left( E \right) = K\frac{\frac{\sigma}{2\pi}}{(E-E_L)^2 + \left(\frac{\sigma}{2}\right)^2}\]

Parameters

  • \(E_L\) (E_l) \(\left[\text{keV}\right]\) : Energy of the line
  • \(\sigma\) (sigma) \(\left[\text{keV}\right]\) : FWHM of the line
  • \(K\) (norm) \(\left[\frac{\text{photons}}{\text{cm}^2\text{s}}\right]\) : Normalization
Source code in src/jaxspec/model/additive.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
class Lorentz(AdditiveComponent):
    r"""
    A Lorentzian line profile

    $$\mathcal{M}\left( E \right) = K\frac{\frac{\sigma}{2\pi}}{(E-E_L)^2 + \left(\frac{\sigma}{2}\right)^2}$$

    !!! abstract "Parameters"
        - $E_L$ (`E_l`) $\left[\text{keV}\right]$ : Energy of the line
        - $\sigma$ (`sigma`) $\left[\text{keV}\right]$ : FWHM of the line
        - $K$ (`norm`) $\left[\frac{\text{photons}}{\text{cm}^2\text{s}}\right]$ : Normalization
    """

    def __init__(self):
        self.E_l = nnx.Param(jnp.asarray(1.0, dtype=jnp.float64))
        self.sigma = nnx.Param(jnp.asarray(1e-3, dtype=jnp.float64))
        self.norm = nnx.Param(jnp.asarray(1.0, dtype=jnp.float64))

    def continuum(self, energy):
        return (
            self.norm
            * self.sigma
            / (2 * jnp.pi)
            / ((energy - self.E_l) ** 2 + (self.sigma / 2) ** 2)
        )

NSatmos

Bases: AdditiveComponent

A neutron star atmosphere model based on the NSATMOS model from XSPEC. See this page

Warning

The boundary case of \(R_{\text{NS}} < 1.125 R_{\text{S}}\) is handled with a null flux instead of a constant value as in XSPEC.

Parameters

  • \(T_{eff}\) (Tinf) \(\left[\text{Kelvin}\right]\) : Effective temperature at the surface (No redshift applied)
  • \(M_{ns}\) (mass) \(\left[M_{\odot}\right]\) : Mass of the NS
  • \(R_∞\) (radius) \(\left[\text{km}\right]\) : Radius at infinity (modulated by gravitational effects)
  • \(D\) (distance) \(\left[\text{kpc}\right]\) : Distance to the neutron star
  • norm (norm) \(\left[\text{dimensionless}\right]\) : fraction of the neutron star surface emitting
Source code in src/jaxspec/model/additive.py
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
class NSatmos(AdditiveComponent):
    r"""
    A neutron star atmosphere model based on the `NSATMOS` model from `XSPEC`. See [this page](https://heasarc.gsfc.nasa.gov/docs/xanadu/xspec/manual/node205.html)

    !!! warning
        The boundary case of $R_{\text{NS}} < 1.125 R_{\text{S}}$ is handled with a null flux instead of a constant value as in `XSPEC`.

    !!! abstract "Parameters"
        * $T_{eff}$ (`Tinf`) $\left[\text{Kelvin}\right]$ : Effective temperature at the surface (No redshift applied)
        * $M_{ns}$ (`mass`) $\left[M_{\odot}\right]$ : Mass of the NS
        * $R_∞$  (`radius`) $\left[\text{km}\right]$ : Radius at infinity (modulated by gravitational effects)
        * $D$ (`distance`) $\left[\text{kpc}\right]$ : Distance to the neutron star
        * norm (`norm`) $\left[\text{dimensionless}\right]$ : fraction of the neutron star surface emitting
    """

    def __init__(self):
        self.Tinf = nnx.Param(6.0)
        self.mass = nnx.Param(1.4)
        self.radius = nnx.Param(10.0)
        self.distance = nnx.Param(10.0)
        self.norm = nnx.Param(1.0)

        entry_table = Table.read(table_manager.fetch("nsatmosdata.fits"), 1)

        tab_temperature = np.asarray(entry_table["TEMP"][0], dtype=float)  # Logarithmic value
        tab_gravity = np.asarray(entry_table["GRAVITY"][0], dtype=float)  # Logarithmic value
        tab_mucrit = np.asarray(entry_table["MUCRIT"][0], dtype=float)
        tab_energy = np.asarray(entry_table["ENERGY"][0], dtype=float)
        tab_flux_flat = Table.read(table_manager.fetch("nsatmosdata.fits"), 2)["FLUX"]

        tab_flux = np.empty(
            (
                tab_temperature.size,
                tab_gravity.size,
                tab_mucrit.size,
                tab_energy.size,
            )
        )

        for i in range(len(tab_temperature)):
            for j in range(len(tab_gravity)):
                for k in range(len(tab_mucrit)):
                    tab_flux[i, j, k] = np.array(
                        tab_flux_flat[
                            i * len(tab_gravity) * len(tab_mucrit) + j * len(tab_mucrit) + k
                        ]
                    )

        tab_flux = np.asarray(tab_flux, dtype=float)

        self._tab_temperature = tab_temperature
        self._tab_gravity = tab_gravity
        self._tab_mucrit = tab_mucrit
        self._tab_energy = tab_energy
        self._tab_flux = tab_flux

    def interp_flux_func(self, temperature_log, gravity_log, mu):
        return interpax.interp3d(
            10.0**temperature_log,
            10.0**gravity_log,
            mu,
            10.0**self._tab_temperature,
            10.0**self._tab_gravity,
            self._tab_mucrit,
            self._tab_flux,
            method="linear",
        )

    @partial(jnp.vectorize, excluded=(0,))
    def continuum(self, energy):
        # log10 of temperature in Kelvin
        # 'Tinf': temp_log, # 5 to 6.5
        # 'M': mass, # 0.5 to 3
        #  'Rns': radius, # 5 to 30

        temp_log = self.Tinf
        mass = self.mass
        radius = self.radius
        distance = self.distance
        norm = self.norm

        # Derive parameters usable to retrive value in the flux table
        Rcgs = 1e5 * radius  # Radius in cgs
        r_schwarzschild = 2.95e5 * mass  # Schwarzschild radius in cgs
        r_normalized = Rcgs / r_schwarzschild  # Ratio of the radius to the Schwarzschild radius
        r_over_Dsql = 2 * jnp.log10(
            Rcgs / (3.09e21 * distance)
        )  # Log( (R/D)**2 ), 3.09e21 constant transforms radius in cgs to kpc
        zred1 = 1 / jnp.sqrt(1 - (1 / r_normalized))  # Gravitational redshift
        gravity = (6.67e-8 * 1.99e33 * mass / Rcgs**2) * zred1  # Gravity field g in cgs
        gravity_log = jnp.log10(
            gravity
        )  # Log gravity because this is the format given in the table

        # Not sure about mu yet, but it is linked to causality
        cmu = jnp.where(
            r_normalized < 1.5, jnp.sqrt(1.0 - 6.75 / r_normalized**2 + 6.75 / r_normalized**3), 0.0
        )

        # Interpolate the flux table to get the flux at the surface

        flux = self.interp_flux_func(temp_log, gravity_log, cmu)

        # Rescale the photon energies and fluxes back to the correct local temperature
        Tfactor = 10.0 ** (temp_log - 6.0)
        fluxshift = 3.0 * (temp_log - 6.0)
        E = self._tab_energy * Tfactor
        flux += fluxshift

        # Rescale applying redshift
        fluxshift = -jnp.log10(zred1)
        E = E / zred1
        flux += fluxshift

        # Convert to counts/keV (which corresponds to dividing by1.602e-9*EkeV)
        # Multiply by the area of the star, and calculate the count rate at the observer
        flux += r_over_Dsql
        counts = 10.0 ** (flux - jnp.log10(1.602e-9) - jnp.log10(E))

        true_flux = norm * jnp.exp(
            interpax.interp1d(jnp.log(energy), jnp.log(E), jnp.log(counts), method="linear")
        )

        return jax.lax.select(r_normalized < 1.125, jnp.zeros_like(true_flux), true_flux)

Powerlaw

Bases: AdditiveComponent

A power law model

\[\mathcal{M}\left( E \right) = K \left( \frac{E}{E_0} \right)^{-\alpha}\]

Parameters

  • \(\alpha\) (alpha) \(\left[\text{dimensionless}\right]\) : Photon index of the power law
  • \(E_0\) \(\left[ \mathrm{keV}\right]\) : Reference energy fixed at 1 keV
  • \(K\) (norm) \(\left[\frac{\text{photons}}{\text{keV}\text{cm}^2\text{s}}\right]\) : Normalization at the reference energy (1 keV)
Source code in src/jaxspec/model/additive.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
class Powerlaw(AdditiveComponent):
    r"""
    A power law model

    $$\mathcal{M}\left( E \right) = K \left( \frac{E}{E_0} \right)^{-\alpha}$$

    !!! abstract "Parameters"
        * $\alpha$ (`alpha`) $\left[\text{dimensionless}\right]$ : Photon index of the power law
        * $E_0$ $\left[ \mathrm{keV}\right]$ : Reference energy fixed at 1 keV
        * $K$ (`norm`) $\left[\frac{\text{photons}}{\text{keV}\text{cm}^2\text{s}}\right]$ : Normalization at the reference energy (1 keV)
    """

    def __init__(self):
        self.alpha = nnx.Param(1.7)
        self.norm = nnx.Param(1e-4)

    def integrated_continuum(self, e_low, e_high):
        # Mask the pole before evaluating either branch to keep gradients finite.
        one_minus_alpha = 1 - self.alpha
        is_pole = jnp.abs(one_minus_alpha) < 1e-8
        safe = jnp.where(is_pole, 1.0, one_minus_alpha)

        return self.norm * jnp.where(
            is_pole,
            jnp.log(e_high / e_low),
            (e_high**safe - e_low**safe) / safe,
        )

Zagauss

Bases: AdditiveComponent

A redshifted Gaussian line profile in wavelength space. If the width is \(\leq 0\) then it is treated as a delta function.

\[\mathcal{M}\left( \lambda \right) = \frac{K (1+z)}{\sigma \sqrt{2 \pi}} \exp\left(\frac{-(\lambda/(1+z) - \lambda_L)^2}{2 \sigma^2}\right)\]

Parameters

  • \(\lambda_L\) (lambdal) \(\left[\unicode{x212B}\right]\) : Wavelength of the line in Angström
  • \(\sigma\) (sigma) \(\left[\unicode{x212B}\right]\) : Width of the line width in Angström
  • \(z\) (redshift) \(\left[\text{dimensionless}\right]\) : Redshift
  • \(K\) (norm) \(\left[\frac{\unicode{x212B}~\text{photons}}{\text{keV}\text{cm}^2\text{s}}\right]\) : Normalization
Source code in src/jaxspec/model/additive.py
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
class Zagauss(AdditiveComponent):
    r"""
    A redshifted Gaussian line profile in wavelength space.
    If the width is $\leq 0$ then it is treated as a delta function.

    $$\mathcal{M}\left( \lambda \right) =
    \frac{K (1+z)}{\sigma \sqrt{2 \pi}} \exp\left(\frac{-(\lambda/(1+z) - \lambda_L)^2}{2 \sigma^2}\right)$$

    !!! abstract "Parameters"
        * $\lambda_L$ (`lambdal`) $\left[\unicode{x212B}\right]$  : Wavelength of the line in Angström
        * $\sigma$ (`sigma`) $\left[\unicode{x212B}\right]$  : Width of the line width in Angström
        * $z$ (`redshift`) $\left[\text{dimensionless}\right]$ : Redshift
        * $K$ (`norm`) $\left[\frac{\unicode{x212B}~\text{photons}}{\text{keV}\text{cm}^2\text{s}}\right]$ : Normalization
    """

    def __init__(self):
        self.lambdal = nnx.Param(12.0)
        self.sigma = nnx.Param(1e-2)
        self.redshift = nnx.Param(0.0)
        self.norm = nnx.Param(1.0)

    def continuum(self, energy) -> (jax.Array, jax.Array):
        hc = (astropy.constants.h * astropy.constants.c).to(u.angstrom * u.keV).value

        redshift = self.redshift

        return (
            self.norm
            * (1 + redshift)
            * jsp.stats.norm.pdf(
                (hc / energy) / (1 + redshift),
                loc=jnp.asarray(self.lambdal, dtype=jnp.float64),
                scale=jnp.asarray(self.sigma, dtype=jnp.float64),
            )
        )

Zgauss

Bases: AdditiveComponent

A redshifted Gaussian line profile. If the width is \(\leq 0\) then it is treated as a delta function.

\[\mathcal{M}\left( E \right) = \frac{K}{(1+z) \sigma \sqrt{2 \pi}}\exp\left(\frac{-(E(1+z)-E_L)^2}{2\sigma^2}\right)\]

Parameters

  • \(E_L\) (El) \(\left[\text{keV}\right]\) : Energy of the line
  • \(\sigma\) (sigma) \(\left[\text{keV}\right]\) : Width of the line
  • \(K\) (norm) \(\left[\frac{\text{photons}}{\text{cm}^2\text{s}}\right]\) : Normalization
  • \(z\) (redshift) \(\left[\text{dimensionless}\right]\) : Redshift
Source code in src/jaxspec/model/additive.py
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
class Zgauss(AdditiveComponent):
    r"""
    A redshifted Gaussian line profile. If the width is $\leq 0$ then it is treated as a delta function.

    $$\mathcal{M}\left( E \right) =
    \frac{K}{(1+z) \sigma \sqrt{2 \pi}}\exp\left(\frac{-(E(1+z)-E_L)^2}{2\sigma^2}\right)$$

    !!! abstract "Parameters"
        * $E_L$ (`El`) $\left[\text{keV}\right]$ : Energy of the line
        * $\sigma$ (`sigma`) $\left[\text{keV}\right]$ : Width of the line
        * $K$ (`norm`) $\left[\frac{\text{photons}}{\text{cm}^2\text{s}}\right]$ : Normalization
        * $z$ (`redshift`) $\left[\text{dimensionless}\right]$ : Redshift
    """

    def __init__(self):
        self.El = nnx.Param(2.0)
        self.sigma = nnx.Param(1e-2)
        self.redshift = nnx.Param(0.0)
        self.norm = nnx.Param(1.0)

    def continuum(self, energy) -> (jax.Array, jax.Array):
        return (self.norm / (1 + self.redshift)) * jsp.stats.norm.pdf(
            energy * (1 + self.redshift),
            loc=jnp.asarray(self.El, dtype=jnp.float64),
            scale=jnp.asarray(self.sigma, dtype=jnp.float64),
        )