specsy 0.6.4__tar.gz → 0.9.dev1__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 (52) hide show
  1. {specsy-0.6.4/src/specsy.egg-info → specsy-0.9.dev1}/PKG-INFO +14 -18
  2. {specsy-0.6.4 → specsy-0.9.dev1}/pyproject.toml +15 -18
  3. {specsy-0.6.4 → specsy-0.9.dev1}/src/specsy/__init__.py +6 -11
  4. {specsy-0.6.4/src/specsy/inference → specsy-0.9.dev1/src/specsy}/emission.py +3 -3
  5. specsy-0.9.dev1/src/specsy/inference.py +10 -0
  6. {specsy-0.6.4 → specsy-0.9.dev1}/src/specsy/io.py +29 -30
  7. specsy-0.9.dev1/src/specsy/models/__init__.py +2 -0
  8. specsy-0.9.dev1/src/specsy/models/chemistry.py +443 -0
  9. {specsy-0.6.4 → specsy-0.9.dev1}/src/specsy/models/chemistry_inference.py +86 -20
  10. {specsy-0.6.4 → specsy-0.9.dev1}/src/specsy/models/emissivity.py +1 -2
  11. {specsy-0.6.4 → specsy-0.9.dev1}/src/specsy/models/extinction.py +5 -10
  12. specsy-0.9.dev1/src/specsy/models/literature.py +35 -0
  13. specsy-0.9.dev1/src/specsy/observations.py +213 -0
  14. {specsy-0.6.4 → specsy-0.9.dev1}/src/specsy/operations/interpolation.py +59 -25
  15. {specsy-0.6.4 → specsy-0.9.dev1}/src/specsy/plotting/plots.py +15 -15
  16. specsy-0.9.dev1/src/specsy/sampler.py +109 -0
  17. specsy-0.6.4/src/specsy/config.toml → specsy-0.9.dev1/src/specsy/specsy.toml +3 -2
  18. {specsy-0.6.4 → specsy-0.9.dev1}/src/specsy/tools.py +8 -1
  19. {specsy-0.6.4 → specsy-0.9.dev1}/src/specsy/treatement.py +17 -7
  20. {specsy-0.6.4 → specsy-0.9.dev1/src/specsy.egg-info}/PKG-INFO +14 -18
  21. {specsy-0.6.4 → specsy-0.9.dev1}/src/specsy.egg-info/SOURCES.txt +7 -15
  22. specsy-0.9.dev1/src/specsy.egg-info/requires.txt +24 -0
  23. specsy-0.6.4/src/specsy/innate/__init__.py +0 -1
  24. specsy-0.6.4/src/specsy/innate/interpol_pytensor.py +0 -118
  25. specsy-0.6.4/src/specsy/innate/main.py +0 -137
  26. specsy-0.6.4/src/specsy/models/__init__.py +0 -5
  27. specsy-0.6.4/src/specsy/models/chemistry.py +0 -443
  28. specsy-0.6.4/src/specsy/plotting/__init__.py +0 -0
  29. specsy-0.6.4/src/specsy/resources/Benjamin1999_OpticalDepthFunctionCoefficients.txt +0 -5
  30. specsy-0.6.4/src/specsy/resources/HI_t3_elec.ascii +0 -55
  31. specsy-0.6.4/src/specsy/resources/HeII_t4_elec.ascii +0 -110
  32. specsy-0.6.4/src/specsy/resources/HeI_t5_elec.ascii +0 -334
  33. specsy-0.6.4/src/specsy/resources/gordon_2003_LMC2_supershell.txt +0 -33
  34. specsy-0.6.4/src/specsy/resources/gordon_2003_LMC_average.txt +0 -32
  35. specsy-0.6.4/src/specsy/resources/gordon_2003_SMC_bar.txt +0 -37
  36. specsy-0.6.4/src/specsy/workflow/__init__.py +0 -0
  37. specsy-0.6.4/src/specsy.egg-info/requires.txt +0 -30
  38. {specsy-0.6.4 → specsy-0.9.dev1}/MANIFEST.in +0 -0
  39. {specsy-0.6.4 → specsy-0.9.dev1}/README.rst +0 -0
  40. {specsy-0.6.4 → specsy-0.9.dev1}/setup.cfg +0 -0
  41. {specsy-0.6.4 → specsy-0.9.dev1}/src/specsy/core.py +0 -0
  42. {specsy-0.6.4 → specsy-0.9.dev1}/src/specsy/models/fluxes_line.py +0 -0
  43. {specsy-0.6.4 → specsy-0.9.dev1}/src/specsy/models/nebular_continuum.py +0 -0
  44. {specsy-0.6.4/src/specsy/inference → specsy-0.9.dev1/src/specsy/operations}/__init__.py +0 -0
  45. {specsy-0.6.4 → specsy-0.9.dev1}/src/specsy/operations/pytensors.py +0 -0
  46. {specsy-0.6.4 → specsy-0.9.dev1}/src/specsy/operations/tensors.py +0 -0
  47. {specsy-0.6.4 → specsy-0.9.dev1}/src/specsy/operations/tests.py +0 -0
  48. {specsy-0.6.4/src/specsy/operations → specsy-0.9.dev1/src/specsy/plotting}/__init__.py +0 -0
  49. {specsy-0.6.4 → specsy-0.9.dev1}/src/specsy/plotting/bokeh_functions.py +0 -0
  50. {specsy-0.6.4 → specsy-0.9.dev1}/src/specsy/plotting/specsy_theme.toml +0 -0
  51. {specsy-0.6.4 → specsy-0.9.dev1}/src/specsy.egg-info/dependency_links.txt +0 -0
  52. {specsy-0.6.4 → specsy-0.9.dev1}/src/specsy.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: specsy
