sparclclient 1.2.6b13__py2.py3-none-any.whl → 1.2.7__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
@@ -35,4 +35,5 @@ __all__ = ["client", "align_records"]
35
35
  #__version__ = "1.2.3"
36
36
  #__version__ = "1.2.4"
37
37
  #__version__ = "1.2.5"
38
- __version__ = "1.2.6b13"
38
+ #__version__ = "1.2.6"
39
+ __version__ = "1.2.7"
sparcl/client.py CHANGED
@@ -163,7 +163,7 @@ class SparclClient: # was SparclApi()
163
163
  Defaults to True.
164
164
 
165
165
  Example:
166
- >>> client = SparclClient()
166
+ >>> client = SparclClient(announcement=False)
167
167
 
168
168
  Raises:
169
169
  Exception: Object creation compares the version from the
@@ -172,7 +172,7 @@ class SparclClient: # was SparclApi()
172
172
 
173
173
  """
174
174
 
175
- KNOWN_GOOD_API_VERSION = 12.0 # @@@ Change when Server version incremented
175
+ KNOWN_GOOD_API_VERSION = 13.0 # @@@ Change when Server version incremented
176
176
 
177
177
  def __init__(
178
178
  self,
@@ -189,7 +189,7 @@ class SparclClient: # was SparclApi()
189
189
  self.session = session
190
190
  self.session.auth = None
191
191
  self.rooturl = url.rstrip("/") # eg. "http://localhost:8050"
192
- self.apiurl = f"{self.rooturl}/sparc"
192
+ self.apiurl = f"{self.rooturl}/api"
193
193
  self.apiversion = None
194
194
  self.token = None
195
195
  self.refresh_token = None
@@ -199,7 +199,8 @@ class SparclClient: # was SparclApi()
199
199
  #!self.internal_names = internal_names
200
200
  self.c_timeout = min(MAX_CONNECT_TIMEOUT,
201
201
  float(connect_timeout)) # seconds
202
- self.r_timeout = min(MAX_READ_TIMEOUT, float(read_timeout)) # seconds
202
+ self.r_timeout = min(MAX_READ_TIMEOUT,
203
+ float(read_timeout)) # seconds
203
204
 
204
205
  # require response within this num seconds
205
206
  # https://2.python-requests.org/en/master/user/advanced/#timeouts
@@ -214,7 +215,7 @@ class SparclClient: # was SparclApi()
214
215
  if announcement:
215
216
  ann = f"{self.apiurl}/announcement/"
216
217
  annres = requests.get(ann, timeout=self.timeout)
217
- annstr = annres.json()['announcement']
218
+ annstr = annres.json()["announcement"]
218
219
  if annstr:
219
220
  print(f"announcement={annstr}")
220
221
 
@@ -308,7 +309,7 @@ class SparclClient: # was SparclApi()
308
309
 
309
310
  Example:
310
311
  >>>
311
- >> client = SparclClient()
312
+ >> client = SparclClient(announcement=False)
312
313
  >> client.login('test_user@noirlab.edu', 'testpw')
313
314
  Logged in successfully with email='test_user@noirlab.edu'
314
315
  """
@@ -343,8 +344,8 @@ class SparclClient: # was SparclApi()
343
344
  self.renew_token = None
344
345
  self.token_exp = None
345
346
  msg = (
346
- 'Could not login with given credentials. '
347
- 'Reverted to "Anonymous" user.'
347
+ 'Could not login with given credentials. Reverted '
348
+ 'to "Anonymous" user.'
348
349
  )
349
350
  return msg
350
351
 
@@ -372,7 +373,7 @@ class SparclClient: # was SparclApi()
372
373
  None.
373
374
 
374
375
  Example:
375
- >>> client = SparclClient()
376
+ >>> client = SparclClient(announcement=False)
376
377
  >>> client.logout()
377
378
  Logged-out successfully. Previously logged-in with email None.
