jaxspec 0.1.3__py3-none-any.whl → 0.2.0__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/_fit/__init__.py +0 -0
- jaxspec/_fit/_build_model.py +63 -0
- jaxspec/analysis/_plot.py +166 -7
- jaxspec/analysis/results.py +238 -336
- jaxspec/data/instrument.py +47 -12
- jaxspec/data/obsconf.py +12 -2
- jaxspec/data/observation.py +68 -11
- jaxspec/data/ogip.py +32 -13
- jaxspec/data/util.py +5 -75
- jaxspec/fit.py +101 -140
- jaxspec/model/_graph_util.py +151 -0
- jaxspec/model/abc.py +275 -414
- jaxspec/model/additive.py +276 -289
- jaxspec/model/background.py +94 -87
- jaxspec/model/multiplicative.py +101 -85
- jaxspec/scripts/debug.py +1 -1
- jaxspec/util/__init__.py +0 -45
- jaxspec/util/misc.py +25 -0
- jaxspec/util/typing.py +0 -63
- {jaxspec-0.1.3.dist-info → jaxspec-0.2.0.dist-info}/METADATA +36 -16
- jaxspec-0.2.0.dist-info/RECORD +34 -0
- {jaxspec-0.1.3.dist-info → jaxspec-0.2.0.dist-info}/WHEEL +1 -1
- jaxspec/data/grouping.py +0 -23
- jaxspec-0.1.3.dist-info/RECORD +0 -31
- {jaxspec-0.1.3.dist-info → jaxspec-0.2.0.dist-info}/LICENSE.md +0 -0
- {jaxspec-0.1.3.dist-info → jaxspec-0.2.0.dist-info}/entry_points.txt +0 -0
jaxspec/util/typing.py
CHANGED
|
@@ -1,68 +1,5 @@
|
|
|
1
|
-
from typing import Any
|
|
2
|
-
|
|
3
1
|
import numpyro.distributions as dist
|
|
4
2
|
|
|
5
|
-
from jax import numpy as jnp
|
|
6
3
|
from jax.typing import ArrayLike
|
|
7
|
-
from pydantic import BaseModel, field_validator
|
|
8
4
|
|
|
9
5
|
PriorDictType = dict[str, dict[str, dist.Distribution | ArrayLike]]
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def is_flat_dict(input_data: dict[str, Any]) -> bool:
|
|
13
|
-
"""
|
|
14
|
-
Check if the input data is a flat dictionary with string keys and non-dictionary values.
|
|
15
|
-
"""
|
|
16
|
-
return all(isinstance(k, str) and not isinstance(v, dict) for k, v in input_data.items())
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class PriorDictModel(BaseModel):
|
|
20
|
-
"""
|
|
21
|
-
Pydantic model for a nested dictionary of NumPyro distributions or JAX arrays.
|
|
22
|
-
The top level keys are strings, and the values are dictionaries with string keys and values that are either
|
|
23
|
-
NumPyro distributions or JAX arrays (or convertible to JAX arrays).
|
|
24
|
-
"""
|
|
25
|
-
|
|
26
|
-
nested_dict: PriorDictType
|
|
27
|
-
|
|
28
|
-
class Config: # noqa D106
|
|
29
|
-
arbitrary_types_allowed = True
|
|
30
|
-
|
|
31
|
-
@classmethod
|
|
32
|
-
def from_dict(cls, input_prior: dict[str, Any]):
|
|
33
|
-
if is_flat_dict(input_prior):
|
|
34
|
-
nested_dict = {}
|
|
35
|
-
|
|
36
|
-
for key, obj in input_prior.items():
|
|
37
|
-
component, component_number, *parameter = key.split("_")
|
|
38
|
-
|
|
39
|
-
sub_dict = nested_dict.get(f"{component}_{component_number}", {})
|
|
40
|
-
sub_dict["_".join(parameter)] = obj
|
|
41
|
-
|
|
42
|
-
nested_dict[f"{component}_{component_number}"] = sub_dict
|
|
43
|
-
|
|
44
|
-
return cls(nested_dict=nested_dict)
|
|
45
|
-
|
|
46
|
-
return cls(nested_dict=input_prior)
|
|
47
|
-
|
|
48
|
-
@field_validator("nested_dict", mode="before")
|
|
49
|
-
def check_and_cast_nested_dict(cls, value: dict[str, Any]):
|
|
50
|
-
if not isinstance(value, dict):
|
|
51
|
-
raise ValueError("The top level must be a dictionary")
|
|
52
|
-
|
|
53
|
-
for key, inner_dict in value.items():
|
|
54
|
-
if not isinstance(inner_dict, dict):
|
|
55
|
-
raise ValueError(f'The value for key "{key}" must be a dictionary')
|
|
56
|
-
|
|
57
|
-
for inner_key, obj in inner_dict.items():
|
|
58
|
-
if not isinstance(obj, dist.Distribution):
|
|
59
|
-
try:
|
|
60
|
-
# Attempt to cast to JAX array
|
|
61
|
-
value[key][inner_key] = jnp.array(obj, dtype=float)
|
|
62
|
-
|
|
63
|
-
except Exception as e:
|
|
64
|
-
raise ValueError(
|
|
65
|
-
f'The value for key "{inner_key}" in {key} be a NumPyro '
|
|
66
|
-
f"distribution or castable to JAX array. Error: {e}"
|
|
67
|
-
)
|
|
68
|
-
return value
|
|
@@ -1,43 +1,42 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: jaxspec
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: jaxspec is a bayesian spectral fitting library for X-ray astronomy.
|
|
5
|
-
Home-page: https://github.com/renecotyfanboy/jaxspec
|
|
6
5
|
License: MIT
|
|
7
6
|
Author: sdupourque
|
|
8
7
|
Author-email: sdupourque@irap.omp.eu
|
|
9
|
-
Requires-Python: >=3.10,<3.
|
|
8
|
+
Requires-Python: >=3.10,<3.13
|
|
10
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
11
10
|
Classifier: Programming Language :: Python :: 3
|
|
12
11
|
Classifier: Programming Language :: Python :: 3.10
|
|
13
12
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
-
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Requires-Dist: arviz (>=0.17.1,<0.21.0)
|
|
15
15
|
Requires-Dist: astropy (>=6.0.0,<7.0.0)
|
|
16
|
+
Requires-Dist: catppuccin (>=2.3.4,<3.0.0)
|
|
16
17
|
Requires-Dist: chainconsumer (>=1.1.2,<2.0.0)
|
|
17
18
|
Requires-Dist: cmasher (>=1.6.3,<2.0.0)
|
|
18
|
-
Requires-Dist:
|
|
19
|
-
Requires-Dist: gpjax (>=0.8.0,<0.9.0)
|
|
19
|
+
Requires-Dist: flax (>=0.10.1,<0.11.0)
|
|
20
20
|
Requires-Dist: interpax (>=0.3.3,<0.4.0)
|
|
21
|
-
Requires-Dist: jax (>=0.4.
|
|
22
|
-
Requires-Dist:
|
|
23
|
-
Requires-Dist: jaxns (<2.6)
|
|
21
|
+
Requires-Dist: jax (>=0.4.37,<0.5.0)
|
|
22
|
+
Requires-Dist: jaxns (>=2.6.7,<3.0.0)
|
|
24
23
|
Requires-Dist: jaxopt (>=0.8.1,<0.9.0)
|
|
25
24
|
Requires-Dist: matplotlib (>=3.8.0,<4.0.0)
|
|
26
|
-
Requires-Dist: mendeleev (>=0.15,<0.
|
|
25
|
+
Requires-Dist: mendeleev (>=0.15,<0.20)
|
|
27
26
|
Requires-Dist: networkx (>=3.1,<4.0)
|
|
28
27
|
Requires-Dist: numpy (<2.0.0)
|
|
29
|
-
Requires-Dist: numpyro (>=0.
|
|
30
|
-
Requires-Dist: optimistix (>=0.0.7,<0.0.
|
|
28
|
+
Requires-Dist: numpyro (>=0.16.1,<0.17.0)
|
|
29
|
+
Requires-Dist: optimistix (>=0.0.7,<0.0.10)
|
|
31
30
|
Requires-Dist: pandas (>=2.2.0,<3.0.0)
|
|
32
31
|
Requires-Dist: pooch (>=1.8.2,<2.0.0)
|
|
33
|
-
Requires-Dist: pyzmq (<27)
|
|
34
32
|
Requires-Dist: scipy (<1.15)
|
|
35
33
|
Requires-Dist: seaborn (>=0.13.1,<0.14.0)
|
|
36
|
-
Requires-Dist: simpleeval (>=0.9.13,<
|
|
37
|
-
Requires-Dist: sparse (>=0.15.
|
|
34
|
+
Requires-Dist: simpleeval (>=0.9.13,<1.1.0)
|
|
35
|
+
Requires-Dist: sparse (>=0.15.4,<0.16.0)
|
|
38
36
|
Requires-Dist: tinygp (>=0.3.0,<0.4.0)
|
|
39
37
|
Requires-Dist: watermark (>=2.4.3,<3.0.0)
|
|
40
38
|
Project-URL: Documentation, https://jaxspec.readthedocs.io/en/latest/
|
|
39
|
+
Project-URL: Homepage, https://github.com/renecotyfanboy/jaxspec
|
|
41
40
|
Description-Content-Type: text/markdown
|
|
42
41
|
|
|
43
42
|
<p align="center">
|
|
@@ -78,3 +77,24 @@ Once the environment is set up, you can install jaxspec directly from pypi
|
|
|
78
77
|
pip install jaxspec --upgrade
|
|
79
78
|
```
|
|
80
79
|
|
|
80
|
+
## Citation
|
|
81
|
+
|
|
82
|
+
If you use `jaxspec` in your research, please consider citing the following article
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
@ARTICLE{2024A&A...690A.317D,
|
|
86
|
+
author = {{Dupourqu{\'e}}, S. and {Barret}, D. and {Diez}, C.~M. and {Guillot}, S. and {Quintin}, E.},
|
|
87
|
+
title = "{jaxspec: A fast and robust Python library for X-ray spectral fitting}",
|
|
88
|
+
journal = {\aap},
|
|
89
|
+
keywords = {methods: data analysis, methods: statistical, X-rays: general},
|
|
90
|
+
year = 2024,
|
|
91
|
+
month = oct,
|
|
92
|
+
volume = {690},
|
|
93
|
+
eid = {A317},
|
|
94
|
+
pages = {A317},
|
|
95
|
+
doi = {10.1051/0004-6361/202451736},
|
|
96
|
+
adsurl = {https://ui.adsabs.harvard.edu/abs/2024A&A...690A.317D},
|
|
97
|
+
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
jaxspec/__init__.py,sha256=Sbn02lX6Y-zNXk17N8dec22c5jeypiS0LkHmGfz7lWA,126
|
|
2
|
+
jaxspec/_fit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
jaxspec/_fit/_build_model.py,sha256=NgLobtysyhCoiRguAazYGRIpG75iW-pG0Ss_hQGuCT4,2019
|
|
4
|
+
jaxspec/analysis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
jaxspec/analysis/_plot.py,sha256=1VbWentCLHR8XzM3jZtGyppbQRFWnChNztrwpZ2reA4,6185
|
|
6
|
+
jaxspec/analysis/compare.py,sha256=g2UFhmR9Zt-7cz5gQFOB6lXuklXB3yTyUvjTypOzoSY,725
|
|
7
|
+
jaxspec/analysis/results.py,sha256=jgv-AuaxYK6xR5NuCrP4RuskGwfQzuaxynjxjJFF1Gw,24784
|
|
8
|
+
jaxspec/data/__init__.py,sha256=aantcYKC9kZFvaE-V2SIwSuLhIld17Kjrd9CIUu___Y,415
|
|
9
|
+
jaxspec/data/instrument.py,sha256=RDiG_LkucvnF2XE_ghTFME6d_2YirgQUcEY0gEle6dk,4775
|
|
10
|
+
jaxspec/data/obsconf.py,sha256=r0deDgzpfKJZFMeiKQYUnkqQEmoDYTzl3eQFjb5xYjo,10263
|
|
11
|
+
jaxspec/data/observation.py,sha256=dfb-hJFpeSPMS52oNmQl39CB9GD_MK1gG9vHlQXhhwU,7741
|
|
12
|
+
jaxspec/data/ogip.py,sha256=57lfUgvMhM4j5tdfnOmwLI0ehx09pG7SvJx6VNIJFHE,9543
|
|
13
|
+
jaxspec/data/util.py,sha256=gW9s5Yt9hpKmJ6XPSFsC9-KsFaBNqK7GWCjVAS0jrnU,7286
|
|
14
|
+
jaxspec/fit.py,sha256=8efhb2giQGgdTJ4jb9lT0gApQaYiuIS1hkalAMHZDnE,23513
|
|
15
|
+
jaxspec/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
+
jaxspec/model/_graph_util.py,sha256=hPvHYmAxb7P3nyIecaZ7RqWOjwcZ1WvUByt_yNANiaY,4552
|
|
17
|
+
jaxspec/model/abc.py,sha256=sHaFKOGfpD1ocXKlzEMdsmGLluikmBSmX8FAu7duFMQ,15489
|
|
18
|
+
jaxspec/model/additive.py,sha256=kJHyJgL8jlSduIWoIRHQBlfIiZOdJuGL_eq0QBzAx5A,20221
|
|
19
|
+
jaxspec/model/background.py,sha256=INRuuHIYgfu2E1a8Ddqpr_gF1wnhPtOpciWCteZfVVg,7687
|
|
20
|
+
jaxspec/model/list.py,sha256=0RPAoscVz_zM1CWdx_Gd5wfrQWV5Nv4Kd4bSXu2ayUA,860
|
|
21
|
+
jaxspec/model/multiplicative.py,sha256=yErnav1lOg-CFM_ge7yEQ6TN2JeKNtZPkQPOtgjR6Ug,7894
|
|
22
|
+
jaxspec/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
|
+
jaxspec/scripts/debug.py,sha256=qhyDtX4G5UdChmTLCM-5Wti4XZU-sU5S-wDb6TZjrvM,292
|
|
24
|
+
jaxspec/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
|
+
jaxspec/util/abundance.py,sha256=fsC313taIlGzQsZNwbYsJupDWm7ZbqzGhY66Ku394Mw,8546
|
|
26
|
+
jaxspec/util/integrate.py,sha256=_Ax_knpC7d4et2-QFkOUzVtNeQLX1-cwLvm-FRBxYcw,4505
|
|
27
|
+
jaxspec/util/misc.py,sha256=O3qorCL1Y2X1BS2jdd36C1eDHK9QDXTSOr9kj3uqcJo,654
|
|
28
|
+
jaxspec/util/online_storage.py,sha256=vm56RfcbFKpkRVfr0bXO7J9aQxuBq-I_oEgA26YIhCo,2469
|
|
29
|
+
jaxspec/util/typing.py,sha256=ZQM_l68qyYnIBZPz_1mKvwPMx64jvVBD8Uj6bx9sHv0,140
|
|
30
|
+
jaxspec-0.2.0.dist-info/LICENSE.md,sha256=2q5XoWzddts5IqzIcgYYMOL21puU3MfO8gvT3Ype1eQ,1073
|
|
31
|
+
jaxspec-0.2.0.dist-info/METADATA,sha256=MRbKhSlcAJAJWzG5ZcujxPEjEFuWshv0WgLr5hSkKdY,4463
|
|
32
|
+
jaxspec-0.2.0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
|
33
|
+
jaxspec-0.2.0.dist-info/entry_points.txt,sha256=kzLG2mGlCWITRn4Q6zKG_idx-_RKAncvA0DMNYTgHAg,71
|
|
34
|
+
jaxspec-0.2.0.dist-info/RECORD,,
|
jaxspec/data/grouping.py
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import numpy as np
|
|
2
|
-
from .observation import Observation
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def constant_rebin(obs: Observation, downfactor: int):
|
|
6
|
-
"""
|
|
7
|
-
Create a grouping matrix for constant rebinning of the data.
|
|
8
|
-
|
|
9
|
-
Parameters:
|
|
10
|
-
obs: Observation object.
|
|
11
|
-
downfactor: Downfactor for the rebinning.
|
|
12
|
-
|
|
13
|
-
Returns:
|
|
14
|
-
A grouping matrix.
|
|
15
|
-
"""
|
|
16
|
-
n_channels = len(obs.pha.channel)
|
|
17
|
-
n_bins = n_channels // downfactor + 1 * (n_channels % downfactor != 0)
|
|
18
|
-
grouping = np.zeros((n_bins, n_channels), dtype=bool)
|
|
19
|
-
|
|
20
|
-
for i in range(n_bins):
|
|
21
|
-
grouping[i, i * downfactor : (i + 1) * downfactor] = True
|
|
22
|
-
|
|
23
|
-
return grouping
|
jaxspec-0.1.3.dist-info/RECORD
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
jaxspec/__init__.py,sha256=Sbn02lX6Y-zNXk17N8dec22c5jeypiS0LkHmGfz7lWA,126
|
|
2
|
-
jaxspec/analysis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
jaxspec/analysis/_plot.py,sha256=C4XljmuzQz8xQur_jQddgInrBDmKgTn0eugSreLoD5k,862
|
|
4
|
-
jaxspec/analysis/compare.py,sha256=g2UFhmR9Zt-7cz5gQFOB6lXuklXB3yTyUvjTypOzoSY,725
|
|
5
|
-
jaxspec/analysis/results.py,sha256=Kz3eryxS3N_hiajcFLTWS1dtgTQo5hlh-rDCnJ3A-3c,27811
|
|
6
|
-
jaxspec/data/__init__.py,sha256=aantcYKC9kZFvaE-V2SIwSuLhIld17Kjrd9CIUu___Y,415
|
|
7
|
-
jaxspec/data/grouping.py,sha256=hhgBt-voiH0DDSyePacaIGsaMnrYbJM_-ZeU66keC7I,622
|
|
8
|
-
jaxspec/data/instrument.py,sha256=0pSf1p82g7syDMmKm13eVbYih-Veiq5DnwsyZe6_b4g,3890
|
|
9
|
-
jaxspec/data/obsconf.py,sha256=gv14sL6azK2avRiMCWuTbyLBPulzm4PwvoLY6iWPEVE,9833
|
|
10
|
-
jaxspec/data/observation.py,sha256=1UnFu5ihZp9z-vP_I7tsFY8jhhIJunv46JyuE-acrg0,6394
|
|
11
|
-
jaxspec/data/ogip.py,sha256=sv9p00qHS5pzw61pzWyyF0nV-E-RXySdSFK2tUavokA,9545
|
|
12
|
-
jaxspec/data/util.py,sha256=ycLPVE-cjn6VpUWYlBU1BGfw73ANXIBilyVAUOYOSj0,9540
|
|
13
|
-
jaxspec/fit.py,sha256=hI0koMO4KsNpe9mLlaFm_tNLgm4BVAYVyiMb1E1eyZE,24553
|
|
14
|
-
jaxspec/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
-
jaxspec/model/abc.py,sha256=wbzpKYB2sB-qdP1B0YaUw7VHEYeTegeDhaoJ1EHPWaQ,20924
|
|
16
|
-
jaxspec/model/additive.py,sha256=wjY2wL3Io3F45GJpz-UB8xYVnA-W1OFBnZMbj5pWPbQ,22449
|
|
17
|
-
jaxspec/model/background.py,sha256=QSFFiuyUEvuzXBx3QfkvVneUR8KKEP-VaANEVXcavDE,7865
|
|
18
|
-
jaxspec/model/list.py,sha256=0RPAoscVz_zM1CWdx_Gd5wfrQWV5Nv4Kd4bSXu2ayUA,860
|
|
19
|
-
jaxspec/model/multiplicative.py,sha256=GCQ6JRz92QqbzDBFwWxGZ9SUqTJZQpD7B6ji9VEFXWo,8135
|
|
20
|
-
jaxspec/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
|
-
jaxspec/scripts/debug.py,sha256=RIRykBW_kzt8__PhOohQn2xtDW6oAz49E8rmuR5ewAU,293
|
|
22
|
-
jaxspec/util/__init__.py,sha256=vKurfp7p2hxHptJjXhXqFAXAikAGXAqISMJUqPeiGTw,1259
|
|
23
|
-
jaxspec/util/abundance.py,sha256=fsC313taIlGzQsZNwbYsJupDWm7ZbqzGhY66Ku394Mw,8546
|
|
24
|
-
jaxspec/util/integrate.py,sha256=_Ax_knpC7d4et2-QFkOUzVtNeQLX1-cwLvm-FRBxYcw,4505
|
|
25
|
-
jaxspec/util/online_storage.py,sha256=vm56RfcbFKpkRVfr0bXO7J9aQxuBq-I_oEgA26YIhCo,2469
|
|
26
|
-
jaxspec/util/typing.py,sha256=8qK1aJlsqTcVKjYN-BxsDx20BTwtnS-wMw6Bdurpm-o,2459
|
|
27
|
-
jaxspec-0.1.3.dist-info/LICENSE.md,sha256=2q5XoWzddts5IqzIcgYYMOL21puU3MfO8gvT3Ype1eQ,1073
|
|
28
|
-
jaxspec-0.1.3.dist-info/METADATA,sha256=HF52McS84ujvKhSIWFHdlqrkTIukDcxUAmkMMhMDoJU,3708
|
|
29
|
-
jaxspec-0.1.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
30
|
-
jaxspec-0.1.3.dist-info/entry_points.txt,sha256=kzLG2mGlCWITRn4Q6zKG_idx-_RKAncvA0DMNYTgHAg,71
|
|
31
|
-
jaxspec-0.1.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|