3
- Version: 0.6.4
3
+ Version: 0.9.dev1
4
4
  Summary: Model fitting package for the chemical analysis of astronomical spectra
5
5
  Author-email: Vital Fernández <vgf@umich.edu>
6
6
  License-Expression: GPL-3.0-or-later
@@ -8,30 +8,26 @@ Classifier: Programming Language :: Python :: 3
8
8
  Classifier: Programming Language :: Python :: 3.11
9
9
  Requires-Python: >=3.11
10
10
  Description-Content-Type: text/x-rst
11
- Requires-Dist: arviz~=0.21
11
+ Requires-Dist: arviz~=0.23.4
12
12
  Requires-Dist: corner~=2.2
13
13
  Requires-Dist: h5netcdf~=1.3.0
14
- Requires-Dist: jax~=0.4
15
- Requires-Dist: jaxlib~=0.4
16
- Requires-Dist: lime-stable~=2.0.dev6
17
- Requires-Dist: lmfit~=1.3
18
- Requires-Dist: bokeh~=3.7
19
- Requires-Dist: matplotlib~=3.10
20
- Requires-Dist: numpy~=2.2
21
- Requires-Dist: pymc~=5.1
22
- Requires-Dist: scipy~=1.15
14
+ Requires-Dist: jax~=0.9.2
15
+ Requires-Dist: jaxlib~=0.9.2
16
+ Requires-Dist: aspect-stable~=0.7.dev1
17
+ Requires-Dist: lime-stable~=2.2.dev1
18
+ Requires-Dist: innate-stable~=0.2.1
19
+ Requires-Dist: pymc~=5.28
23
20
  Requires-Dist: toml~=0.10
24
- Requires-Dist: tomli>=2.0.0; python_version < "3.11"
25
- Requires-Dist: xarray~=2024.3.0
21
+ Requires-Dist: xarray~=2026.2.0
26
22
  Provides-Extra: tensors
27
- Requires-Dist: pytensor~=2.20; extra == "tensors"
23
+ Requires-Dist: pytensor~=2.38.2; extra == "tensors"
28
24
  Provides-Extra: docs
29
- Requires-Dist: nbsphinx~=0.9; extra == "docs"
30
- Requires-Dist: ipympl~=0.9; extra == "docs"
31
25
  Requires-Dist: sphinx-rtd-theme~=3.0; extra == "docs"
26
+ Requires-Dist: ipympl~=0.9; extra == "docs"
27
+ Requires-Dist: myst-nb~=1.3; extra == "docs"
32
28
  Provides-Extra: tests
33
- Requires-Dist: pytest~=8.3; extra == "tests"
34
- Requires-Dist: pytest-cov~=6.0; extra == "tests"
29
+ Requires-Dist: pytest~=8.4; extra == "tests"
30
+ Requires-Dist: pytest-cov~=7.0; extra == "tests"
35
31
  Requires-Dist: pytest-mpl~=0.17; extra == "tests"
36
32
 
37
33
  ###################