378
379
  """
@@ -412,16 +413,16 @@ class SparclClient: # was SparclApi()
412
413
  parameter of client.retrieve().
413
414
 
414
415
  Args:
415
- dataset_list (:obj:`list` of :obj:`str`, optional): List of
416
- data sets from which to get the default fields. Defaults
417
- to None, which will return the intersection of default
418
- fields in all data sets hosted on the SPARCL database.
416
+ dataset_list (:obj:`list`, optional): List of data sets from
417
+ which to get the default fields. Defaults to None, which
418
+ will return the intersection of default fields in all
419
+ data sets hosted on the SPARCL database.
419
420
 
420
421
  Returns:
421
422
  List of fields tagged as 'default' from DATASET_LIST.
422
423
 
423
424
  Example:
424
- >>> client = SparclClient()
425
+ >>> client = SparclClient(announcement=False)
425
426
  >>> client.get_default_fields()
426
427
  ['dec', 'flux', 'ra', 'sparcl_id', 'specid', 'wavelength']
427
428
  """
@@ -443,16 +444,16 @@ class SparclClient: # was SparclApi()
443
444
  of client.retrieve().
444
445
 
445
446
  Args:
446
- dataset_list (:obj:`list` of :obj:`str`, optional): List of data
447
- sets from which to get all fields. Defaults to None, which
448
- will return the intersection of all fields in all data sets
449
- hosted on the SPARCL database.
447
+ dataset_list (:obj:`list`, optional): List of data sets from
448
+ which to get all fields. Defaults to None, which
449
+ will return the intersection of all fields in all
450
+ data sets hosted on the SPARCL database.
450
451
 
451
452
  Returns:
452
453
  List of fields tagged as 'all' from DATASET_LIST.
453
454
 
454
455
  Example:
455
- >>> client = SparclClient()
456
+ >>> client = SparclClient(announcement=False)
456
457
  >>> client.get_all_fields()
457
458
  ['data_release', 'datasetgroup', 'dateobs', 'dateobs_center', 'dec', 'exptime', 'flux', 'instrument', 'ivar', 'mask', 'model', 'ra', 'redshift', 'redshift_err', 'redshift_warning', 'site', 'sparcl_id', 'specid', 'specprimary', 'spectype', 'survey', 'targetid', 'telescope', 'wave_sigma', 'wavelength', 'wavemax', 'wavemin']
458
459
  """ # noqa: E501
@@ -500,16 +501,16 @@ class SparclClient: # was SparclApi()
500
501
  client.retreive().
501
502
 
502
503
  Args:
503
- dataset_list (:obj:`list` of :obj:`str`, optional): List of data
504
- sets from which to get available fields. Defaults to None,
505
- which will return the intersection of all available fields
506
- in all data sets hosted on the SPARCL database.
504
+ dataset_list (:obj:`list`, optional): List of data sets from
505
+ which to get available fields. Defaults to None, which
506
+ will return the intersection of all available fields in
507
+ all data sets hosted on the SPARCL database.
507
508
 
508
509
  Returns:
509
510
  Set of fields available from data sets in DATASET_LIST.
510
511
 
511
512
  Example:
512
- >>> client = SparclClient()
513
+ >>> client = SparclClient(announcement=False)
513
514
  >>> sorted(client.get_available_fields())
514
515
  ['data_release', 'datasetgroup', 'dateobs', 'dateobs_center', 'dec', 'exptime', 'extra_files', 'file', 'flux', 'instrument', 'ivar', 'mask', 'model', 'ra', 'redshift', 'redshift_err', 'redshift_warning', 'site', 'sparcl_id', 'specid', 'specprimary', 'spectype', 'survey', 'targetid', 'telescope', 'updated', 'wave_sigma', 'wavelength', 'wavemax', 'wavemin']
515
516
 
@@ -529,9 +530,9 @@ class SparclClient: # was SparclApi()
529
530
  API version (:obj:`float`).
530
531
 
531
532
  Example:
532
- >>> client = SparclClient()
533
+ >>> client = SparclClient(announcement=False)
533
534
  >>> client.version
534
- 12.0
535
+ 13.0
535
536
  """
