sparclclient 1.2.9b1__tar.gz → 1.3.0b1__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.
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/PKG-INFO +1 -1
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/sparcl/__init__.py +1 -1
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/sparcl/specutils.py +76 -10
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/.github/workflows/django.yml +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/.gitignore +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/.gitlab-ci.yml +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/.pre-commit-config.yaml +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/.readthedocs.yaml +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/LICENSE +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/Makefile +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/README.md +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/make.bat +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/pyproject.toml +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/requirements-client.txt +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/requirements-internal.txt +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/requirements.txt +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/source/conf.py +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/source/index.rst +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/source/sparcl.rst +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/sparcl/Results.py +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/sparcl/benchmarks/Benchmark_SPARCL_example.ipynb +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/sparcl/benchmarks/__init__.py +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/sparcl/benchmarks/benchmarks.py +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/sparcl/benchmarks/sparcl_benchmarking.ipynb +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/sparcl/client.py +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/sparcl/conf.py +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/sparcl/exceptions.py +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/sparcl/fields.py +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/sparcl/gather_2d.py +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/sparcl/notebooks/sparcl-examples.ipynb +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/sparcl/resample_spectra.py +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/sparcl/sparc.ini +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/sparcl/type_conversion.py +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/sparcl/unsupported.py +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/sparcl/utils.py +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/tests/expected_dev1.py +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/tests/expected_pat.py +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/tests/methods_tests.py +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/tests/tests_api.py +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/tests/utils.py +0 -0
- {sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/tox.ini +0 -0
|
@@ -12,7 +12,32 @@ from astropy.nddata import InverseVariance
|
|
|
12
12
|
import astropy.units as u
|
|
13
13
|
|
|
14
14
|
def _validate_records(records, r0, collection):
|
|
15
|
-
"""Validate that records can be converted to Spectrum.
|
|
15
|
+
"""Validate that records can be converted to Spectrum.
|
|
16
|
+
|
|
17
|
+
Parameters
|
|
18
|
+
----------
|
|
19
|
+
records : list of dict
|
|
20
|
+
All records to validate.
|
|
21
|
+
r0 : dict
|
|
22
|
+
First record, used as reference for validation.
|
|
23
|
+
collection: bool
|
|
24
|
+
If ``True``, attempt to convert to a
|
|
25
|
+
:class:`~specutils.SpectrumCollection` instead.
|
|
26
|
+
|
|
27
|
+
Raises
|
|
28
|
+
------
|
|
29
|
+
ValueError
|
|
30
|
+
If records lack 'wavelength' attribute.
|
|
31
|
+
If records have different data releases.
|
|
32
|
+
If wavelength array lengths differ (suggests using SpectrumList).
|
|
33
|
+
If wavelength pixel values differ and collection=False
|
|
34
|
+
(suggests using SpectrumCollection).
|
|
35
|
+
|
|
36
|
+
Warnings
|
|
37
|
+
--------
|
|
38
|
+
UserWarning
|
|
39
|
+
If records come from different data releases.
|
|
40
|
+
"""
|
|
16
41
|
|
|
17
42
|
# Check if the first record has wavelength data
|
|
18
43
|
if 'wavelength' not in r0:
|
|
@@ -39,7 +64,45 @@ def _validate_records(records, r0, collection):
|
|
|
39
64
|
def _extract_record_data(records, flux, uncertainty, mask, model, redshift,
|
|
40
65
|
meta, spectral_axis, has_model, has_redshift,
|
|
41
66
|
collection, single_record):
|
|
42
|
-
"""Extract all data from records into arrays.
|
|
67
|
+
"""Extract all data from records into arrays. This function modifies
|
|
68
|
+
arrays in-place rather than returning values.
|
|
69
|
+
|
|
70
|
+
Parameters
|
|
71
|
+
----------
|
|
72
|
+
records: list of dict
|
|
73
|
+
Records containing flux, ivar, mask, wavelength, and optional
|
|
74
|
+
model/redshift.
|
|
75
|
+
flux : np.ndarray
|
|
76
|
+
Pre-allocated array for flux values. Shape: (n_pixels,) if
|
|
77
|
+
single_record, else (n_records, n_pixels).
|
|
78
|
+
uncertainty : np.ndarray
|
|
79
|
+
Pre-allocated array for inverse variance.
|
|
80
|
+
mask : np.ndarray
|
|
81
|
+
Pre-allocated array for data quality masks.
|
|
82
|
+
model : np.ndarray or None
|
|
83
|
+
Pre-allocated array for model values if has_model=True.
|
|
84
|
+
redshift : list
|
|
85
|
+
Empty list to populate with redshift values.
|
|
86
|
+
meta : dict
|
|
87
|
+
Empty dict to populate with metadata.
|
|
88
|
+
spectral_axis : np.ndarray
|
|
89
|
+
For collections, pre-allocated 2D array to store wavelength grids.
|
|
90
|
+
For non-collections, this is just r0.wavelength (not modified).
|
|
91
|
+
has_model : bool
|
|
92
|
+
Whether records contain 'model' attribute.
|
|
93
|
+
has_redshift : bool
|
|
94
|
+
Whether records contain 'redshift' attribute.
|
|
95
|
+
collection : bool
|
|
96
|
+
If True, stores wavelength arrays for each record in spectral_axis.
|
|
97
|
+
single_record : bool
|
|
98
|
+
If True, treats arrays as 1D. If False, treats as 2D with row per
|
|
99
|
+
record.
|
|
100
|
+
|
|
101
|
+
Returns
|
|
102
|
+
-------
|
|
103
|
+
None
|
|
104
|
+
All outputs are written to the input arrays/containers in-place.
|
|
105
|
+
"""
|
|
43
106
|
for k, record in enumerate(records):
|
|
44
107
|
if single_record:
|
|
45
108
|
# For single record, assign directly (1D)
|
|
@@ -83,7 +146,7 @@ def to_Spectrum(results, *, collection=False):
|
|
|
83
146
|
----------
|
|
84
147
|
results : :class:`sparcl.Results.Retrieved`
|
|
85
148
|
Retrieved results, or a single record from a set of results.
|
|
86
|
-
collection :
|
|
149
|
+
collection : bool, optional
|
|
87
150
|
If ``True``, attempt to convert to a
|
|
88
151
|
:class:`~specutils.SpectrumCollection` instead.
|
|
89
152
|
|
|
@@ -131,16 +194,16 @@ def to_Spectrum(results, *, collection=False):
|
|
|
131
194
|
|
|
132
195
|
# Build spectral axis
|
|
133
196
|
if collection:
|
|
134
|
-
spectral_axis = np.
|
|
197
|
+
spectral_axis = np.empty((len(records), r0.wavelength.shape[0]),
|
|
135
198
|
dtype=r0.wavelength.dtype)
|
|
136
199
|
else:
|
|
137
200
|
spectral_axis = r0.wavelength
|
|
138
201
|
|
|
139
202
|
# Initialize arrays
|
|
140
|
-
flux = np.
|
|
141
|
-
uncertainty = np.
|
|
142
|
-
mask = np.
|
|
143
|
-
model = np.
|
|
203
|
+
flux = np.empty(flux_shape, dtype=r0.flux.dtype)
|
|
204
|
+
uncertainty = np.empty(flux_shape, dtype=r0.ivar.dtype)
|
|
205
|
+
mask = np.empty(flux_shape, dtype=r0.mask.dtype)
|
|
206
|
+
model = np.empty(flux_shape, dtype=r0.model.dtype) if has_model else None
|
|
144
207
|
redshift = []
|
|
145
208
|
meta = {}
|
|
146
209
|
|
|
@@ -152,6 +215,9 @@ def to_Spectrum(results, *, collection=False):
|
|
|
152
215
|
# Convert redshift list to numpy array if exists
|
|
153
216
|
if has_redshift:
|
|
154
217
|
redshift = np.array(redshift)
|
|
218
|
+
if single_record and len(redshift) == 1:
|
|
219
|
+
# Convert to scalar if single record
|
|
220
|
+
redshift = redshift[0]
|
|
155
221
|
else:
|
|
156
222
|
redshift = None
|
|
157
223
|
|
|
@@ -161,7 +227,7 @@ def to_Spectrum(results, *, collection=False):
|
|
|
161
227
|
|
|
162
228
|
# Prepare arguments common to both Spectrum and SpectrumCollection
|
|
163
229
|
common_args = {
|
|
164
|
-
'flux': flux * u.Unit('
|
|
230
|
+
'flux': flux * 10**-17 * u.Unit('erg cm-2 s-1 AA-1'),
|
|
165
231
|
'spectral_axis': spectral_axis * u.AA,
|
|
166
232
|
'uncertainty': InverseVariance(uncertainty),
|
|
167
233
|
'mask': mask,
|
|
@@ -200,7 +266,7 @@ def to_SpectrumList(results):
|
|
|
200
266
|
if attribute not in ('flux', 'wavelength', 'ivar',
|
|
201
267
|
'redshift', 'mask'):
|
|
202
268
|
meta[attribute] = r[attribute]
|
|
203
|
-
s1 = Spectrum(flux=r.flux*u.Unit('
|
|
269
|
+
s1 = Spectrum(flux=r.flux*10**-17*u.Unit('erg cm-2 s-1 AA-1'),
|
|
204
270
|
spectral_axis=r.wavelength*u.AA,
|
|
205
271
|
uncertainty=InverseVariance(r.ivar),
|
|
206
272
|
redshift=redshift,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sparclclient-1.2.9b1 → sparclclient-1.3.0b1}/sparcl/benchmarks/Benchmark_SPARCL_example.ipynb
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|