@@ -4,42 +4,39 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "specsy"
7
- version = "0.6.4"
7
+ version = "0.9.dev1"
8
8
  readme = "README.rst"
9
9
  requires-python = ">=3.11"
10
10
  license = "GPL-3.0-or-later"
11
11
  authors = [{name = "Vital Fernández", email = "vgf@umich.edu"}]
12
12
  description = "Model fitting package for the chemical analysis of astronomical spectra"
13
- dependencies = ["arviz~=0.21",
13
+ dependencies = ["arviz~=0.23.4",
14
14
  "corner~=2.2",
15
15
  "h5netcdf~=1.3.0",
16
- "jax~=0.4",
17
- "jaxlib~=0.4",
18
- "lime-stable~=2.0.dev6",
19
- "lmfit~=1.3",
20
- "bokeh~=3.7",
21
- "matplotlib~=3.10",
22
- "numpy~=2.2",
23
- "pymc~=5.1",
24
- "scipy~=1.15",
16
+ "jax~=0.9.2",
17
+ "jaxlib~=0.9.2",
18
+ "aspect-stable~=0.7.dev1",
19
+ "lime-stable~=2.2.dev1",
20
+ "innate-stable~=0.2.1",
21
+ "pymc~=5.28",
25
22
  "toml~=0.10",
26
- "tomli >= 2.0.0 ; python_version < '3.11'",
27
- "xarray~=2024.3.0"]
23
+ "xarray~=2026.2.0"]
28
24
 
29
25
  classifiers = ["Programming Language :: Python :: 3",
30
26
  "Programming Language :: Python :: 3.11"]
31
27
 
32
28
  [project.optional-dependencies]
33
- tensors = ["pytensor~=2.20"]
29
+ tensors = ["pytensor~=2.38.2"]
34
30
 
35
- docs = ["nbsphinx~=0.9",
31
+ docs = ["sphinx-rtd-theme~=3.0",
36
32
  "ipympl~=0.9",
37
- "sphinx-rtd-theme~=3.0"]
33
+ "myst-nb~=1.3"]
38
34
 