536
537
 
537
538
  if self.apiversion is None:
@@ -556,10 +557,10 @@ class SparclClient: # was SparclApi()
556
557
  """Find records in the SPARCL database.
557
558
 
558
559
  Args:
559
- outfields (:obj:`list` of :obj:`str`, optional): List of
560
- fields to return. Only CORE fields may be passed to
561
- this parameter. Defaults to None, which will return
562
- only the sparcl_id and _dr fields.
560
+ outfields (:obj:`list`, optional): List of fields to return.
561
+ Only CORE fields may be passed to this parameter.
562
+ Defaults to None, which will return only the sparcl_id
563
+ and _dr fields.
563
564
 
564
565
  constraints (:obj:`dict`, optional): Key-Value pairs of
565
566
  constraints to place on the record selection. The Key
@@ -582,7 +583,7 @@ class SparclClient: # was SparclApi()
582
583
  :class:`~sparcl.Results.Found`: Contains header and records.
583
584
 
584
585
  Example:
585
- >>> client = SparclClient()
586
+ >>> client = SparclClient(announcement=False)
586
587
  >>> outs = ['sparcl_id', 'ra', 'dec']
587
588
  >>> cons = {'spectype': ['GALAXY'], 'redshift': [0.5, 0.9]}
588
589
  >>> found = client.find(outfields=outs, constraints=cons)
@@ -642,17 +643,22 @@ class SparclClient: # was SparclApi()
642
643
  return found
643
644
 
644
645
  def missing(
645
- self, uuid_list, *, dataset_list=None, countOnly=False, verbose=False
646
+ self,
647
+ uuid_list,
648
+ *,
649
+ dataset_list=None,
650
+ countOnly=False,
651
+ verbose=False
646
652
  ):
647
653
  """Return the subset of sparcl_ids in the given uuid_list that are
648
654
  NOT stored in the SPARCL database.
649
655
 
650
656
  Args:
651
- uuid_list (:obj:`list` of :obj:`str`): List of sparcl_ids.
657
+ uuid_list (:obj:`list`): List of sparcl_ids.
652
658
 
653
- dataset_list (:obj:`list` of :obj:`str`, optional): List of data
654
- sets from which to find missing sparcl_ids. Defaults to None,
655
- meaning all data sets hosted on the SPARCL database.
659
+ dataset_list (:obj:`list`, optional): List of data sets from
660
+ which to find missing sparcl_ids. Defaults to None, meaning
661
+ all data sets hosted on the SPARCL database.
656
662
 
657
663
  countOnly (:obj:`bool`, optional): Set to True to return only
658
664
  a count of the missing sparcl_ids from the uuid_list.
@@ -666,9 +672,9 @@ class SparclClient: # was SparclApi()
666
672
  are NOT stored in the SPARCL database.
667
673
 
668
674
  Example:
669
- >>> client = SparclClient()
670
- >>> sparcl_ids = ['ddbb57ee-8e90-4a0d-823b-0f5d97028076',]
671
- >>> client.missing(uuid_list=sparcl_ids)
675
+ >>> client = SparclClient(announcement=False)
676
+ >>> ids = ['ddbb57ee-8e90-4a0d-823b-0f5d97028076',]
677
+ >>> client.missing(ids)
672
678
  ['ddbb57ee-8e90-4a0d-823b-0f5d97028076']
