sparclclient 1.2.9b1__py2.py3-none-any.whl → 1.3.0b2__py2.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.
sparcl/__init__.py CHANGED
@@ -38,4 +38,4 @@ __all__ = ["client", "align_records"]
38
38
  #__version__ = "1.2.6"
39
39
  #__version__ = "1.2.7"
40
40
  #__version__ = "1.2.8"
41
- __version__ = "1.2.9b1"
41
+ __version__ = "1.3.0b2"
sparcl/specutils.py CHANGED
@@ -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 : :class:`bool`, optional
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.zeros((len(records), r0.wavelength.shape[0]),
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.zeros(flux_shape, dtype=r0.flux.dtype)
141
- uncertainty = np.zeros(flux_shape, dtype=r0.ivar.dtype)
142
- mask = np.zeros(flux_shape, dtype=r0.mask.dtype)
143
- model = np.zeros(flux_shape, dtype=r0.model.dtype) if has_model else None
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('1e-17 erg cm-2 s-1 AA-1'),
230
+ 'flux': flux * u.Unit('10**-17 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('1e-17 erg cm-2 s-1 AA-1'),
269
+ s1 = Spectrum(flux=r.flux*u.Unit('10**-17 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,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sparclclient
3
- Version: 1.2.9b1
3
+ Version: 1.3.0b2
4
4
  Summary: A client for getting spectra and meta-data from NOIRLab.
5
5
  Author-email: "S. Pothier" <datalab-spectro@noirlab.edu>
6
6
  Description-Content-Type: text/markdown
@@ -1,5 +1,5 @@
1
1
  sparcl/Results.py,sha256=IlnYZrDddARv3PJ3HPcyHJwTdMroqGdw-eaSrbmAA64,9290
2
- sparcl/__init__.py,sha256=YqaePEJGAUXC3_s-RCRYbHQlTaC_Bd6W9ObvBHvQXJ8,1193
2
+ sparcl/__init__.py,sha256=akq-_0bDWSDTnmS3BZ827HTpiWKYYRO8qtlOpXd4ax8,1193
3
3
  sparcl/client.py,sha256=OAY9F1KbyVc5kos7twqOFnQcGtoqraNG6-CJWqmVE3o,39976
4
4
  sparcl/conf.py,sha256=GFNDelaiVIAkjNjvFlG7HAlPpU39nqZmTPohQGmOcgI,928
5
5
  sparcl/exceptions.py,sha256=sznmOMGENHvxutSXlRVWqi87bR2Qiebka7LyR3mAII0,4244
@@ -7,7 +7,7 @@ sparcl/fields.py,sha256=NZUBqDidpbXfeX5F4b306F323xZY2CRIx8eVv-HWTVU,5127
7
7
  sparcl/gather_2d.py,sha256=YTFVQl38dRZjUu0AEUFVZtQm7zC8mU3LVvUTDGxp6u8,8722
8
8
  sparcl/resample_spectra.py,sha256=nk5HiyaGF-b9SiTmIC9yJBbYX4VYsiLFHyW186bPs2s,1310
9
9
  sparcl/sparc.ini,sha256=q_wjo9DLnCYRxWFMl0CtMYp4DD1AXfEcK6BP6cmncwo,329
10
- sparcl/specutils.py,sha256=IKI4VQ53_ay6kgfAGdvNkpseCH0eURes3RupGJ2-JVA,8738
10
+ sparcl/specutils.py,sha256=QUwlx0bsxEdG50WQ5Fp3uLvDsoDKg5Zl5Te-xnIVRDs,10968
11
11
  sparcl/type_conversion.py,sha256=QmXNX9j_7QHnBu83f2ZBfREoql9wuo98ZbhQtSjRRWc,12965
12
12
  sparcl/unsupported.py,sha256=bfkkZa-PuqwN-Bqo3vCIrLupbWMDTCiTHPMNfXnqmMc,1848
13
13
  sparcl/utils.py,sha256=pDAk9roe7ezfVohnKcLMxFjjXHkp7EQLbgVNe5sSTrk,6259
@@ -16,7 +16,7 @@ sparcl/benchmarks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
16
16
  sparcl/benchmarks/benchmarks.py,sha256=OmlSdnAPLmcvGXsr-HzGyfAAcnoqlO0JQ4EIA7JGhZc,9424
17
17
  sparcl/benchmarks/sparcl_benchmarking.ipynb,sha256=gwof2hqM9Qb49qzRX-mky7WNqXZCMSB7ry8bX8dImxc,17559
18
18
  sparcl/notebooks/sparcl-examples.ipynb,sha256=gEwMKI1x7A1YsVeCsQn1QoMO0ZuIhMUAu3qedTiQ7hM,169268
19
- sparclclient-1.2.9b1.dist-info/LICENSE,sha256=y10EluGMCzGs9X4oYCYyix3l6u-lawB_vlGR8qe442Q,1576
20
- sparclclient-1.2.9b1.dist-info/WHEEL,sha256=ssQ84EZ5gH1pCOujd3iW7HClo_O_aDaClUbX4B8bjKY,100
21
- sparclclient-1.2.9b1.dist-info/METADATA,sha256=0L79znAjI_0CMKc_AUJgjebyNgf1mdrvFHOQ7tpi20o,677
22
- sparclclient-1.2.9b1.dist-info/RECORD,,
19
+ sparclclient-1.3.0b2.dist-info/LICENSE,sha256=y10EluGMCzGs9X4oYCYyix3l6u-lawB_vlGR8qe442Q,1576
20
+ sparclclient-1.3.0b2.dist-info/WHEEL,sha256=ssQ84EZ5gH1pCOujd3iW7HClo_O_aDaClUbX4B8bjKY,100
21
+ sparclclient-1.3.0b2.dist-info/METADATA,sha256=_fYIDfWnBvAOom0dDYuB1G_5zK3WxNXDzEAJYyNpKMg,677
22
+ sparclclient-1.3.0b2.dist-info/RECORD,,