sparclclient 1.2.4b2__tar.gz → 1.2.5b1__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.4b2 → sparclclient-1.2.5b1}/PKG-INFO +1 -1
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/sparcl/__init__.py +2 -1
- sparclclient-1.2.5b1/sparcl/benchmarks/Benchmark_SPARCL_example.ipynb +290 -0
- sparclclient-1.2.5b1/sparcl/benchmarks/sparcl_benchmarking.ipynb +789 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/sparcl/client.py +9 -3
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/sparcl/exceptions.py +6 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/.github/workflows/django.yml +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/.gitignore +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/.pre-commit-config.yaml +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/.readthedocs.yaml +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/LICENSE +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/Makefile +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/README.md +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/make.bat +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/pyproject.toml +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/requirements-client.txt +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/requirements-internal.txt +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/requirements.txt +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/source/conf.py +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/source/index.rst +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/source/sparcl.rst +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/sparcl/Results.py +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/sparcl/benchmarks/__init__.py +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/sparcl/benchmarks/benchmarks.py +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/sparcl/conf.py +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/sparcl/fields.py +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/sparcl/gather_2d.py +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/sparcl/notebooks/sparcl-examples.ipynb +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/sparcl/resample_spectra.py +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/sparcl/sparc.ini +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/sparcl/type_conversion.py +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/sparcl/unsupported.py +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/sparcl/utils.py +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/tests/expected_dev1.py +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/tests/expected_pat.py +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/tests/methods_tests.py +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/tests/tests_api.py +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/tests/utils.py +0 -0
- {sparclclient-1.2.4b2 → sparclclient-1.2.5b1}/tox.ini +0 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "markdown",
|
|
5
|
+
"id": "17a35c00-bc12-4a45-b883-762edde6f1ce",
|
|
6
|
+
"metadata": {},
|
|
7
|
+
"source": [
|
|
8
|
+
"# Example Benchmarking for SPARCL"
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"cell_type": "code",
|
|
13
|
+
"execution_count": null,
|
|
14
|
+
"id": "7f33d932-4fbd-47e9-b390-316c00fcddad",
|
|
15
|
+
"metadata": {},
|
|
16
|
+
"outputs": [],
|
|
17
|
+
"source": [
|
|
18
|
+
"# import some helpful python packages \n",
|
|
19
|
+
"import numpy as np\n",
|
|
20
|
+
"import pandas as pd\n",
|
|
21
|
+
"import time\n",
|
|
22
|
+
"from astropy.table import Table\n",
|
|
23
|
+
"\n",
|
|
24
|
+
"import matplotlib.pyplot as plt\n",
|
|
25
|
+
"\n",
|
|
26
|
+
"## DataLab related modules\n",
|
|
27
|
+
"from sparcl.client import SparclClient\n",
|
|
28
|
+
"from dl import queryClient as qc"
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"cell_type": "code",
|
|
33
|
+
"execution_count": null,
|
|
34
|
+
"id": "8e5af373-bf6c-45d2-8a96-5a6b0c2a5a4d",
|
|
35
|
+
"metadata": {},
|
|
36
|
+
"outputs": [],
|
|
37
|
+
"source": [
|
|
38
|
+
"%%time\n",
|
|
39
|
+
"## Define here astrosparcl vs. astrosparcl2\n",
|
|
40
|
+
"client_astrosparcl = SparclClient()\n",
|
|
41
|
+
"client_astrosparcl2 = SparclClient(url='https://astrosparcl2.datalab.noirlab.edu')"
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"cell_type": "code",
|
|
46
|
+
"execution_count": null,
|
|
47
|
+
"id": "f72f1a5a-8b33-4edb-845c-300e277e6316",
|
|
48
|
+
"metadata": {},
|
|
49
|
+
"outputs": [],
|
|
50
|
+
"source": [
|
|
51
|
+
"client_astrosparcl"
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"cell_type": "code",
|
|
56
|
+
"execution_count": null,
|
|
57
|
+
"id": "54d1f19c-1772-4967-b45e-d2a17d549f7b",
|
|
58
|
+
"metadata": {},
|
|
59
|
+
"outputs": [],
|
|
60
|
+
"source": [
|
|
61
|
+
"client_astrosparcl2"
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"cell_type": "code",
|
|
66
|
+
"execution_count": null,
|
|
67
|
+
"id": "85a8075d-2b30-48e1-81bb-d75eceeb096f",
|
|
68
|
+
"metadata": {},
|
|
69
|
+
"outputs": [],
|
|
70
|
+
"source": [
|
|
71
|
+
"def run_desi_query(NN, randomid=[0,1]):\n",
|
|
72
|
+
"\n",
|
|
73
|
+
" # Query for DESI; keep only objects with a unique spectrum to avoid duplicates\n",
|
|
74
|
+
" query = f'''SELECT targetid FROM desi_dr1.zpix \n",
|
|
75
|
+
" WHERE zcat_nspec=1 AND random_id BETWEEN {randomid[0]} AND {randomid[1]} LIMIT {NN}'''\n",
|
|
76
|
+
"\n",
|
|
77
|
+
" t = qc.query(sql=query, fmt='table')\n",
|
|
78
|
+
"\n",
|
|
79
|
+
" return(t)"
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"cell_type": "code",
|
|
84
|
+
"execution_count": null,
|
|
85
|
+
"id": "85cc1d16-07a5-4d41-849e-572e277e4915",
|
|
86
|
+
"metadata": {},
|
|
87
|
+
"outputs": [],
|
|
88
|
+
"source": [
|
|
89
|
+
"def run_sdss_query(NN, randomid=[0,1]):\n",
|
|
90
|
+
"\n",
|
|
91
|
+
" # Query for SDSS; already unique per specobjid\n",
|
|
92
|
+
" query = f'''SELECT specobjid FROM sdss_dr16.specobj \n",
|
|
93
|
+
" WHERE random_id BETWEEN {randomid[0]} AND {randomid[1]} LIMIT {NN}'''\n",
|
|
94
|
+
"\n",
|
|
95
|
+
" t = qc.query(sql=query, fmt='table')\n",
|
|
96
|
+
"\n",
|
|
97
|
+
" return(t)"
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"cell_type": "code",
|
|
102
|
+
"execution_count": null,
|
|
103
|
+
"id": "06d97329-3fd7-41b2-a623-2373a4c876d0",
|
|
104
|
+
"metadata": {},
|
|
105
|
+
"outputs": [],
|
|
106
|
+
"source": [
|
|
107
|
+
"# Define the fields to include in the retrieve function (common to SDSS and DESI)\n",
|
|
108
|
+
"inc = ['specid', 'redshift', 'specprimary', 'wavelength', 'flux', 'ivar']"
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"cell_type": "code",
|
|
113
|
+
"execution_count": null,
|
|
114
|
+
"id": "f2620054-aa25-41e4-adc1-da37b78b5cc6",
|
|
115
|
+
"metadata": {},
|
|
116
|
+
"outputs": [],
|
|
117
|
+
"source": [
|
|
118
|
+
"def get_spec_timing(specids, dataset=['DESI-DR1']):\n",
|
|
119
|
+
"## Version for astrosparcl\n",
|
|
120
|
+
"## dataset = 'DESI-DR1' by default, can set 'SDSS-DR16' or others by request\n",
|
|
121
|
+
" \n",
|
|
122
|
+
" start_time = time.time()\n",
|
|
123
|
+
"\n",
|
|
124
|
+
" ## Retrieve spectra\n",
|
|
125
|
+
" results = client_astrosparcl.retrieve_by_specid(specid_list=specids, include=inc, dataset_list=dataset, limit=24000)\n",
|
|
126
|
+
" \n",
|
|
127
|
+
" ## Time rounded to 0.1 sec\n",
|
|
128
|
+
" duration = np.round((time.time() - start_time), 1)\n",
|
|
129
|
+
" print(f'Querying N={len(specids)}; retrieved N={results.count} in {duration} sec')\n",
|
|
130
|
+
"\n",
|
|
131
|
+
" ## save space\n",
|
|
132
|
+
" results = 0\n",
|
|
133
|
+
"\n",
|
|
134
|
+
" return(duration)"
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"cell_type": "code",
|
|
139
|
+
"execution_count": null,
|
|
140
|
+
"id": "8f7382a9-cb26-4a64-a848-ef85d7dc1756",
|
|
141
|
+
"metadata": {},
|
|
142
|
+
"outputs": [],
|
|
143
|
+
"source": [
|
|
144
|
+
"def get_spec_timing_2(specids, dataset=['DESI-DR1']):\n",
|
|
145
|
+
"## Version for astrosparcl2\n",
|
|
146
|
+
"## dataset = 'DESI-DR1' by default, can set 'SDSS-DR16' or others by request\n",
|
|
147
|
+
"\n",
|
|
148
|
+
" start_time = time.time()\n",
|
|
149
|
+
"\n",
|
|
150
|
+
" ## Retrieve spectra\n",
|
|
151
|
+
" results = client_astrosparcl2.retrieve_by_specid(specid_list=specids, include=inc, dataset_list=dataset, limit=24000)\n",
|
|
152
|
+
"\n",
|
|
153
|
+
" ## Time rounded to 0.1 sec\n",
|
|
154
|
+
" duration = np.round((time.time() - start_time), 1)\n",
|
|
155
|
+
" print(f'Querying N={len(specids)}; retrieved N={results.count} in {duration} sec')\n",
|
|
156
|
+
"\n",
|
|
157
|
+
" ## save space\n",
|
|
158
|
+
" results = 0\n",
|
|
159
|
+
"\n",
|
|
160
|
+
" return(duration)"
|
|
161
|
+
]
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"cell_type": "code",
|
|
165
|
+
"execution_count": null,
|
|
166
|
+
"id": "65482bb6-d4f1-42ca-89a3-07e11f93fd2e",
|
|
167
|
+
"metadata": {},
|
|
168
|
+
"outputs": [],
|
|
169
|
+
"source": [
|
|
170
|
+
"# Define the Nb to retrieve\n",
|
|
171
|
+
"## Focus on small numbers up to 200\n",
|
|
172
|
+
"Ns = [1, 2, 4, 20, 40, 200] ##, 2000, 20000] # can extend to 24,000\n",
|
|
173
|
+
"\n",
|
|
174
|
+
"out = Table()\n",
|
|
175
|
+
"out['N'] = Ns\n",
|
|
176
|
+
"# astrosparcl\n",
|
|
177
|
+
"out['T_retrieve_DESI'] = 0.0\n",
|
|
178
|
+
"out['T_retrieve_SDSS'] = 0.0\n",
|
|
179
|
+
"# astrosparcl2\n",
|
|
180
|
+
"out['T2_retrieve_DESI'] = 0.0\n",
|
|
181
|
+
"out['T2_retrieve_SDSS'] = 0.0\n",
|
|
182
|
+
"\n",
|
|
183
|
+
"for i, N in enumerate(Ns):\n",
|
|
184
|
+
"\n",
|
|
185
|
+
" # Query for SDSS specobjid's\n",
|
|
186
|
+
" ## NOTE: need to change code for randomid for SDSS as fct(N bins) and sample size)\n",
|
|
187
|
+
" t_sdss = run_sdss_query(N) #, randomid=[0+i*0.1, 0.3+i*0.1])\n",
|
|
188
|
+
" ids = t_sdss['specobjid']\n",
|
|
189
|
+
" ids = ids.astype(int).tolist() \n",
|
|
190
|
+
"\n",
|
|
191
|
+
" # Call retrieve and check timing for SDSS\n",
|
|
192
|
+
" out['T_retrieve_SDSS'][i] = get_spec_timing(ids, dataset=['SDSS-DR16','BOSS-DR16'])\n",
|
|
193
|
+
" out['T2_retrieve_SDSS'][i] = get_spec_timing_2(ids, dataset=['SDSS-DR16','BOSS-DR16'])"
|
|
194
|
+
]
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"cell_type": "code",
|
|
198
|
+
"execution_count": null,
|
|
199
|
+
"id": "862e8456-d61b-43d1-bf8a-03507c76861b",
|
|
200
|
+
"metadata": {},
|
|
201
|
+
"outputs": [],
|
|
202
|
+
"source": [
|
|
203
|
+
"out"
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"cell_type": "code",
|
|
208
|
+
"execution_count": null,
|
|
209
|
+
"id": "0bb31825-4a4d-48dd-8e0a-074a41b8c58d",
|
|
210
|
+
"metadata": {},
|
|
211
|
+
"outputs": [],
|
|
212
|
+
"source": [
|
|
213
|
+
"for i, N in enumerate(Ns):\n",
|
|
214
|
+
" \n",
|
|
215
|
+
" # Query for DESI targetid's\n",
|
|
216
|
+
" t_desi = run_desi_query(N, randomid=[0+i*0.1, 0.1+i*0.1])\n",
|
|
217
|
+
" ids = t_desi['targetid']\n",
|
|
218
|
+
" ids = ids.astype(int).tolist()\n",
|
|
219
|
+
"\n",
|
|
220
|
+
" # Call retrieve and check timing\n",
|
|
221
|
+
" out['T_retrieve_DESI'][i] = get_spec_timing(ids)\n",
|
|
222
|
+
" out['T2_retrieve_DESI'][i] = get_spec_timing_2(ids)"
|
|
223
|
+
]
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"cell_type": "code",
|
|
227
|
+
"execution_count": null,
|
|
228
|
+
"id": "ab087231-5e31-4fa5-afa9-1d0361b9962a",
|
|
229
|
+
"metadata": {},
|
|
230
|
+
"outputs": [],
|
|
231
|
+
"source": [
|
|
232
|
+
"out"
|
|
233
|
+
]
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
"cell_type": "code",
|
|
237
|
+
"execution_count": null,
|
|
238
|
+
"id": "990223ec-eaee-418f-bc7a-61120e33751f",
|
|
239
|
+
"metadata": {},
|
|
240
|
+
"outputs": [],
|
|
241
|
+
"source": [
|
|
242
|
+
"#out_save = out.copy()\n",
|
|
243
|
+
"#out_save"
|
|
244
|
+
]
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"cell_type": "code",
|
|
248
|
+
"execution_count": null,
|
|
249
|
+
"id": "43354fc9-6fa9-4186-89d7-792c240f3698",
|
|
250
|
+
"metadata": {},
|
|
251
|
+
"outputs": [],
|
|
252
|
+
"source": [
|
|
253
|
+
"#outfile = \"results_250616_astrosparcl.fits\"\n",
|
|
254
|
+
"#out_save['N','T_retrieve_DESI','T_retrieve_SDSS'].write(outfile, overwrite=False)"
|
|
255
|
+
]
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"cell_type": "code",
|
|
259
|
+
"execution_count": null,
|
|
260
|
+
"id": "a516ce42-82dc-4910-92c4-d2cb34fea012",
|
|
261
|
+
"metadata": {},
|
|
262
|
+
"outputs": [],
|
|
263
|
+
"source": [
|
|
264
|
+
"#outfile = \"results_250613_astrosparcl2.fits\"\n",
|
|
265
|
+
"#out_save['N','T2_retrieve_DESI','T2_retrieve_SDSS'].write(outfile, overwrite=False)"
|
|
266
|
+
]
|
|
267
|
+
}
|
|
268
|
+
],
|
|
269
|
+
"metadata": {
|
|
270
|
+
"kernelspec": {
|
|
271
|
+
"display_name": "Python 3 (ipykernel)",
|
|
272
|
+
"language": "python",
|
|
273
|
+
"name": "python3"
|
|
274
|
+
},
|
|
275
|
+
"language_info": {
|
|
276
|
+
"codemirror_mode": {
|
|
277
|
+
"name": "ipython",
|
|
278
|
+
"version": 3
|
|
279
|
+
},
|
|
280
|
+
"file_extension": ".py",
|
|
281
|
+
"mimetype": "text/x-python",
|
|
282
|
+
"name": "python",
|
|
283
|
+
"nbconvert_exporter": "python",
|
|
284
|
+
"pygments_lexer": "ipython3",
|
|
285
|
+
"version": "3.10.13"
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
"nbformat": 4,
|
|
289
|
+
"nbformat_minor": 5
|
|
290
|
+
}
|
|
@@ -0,0 +1,789 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "code",
|
|
5
|
+
"execution_count": 1,
|
|
6
|
+
"id": "049ba371-1951-40c3-b874-362814854321",
|
|
7
|
+
"metadata": {},
|
|
8
|
+
"outputs": [],
|
|
9
|
+
"source": [
|
|
10
|
+
"# SPARCL imports\n",
|
|
11
|
+
"from sparcl.client import SparclClient\n",
|
|
12
|
+
"\n",
|
|
13
|
+
"# 3rd party imports\n",
|
|
14
|
+
"import numpy as np\n",
|
|
15
|
+
"import astropy.units as u\n",
|
|
16
|
+
"from specutils import Spectrum1D\n",
|
|
17
|
+
"from astropy.nddata import InverseVariance\n",
|
|
18
|
+
"from astropy.convolution import convolve, Gaussian1DKernel\n",
|
|
19
|
+
"%matplotlib inline\n",
|
|
20
|
+
"import matplotlib.pyplot as plt\n",
|
|
21
|
+
"import pandas as pd\n",
|
|
22
|
+
"\n",
|
|
23
|
+
"# Data Lab imports\n",
|
|
24
|
+
"from dl import queryClient as qc\n",
|
|
25
|
+
"from dl import authClient as ac\n",
|
|
26
|
+
"from getpass import getpass\n",
|
|
27
|
+
"\n",
|
|
28
|
+
"# plots default setup\n",
|
|
29
|
+
"plt.rcParams['font.size'] = 14\n",
|
|
30
|
+
"plt.rcParams['figure.figsize'] = (14,8)\n",
|
|
31
|
+
"\n",
|
|
32
|
+
"import time"
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"cell_type": "code",
|
|
37
|
+
"execution_count": 2,
|
|
38
|
+
"id": "4ba4b161-493b-4b49-ac3b-ea9ee523c3e6",
|
|
39
|
+
"metadata": {},
|
|
40
|
+
"outputs": [
|
|
41
|
+
{
|
|
42
|
+
"name": "stdout",
|
|
43
|
+
"output_type": "stream",
|
|
44
|
+
"text": [
|
|
45
|
+
"(sparclclient:1.2.4, api:12.0, https://astrosparcl.datalab.noirlab.edu/sparc, client_hash=, verbose=False, connect_timeout=1.1, read_timeout=5400.0)\n",
|
|
46
|
+
"(sparclclient:1.2.4, api:12.0, https://astrosparcl2.datalab.noirlab.edu/sparc, client_hash=, verbose=False, connect_timeout=1.1, read_timeout=5400.0)\n"
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"source": [
|
|
51
|
+
"client_astrosparcl = SparclClient()\n",
|
|
52
|
+
"print(client_astrosparcl)\n",
|
|
53
|
+
"client_astrosparcl2 = SparclClient(url='https://astrosparcl2.datalab.noirlab.edu')\n",
|
|
54
|
+
"print(client_astrosparcl2)"
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"cell_type": "markdown",
|
|
59
|
+
"id": "71ba4082-94ad-4965-a152-b942edf0da9f",
|
|
60
|
+
"metadata": {},
|
|
61
|
+
"source": [
|
|
62
|
+
"# client.find"
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"cell_type": "code",
|
|
67
|
+
"execution_count": 3,
|
|
68
|
+
"id": "1d0d31a0-7415-4d92-b9d2-e6d49bba9d55",
|
|
69
|
+
"metadata": {},
|
|
70
|
+
"outputs": [],
|
|
71
|
+
"source": [
|
|
72
|
+
"out = ['sparcl_id', 'ra', 'dec', 'redshift', 'spectype', 'data_release']\n",
|
|
73
|
+
"cons1 = {'spectype': ['GALAXY'], 'redshift': [0.3, 6.2]}\n",
|
|
74
|
+
"cons2 = {'spectype': ['QSO'], 'redshift': [0.5, 7.1]}\n",
|
|
75
|
+
"\n",
|
|
76
|
+
"cons1_1 = {'ra': [93.2,140.3]}\n",
|
|
77
|
+
"cons2_2 = {'ra': [141.2,191.9]}\n",
|
|
78
|
+
"\n",
|
|
79
|
+
"cons11 = {'data_release': ['BOSS-DR16','DESI-DR1']}\n",
|
|
80
|
+
"cons22 = {'data_release': ['SDSS-DR16','DESI-DR1']}"
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"cell_type": "markdown",
|
|
85
|
+
"id": "125471ce-a32b-44e3-b63e-975c12951829",
|
|
86
|
+
"metadata": {},
|
|
87
|
+
"source": [
|
|
88
|
+
"### client.find: limit=100,000"
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"cell_type": "code",
|
|
93
|
+
"execution_count": 4,
|
|
94
|
+
"id": "469f73bc-77fd-40a3-bcfa-7f11c7d8e965",
|
|
95
|
+
"metadata": {},
|
|
96
|
+
"outputs": [
|
|
97
|
+
{
|
|
98
|
+
"name": "stdout",
|
|
99
|
+
"output_type": "stream",
|
|
100
|
+
"text": [
|
|
101
|
+
"CPU times: user 981 ms, sys: 129 ms, total: 1.11 s\n",
|
|
102
|
+
"Wall time: 32.7 s\n"
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"data": {
|
|
107
|
+
"text/plain": [
|
|
108
|
+
"Find Results: 100000 records"
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
"execution_count": 4,
|
|
112
|
+
"metadata": {},
|
|
113
|
+
"output_type": "execute_result"
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"source": [
|
|
117
|
+
"%%time\n",
|
|
118
|
+
"found_1 = client_astrosparcl.find(outfields=out, constraints=cons1, limit=100000)\n",
|
|
119
|
+
"found_1"
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"cell_type": "code",
|
|
124
|
+
"execution_count": 5,
|
|
125
|
+
"id": "0ddd1ac0-6ef9-46d5-a445-29a9642de73a",
|
|
126
|
+
"metadata": {},
|
|
127
|
+
"outputs": [
|
|
128
|
+
{
|
|
129
|
+
"name": "stdout",
|
|
130
|
+
"output_type": "stream",
|
|
131
|
+
"text": [
|
|
132
|
+
"CPU times: user 914 ms, sys: 73.7 ms, total: 988 ms\n",
|
|
133
|
+
"Wall time: 5.47 s\n"
|
|
134
|
+
]
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"data": {
|
|
138
|
+
"text/plain": [
|
|
139
|
+
"Find Results: 100000 records"
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
"execution_count": 5,
|
|
143
|
+
"metadata": {},
|
|
144
|
+
"output_type": "execute_result"
|
|
145
|
+
}
|
|
146
|
+
],
|
|
147
|
+
"source": [
|
|
148
|
+
"%%time\n",
|
|
149
|
+
"found_2 = client_astrosparcl2.find(outfields=out, constraints=cons2, limit=100000)\n",
|
|
150
|
+
"found_2"
|
|
151
|
+
]
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"cell_type": "markdown",
|
|
155
|
+
"id": "675d12b7-bae2-4f7f-a792-a9aa58e240a4",
|
|
156
|
+
"metadata": {},
|
|
157
|
+
"source": [
|
|
158
|
+
"### client.find: limit=1,000,000"
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"cell_type": "code",
|
|
163
|
+
"execution_count": 6,
|
|
164
|
+
"id": "6453c7b9-db57-459d-8ffa-dddc09acd1c6",
|
|
165
|
+
"metadata": {},
|
|
166
|
+
"outputs": [
|
|
167
|
+
{
|
|
168
|
+
"name": "stdout",
|
|
169
|
+
"output_type": "stream",
|
|
170
|
+
"text": [
|
|
171
|
+
"CPU times: user 8.44 s, sys: 967 ms, total: 9.4 s\n",
|
|
172
|
+
"Wall time: 51.5 s\n"
|
|
173
|
+
]
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"data": {
|
|
177
|
+
"text/plain": [
|
|
178
|
+
"Find Results: 1000000 records"
|
|
179
|
+
]
|
|
180
|
+
},
|
|
181
|
+
"execution_count": 6,
|
|
182
|
+
"metadata": {},
|
|
183
|
+
"output_type": "execute_result"
|
|
184
|
+
}
|
|
185
|
+
],
|
|
186
|
+
"source": [
|
|
187
|
+
"%%time\n",
|
|
188
|
+
"found_2 = client_astrosparcl2.find(outfields=out, constraints=cons2, limit=1000000)\n",
|
|
189
|
+
"found_2"
|
|
190
|
+
]
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"cell_type": "code",
|
|
194
|
+
"execution_count": 7,
|
|
195
|
+
"id": "b38acaba-b481-4de1-a304-33371c7b5522",
|
|
196
|
+
"metadata": {},
|
|
197
|
+
"outputs": [
|
|
198
|
+
{
|
|
199
|
+
"name": "stdout",
|
|
200
|
+
"output_type": "stream",
|
|
201
|
+
"text": [
|
|
202
|
+
"CPU times: user 9.03 s, sys: 820 ms, total: 9.85 s\n",
|
|
203
|
+
"Wall time: 58.8 s\n"
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"data": {
|
|
208
|
+
"text/plain": [
|
|
209
|
+
"Find Results: 1000000 records"
|
|
210
|
+
]
|
|
211
|
+
},
|
|
212
|
+
"execution_count": 7,
|
|
213
|
+
"metadata": {},
|
|
214
|
+
"output_type": "execute_result"
|
|
215
|
+
}
|
|
216
|
+
],
|
|
217
|
+
"source": [
|
|
218
|
+
"%%time\n",
|
|
219
|
+
"found_1 = client_astrosparcl.find(outfields=out, constraints=cons1, limit=1000000)\n",
|
|
220
|
+
"found_1"
|
|
221
|
+
]
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"cell_type": "markdown",
|
|
225
|
+
"id": "96455ba7-b56c-4717-8c60-49c3f06059fd",
|
|
226
|
+
"metadata": {},
|
|
227
|
+
"source": [
|
|
228
|
+
"### client.find: limit=10,000,000"
|
|
229
|
+
]
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"cell_type": "code",
|
|
233
|
+
"execution_count": 4,
|
|
234
|
+
"id": "63f9da26-eedf-4db7-aee0-7597e9b87503",
|
|
235
|
+
"metadata": {},
|
|
236
|
+
"outputs": [
|
|
237
|
+
{
|
|
238
|
+
"name": "stdout",
|
|
239
|
+
"output_type": "stream",
|
|
240
|
+
"text": [
|
|
241
|
+
"CPU times: user 1min 36s, sys: 9.11 s, total: 1min 45s\n",
|
|
242
|
+
"Wall time: 6min 41s\n"
|
|
243
|
+
]
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"data": {
|
|
247
|
+
"text/plain": [
|
|
248
|
+
"Find Results: 10000000 records"
|
|
249
|
+
]
|
|
250
|
+
},
|
|
251
|
+
"execution_count": 4,
|
|
252
|
+
"metadata": {},
|
|
253
|
+
"output_type": "execute_result"
|
|
254
|
+
}
|
|
255
|
+
],
|
|
256
|
+
"source": [
|
|
257
|
+
"%%time\n",
|
|
258
|
+
"found_2 = client_astrosparcl2.find(outfields=out, constraints=cons11, limit=10000000)\n",
|
|
259
|
+
"found_2"
|
|
260
|
+
]
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
"cell_type": "code",
|
|
264
|
+
"execution_count": 4,
|
|
265
|
+
"id": "d0b77073-7b6f-4c2e-9be4-9ac07961f107",
|
|
266
|
+
"metadata": {},
|
|
267
|
+
"outputs": [
|
|
268
|
+
{
|
|
269
|
+
"name": "stdout",
|
|
270
|
+
"output_type": "stream",
|
|
271
|
+
"text": [
|
|
272
|
+
"CPU times: user 1min 35s, sys: 13.2 s, total: 1min 48s\n",
|
|
273
|
+
"Wall time: 22min 52s\n"
|
|
274
|
+
]
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
"data": {
|
|
278
|
+
"text/plain": [
|
|
279
|
+
"Find Results: 10000000 records"
|
|
280
|
+
]
|
|
281
|
+
},
|
|
282
|
+
"execution_count": 4,
|
|
283
|
+
"metadata": {},
|
|
284
|
+
"output_type": "execute_result"
|
|
285
|
+
}
|
|
286
|
+
],
|
|
287
|
+
"source": [
|
|
288
|
+
"%%time\n",
|
|
289
|
+
"found_1 = client_astrosparcl.find(outfields=out, constraints=cons22, limit=10000000)\n",
|
|
290
|
+
"found_1"
|
|
291
|
+
]
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"cell_type": "markdown",
|
|
295
|
+
"id": "3d9c9134-6be1-4414-96d3-e05ee3e71912",
|
|
296
|
+
"metadata": {},
|
|
297
|
+
"source": [
|
|
298
|
+
"### client.find: limit=None"
|
|
299
|
+
]
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"cell_type": "code",
|
|
303
|
+
"execution_count": 10,
|
|
304
|
+
"id": "cc4f3a46-08f8-4846-8143-ee6af634cf8f",
|
|
305
|
+
"metadata": {},
|
|
306
|
+
"outputs": [
|
|
307
|
+
{
|
|
308
|
+
"name": "stdout",
|
|
309
|
+
"output_type": "stream",
|
|
310
|
+
"text": [
|
|
311
|
+
"CPU times: user 5min, sys: 2min 47s, total: 7min 48s\n",
|
|
312
|
+
"Wall time: 29min 1s\n"
|
|
313
|
+
]
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
"data": {
|
|
317
|
+
"text/plain": [
|
|
318
|
+
"Find Results: 30892024 records"
|
|
319
|
+
]
|
|
320
|
+
},
|
|
321
|
+
"execution_count": 10,
|
|
322
|
+
"metadata": {},
|
|
323
|
+
"output_type": "execute_result"
|
|
324
|
+
}
|
|
325
|
+
],
|
|
326
|
+
"source": [
|
|
327
|
+
"%%time\n",
|
|
328
|
+
"found_2 = client_astrosparcl2.find(outfields=out, limit=None)\n",
|
|
329
|
+
"found_2"
|
|
330
|
+
]
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
"cell_type": "code",
|
|
334
|
+
"execution_count": 8,
|
|
335
|
+
"id": "24da8b92-3881-48c6-9936-aed48a68cdb3",
|
|
336
|
+
"metadata": {},
|
|
337
|
+
"outputs": [
|
|
338
|
+
{
|
|
339
|
+
"name": "stdout",
|
|
340
|
+
"output_type": "stream",
|
|
341
|
+
"text": [
|
|
342
|
+
"CPU times: user 5min 30s, sys: 3min 32s, total: 9min 3s\n",
|
|
343
|
+
"Wall time: 56min 29s\n"
|
|
344
|
+
]
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
"data": {
|
|
348
|
+
"text/plain": [
|
|
349
|
+
"Find Results: 30892024 records"
|
|
350
|
+
]
|
|
351
|
+
},
|
|
352
|
+
"execution_count": 8,
|
|
353
|
+
"metadata": {},
|
|
354
|
+
"output_type": "execute_result"
|
|
355
|
+
}
|
|
356
|
+
],
|
|
357
|
+
"source": [
|
|
358
|
+
"%%time\n",
|
|
359
|
+
"found_1 = client_astrosparcl.find(outfields=out, limit=None)\n",
|
|
360
|
+
"found_1"
|
|
361
|
+
]
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
"cell_type": "code",
|
|
365
|
+
"execution_count": null,
|
|
366
|
+
"id": "65fc6f11-4bb1-4920-8410-0ffc0102a472",
|
|
367
|
+
"metadata": {},
|
|
368
|
+
"outputs": [],
|
|
369
|
+
"source": []
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
"cell_type": "markdown",
|
|
373
|
+
"id": "3a51eafa-4a54-4dd2-9b34-46fff075f2d1",
|
|
374
|
+
"metadata": {},
|
|
375
|
+
"source": [
|
|
376
|
+
"# client.retrieve"
|
|
377
|
+
]
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
"cell_type": "code",
|
|
381
|
+
"execution_count": 5,
|
|
382
|
+
"id": "efa34af0-4b22-4316-a8d8-9a4b4f7776fe",
|
|
383
|
+
"metadata": {},
|
|
384
|
+
"outputs": [],
|
|
385
|
+
"source": [
|
|
386
|
+
"# Define the fields to include in the retrieve function\n",
|
|
387
|
+
"inc = ['sparcl_id', 'specid', 'data_release', 'redshift', 'flux',\n",
|
|
388
|
+
" 'wavelength', 'spectype', 'ra', 'dec']"
|
|
389
|
+
]
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
"cell_type": "markdown",
|
|
393
|
+
"id": "933c543f-88bf-479c-b467-f1945f4d5ea3",
|
|
394
|
+
"metadata": {},
|
|
395
|
+
"source": [
|
|
396
|
+
"### client.retrieve: limit=1,000"
|
|
397
|
+
]
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
"cell_type": "code",
|
|
401
|
+
"execution_count": 17,
|
|
402
|
+
"id": "bb013ba1-9012-452a-93e2-5290b6cc365e",
|
|
403
|
+
"metadata": {},
|
|
404
|
+
"outputs": [
|
|
405
|
+
{
|
|
406
|
+
"name": "stdout",
|
|
407
|
+
"output_type": "stream",
|
|
408
|
+
"text": [
|
|
409
|
+
"CPU times: user 1.8 s, sys: 1.93 s, total: 3.74 s\n",
|
|
410
|
+
"Wall time: 50.6 s\n"
|
|
411
|
+
]
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
"data": {
|
|
415
|
+
"text/plain": [
|
|
416
|
+
"Retrieved Results: 1000 records"
|
|
417
|
+
]
|
|
418
|
+
},
|
|
419
|
+
"execution_count": 17,
|
|
420
|
+
"metadata": {},
|
|
421
|
+
"output_type": "execute_result"
|
|
422
|
+
}
|
|
423
|
+
],
|
|
424
|
+
"source": [
|
|
425
|
+
"%%time\n",
|
|
426
|
+
"ids_2 = found_2.ids\n",
|
|
427
|
+
"results_2 = client_astrosparcl2.retrieve(uuid_list=ids_2, include=inc, limit=1000)\n",
|
|
428
|
+
"results_2"
|
|
429
|
+
]
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
"cell_type": "code",
|
|
433
|
+
"execution_count": 18,
|
|
434
|
+
"id": "d2230e68-9532-4819-b621-79d386bcf63c",
|
|
435
|
+
"metadata": {},
|
|
436
|
+
"outputs": [
|
|
437
|
+
{
|
|
438
|
+
"name": "stdout",
|
|
439
|
+
"output_type": "stream",
|
|
440
|
+
"text": [
|
|
441
|
+
"CPU times: user 3.48 s, sys: 4.02 s, total: 7.5 s\n",
|
|
442
|
+
"Wall time: 1min 3s\n"
|
|
443
|
+
]
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
"data": {
|
|
447
|
+
"text/plain": [
|
|
448
|
+
"Retrieved Results: 1000 records"
|
|
449
|
+
]
|
|
450
|
+
},
|
|
451
|
+
"execution_count": 18,
|
|
452
|
+
"metadata": {},
|
|
453
|
+
"output_type": "execute_result"
|
|
454
|
+
}
|
|
455
|
+
],
|
|
456
|
+
"source": [
|
|
457
|
+
"%%time\n",
|
|
458
|
+
"ids_1 = found_1.ids\n",
|
|
459
|
+
"results_1 = client_astrosparcl.retrieve(uuid_list=ids_1, include=inc, limit=1000)\n",
|
|
460
|
+
"results_1"
|
|
461
|
+
]
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
"cell_type": "markdown",
|
|
465
|
+
"id": "91d08444-a450-4103-af86-f75fbadc41da",
|
|
466
|
+
"metadata": {},
|
|
467
|
+
"source": [
|
|
468
|
+
"### client.retrieve: limit=5,000"
|
|
469
|
+
]
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
"cell_type": "code",
|
|
473
|
+
"execution_count": 19,
|
|
474
|
+
"id": "55efbd37-7010-4e61-b2e0-d79c2c9082d0",
|
|
475
|
+
"metadata": {},
|
|
476
|
+
"outputs": [
|
|
477
|
+
{
|
|
478
|
+
"name": "stdout",
|
|
479
|
+
"output_type": "stream",
|
|
480
|
+
"text": [
|
|
481
|
+
"CPU times: user 9.88 s, sys: 10.8 s, total: 20.7 s\n",
|
|
482
|
+
"Wall time: 10min 23s\n"
|
|
483
|
+
]
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
"data": {
|
|
487
|
+
"text/plain": [
|
|
488
|
+
"Retrieved Results: 5000 records"
|
|
489
|
+
]
|
|
490
|
+
},
|
|
491
|
+
"execution_count": 19,
|
|
492
|
+
"metadata": {},
|
|
493
|
+
"output_type": "execute_result"
|
|
494
|
+
}
|
|
495
|
+
],
|
|
496
|
+
"source": [
|
|
497
|
+
"%%time\n",
|
|
498
|
+
"ids_1 = found_1.ids\n",
|
|
499
|
+
"results_1 = client_astrosparcl.retrieve(uuid_list=ids_1, include=inc, limit=5000)\n",
|
|
500
|
+
"results_1"
|
|
501
|
+
]
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
"cell_type": "code",
|
|
505
|
+
"execution_count": 20,
|
|
506
|
+
"id": "cf624549-2c37-41d0-bd56-17852bd39d6d",
|
|
507
|
+
"metadata": {},
|
|
508
|
+
"outputs": [
|
|
509
|
+
{
|
|
510
|
+
"name": "stdout",
|
|
511
|
+
"output_type": "stream",
|
|
512
|
+
"text": [
|
|
513
|
+
"CPU times: user 7.77 s, sys: 7.41 s, total: 15.2 s\n",
|
|
514
|
+
"Wall time: 3min 53s\n"
|
|
515
|
+
]
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
"data": {
|
|
519
|
+
"text/plain": [
|
|
520
|
+
"Retrieved Results: 5000 records"
|
|
521
|
+
]
|
|
522
|
+
},
|
|
523
|
+
"execution_count": 20,
|
|
524
|
+
"metadata": {},
|
|
525
|
+
"output_type": "execute_result"
|
|
526
|
+
}
|
|
527
|
+
],
|
|
528
|
+
"source": [
|
|
529
|
+
"%%time\n",
|
|
530
|
+
"ids_2 = found_2.ids\n",
|
|
531
|
+
"results_2 = client_astrosparcl2.retrieve(uuid_list=ids_2, include=inc, limit=5000)\n",
|
|
532
|
+
"results_2"
|
|
533
|
+
]
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
"cell_type": "markdown",
|
|
537
|
+
"id": "4bedd466-a23f-458c-adaf-441dece2e794",
|
|
538
|
+
"metadata": {},
|
|
539
|
+
"source": [
|
|
540
|
+
"### client.retrieve: limit=10,000"
|
|
541
|
+
]
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
"cell_type": "code",
|
|
545
|
+
"execution_count": 21,
|
|
546
|
+
"id": "5de660f1-16c1-4a2e-af05-a9a23b3d45b3",
|
|
547
|
+
"metadata": {},
|
|
548
|
+
"outputs": [
|
|
549
|
+
{
|
|
550
|
+
"name": "stdout",
|
|
551
|
+
"output_type": "stream",
|
|
552
|
+
"text": [
|
|
553
|
+
"CPU times: user 16.5 s, sys: 15.6 s, total: 32.1 s\n",
|
|
554
|
+
"Wall time: 8min\n"
|
|
555
|
+
]
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
"data": {
|
|
559
|
+
"text/plain": [
|
|
560
|
+
"Retrieved Results: 10000 records"
|
|
561
|
+
]
|
|
562
|
+
},
|
|
563
|
+
"execution_count": 21,
|
|
564
|
+
"metadata": {},
|
|
565
|
+
"output_type": "execute_result"
|
|
566
|
+
}
|
|
567
|
+
],
|
|
568
|
+
"source": [
|
|
569
|
+
"%%time\n",
|
|
570
|
+
"ids_2 = found_2.ids\n",
|
|
571
|
+
"results_2 = client_astrosparcl2.retrieve(uuid_list=ids_2, include=inc, limit=10000)\n",
|
|
572
|
+
"results_2"
|
|
573
|
+
]
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
"cell_type": "code",
|
|
577
|
+
"execution_count": 22,
|
|
578
|
+
"id": "be7339da-feec-4d18-8bcb-7d629910a120",
|
|
579
|
+
"metadata": {},
|
|
580
|
+
"outputs": [
|
|
581
|
+
{
|
|
582
|
+
"name": "stdout",
|
|
583
|
+
"output_type": "stream",
|
|
584
|
+
"text": [
|
|
585
|
+
"CPU times: user 19.7 s, sys: 19.1 s, total: 38.7 s\n",
|
|
586
|
+
"Wall time: 21min 19s\n"
|
|
587
|
+
]
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
"data": {
|
|
591
|
+
"text/plain": [
|
|
592
|
+
"Retrieved Results: 10000 records"
|
|
593
|
+
]
|
|
594
|
+
},
|
|
595
|
+
"execution_count": 22,
|
|
596
|
+
"metadata": {},
|
|
597
|
+
"output_type": "execute_result"
|
|
598
|
+
}
|
|
599
|
+
],
|
|
600
|
+
"source": [
|
|
601
|
+
"%%time\n",
|
|
602
|
+
"ids_1 = found_1.ids\n",
|
|
603
|
+
"results_1 = client_astrosparcl.retrieve(uuid_list=ids_1, include=inc, limit=10000)\n",
|
|
604
|
+
"results_1"
|
|
605
|
+
]
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
"cell_type": "markdown",
|
|
609
|
+
"id": "83446a5c-a01a-42a3-a8e2-9fe1a25371ce",
|
|
610
|
+
"metadata": {},
|
|
611
|
+
"source": [
|
|
612
|
+
"### client.retrieve: limit=20,000"
|
|
613
|
+
]
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
"cell_type": "code",
|
|
617
|
+
"execution_count": 6,
|
|
618
|
+
"id": "4919d147-4dfe-4da6-984b-2b530b976f09",
|
|
619
|
+
"metadata": {},
|
|
620
|
+
"outputs": [
|
|
621
|
+
{
|
|
622
|
+
"name": "stdout",
|
|
623
|
+
"output_type": "stream",
|
|
624
|
+
"text": [
|
|
625
|
+
"CPU times: user 38 s, sys: 35.1 s, total: 1min 13s\n",
|
|
626
|
+
"Wall time: 20min 57s\n"
|
|
627
|
+
]
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
"data": {
|
|
631
|
+
"text/plain": [
|
|
632
|
+
"Retrieved Results: 20000 records"
|
|
633
|
+
]
|
|
634
|
+
},
|
|
635
|
+
"execution_count": 6,
|
|
636
|
+
"metadata": {},
|
|
637
|
+
"output_type": "execute_result"
|
|
638
|
+
}
|
|
639
|
+
],
|
|
640
|
+
"source": [
|
|
641
|
+
"%%time\n",
|
|
642
|
+
"ids_1 = found_1.ids\n",
|
|
643
|
+
"results_1 = client_astrosparcl.retrieve(uuid_list=ids_1, include=inc, limit=20000)\n",
|
|
644
|
+
"results_1"
|
|
645
|
+
]
|
|
646
|
+
},
|
|
647
|
+
{
|
|
648
|
+
"cell_type": "code",
|
|
649
|
+
"execution_count": 24,
|
|
650
|
+
"id": "b1d2f32d-0a00-4c08-8950-560196cd3ea2",
|
|
651
|
+
"metadata": {},
|
|
652
|
+
"outputs": [
|
|
653
|
+
{
|
|
654
|
+
"name": "stdout",
|
|
655
|
+
"output_type": "stream",
|
|
656
|
+
"text": [
|
|
657
|
+
"CPU times: user 31.5 s, sys: 28 s, total: 59.4 s\n",
|
|
658
|
+
"Wall time: 19min 59s\n"
|
|
659
|
+
]
|
|
660
|
+
},
|
|
661
|
+
{
|
|
662
|
+
"data": {
|
|
663
|
+
"text/plain": [
|
|
664
|
+
"Retrieved Results: 20000 records"
|
|
665
|
+
]
|
|
666
|
+
},
|
|
667
|
+
"execution_count": 24,
|
|
668
|
+
"metadata": {},
|
|
669
|
+
"output_type": "execute_result"
|
|
670
|
+
}
|
|
671
|
+
],
|
|
672
|
+
"source": [
|
|
673
|
+
"%%time\n",
|
|
674
|
+
"ids_2 = found_2.ids\n",
|
|
675
|
+
"results_2 = client_astrosparcl2.retrieve(uuid_list=ids_2, include=inc, limit=20000)\n",
|
|
676
|
+
"results_2"
|
|
677
|
+
]
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
"cell_type": "markdown",
|
|
681
|
+
"id": "fc0f4354-67ff-45d1-9356-a28856ab1702",
|
|
682
|
+
"metadata": {},
|
|
683
|
+
"source": [
|
|
684
|
+
"### client.retrieve: limit=24,000 (max allowed)"
|
|
685
|
+
]
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
"cell_type": "code",
|
|
689
|
+
"execution_count": 35,
|
|
690
|
+
"id": "c38f2df1-27bc-457b-b671-06fcc2853909",
|
|
691
|
+
"metadata": {},
|
|
692
|
+
"outputs": [
|
|
693
|
+
{
|
|
694
|
+
"name": "stdout",
|
|
695
|
+
"output_type": "stream",
|
|
696
|
+
"text": [
|
|
697
|
+
"CPU times: user 46.6 s, sys: 46 s, total: 1min 32s\n",
|
|
698
|
+
"Wall time: 15min 37s\n"
|
|
699
|
+
]
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
"data": {
|
|
703
|
+
"text/plain": [
|
|
704
|
+
"Retrieved Results: 24000 records"
|
|
705
|
+
]
|
|
706
|
+
},
|
|
707
|
+
"execution_count": 35,
|
|
708
|
+
"metadata": {},
|
|
709
|
+
"output_type": "execute_result"
|
|
710
|
+
}
|
|
711
|
+
],
|
|
712
|
+
"source": [
|
|
713
|
+
"%%time\n",
|
|
714
|
+
"ids_2 = found_2.ids\n",
|
|
715
|
+
"results_2 = client_astrosparcl2.retrieve(uuid_list=ids_2, include=inc, limit=24000)\n",
|
|
716
|
+
"results_2"
|
|
717
|
+
]
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
"cell_type": "code",
|
|
721
|
+
"execution_count": 37,
|
|
722
|
+
"id": "8118ecd9-97e2-49f5-aed9-b21dae5a2fc3",
|
|
723
|
+
"metadata": {},
|
|
724
|
+
"outputs": [
|
|
725
|
+
{
|
|
726
|
+
"name": "stdout",
|
|
727
|
+
"output_type": "stream",
|
|
728
|
+
"text": [
|
|
729
|
+
"CPU times: user 48 s, sys: 46.5 s, total: 1min 34s\n",
|
|
730
|
+
"Wall time: 55min 34s\n"
|
|
731
|
+
]
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
"data": {
|
|
735
|
+
"text/plain": [
|
|
736
|
+
"Retrieved Results: 24000 records"
|
|
737
|
+
]
|
|
738
|
+
},
|
|
739
|
+
"execution_count": 37,
|
|
740
|
+
"metadata": {},
|
|
741
|
+
"output_type": "execute_result"
|
|
742
|
+
}
|
|
743
|
+
],
|
|
744
|
+
"source": [
|
|
745
|
+
"%%time\n",
|
|
746
|
+
"ids_1 = found_1.ids\n",
|
|
747
|
+
"results_1 = client_astrosparcl.retrieve(uuid_list=ids_1, include=inc, limit=24000)\n",
|
|
748
|
+
"results_1"
|
|
749
|
+
]
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
"cell_type": "code",
|
|
753
|
+
"execution_count": null,
|
|
754
|
+
"id": "9f04b5df-fbd8-49b5-9b29-e1b522dfa96d",
|
|
755
|
+
"metadata": {},
|
|
756
|
+
"outputs": [],
|
|
757
|
+
"source": []
|
|
758
|
+
},
|
|
759
|
+
{
|
|
760
|
+
"cell_type": "code",
|
|
761
|
+
"execution_count": null,
|
|
762
|
+
"id": "8d990bf9-5102-4fcc-b16d-6091bf8e0be1",
|
|
763
|
+
"metadata": {},
|
|
764
|
+
"outputs": [],
|
|
765
|
+
"source": []
|
|
766
|
+
}
|
|
767
|
+
],
|
|
768
|
+
"metadata": {
|
|
769
|
+
"kernelspec": {
|
|
770
|
+
"display_name": "Python 3 (ipykernel)",
|
|
771
|
+
"language": "python",
|
|
772
|
+
"name": "python3"
|
|
773
|
+
},
|
|
774
|
+
"language_info": {
|
|
775
|
+
"codemirror_mode": {
|
|
776
|
+
"name": "ipython",
|
|
777
|
+
"version": 3
|
|
778
|
+
},
|
|
779
|
+
"file_extension": ".py",
|
|
780
|
+
"mimetype": "text/x-python",
|
|
781
|
+
"name": "python",
|
|
782
|
+
"nbconvert_exporter": "python",
|
|
783
|
+
"pygments_lexer": "ipython3",
|
|
784
|
+
"version": "3.11.12"
|
|
785
|
+
}
|
|
786
|
+
},
|
|
787
|
+
"nbformat": 4,
|
|
788
|
+
"nbformat_minor": 5
|
|
789
|
+
}
|
|
@@ -337,7 +337,7 @@ class SparclClient: # was SparclApi()
|
|
|
337
337
|
return msg
|
|
338
338
|
|
|
339
339
|
self.set_token_exp()
|
|
340
|
-
print(f"Logged in successfully with {email
|
|
340
|
+
print(f"Logged in successfully with email={email}")
|
|
341
341
|
return None
|
|
342
342
|
|
|
343
343
|
def set_token_exp(self):
|
|
@@ -680,6 +680,8 @@ class SparclClient: # was SparclApi()
|
|
|
680
680
|
if res.status_code != 200:
|
|
681
681
|
raise Exception(res)
|
|
682
682
|
ret = res.json()
|
|
683
|
+
if countOnly:
|
|
684
|
+
return len(ret)
|
|
683
685
|
return ret
|
|
684
686
|
# END missing()
|
|
685
687
|
|
|
@@ -733,6 +735,8 @@ class SparclClient: # was SparclApi()
|
|
|
733
735
|
if res.status_code != 200:
|
|
734
736
|
raise Exception(res)
|
|
735
737
|
ret = res.json()
|
|
738
|
+
if countOnly:
|
|
739
|
+
return len(ret)
|
|
736
740
|
return ret
|
|
737
741
|
# END missing_specids()
|
|
738
742
|
|
|
@@ -944,7 +948,9 @@ class SparclClient: # was SparclApi()
|
|
|
944
948
|
"spectra/sec)"
|
|
945
949
|
)
|
|
946
950
|
print(f'{meta["status"]}')
|
|
947
|
-
|
|
951
|
+
|
|
952
|
+
# Format/consolodate the server messages to one message with the count of missing
|
|
953
|
+
# files
|
|
948
954
|
if len(meta["status"].get("warnings", [])) > 0:
|
|
949
955
|
warnings = meta["status"].get("warnings")
|
|
950
956
|
if verbose:
|
|
@@ -957,7 +963,7 @@ class SparclClient: # was SparclApi()
|
|
|
957
963
|
missingcount += int(matches.groups()[0])
|
|
958
964
|
|
|
959
965
|
# using old style substitution to avoid issue with the {} in the message # noqa: E501
|
|
960
|
-
warning_message = missing_message % (missingcount,
|
|
966
|
+
warning_message = missing_message % (missingcount, req_num, missingcount) # noqa: E501
|
|
961
967
|
warn(warning_message, stacklevel=2)
|
|
962
968
|
|
|
963
969
|
return Retrieved(results, client=self)
|
|
@@ -13,8 +13,11 @@ def genSparclException(response, verbose=False):
|
|
|
13
13
|
# As of Python 3.10.0.alpha6, python "match" statement could be used
|
|
14
14
|
# instead of if-elif-else.
|
|
15
15
|
# https://docs.python.org/3.10/whatsnew/3.10.html#pep-634-structural-pattern-matching
|
|
16
|
+
|
|
16
17
|
if status.get("errorCode") == "BADPATH":
|
|
17
18
|
return BadPath(status.get("errorMessage"))
|
|
19
|
+
elif response.status_code == 429: # too many requests, throttled
|
|
20
|
+
return TooManyRequests(status.get("detail"))
|
|
18
21
|
elif status.get("errorCode") == "BADQUERY":
|
|
19
22
|
return BadQuery(status.get("errorMessage"))
|
|
20
23
|
elif status.get("errorCode") == "UNKFIELD":
|
|
@@ -64,6 +67,9 @@ class BadPath(BaseSparclException):
|
|
|
64
67
|
|
|
65
68
|
error_code = "BADPATH"
|
|
66
69
|
|
|
70
|
+
class TooManyRequests(BaseSparclException):
|
|
71
|
+
|
|
72
|
+
error_code = "TOOMANYREQUESTS"
|
|
67
73
|
|
|
68
74
|
class BadQuery(BaseSparclException):
|
|
69
75
|
"""Bad find constraints."""
|
|
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
|
|
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
|