673
679
  """
674
680
 
@@ -703,11 +709,11 @@ class SparclClient: # was SparclApi()
703
709
  NOT stored in the SPARCL database.
704
710
 
705
711
  Args:
706
- specid_list (:obj:`list` of :obj:`int`): List of specids.
712
+ specid_list (:obj:`list`): List of specids.
707
713
 
708
- dataset_list (:obj:`list` of :obj:`str`, optional): List of data
709
- sets from which to find missing specids. Defaults to None,
710
- meaning all data sets hosted on the SPARCL database.
714
+ dataset_list (:obj:`list`, optional): List of data sets from
715
+ which to find missing specids. Defaults to None, meaning
716
+ all data sets hosted on the SPARCL database.
711
717
 
712
718
  countOnly (:obj:`bool`, optional): Set to True to return only
713
719
  a count of the missing specids from the specid_list.
@@ -721,10 +727,11 @@ class SparclClient: # was SparclApi()
721
727
  are NOT stored in the SPARCL database.
722
728
 
723
729
  Example:
724
- >>> client = SparclClient()
725
- >>> specids = [398913623742323421, 6181239242670493696]
726
- >>> client.missing_specids(specid_list=specids)
727
- [398913623742323421]
730
+ >>> client = SparclClient(announcement=False)
731
+ >>> found = client.find(outfields=['specid'], limit=2)
732
+ >>> specids = [f.specid for f in found.records]
733
+ >>> client.missing_specids(specids + ['6802933904984788992'])
734
+ ['6802933904984788992']
728
735
  """
729
736
  if dataset_list is None:
730
737
  dataset_list = self.fields.all_drs
@@ -790,15 +797,15 @@ class SparclClient: # was SparclApi()
790
797
  sparcl_ids.
791
798
 
792
799
  Args:
793
- uuid_list (:obj:`list` of :obj:`str`): List of sparcl_ids.
800
+ uuid_list (:obj:`list`): List of sparcl_ids.
794
801
 
795
- include (:obj:`list` of :obj:`str`, optional): List of field
796
- names to include in each record. Defaults to 'DEFAULT',
797
- which will return the fields tagged as 'default'.
802
+ include (:obj:`list`, optional): List of field names to include
803
+ in each record. Defaults to 'DEFAULT', which will return
804
+ the fields tagged as 'default'.
798
805
 
799
- dataset_list (:obj:`list` of :obj:`str`, optional): List of data
800
- sets from which to retrieve spectra data. Defaults to None,
801
- meaning all data sets hosted on the SPARCL database.
806
+ dataset_list (:obj:`list`, optional): List of data sets from
807
+ which to retrieve spectra data. Defaults to None, meaning all
808
+ data sets hosted on the SPARCL database.
802
809
 
803
810
  limit (:obj:`int`, optional): Maximum number of records to
804
811
  return. Defaults to 500. Maximum allowed is 24,000.
@@ -810,7 +817,7 @@ class SparclClient: # was SparclApi()
810
817
  :class:`~sparcl.Results.Retrieved`: Contains header and records.
811
818
 
812
819
  Example:
813
- >>> client = SparclClient()
820
+ >>> client = SparclClient(announcement=False)
814
821
  >>> ids = client.find(limit=1).ids
815
822
  >>> inc = ['sparcl_id', 'flux', 'wavelength', 'model']
816
823
  >>> ret = client.retrieve(uuid_list=ids, include=inc)
@@ -993,15 +1000,15 @@ class SparclClient: # was SparclApi()
993
1000
  specids.
994
1001
 
995
1002
  Args:
996
- specid_list (:obj:`list` of :obj:`int`): List of specids.
1003
+ specid_list (:obj:`list`): List of specids.
997
1004
 
998
- include (:obj:`list` of :obj:`str`, optional): List of field
999
- names to include in each record. Defaults to 'DEFAULT',
1000
- which will return the fields tagged as 'default'.
1005
+ include (:obj:`list`, optional): List of field names to include
1006
+ in each record. Defaults to 'DEFAULT', which will return
1007
+ the fields tagged as 'default'.
1001
1008
 
1002
- dataset_list (:obj:`list` of :obj:`str`, optional): List of data
1003
- sets from which to retrieve spectra data. Defaults to None,
1004
- meaning all data sets hosted on the SPARCL database.
1009
+ dataset_list (:obj:`list`, optional): List of data sets from
1010
+ which to retrieve spectra data. Defaults to None, meaning all
1011
+ data sets hosted on the SPARCL database.
1005
1012
 
1006
1013
  limit (:obj:`int`, optional): Maximum number of records to
1007
1014
  return. Defaults to 500. Maximum allowed is 24,000.
