jaxspec 0.1.0__tar.gz → 0.1.2__tar.gz

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.
Files changed (33) hide show
  1. {jaxspec-0.1.0 → jaxspec-0.1.2}/PKG-INFO +13 -7
  2. {jaxspec-0.1.0 → jaxspec-0.1.2}/README.md +8 -1
  3. {jaxspec-0.1.0 → jaxspec-0.1.2}/pyproject.toml +10 -11
  4. jaxspec-0.1.2/src/jaxspec/analysis/_plot.py +35 -0
  5. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/data/obsconf.py +34 -0
  6. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/fit.py +247 -261
  7. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/model/abc.py +60 -11
  8. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/model/additive.py +1 -3
  9. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/model/multiplicative.py +3 -11
  10. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/util/typing.py +27 -2
  11. jaxspec-0.1.0/src/jaxspec/model/_additive/apec.py +0 -316
  12. jaxspec-0.1.0/src/jaxspec/model/_additive/apec_loaders.py +0 -73
  13. jaxspec-0.1.0/src/jaxspec/scripts/__init__.py +0 -0
  14. {jaxspec-0.1.0 → jaxspec-0.1.2}/LICENSE.md +0 -0
  15. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/__init__.py +0 -0
  16. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/analysis/__init__.py +0 -0
  17. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/analysis/compare.py +0 -0
  18. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/analysis/results.py +0 -0
  19. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/data/__init__.py +0 -0
  20. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/data/grouping.py +0 -0
  21. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/data/instrument.py +0 -0
  22. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/data/observation.py +0 -0
  23. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/data/ogip.py +0 -0
  24. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/data/util.py +0 -0
  25. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/model/__init__.py +0 -0
  26. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/model/background.py +0 -0
  27. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/model/list.py +0 -0
  28. {jaxspec-0.1.0/src/jaxspec/model/_additive → jaxspec-0.1.2/src/jaxspec/scripts}/__init__.py +0 -0
  29. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/scripts/debug.py +0 -0
  30. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/util/__init__.py +0 -0
  31. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/util/abundance.py +0 -0
  32. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/util/integrate.py +0 -0
  33. {jaxspec-0.1.0 → jaxspec-0.1.2}/src/jaxspec/util/online_storage.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jaxspec
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: jaxspec is a bayesian spectral fitting library for X-ray astronomy.
5
5
  Home-page: https://github.com/renecotyfanboy/jaxspec
6
6
  License: MIT
@@ -15,19 +15,18 @@ Requires-Dist: arviz (>=0.17.1,<0.20.0)
15
15
  Requires-Dist: astropy (>=6.0.0,<7.0.0)
16
16
  Requires-Dist: chainconsumer (>=1.1.2,<2.0.0)
17
17
  Requires-Dist: cmasher (>=1.6.3,<2.0.0)
18
- Requires-Dist: dm-haiku (>=0.0.11,<0.0.13)
18
+ Requires-Dist: dm-haiku (>=0.0.12,<0.0.13)
19
19
  Requires-Dist: gpjax (>=0.8.0,<0.9.0)
20
20
  Requires-Dist: interpax (>=0.3.3,<0.4.0)
21
- Requires-Dist: jax (>=0.4.30,<0.5.0)
21
+ Requires-Dist: jax (>=0.4.33,<0.5.0)
22
22
  Requires-Dist: jaxlib (>=0.4.30,<0.5.0)
23
- Requires-Dist: jaxns (>=2.5.1,<3.0.0)
23
+ Requires-Dist: jaxns (<2.6)
24
24
  Requires-Dist: jaxopt (>=0.8.1,<0.9.0)
25
25
  Requires-Dist: matplotlib (>=3.8.0,<4.0.0)
26
26
  Requires-Dist: mendeleev (>=0.15,<0.18)
27
- Requires-Dist: mkdocstrings (>=0.24,<0.26)
28
27
  Requires-Dist: networkx (>=3.1,<4.0)
29
28
  Requires-Dist: numpy (<2.0.0)
30
- Requires-Dist: numpyro (>=0.15.2,<0.16.0)
29
+ Requires-Dist: numpyro (>=0.15.3,<0.16.0)
31
30
  Requires-Dist: optimistix (>=0.0.7,<0.0.8)