39
- tests = ["pytest~=8.3",
40
- "pytest-cov~=6.0",
35
+ tests = ["pytest~=8.4",
36
+ "pytest-cov~=7.0",
41
37
  "pytest-mpl~=0.17"]
42
38
 
39
+
43
40
  [tool.pytest.ini_options]
44
41
  pythonpath = ["src"]
45
42
  mpl-baseline-path = 'tests/baseline'
@@ -1,7 +1,3 @@
1
- """
2
- Specsy - A python package for the analysis of astronomical spectra
3
- """
4
-
5
1
  import logging
6
2
  import tomllib
7
3
 
@@ -18,15 +14,14 @@ _logger.addHandler(consoleHandle)
18
14
 
19
15
  # Read lime configuration .toml
20
16
  _inst_dir = Path(__file__).parent
21
- _conf_path = _inst_dir/'config.toml'
17
+ _conf_path = _inst_dir/'specsy.toml'
22
18
  with open(_conf_path, mode="rb") as fp:
23
19
  _setup_cfg = tomllib.load(fp)
24
20
 
25
21
  __version__ = _setup_cfg['metadata']['version']
26
22
 
27
- from .tools import flux_distribution
28
- from .innate import Innate, load_inference_data, save_inference_data
29
- from .treatement import SpectraSynthesizer, ChemicalModel
30
- from .models import *
31
- from .plotting.plots import plot_traces, plot_flux_grid, plot_corner_matrix, theme
32
- from .io import load_cfg, load_frame
23
+ from lime import load_cfg as load_cfg, load_frame as load_frame, Line as Line, lines_frame as lines_frame, save_frame as save_frame
24
+ from lime import Spectrum as Spectrum, Cube as Cube
25
+ from innate import load_dataset as load_dataset
26
+ from specsy.observations import Nebula
27
+ from specsy.models.extinction import extinction_coeff_calc
@@ -2,10 +2,10 @@ import numpy as np
2
2
  import pymc
3
3
  import pytensor
4
4
  from pytensor import tensor as tt, function
5
- from ..models.fluxes_line import EmissionTensors
6
- from ..models.chemistry import TOIII_from_TSIII_relation, TOII_from_TOIII_relation
5
+ from models.fluxes_line import EmissionTensors
6
+ # from ..models.chemistry import TOIII_from_TSIII_relation, TOII_from_TOIII_relation
7
7
  from pymc.sampling.jax import sample_blackjax_nuts
8
- from ..innate import save_inference_data
8
+ # from ..innate_old import save_inference_data
9
9
  import arviz as az
10
10
  import xarray as xr
11
11
  from warnings import catch_warnings, simplefilter
@@ -0,0 +1,10 @@
1
+ from specsy.models.chemistry import DirectMethod
2
+
3
+
4
+ class ModelManager:
5
+
6
+ def __init__(self, lines_df, ion_struct):
7
+
8
+ self.direct_method = DirectMethod(lines_df=lines_df, ion_struct=ion_struct)
9
+
10
+ return
@@ -2,15 +2,9 @@ import os
2
2
  import numpy as np
3
3
  import configparser
4
4
  from pathlib import Path
5
-
6
- import pandas as pd
7
-
8
- from lime.transitions import label_decomposition
9
- import lime
10
- from lime.io import load_cfg, save_cfg, save_frame, check_file_dataframe, check_fit_conf
11
5
  from collections.abc import Sequence
12
6
  from astropy.io import fits
13
-
7
+ from innate import load_dataset
14
8
 
15
9
  FITS_INPUTS_EXTENSION = {'lines_list': '20A', 'line_fluxes': 'E', 'line_err': 'E'}
16
10
 
@@ -27,28 +21,6 @@ class SpecSyError(Exception):
27
21
  """SpecSy exception function"""
28
22
 
29
23
 
30
- # Load log
31
- def load_frame(file_address, page: str ='LINELOG', sample_levels: list =['id', 'line'], flux_type=None, lines_list=None,
32
- norm_line=None):
33
-
34
- # Return
35
- if isinstance(file_address, pd.DataFrame):
36
- log = file_address.copy()
37
- else:
38
- log = lime.load_frame(file_address, page, sample_levels)
39
-
40
- extra_column = 'line_extract' if norm_line is not None else 'line_flux'
41
-
42
- # Create new column for the lines flux with the requested type (None for user to introduce "line_flux")
43
- if flux_type is not None:
44
- lime.tools.extract_fluxes(log, flux_type=flux_type, column_name=extra_column)
45
-
46
- # Check for requested lines and their normalization
47
- if norm_line is not None:
48
- lime.tools.normalize_fluxes(log, lines_list, norm_line, flux_column=extra_column, column_name='line_flux')
49
-
50
- return log
51
-
52
24
 
53
25
  def load_HII_CHI_MISTRY_grid(log_scale=False, log_zero_value = -1000):
54
26
 
@@ -285,7 +257,7 @@ def fits_db(fits_address, model_db, ext_name='', header=None):
285
257
  return
286
258
 
287
259
 
288
- def save_trace(trace, prior_dict, line_labels, input_fluxes, input_err, inference_model):
260
+ def pack_results(trace, prior_dict, line_labels, input_fluxes, input_err, inference_model):
289
261
 
290
262
  # ---------------------------- Treat traces and store outputs
291
263
  model_params = []
@@ -344,3 +316,30 @@ def save_trace(trace, prior_dict, line_labels, input_fluxes, input_err, inferenc
344
316
  fit_results = {'models': inference_model, 'trace': trace, 'inputs': inputs, 'outputs': output_dict}
345
317
 
346
318
  return fit_results
319
+
320
+
321
+ def load_emissivity_interp(fname, array_mode=False):
322
+
323
+ emis_set = load_dataset(fname)
324
+
325
+ interp_dict = {}
326
+ for trans, emis_matrix in emis_set[0].items():
327
+
328
+ temp_range = np.linspace(*emis_set[1][trans]['temp_range'])
329
+ den_range = np.linspace(*emis_set[1][trans]['den_range'])
330
+ log_emis = np.log10(emis_matrix)
331
+
332
+ interp = make_bilinear_interp(temp_range, den_range, log_emis)
333
+
334
+ if array_mode:
335
+ x_sym = tensor.dscalar("x")
336
+ y_sym = tensor.dscalar("y")
337
+ interp_dict[trans] = pt_function([x_sym, y_sym], interp(x_sym, y_sym))
338
+
339
+ else:
340
+ interp_dict[trans] = interp
341
+
342
+ return interp_dict
343
+
344
+
345
+ return
@@ -0,0 +1,2 @@
1
+ from specsy.models.nebular_continuum import NebularContinua
2
+ from specsy.models.literature import _TEM_FUNC_DICT, _DEN_FUNC_DICT