@@ -1013,7 +1020,7 @@ class SparclClient: # was SparclApi()
1013
1020
  :class:`~sparcl.Results.Retrieved`: Contains header and records.
1014
1021
 
1015
1022
  Example:
1016
- >>> client = SparclClient()
1023
+ >>> client = SparclClient(announcement=False)
1017
1024
  >>> sids = [5840097619402313728, -8985592895187431424]
1018
1025
  >>> inc = ['specid', 'flux', 'wavelength', 'model']
1019
1026
  >>> ret = client.retrieve_by_specid(specid_list=sids, include=inc)
@@ -1052,9 +1059,9 @@ class SparclClient: # was SparclApi()
1052
1059
  usrcount = len(specid_list)
1053
1060
  dbcount = found.count
1054
1061
  warn = (
1055
- f"UserWarning: Some specIDs were not found. "
1062
+ f"UserWarning: Some SPECIDs were not found. "
1056
1063
  f"{usrcount - dbcount} out of the {usrcount} requested "
1057
- f"specids have no records available in the SPARCL database "
1064
+ f"uuids have no records available in the SPARCL database "
1058
1065
  f"associated with DataSets {dr_list}."
1059
1066
  )
1060
1067
  print(warn)
sparcl/gather_2d.py CHANGED
@@ -39,9 +39,7 @@ def _wavelength_offsets(records):
39
39
  set(records[0].wavelength).union(*[r.wavelength for r in records[1:]])
40
40
  )
41
41
  # offsets[ri] = index into WINDOW
42
- offsets = {
43
- ri: window.index(rec.wavelength[0]) for ri, rec in enumerate(records)
44
- }
42
+ offsets = {ri: window.index(rec.wavelength[0]) for ri, rec in enumerate(records)} # noqa: E501
45
43
  return (window, offsets)
46
44
 
47
45
 
@@ -89,7 +87,7 @@ def _align_wavelengths(records):
89
87
 
90
88
 
91
89
  def _tt1(numrecs=20, dr="BOSS-DR16"):
92
- client = sparcl.client.SparclClient()
90
+ client = sparcl.client.SparclClient(announcement=False)
93
91
  found = client.find(constraints=dict(data_release=[dr]), limit=numrecs)
94
92
  got = client.retrieve(found.ids)
95
93
  records = got.records
@@ -188,7 +186,7 @@ def align_records(records, fields=["flux", "wavelength"], precision=7):
188
186
  - grid(ndarray): 1D numpy array containing wavelength values.
189
187
 
190
188
  Example:
191
- >>> client = sparcl.client.SparclClient()
189
+ >>> client = sparcl.client.SparclClient(announcement=False)
192
190
  >>> specflds = ['wavelength', 'model']
193
191
  >>> cons = {"data_release": ['BOSS-DR16']}
194
192
  >>> found = client.find(constraints=cons, limit=21)
@@ -32,10 +32,9 @@ def _resample_flux(records, wavstep=1):
32
32
 
33
33
 
34
34
  def _tt0(numrecs=20):
35
- client = sparcl.client.SparclClient()
36
- found = client.find(
37
- constraints=dict(data_release=["BOSS-DR16"]), limit=numrecs
38
- )
35
+ client = sparcl.client.SparclClient(announcement=False)
36
+ found = client.find(constraints=dict(data_release=["BOSS-DR16"]),
37
+ limit=numrecs)
39
38
  got = client.retrieve(found.ids)
40
39
  flux_2d, new_wavs = _resample_flux(got.records)
41
40
  return flux_2d, new_wavs
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sparclclient
3
- Version: 1.2.6b13
3
+ Version: 1.2.7
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,11 +1,11 @@
1
1
  sparcl/Results.py,sha256=vnACjm8sp7MrsJ_5LTuKMuyRWqeBJxOxQM302cHmAlk,9159