32
31
  Requires-Dist: pandas (>=2.2.0,<3.0.0)
33
32
  Requires-Dist: pooch (>=1.8.2,<2.0.0)
@@ -41,7 +40,14 @@ Requires-Dist: watermark (>=2.4.3,<3.0.0)
41
40
  Project-URL: Documentation, https://jaxspec.readthedocs.io/en/latest/
42
41
  Description-Content-Type: text/markdown
43
42
 
44
- # jaxspec
43
+ <p align="center">
44
+ <img src="https://raw.githubusercontent.com/renecotyfanboy/jaxspec/main/docs/logo/logo_small.svg" alt="Logo" width="100" height="100">
45
+ </p>
46
+
47
+ <h1 align="center">
48
+ jaxspec
49
+ </h1>
50
+
45
51
 
46
52
  [![PyPI - Version](https://img.shields.io/pypi/v/jaxspec?style=for-the-badge&logo=pypi&color=rgb(37%2C%20150%2C%20190))](https://pypi.org/project/jaxspec/)
47
53
  [![Python package](https://img.shields.io/pypi/pyversions/jaxspec?style=for-the-badge)](https://pypi.org/project/jaxspec/)
@@ -1,4 +1,11 @@
1
- # jaxspec
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/renecotyfanboy/jaxspec/main/docs/logo/logo_small.svg" alt="Logo" width="100" height="100">
3
+ </p>
4
+
5
+ <h1 align="center">
6
+ jaxspec
7
+ </h1>
8
+
2
9
 
3
10
  [![PyPI - Version](https://img.shields.io/pypi/v/jaxspec?style=for-the-badge&logo=pypi&color=rgb(37%2C%20150%2C%20190))](https://pypi.org/project/jaxspec/)
4
11
  [![Python package](https://img.shields.io/pypi/pyversions/jaxspec?style=for-the-badge)](https://pypi.org/project/jaxspec/)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "jaxspec"
3
- version = "0.1.0"
3
+ version = "0.1.2"
4
4
  description = "jaxspec is a bayesian spectral fitting library for X-ray astronomy."
5
5
  authors = ["sdupourque <sdupourque@irap.omp.eu>"]
6
6
  license = "MIT"
@@ -11,13 +11,13 @@ documentation = "https://jaxspec.readthedocs.io/en/latest/"
11
11
 
12
12
  [tool.poetry.dependencies]
13
13
  python = ">=3.10,<3.12"
14
- jax = "^0.4.30"
14
+ jax = "^0.4.33"
15
15
  jaxlib = "^0.4.30"
16
16
  numpy = "<2.0.0"
17
17
  pandas = "^2.2.0"
18
18
  astropy = "^6.0.0"
19
- numpyro = "^0.15.2"
20
- dm-haiku = ">=0.0.11,<0.0.13"
19
+ numpyro = "^0.15.3"
20
+ dm-haiku = "^0.0.12"
21
21
  networkx = "^3.1"
22
22
  matplotlib = "^3.8.0"
23
23
  arviz = ">=0.17.1,<0.20.0"
@@ -28,23 +28,22 @@ gpjax = "^0.8.0"
28
28
  jaxopt = "^0.8.1"
29
29
  tinygp = "^0.3.0"
30
30
  seaborn = "^0.13.1"
31
- mkdocstrings = ">=0.24,<0.26"
32
31
  sparse = "^0.15.1"
33
32
  optimistix = "^0.0.7"
34
33
  scipy = "<1.15"
35
34
  mendeleev = ">=0.15,<0.18"
36
35
  pyzmq = "<27"
37
- jaxns = "^2.5.1"
36
+ jaxns = "<2.6"
38
37
  pooch = "^1.8.2"
39
38
  interpax = "^0.3.3"
40
39
  watermark = "^2.4.3"
41
40
 
42
41
 
43
42
  [tool.poetry.group.docs.dependencies]
44
- mkdocs = "^1.5.3"
43
+ mkdocs = "^1.6.1"
45
44
  mkdocs-material = "^9.4.6"
46
- mkdocstrings = {extras = ["python"], version = ">=0.24,<0.26"}
47
- mkdocs-jupyter = "^0.24.6"
45
+ mkdocstrings = {extras = ["python"], version = ">=0.24,<0.27"}
46
+ mkdocs-jupyter = "^0.25.0"
48
47
 
49
48
 
50
49
  [tool.poetry.group.test.dependencies]
@@ -59,7 +58,7 @@ testbook = "^0.4.2"
59
58
 
60
59
  [tool.poetry.group.dev.dependencies]
61
60
  pre-commit = "^3.5.0"
62
- ruff = ">=0.2.1,<0.6.0"
61
+ ruff = ">=0.2.1,<0.7.0"
63
62
  jupyterlab = "^4.0.7"
64
63
  notebook = "^7.0.6"
65
64
  ipywidgets = "^8.1.1"
@@ -118,4 +117,4 @@ requires = ["poetry-core"]
118
117
  build-backend = "poetry.core.masonry.api"
119
118
 
120
119
  [tool.poetry.scripts]
121
- jaxspec-debug-info = "jaxspec.scripts.debug:debug_info"
120
+ jaxspec-debug-info = "jaxspec.scripts.debug:debug_info"
@@ -0,0 +1,35 @@
1
+ import matplotlib.pyplot as plt
2
+ import numpy as np
3
+
4
+ from jax.typing import ArrayLike
5
+ from scipy.stats import nbinom
6
+
7
+
8
+ def _plot_poisson_data_with_error(
9
+ ax: plt.Axes,
10
+ x_bins: ArrayLike,
11
+ y: ArrayLike,
12
+ percentiles: tuple = (16, 84),
13
+ ):
14
+ """
15
+ Plot Poisson data with error bars. We extrapolate the intrinsic error of the observation assuming a prior rate
16
+ distributed according to a Gamma RV.
17
+ """
18
+ y_low = nbinom.ppf(percentiles[0] / 100, y, 0.5)
19
+ y_high = nbinom.ppf(percentiles[1] / 100, y, 0.5)
20
+
21
+ ax_to_plot = ax.errorbar(
22
+ np.sqrt(x_bins[0] * x_bins[1]),
23
+ y,
24
+ xerr=np.abs(x_bins - np.sqrt(x_bins[0] * x_bins[1])),
25
+ yerr=[
26
+ y - y_low,
27
+ y_high - y,
28
+ ],
29
+ color="black",
30
+ linestyle="none",
31
+ alpha=0.3,
32
+ capsize=2,
33
+ )
34
+
35
+ return ax_to_plot
@@ -229,5 +229,39 @@ class ObsConfiguration(xr.Dataset):
229
229
  attrs=observation.attrs | instrument.attrs,
230
230
  )
231
231
 
232
+ @classmethod
233
+ def mock_from_instrument(
234
+ cls,
235
+ instrument: Instrument,
236
+ exposure: float,
237
+ low_energy: float = 1e-20,
238
+ high_energy: float = 1e20,
239
+ ):
240
+ """
241
+ Create a mock observation configuration from an instrument object. The fake observation will have zero counts.
242
+
243
+ Parameters:
244
+ instrument: The instrument object.
245
+ exposure: The total exposure of the mock observation.
246
+ low_energy: The lower bound of the energy range to consider.
247
+ high_energy: The upper bound of the energy range to consider.
248
+ """
249
+
250
+ n_channels = len(instrument.coords["instrument_channel"])
251
+
252
+ observation = Observation.from_matrix(
253
+ np.zeros(n_channels),
254
+ sparse.eye(n_channels),
255
+ np.arange(n_channels),
256
+ np.zeros(n_channels, dtype=bool),
257
+ exposure,
258
+ backratio=np.ones(n_channels),
259
+ attributes={"description": "Mock observation"} | instrument.attrs,
260
+ )
261
+
262
+ return cls.from_instrument(
263
+ instrument, observation, low_energy=low_energy, high_energy=high_energy
264
+ )
265
+
232
266
  def plot_counts(self, **kwargs):
233
267
  return self.folded_counts.plot.step(x="e_min_folded", where="post", **kwargs)