jaxspec 0.0.2__py3-none-any.whl → 0.0.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- jaxspec/analysis/results.py +1 -1
- jaxspec/data/__init__.py +3 -0
- jaxspec/data/example_data/fakeit.pha +335 -1
- jaxspec/data/instrument.py +14 -9
- jaxspec/data/obsconf.py +109 -51
- jaxspec/data/observation.py +45 -18
- jaxspec/data/ogip.py +100 -40
- jaxspec/data/util.py +51 -47
- jaxspec/fit.py +19 -9
- jaxspec/model/abc.py +29 -6
- jaxspec/model/additive.py +87 -22
- jaxspec/model/background.py +5 -5
- jaxspec/model/multiplicative.py +56 -15
- {jaxspec-0.0.2.dist-info → jaxspec-0.0.4.dist-info}/METADATA +8 -4
- {jaxspec-0.0.2.dist-info → jaxspec-0.0.4.dist-info}/RECORD +17 -16
- {jaxspec-0.0.2.dist-info → jaxspec-0.0.4.dist-info}/LICENSE.md +0 -0
- {jaxspec-0.0.2.dist-info → jaxspec-0.0.4.dist-info}/WHEEL +0 -0
jaxspec/model/abc.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
import haiku as hk
|
|
3
|
+
import jax
|
|
3
4
|
import jax.numpy as jnp
|
|
4
5
|
import networkx as nx
|
|
5
6
|
from haiku._src import base
|
|
@@ -106,7 +107,7 @@ class SpectralModel:
|
|
|
106
107
|
def params(self):
|
|
107
108
|
return self.transformed_func_photon.init(None, jnp.ones(10), jnp.ones(10))
|
|
108
109
|
|
|
109
|
-
def photon_flux(self,
|
|
110
|
+
def photon_flux(self, params, e_low, e_high, n_points=2):
|
|
110
111
|
r"""
|
|
111
112
|
Compute the expected counts between $E_\min$ and $E_\max$ by integrating the model.
|
|
112
113
|
|
|
@@ -114,16 +115,27 @@ class SpectralModel:
|
|
|
114
115
|
\int _{E_\min}^{E_\max}\text{d}E ~ \mathcal{M}\left( E \right)
|
|
115
116
|
\quad \left[\frac{\text{photons}}{\text{cm}^2\text{s}}\right]$$
|
|
116
117
|
|
|
118
|
+
Parameters:
|
|
119
|
+
params : The parameters of the model.
|
|
120
|
+
e_low : The lower bound of the energy bins.
|
|
121
|
+
e_high : The upper bound of the energy bins.
|
|
122
|
+
n_points : The number of points used to integrate the model in each bin.
|
|
123
|
+
|
|
117
124
|
!!! info
|
|
118
125
|
This method is internally used in the inference process and should not be used directly. See
|
|
119
|
-
[`photon_flux`]
|
|
126
|
+
[`photon_flux`][jaxspec.analysis.results.ChainResult.photon_flux] to compute
|
|
120
127
|
the photon flux associated with a set of fitted parameters in a
|
|
121
|
-
[`ChainResult`]
|
|
128
|
+
[`ChainResult`][jaxspec.analysis.results.ChainResult]
|
|
122
129
|
instead.
|
|
123
130
|
"""
|
|
124
|
-
return self.transformed_func_photon.apply(*args, **kwargs)
|
|
125
131
|
|
|
126
|
-
|
|
132
|
+
params = jax.tree_map(lambda x: jnp.asarray(x), params)
|
|
133
|
+
e_low = jnp.asarray(e_low)
|
|
134
|
+
e_high = jnp.asarray(e_high)
|
|
135
|
+
|
|
136
|
+
return self.transformed_func_photon.apply(params, e_low, e_high, n_points=n_points)
|
|
137
|
+
|
|
138
|
+
def energy_flux(self, params, e_low, e_high, n_points=2):
|
|
127
139
|
r"""
|
|
128
140
|
Compute the expected energy flux between $E_\min$ and $E_\max$ by integrating the model.
|
|
129
141
|
|
|
@@ -131,6 +143,12 @@ class SpectralModel:
|
|
|
131
143
|
\int _{E_\min}^{E_\max}\text{d}E ~ E ~ \mathcal{M}\left( E \right)
|
|
132
144
|
\quad \left[\frac{\text{keV}}{\text{cm}^2\text{s}}\right]$$
|
|
133
145
|
|
|
146
|
+
Parameters:
|
|
147
|
+
params : The parameters of the model.
|
|
148
|
+
e_low : The lower bound of the energy bins.
|
|
149
|
+
e_high : The upper bound of the energy bins.
|
|
150
|
+
n_points : The number of points used to integrate the model in each bin.
|
|
151
|
+
|
|
134
152
|
!!! info
|
|
135
153
|
This method is internally used in the inference process and should not be used directly. See
|
|
136
154
|
[`energy_flux`](/references/results/#jaxspec.analysis.results.ChainResult.energy_flux) to compute
|
|
@@ -138,7 +156,12 @@ class SpectralModel:
|
|
|
138
156
|
[`ChainResult`](/references/results/#jaxspec.analysis.results.ChainResult)
|
|
139
157
|
instead.
|
|
140
158
|
"""
|
|
141
|
-
|
|
159
|
+
|
|
160
|
+
params = jax.tree_map(lambda x: jnp.asarray(x), params)
|
|
161
|
+
e_low = jnp.asarray(e_low)
|
|
162
|
+
e_high = jnp.asarray(e_high)
|
|
163
|
+
|
|
164
|
+
return self.transformed_func_energy.apply(params, e_low, e_high, n_points=n_points)
|
|
142
165
|
|
|
143
166
|
def build_namespace(self):
|
|
144
167
|
"""
|
jaxspec/model/additive.py
CHANGED
|
@@ -6,10 +6,9 @@ import haiku as hk
|
|
|
6
6
|
import jax
|
|
7
7
|
import jax.numpy as jnp
|
|
8
8
|
import jax.scipy as jsp
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
from functools import partial
|
|
9
|
+
import astropy.units as u
|
|
10
|
+
import astropy.constants
|
|
11
|
+
|
|
13
12
|
from .abc import ModelComponent
|
|
14
13
|
from haiku.initializers import Constant as HaikuConstant
|
|
15
14
|
from ..util.integrate import integrate_interval
|
|
@@ -72,7 +71,7 @@ class Powerlaw(AdditiveComponent):
|
|
|
72
71
|
??? abstract "Parameters"
|
|
73
72
|
* $\alpha$ : Photon index of the power law $\left[\text{dimensionless}\right]$
|
|
74
73
|
* $E_0$ : Reference energy fixed at 1 keV $\left[ \mathrm{keV}\right]$
|
|
75
|
-
* $K$ : Normalization at 1 keV $\left[\frac{\text{photons}}{\text{cm}^2\text{s}}\right]$
|
|
74
|
+
* $K$ : Normalization at the reference energy (1 keV) $\left[\frac{\text{photons}}{\text{cm}^2\text{s}}\right]$
|
|
76
75
|
"""
|
|
77
76
|
|
|
78
77
|
def continuum(self, energy):
|
|
@@ -135,8 +134,8 @@ class Logparabola(AdditiveComponent):
|
|
|
135
134
|
??? abstract "Parameters"
|
|
136
135
|
* $a$ : Slope of the LogParabola at the pivot energy $\left[\text{dimensionless}\right]$
|
|
137
136
|
* $b$ : Curve parameter of the LogParabola $\left[\text{dimensionless}\right]$
|
|
138
|
-
* $K$ : Normalization at the pivot energy $\left[\frac{\text{photons}}{\text{cm}^2\text{s}}\right]$
|
|
139
137
|
* $E_{\text{Pivot}}$ : Pivot energy fixed at 1 keV $\left[ \mathrm{keV}\right]$
|
|
138
|
+
* $K$ : Normalization at the pivot energy (1keV) $\left[\frac{\text{photons}}{\text{cm}^2\text{s}}\right]$
|
|
140
139
|
"""
|
|
141
140
|
|
|
142
141
|
# TODO : conform with xspec definition
|
|
@@ -188,16 +187,10 @@ class Blackbodyrad(AdditiveComponent):
|
|
|
188
187
|
|
|
189
188
|
class Gauss(AdditiveComponent):
|
|
190
189
|
r"""
|
|
191
|
-
A Gaussian line profile
|
|
192
|
-
|
|
193
|
-
$$\mathcal{M}\left( E \right) = \frac{K}{\sqrt{2\pi\sigma^2}}\exp\left(\frac{-(E-E_L)^2}{2\sigma^2}\right)$$
|
|
190
|
+
A Gaussian line profile. If the width is $$\leq 0$$ then it is treated as a delta function.
|
|
191
|
+
The `Zgauss` variant computes a redshifted Gaussian.
|
|
194
192
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
$$
|
|
198
|
-
\int \mathcal{M}\left( E \right) \text{d}E =
|
|
199
|
-
\frac{K}{2}\left( 1+\text{erf} \frac{(E-E_L)}{\sqrt{2}\sigma} \right)
|
|
200
|
-
$$
|
|
193
|
+
$$\mathcal{M}\left( E \right) = \frac{K}{\sigma \sqrt{2 \pi}}\exp\left(\frac{-(E-E_L)^2}{2\sigma^2}\right)$$
|
|
201
194
|
|
|
202
195
|
??? abstract "Parameters"
|
|
203
196
|
* $E_L$ : Energy of the line $\left[\text{keV}\right]$
|
|
@@ -213,6 +206,7 @@ class Gauss(AdditiveComponent):
|
|
|
213
206
|
return norm * jsp.stats.norm.pdf(energy, loc=line_energy, scale=sigma)
|
|
214
207
|
|
|
215
208
|
|
|
209
|
+
"""
|
|
216
210
|
class APEC(AdditiveComponent):
|
|
217
211
|
def __init__(self, name="apec"):
|
|
218
212
|
super(APEC, self).__init__(name=name)
|
|
@@ -307,6 +301,7 @@ class APEC(AdditiveComponent):
|
|
|
307
301
|
)
|
|
308
302
|
|
|
309
303
|
return (continuum + pseudo) * 1e14 * norm
|
|
304
|
+
"""
|
|
310
305
|
|
|
311
306
|
|
|
312
307
|
class Cutoffpl(AdditiveComponent):
|
|
@@ -319,7 +314,7 @@ class Cutoffpl(AdditiveComponent):
|
|
|
319
314
|
* $\alpha$ : Photon index of the power law $\left[\text{dimensionless}\right]$
|
|
320
315
|
* $\beta$ : Folding energy of the exponential cutoff $\left[\text{keV}\right]$
|
|
321
316
|
* $E_0$ : Reference energy fixed at 1 keV $\left[ \mathrm{keV}\right]$
|
|
322
|
-
* $K$ : Normalization at 1 keV $\left[\frac{\text{photons}}{\text{cm}^2\text{s}}\right]$
|
|
317
|
+
* $K$ : Normalization at the reference energy (1 keV) $\left[\frac{\text{photons}}{\text{cm}^2\text{s}}\right]$
|
|
323
318
|
"""
|
|
324
319
|
|
|
325
320
|
def continuum(self, energy):
|
|
@@ -369,23 +364,93 @@ class Diskbb(AdditiveComponent):
|
|
|
369
364
|
`Diskpbb` with $p=0.75$
|
|
370
365
|
|
|
371
366
|
??? abstract "Parameters"
|
|
367
|
+
* $T_{\text{in}}$ : Temperature at inner disk radius $\left[ \mathrm{keV}\right]$
|
|
372
368
|
* $\text{norm}$ : $\cos i(r_{\text{in}}/d)^{2}$,
|
|
373
369
|
where $r_{\text{in}}$ is "an apparent" inner disk radius $\left[\text{km}\right]$,
|
|
374
|
-
$d$ the distance to the source in units of $10 \text{kpc}$,
|
|
375
|
-
$i$ the angle of the disk ($i=0$ is face-on)
|
|
376
|
-
* $T_{\text{in}}$ : Temperature at inner disk radius $\left[ \mathrm{keV}\right]$
|
|
370
|
+
$d$ the distance to the source in units of $10 \text{kpc}$, $i$ the angle of the disk ($i=0$ is face-on)
|
|
377
371
|
"""
|
|
378
372
|
|
|
379
373
|
def continuum(self, energy):
|
|
380
|
-
norm = hk.get_parameter("norm", [], init=HaikuConstant(1))
|
|
381
374
|
p = 0.75
|
|
382
|
-
tin = hk.get_parameter("Tin", [], init=HaikuConstant(1))
|
|
383
375
|
tout = 0.0
|
|
376
|
+
tin = hk.get_parameter("Tin", [], init=HaikuConstant(1))
|
|
377
|
+
norm = hk.get_parameter("norm", [], init=HaikuConstant(1))
|
|
384
378
|
|
|
385
379
|
# Tout is set to 0 as it is evaluated at R=infinity
|
|
386
380
|
def integrand(kT, e, tin, p):
|
|
387
381
|
return e**2 * (kT / tin) ** (-2 / p - 1) / (jnp.exp(e / kT) - 1)
|
|
388
382
|
|
|
389
383
|
integral = integrate_interval(integrand)
|
|
384
|
+
return norm * 2.78e-3 * (0.75 / p) / tin * jnp.vectorize(lambda e: integral(tout, tin, e, tin, p))(energy)
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
class Agauss(AdditiveComponent):
|
|
388
|
+
r"""
|
|
389
|
+
A simple Gaussian line profile in wavelength space.
|
|
390
|
+
If the width is $\leq 0$ then it is treated as a delta function.
|
|
391
|
+
The `Zagauss` variant computes a redshifted Gaussian.
|
|
392
|
+
|
|
393
|
+
$$\mathcal{M}\left( \lambda \right) =
|
|
394
|
+
\frac{K}{\sigma \sqrt{2 \pi}} \exp\left(\frac{-(\lambda - \lambda_L)^2}{2 \sigma^2}\right)$$
|
|
395
|
+
|
|
396
|
+
??? abstract "Parameters"
|
|
397
|
+
* $\lambda_L$ : Wavelength of the line in Angström $\left[\unicode{x212B}\right]$
|
|
398
|
+
* $\sigma$ : Width of the line width in Angström $\left[\unicode{x212B}\right]$
|
|
399
|
+
* $K$ : Normalization $\left[\frac{\text{photons}}{\text{cm}^2\text{s}}\right]$
|
|
400
|
+
"""
|
|
401
|
+
|
|
402
|
+
def continuum(self, energy) -> (jax.Array, jax.Array):
|
|
403
|
+
hc = (astropy.constants.h * astropy.constants.c).to(u.angstrom * u.keV).value
|
|
404
|
+
line_wavelength = hk.get_parameter("Lambda_l", [], init=HaikuConstant(hc))
|
|
405
|
+
sigma = hk.get_parameter("sigma", [], init=HaikuConstant(0.001))
|
|
406
|
+
norm = hk.get_parameter("norm", [], init=HaikuConstant(1))
|
|
407
|
+
|
|
408
|
+
return norm * jsp.stats.norm.pdf(hc / energy, loc=line_wavelength, scale=sigma)
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
class Zagauss(AdditiveComponent):
|
|
412
|
+
r"""
|
|
413
|
+
A redshifted Gaussian line profile in wavelength space.
|
|
414
|
+
If the width is $\leq 0$ then it is treated as a delta function.
|
|
415
|
+
|
|
416
|
+
$$\mathcal{M}\left( \lambda \right) =
|
|
417
|
+
\frac{K (1+z)}{\sigma \sqrt{2 \pi}} \exp\left(\frac{-(\lambda/(1+z) - \lambda_L)^2}{2 \sigma^2}\right)$$
|
|
418
|
+
|
|
419
|
+
??? abstract "Parameters"
|
|
420
|
+
* $\lambda_L$ : Wavelength of the line in Angström $\left[\text{\AA}\right]$
|
|
421
|
+
* $\sigma$ : Width of the line width in Angström $\left[\text{\AA}\right]$
|
|
422
|
+
* $K$ : Normalization $\left[\frac{\text{photons}}{\text{cm}^2\text{s}}\right]$
|
|
423
|
+
* $z$ : Redshift [dimensionless]
|
|
424
|
+
"""
|
|
425
|
+
|
|
426
|
+
def continuum(self, energy) -> (jax.Array, jax.Array):
|
|
427
|
+
hc = (astropy.constants.h * astropy.constants.c).to(u.angstrom * u.keV).value
|
|
428
|
+
line_wavelength = hk.get_parameter("Lambda_l", [], init=HaikuConstant(hc))
|
|
429
|
+
sigma = hk.get_parameter("sigma", [], init=HaikuConstant(0.001))
|
|
430
|
+
norm = hk.get_parameter("norm", [], init=HaikuConstant(1))
|
|
431
|
+
redshift = hk.get_parameter("redshift", [], init=HaikuConstant(0))
|
|
432
|
+
|
|
433
|
+
return norm * (1 + redshift) * jsp.stats.norm.pdf((hc / energy) / (1 + redshift), loc=line_wavelength, scale=sigma)
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
class Zgauss(AdditiveComponent):
|
|
437
|
+
r"""
|
|
438
|
+
A redshifted Gaussian line profile. If the width is $\leq 0$ then it is treated as a delta function.
|
|
439
|
+
|
|
440
|
+
$$\mathcal{M}\left( E \right) =
|
|
441
|
+
\frac{K}{(1+z) \sigma \sqrt{2 \pi}}\exp\left(\frac{-(E(1+z)-E_L)^2}{2\sigma^2}\right)$$
|
|
442
|
+
|
|
443
|
+
??? abstract "Parameters"
|
|
444
|
+
* $E_L$ : Energy of the line $\left[\text{keV}\right]$
|
|
445
|
+
* $\sigma$ : Width of the line $\left[\text{keV}\right]$
|
|
446
|
+
* $K$ : Normalization $\left[\frac{\text{photons}}{\text{cm}^2\text{s}}\right]$
|
|
447
|
+
* $z$ : Redshift [dimensionless]
|
|
448
|
+
"""
|
|
449
|
+
|
|
450
|
+
def continuum(self, energy) -> (jax.Array, jax.Array):
|
|
451
|
+
line_energy = hk.get_parameter("E_l", [], init=HaikuConstant(1))
|
|
452
|
+
sigma = hk.get_parameter("sigma", [], init=HaikuConstant(1))
|
|
453
|
+
norm = hk.get_parameter("norm", [], init=HaikuConstant(1))
|
|
454
|
+
redshift = hk.get_parameter("redshift", [], init=HaikuConstant(0))
|
|
390
455
|
|
|
391
|
-
return norm
|
|
456
|
+
return (norm / (1 + redshift)) * jsp.stats.norm.pdf(energy * (1 + redshift), loc=line_energy, scale=sigma)
|
jaxspec/model/background.py
CHANGED
|
@@ -61,6 +61,7 @@ class BackgroundWithError(BackgroundModel):
|
|
|
61
61
|
return countrate
|
|
62
62
|
|
|
63
63
|
|
|
64
|
+
'''
|
|
64
65
|
class ConjugateBackground(BackgroundModel):
|
|
65
66
|
r"""
|
|
66
67
|
This class fit an expected rate $\lambda$ in each bin of the background spectrum. Assuming a Gamma prior
|
|
@@ -87,15 +88,14 @@ class ConjugateBackground(BackgroundModel):
|
|
|
87
88
|
|
|
88
89
|
def numpyro_model(self, energy, observed_counts, name: str = "bkg", observed=True):
|
|
89
90
|
# Gamma in numpyro is parameterized by concentration and rate (alpha/beta)
|
|
90
|
-
alpha = observed_counts + 1
|
|
91
|
-
beta = 1
|
|
91
|
+
# alpha = observed_counts + 1
|
|
92
|
+
# beta = 1
|
|
92
93
|
|
|
93
94
|
with numpyro.plate(f"{name}_plate", len(observed_counts)):
|
|
94
|
-
countrate = numpyro.sample(
|
|
95
|
-
f"{name}", dist.NegativeBinomialProbs(alpha, probs=beta / (beta + 1)), obs=observed_counts if observed else None
|
|
96
|
-
)
|
|
95
|
+
countrate = numpyro.sample(f"{name}", dist.Gamma(2 * observed_counts + 1, 2), obs=None)
|
|
97
96
|
|
|
98
97
|
return countrate
|
|
98
|
+
'''
|
|
99
99
|
|
|
100
100
|
|
|
101
101
|
class GaussianProcessBackground(BackgroundModel):
|
jaxspec/model/multiplicative.py
CHANGED
|
@@ -29,9 +29,9 @@ class Expfac(MultiplicativeComponent):
|
|
|
29
29
|
$$
|
|
30
30
|
|
|
31
31
|
??? abstract "Parameters"
|
|
32
|
-
* $A$ :
|
|
33
|
-
* $f$ :
|
|
34
|
-
* $E_c$ :
|
|
32
|
+
* $A$ : Amplitude of the modification $\left[\text{dimensionless}\right]$
|
|
33
|
+
* $f$ : Exponential factor $\left[\text{keV}^{-1}\right]$
|
|
34
|
+
* $E_c$ : Start energy of modification $\left[\text{keV}\right]$
|
|
35
35
|
|
|
36
36
|
"""
|
|
37
37
|
|
|
@@ -45,12 +45,21 @@ class Expfac(MultiplicativeComponent):
|
|
|
45
45
|
|
|
46
46
|
class Tbabs(MultiplicativeComponent):
|
|
47
47
|
r"""
|
|
48
|
-
The Tuebingen-Boulder ISM absorption model.
|
|
48
|
+
The Tuebingen-Boulder ISM absorption model. This model calculates the cross section for X-ray absorption by the ISM
|
|
49
|
+
as the sum of the cross sections for X-ray absorption due to the gas-phase ISM, the grain-phase ISM,
|
|
50
|
+
and the molecules in the ISM.
|
|
51
|
+
|
|
52
|
+
$$
|
|
53
|
+
\mathcal{M}(E) = \exp^{-N_{\text{H}}\sigma(E)}
|
|
54
|
+
$$
|
|
49
55
|
|
|
50
56
|
??? abstract "Parameters"
|
|
51
|
-
* $
|
|
57
|
+
* $N_{\text{H}}$ : Equivalent hydrogen column density
|
|
52
58
|
$\left[\frac{\text{atoms}~10^{22}}{\text{cm}^2}\right]$
|
|
53
59
|
|
|
60
|
+
!!! note
|
|
61
|
+
Abundances and cross-sections $\sigma$ can be found in Wilms et al. (2000).
|
|
62
|
+
|
|
54
63
|
"""
|
|
55
64
|
|
|
56
65
|
ref = importlib.resources.files("jaxspec") / "tables/xsect_tbabs_wilm.fits"
|
|
@@ -71,7 +80,7 @@ class Phabs(MultiplicativeComponent):
|
|
|
71
80
|
A photoelectric absorption model.
|
|
72
81
|
|
|
73
82
|
??? abstract "Parameters"
|
|
74
|
-
* $
|
|
83
|
+
* $N_{\text{H}}$ : Equivalent hydrogen column density
|
|
75
84
|
$\left[\frac{\text{atoms}~10^{22}}{\text{cm}^2}\right]$
|
|
76
85
|
|
|
77
86
|
"""
|
|
@@ -94,7 +103,7 @@ class Wabs(MultiplicativeComponent):
|
|
|
94
103
|
A photo-electric absorption using Wisconsin (Morrison & McCammon 1983) cross-sections.
|
|
95
104
|
|
|
96
105
|
??? abstract "Parameters"
|
|
97
|
-
* $
|
|
106
|
+
* $N_{\text{H}}$ : Equivalent hydrogen column density
|
|
98
107
|
$\left[\frac{\text{atoms}~10^{22}}{\text{cm}^2}\right]$
|
|
99
108
|
|
|
100
109
|
"""
|
|
@@ -122,9 +131,9 @@ class Gabs(MultiplicativeComponent):
|
|
|
122
131
|
$$
|
|
123
132
|
|
|
124
133
|
??? abstract "Parameters"
|
|
125
|
-
* $\tau$ :
|
|
126
|
-
* $\sigma$ :
|
|
127
|
-
* $E_0$ :
|
|
134
|
+
* $\tau$ : Absorption strength $\left[\text{dimensionless}\right]$
|
|
135
|
+
* $\sigma$ : Absorption width $\left[\text{keV}\right]$
|
|
136
|
+
* $E_0$ : Absorption center $\left[\text{keV}\right]$
|
|
128
137
|
|
|
129
138
|
!!! note
|
|
130
139
|
The optical depth at line center is $\tau/(\sqrt{2 \pi} \sigma)$.
|
|
@@ -149,8 +158,8 @@ class Highecut(MultiplicativeComponent):
|
|
|
149
158
|
$$
|
|
150
159
|
|
|
151
160
|
??? abstract "Parameters"
|
|
152
|
-
* $E_c$ :
|
|
153
|
-
* $E_f$ :
|
|
161
|
+
* $E_c$ : Cutoff energy $\left[\text{keV}\right]$
|
|
162
|
+
* $E_f$ : Folding energy $\left[\text{keV}\right]$
|
|
154
163
|
"""
|
|
155
164
|
|
|
156
165
|
def continuum(self, energy):
|
|
@@ -170,9 +179,9 @@ class Zedge(MultiplicativeComponent):
|
|
|
170
179
|
$$
|
|
171
180
|
|
|
172
181
|
??? abstract "Parameters"
|
|
173
|
-
* $E_c$ :
|
|
174
|
-
* $E_f$ :
|
|
175
|
-
* $z$ :
|
|
182
|
+
* $E_c$ : Threshold energy
|
|
183
|
+
* $E_f$ : Absorption depth at the threshold
|
|
184
|
+
* $z$ : Redshift [dimensionless]
|
|
176
185
|
"""
|
|
177
186
|
|
|
178
187
|
def continuum(self, energy):
|
|
@@ -181,3 +190,35 @@ class Zedge(MultiplicativeComponent):
|
|
|
181
190
|
z = hk.get_parameter("z", [], init=HaikuConstant(0))
|
|
182
191
|
|
|
183
192
|
return jnp.where(energy <= E_c, 1.0, jnp.exp(-D * (energy * (1 + z) / E_c) ** 3))
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
class Tbpcf(MultiplicativeComponent):
|
|
196
|
+
r"""
|
|
197
|
+
Partial covering model using the Tuebingen-Boulder ISM absorption model (for more details, see `Tbabs`).
|
|
198
|
+
|
|
199
|
+
$$
|
|
200
|
+
\mathcal{M}(E) = f \exp^{-N_{\text{H}}\sigma(E)} + (1-f)
|
|
201
|
+
$$
|
|
202
|
+
|
|
203
|
+
??? abstract "Parameters"
|
|
204
|
+
* $N_{\text{H}}$ : Equivalent hydrogen column density
|
|
205
|
+
$\left[\frac{\text{atoms}~10^{22}}{\text{cm}^2}\right]$
|
|
206
|
+
* $f$ : Partial covering fraction, ranges between 0 and 1 [dimensionless]
|
|
207
|
+
|
|
208
|
+
!!! note
|
|
209
|
+
Abundances and cross-sections $\sigma$ can be found in Wilms et al. (2000).
|
|
210
|
+
|
|
211
|
+
"""
|
|
212
|
+
|
|
213
|
+
ref = importlib.resources.files("jaxspec") / "tables/xsect_tbabs_wilm.fits"
|
|
214
|
+
with importlib.resources.as_file(ref) as path:
|
|
215
|
+
table = Table.read(path)
|
|
216
|
+
energy = jnp.asarray(np.array(table["ENERGY"]), dtype=np.float32)
|
|
217
|
+
sigma = jnp.asarray(np.array(table["SIGMA"]), dtype=np.float32)
|
|
218
|
+
|
|
219
|
+
def continuum(self, energy):
|
|
220
|
+
nh = hk.get_parameter("N_H", [], init=HaikuConstant(1))
|
|
221
|
+
f = hk.get_parameter("f", [], init=HaikuConstant(0.2))
|
|
222
|
+
sigma = jnp.interp(energy, self.energy, self.sigma, left=1e9, right=0.0)
|
|
223
|
+
|
|
224
|
+
return f * jnp.exp(-nh * sigma) + (1 - f)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: jaxspec
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.4
|
|
4
4
|
Summary: jaxspec is a bayesian spectral fitting library for X-ray astronomy.
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: sdupourque
|
|
@@ -10,11 +10,11 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.10
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
-
Requires-Dist: arviz (>=0.17.
|
|
13
|
+
Requires-Dist: arviz (>=0.17.1,<0.18.0)
|
|
14
14
|
Requires-Dist: astropy (>=6.0.0,<7.0.0)
|
|
15
15
|
Requires-Dist: chainconsumer (>=1.0.0,<2.0.0)
|
|
16
16
|
Requires-Dist: cmasher (>=1.6.3,<2.0.0)
|
|
17
|
-
Requires-Dist: dm-haiku (>=0.0.11,<0.0.
|
|
17
|
+
Requires-Dist: dm-haiku (>=0.0.11,<0.0.13)
|
|
18
18
|
Requires-Dist: gpjax (>=0.8.0,<0.9.0)
|
|
19
19
|
Requires-Dist: jax (>=0.4.23,<0.5.0)
|
|
20
20
|
Requires-Dist: jaxlib (>=0.4.23,<0.5.0)
|
|
@@ -23,15 +23,19 @@ Requires-Dist: matplotlib (>=3.8.0,<4.0.0)
|
|
|
23
23
|
Requires-Dist: mkdocstrings (>=0.24.0,<0.25.0)
|
|
24
24
|
Requires-Dist: networkx (>=3.1,<4.0)
|
|
25
25
|
Requires-Dist: numpy (>=1.26.1,<2.0.0)
|
|
26
|
-
Requires-Dist: numpyro (>=0.13.2,<0.
|
|
26
|
+
Requires-Dist: numpyro (>=0.13.2,<0.15.0)
|
|
27
27
|
Requires-Dist: pandas (>=2.2.0,<3.0.0)
|
|
28
|
+
Requires-Dist: scipy (<1.13)
|
|
28
29
|
Requires-Dist: seaborn (>=0.13.1,<0.14.0)
|
|
29
30
|
Requires-Dist: simpleeval (>=0.9.13,<0.10.0)
|
|
31
|
+
Requires-Dist: sparse (>=0.15.1,<0.16.0)
|
|
30
32
|
Requires-Dist: tinygp (>=0.3.0,<0.4.0)
|
|
31
33
|
Description-Content-Type: text/markdown
|
|
32
34
|
|
|
33
35
|
# jaxspec
|
|
34
36
|
|
|
37
|
+
[)](https://pypi.org/project/jaxspec/)
|
|
38
|
+
[](https://pypi.org/project/jaxspec/)
|
|
35
39
|
[](https://jaxspec.readthedocs.io/en/latest/)
|
|
36
40
|
[](https://app.codecov.io/gh/renecotyfanboy/jaxspec)
|
|
37
41
|
[](https://join.slack.com/t/jaxspec/shared_invite/zt-2cuxkdl2f-t0EEAKP~HBEHKvIUZJL2sg)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
jaxspec/__init__.py,sha256=fKMzN6U8LmdsTrUn_-w4An0X-ta38xB7AdBjQWbcWZU,147
|
|
2
2
|
jaxspec/analysis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
jaxspec/analysis/compare.py,sha256=PZ9WdRe1kdIlNyzoD3vkGvcawe44cToA6KB9FfUdzWg,726
|
|
4
|
-
jaxspec/analysis/results.py,sha256=
|
|
5
|
-
jaxspec/data/__init__.py,sha256=
|
|
4
|
+
jaxspec/analysis/results.py,sha256=IjTj72rJaovG6wR4iuBB6KJQYBBsCTEhxD00R9rHWs8,15790
|
|
5
|
+
jaxspec/data/__init__.py,sha256=5MmiOFyDBg_lBMN0piUY0ULN0gD_mW33rurVOYXebdA,497
|
|
6
6
|
jaxspec/data/example_data/MOS1.arf,sha256=kBetpqOR1G-bVpuNAzj7q7YqU5fnwp6woW5OAtSGgVk,34560
|
|
7
7
|
jaxspec/data/example_data/MOS1.pha,sha256=fh_2ZFRbq0_c4e-UdocVtNh6ObJSth4HDnFCflyGkqw,83520
|
|
8
8
|
jaxspec/data/example_data/MOS1.rmf,sha256=LRE40iwxxTmKTu0RcLC4iwc1Ds_senrvT1UIcctDCa4,14846400
|
|
@@ -18,25 +18,26 @@ jaxspec/data/example_data/PN.pha,sha256=qYXgYHa_Bg06UzHyBBOvqSCKjXcfpsZx6JGKGGBX
|
|
|
18
18
|
jaxspec/data/example_data/PN.rmf,sha256=kbqe-C2oufc-anmd_gl7h8aKcCCsbFqg3NQGe_nLQoc,3962880
|
|
19
19
|
jaxspec/data/example_data/PN_spectrum_grp20.fits,sha256=qYXgYHa_Bg06UzHyBBOvqSCKjXcfpsZx6JGKGGBXfJA,138240
|
|
20
20
|
jaxspec/data/example_data/PNbackground_spectrum.fits,sha256=VeAX4MGbMkJF_vBJ3_KnouSbmjkWZ8qcT2Z8T2g7H0k,120960
|
|
21
|
+
jaxspec/data/example_data/fakeit.pha,sha256=IhkeWkE-b3ELECd_Uasjo9h3cXgcjCYH20wDpXJ8LMk,60480
|
|
21
22
|
jaxspec/data/grouping.py,sha256=hhgBt-voiH0DDSyePacaIGsaMnrYbJM_-ZeU66keC7I,622
|
|
22
|
-
jaxspec/data/instrument.py,sha256=
|
|
23
|
-
jaxspec/data/obsconf.py,sha256
|
|
24
|
-
jaxspec/data/observation.py,sha256=
|
|
25
|
-
jaxspec/data/ogip.py,sha256=
|
|
26
|
-
jaxspec/data/util.py,sha256=
|
|
27
|
-
jaxspec/fit.py,sha256=
|
|
23
|
+
jaxspec/data/instrument.py,sha256=0Ef3zhNT7ca-nHtRCGKXpbkyXpgVVpNtO8_XrMGWnyU,3984
|
|
24
|
+
jaxspec/data/obsconf.py,sha256=tnXCXim6eBjZbvNbx2ViRJ3wzQhNacXRcCrLZlPTdY0,7378
|
|
25
|
+
jaxspec/data/observation.py,sha256=1UnFu5ihZp9z-vP_I7tsFY8jhhIJunv46JyuE-acrg0,6394
|
|
26
|
+
jaxspec/data/ogip.py,sha256=d0OEEkznA7s8xPkqPrnfIvedTdIRsQuBnRK4wHoQ17M,8793
|
|
27
|
+
jaxspec/data/util.py,sha256=BsIVpmx2kAvAn-w6uSjC793OmPAfmDKMGGLDuk9yztY,7923
|
|
28
|
+
jaxspec/fit.py,sha256=FhnedL7-_9eovErw2SESH5sbMhU-qJNdkqxkoVsLglo,9531
|
|
28
29
|
jaxspec/model/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
29
|
-
jaxspec/model/abc.py,sha256=
|
|
30
|
-
jaxspec/model/additive.py,sha256=
|
|
31
|
-
jaxspec/model/background.py,sha256=
|
|
30
|
+
jaxspec/model/abc.py,sha256=O5DwgcXWfuGSYxTk_TmZcZXak1lLuEvBzJXUTd3E9tE,17851
|
|
31
|
+
jaxspec/model/additive.py,sha256=iu_n820tOdKbG5BKsFM-nVOa2_sKPWBSQ_TKS1bljSk,18656
|
|
32
|
+
jaxspec/model/background.py,sha256=zej99rVfcRb75T85o3u4qeYQIgnFwGtxK8niZJ8S5mM,6872
|
|
32
33
|
jaxspec/model/list.py,sha256=0RPAoscVz_zM1CWdx_Gd5wfrQWV5Nv4Kd4bSXu2ayUA,860
|
|
33
|
-
jaxspec/model/multiplicative.py,sha256=
|
|
34
|
+
jaxspec/model/multiplicative.py,sha256=sAKDkiplhdY7TsaPk7gwkR18dcXmU2nytgBCiHNBPMk,7537
|
|
34
35
|
jaxspec/tables/xsect_phabs_aspl.fits,sha256=Pq_7oqYuOmEeCk4f9KVzQtfVdvAj17u2MnENx1uaUBk,86400
|
|
35
36
|
jaxspec/tables/xsect_tbabs_wilm.fits,sha256=PPReRcnWccTE_BKDFLfDposw8Jbu3ms-sIv1UiSkSTU,86400
|
|
36
37
|
jaxspec/tables/xsect_wabs_angr.fits,sha256=mzBzpHejC1LiB_LEv3mvxq4Zq7qPIHGQrExpcCT3QHM,86400
|
|
37
38
|
jaxspec/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
38
39
|
jaxspec/util/integrate.py,sha256=6oGYhRTevgOo47hbzdcomOCShC2cpKgF8AP7bkx-Zsw,4379
|
|
39
|
-
jaxspec-0.0.
|
|
40
|
-
jaxspec-0.0.
|
|
41
|
-
jaxspec-0.0.
|
|
42
|
-
jaxspec-0.0.
|
|
40
|
+
jaxspec-0.0.4.dist-info/LICENSE.md,sha256=2q5XoWzddts5IqzIcgYYMOL21puU3MfO8gvT3Ype1eQ,1073
|
|
41
|
+
jaxspec-0.0.4.dist-info/METADATA,sha256=JSU_vEIQjYwXmTQBXPrXL4ZC8Xfg3s60ktPDmBoB_3E,3194
|
|
42
|
+
jaxspec-0.0.4.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
|
43
|
+
jaxspec-0.0.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|