2
- sparcl/__init__.py,sha256=nzI5cO-Rr3chwX0dScwd-8pzeEigrpiyu-Vh_psbFic,1125
3
- sparcl/client.py,sha256=a3uUD19yi_hHAkRtpk-A2gXQ_w1l1LktDFLCrUUAcV0,39876
2
+ sparcl/__init__.py,sha256=TmDsE7whfCiBI6cRoqHFByLECUQwjJzzQsM_hkaBIOI,1145
3
+ sparcl/client.py,sha256=C9vYeHqZvl0lzVw1BRJeGCv5zk2W2XH1aLsFtBYeYk4,40013
4
4
  sparcl/conf.py,sha256=GFNDelaiVIAkjNjvFlG7HAlPpU39nqZmTPohQGmOcgI,928
5
5
  sparcl/exceptions.py,sha256=sznmOMGENHvxutSXlRVWqi87bR2Qiebka7LyR3mAII0,4244
6
6
  sparcl/fields.py,sha256=NZUBqDidpbXfeX5F4b306F323xZY2CRIx8eVv-HWTVU,5127
7
- sparcl/gather_2d.py,sha256=r_ZXinXlr3bOOwHrNBSWvtKC4-Dohv4nYA3iEiT1_G8,8686
8
- sparcl/resample_spectra.py,sha256=Z_Lkoq4LapaIQp7tqZ88LayRLE8o9c832Icc0jSr5ok,1282
7
+ sparcl/gather_2d.py,sha256=YTFVQl38dRZjUu0AEUFVZtQm7zC8mU3LVvUTDGxp6u8,8722
8
+ sparcl/resample_spectra.py,sha256=nk5HiyaGF-b9SiTmIC9yJBbYX4VYsiLFHyW186bPs2s,1310
9
9
  sparcl/sparc.ini,sha256=q_wjo9DLnCYRxWFMl0CtMYp4DD1AXfEcK6BP6cmncwo,329
10
10
  sparcl/type_conversion.py,sha256=QmXNX9j_7QHnBu83f2ZBfREoql9wuo98ZbhQtSjRRWc,12965
11
11
  sparcl/unsupported.py,sha256=bfkkZa-PuqwN-Bqo3vCIrLupbWMDTCiTHPMNfXnqmMc,1848
@@ -15,7 +15,7 @@ sparcl/benchmarks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
15
15
  sparcl/benchmarks/benchmarks.py,sha256=OmlSdnAPLmcvGXsr-HzGyfAAcnoqlO0JQ4EIA7JGhZc,9424
16
16
  sparcl/benchmarks/sparcl_benchmarking.ipynb,sha256=gwof2hqM9Qb49qzRX-mky7WNqXZCMSB7ry8bX8dImxc,17559
17
17
  sparcl/notebooks/sparcl-examples.ipynb,sha256=gEwMKI1x7A1YsVeCsQn1QoMO0ZuIhMUAu3qedTiQ7hM,169268
18
- sparclclient-1.2.6b13.dist-info/LICENSE,sha256=y10EluGMCzGs9X4oYCYyix3l6u-lawB_vlGR8qe442Q,1576
19
- sparclclient-1.2.6b13.dist-info/WHEEL,sha256=ssQ84EZ5gH1pCOujd3iW7HClo_O_aDaClUbX4B8bjKY,100
20
- sparclclient-1.2.6b13.dist-info/METADATA,sha256=IGZU4IteE-oPqmbyRJMlWC4Gx9QzHKQK4MeeYDlG8hA,681
21
- sparclclient-1.2.6b13.dist-info/RECORD,,
18
+ sparclclient-1.2.7.dist-info/LICENSE,sha256=y10EluGMCzGs9X4oYCYyix3l6u-lawB_vlGR8qe442Q,1576
19
+ sparclclient-1.2.7.dist-info/WHEEL,sha256=ssQ84EZ5gH1pCOujd3iW7HClo_O_aDaClUbX4B8bjKY,100
20
+ sparclclient-1.2.7.dist-info/METADATA,sha256=IZi9L81fw8Bs6TZqTKcmwQlA5BXe4N_e-sOzq2BxONo,678
21
+ sparclclient-1.2.7.dist-info/RECORD,,