sdss-almanac 0.2.12__py3-none-any.whl → 0.3.1__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.
- almanac/__init__.py +1 -1
- almanac/cli.py +48 -21
- {sdss_almanac-0.2.12.dist-info → sdss_almanac-0.3.1.dist-info}/METADATA +1 -1
- {sdss_almanac-0.2.12.dist-info → sdss_almanac-0.3.1.dist-info}/RECORD +8 -8
- {sdss_almanac-0.2.12.dist-info → sdss_almanac-0.3.1.dist-info}/WHEEL +0 -0
- {sdss_almanac-0.2.12.dist-info → sdss_almanac-0.3.1.dist-info}/entry_points.txt +0 -0
- {sdss_almanac-0.2.12.dist-info → sdss_almanac-0.3.1.dist-info}/licenses/LICENSE.md +0 -0
- {sdss_almanac-0.2.12.dist-info → sdss_almanac-0.3.1.dist-info}/top_level.txt +0 -0
almanac/__init__.py
CHANGED
almanac/cli.py
CHANGED
@@ -217,7 +217,7 @@ def lookup(identifier, careful, **kwargs):
|
|
217
217
|
from almanac.apogee import get_exposures
|
218
218
|
from sdssdb.peewee.sdss5db.targetdb import (
|
219
219
|
Assignment, AssignmentStatus,CartonToTarget, Target, Hole, Observatory,
|
220
|
-
Design, DesignToField
|
220
|
+
Design, DesignToField, Field
|
221
221
|
)
|
222
222
|
from sdssdb.peewee.sdss5db.catalogdb import SDSS_ID_flat
|
223
223
|
|
@@ -225,62 +225,87 @@ def lookup(identifier, careful, **kwargs):
|
|
225
225
|
from rich.console import Console
|
226
226
|
from rich.live import Live
|
227
227
|
|
228
|
-
|
228
|
+
sq = (
|
229
229
|
SDSS_ID_flat
|
230
|
-
.select(
|
231
|
-
SDSS_ID_flat.catalogid,
|
232
|
-
SDSS_ID_flat.sdss_id,
|
233
|
-
)
|
230
|
+
.select(SDSS_ID_flat.sdss_id)
|
234
231
|
.where(
|
235
232
|
(SDSS_ID_flat.sdss_id == identifier)
|
236
233
|
| (SDSS_ID_flat.catalogid == identifier)
|
237
234
|
)
|
235
|
+
.alias("sq")
|
236
|
+
)
|
237
|
+
q = (
|
238
|
+
SDSS_ID_flat
|
239
|
+
.select(SDSS_ID_flat.catalogid, SDSS_ID_flat.sdss_id)
|
240
|
+
.distinct()
|
241
|
+
.join(sq, on=(SDSS_ID_flat.sdss_id == sq.c.sdss_id))
|
238
242
|
.tuples()
|
239
243
|
)
|
240
244
|
|
241
|
-
|
242
|
-
|
245
|
+
sdss_ids, catalogids = (set(), [])
|
246
|
+
for catalogid, sdss_id in q:
|
247
|
+
sdss_ids.add(sdss_id)
|
248
|
+
catalogids.append(catalogid)
|
249
|
+
|
250
|
+
if not catalogids:
|
243
251
|
raise click.ClickException(f"Identifier {identifier} not found in SDSS-V database")
|
244
252
|
|
253
|
+
if len(sdss_ids) != 1:
|
254
|
+
raise click.ClickException(f"Identifier {identifier} is ambiguous and matches multiple SDSS IDs: {', '.join(map(str, sdss_ids))}")
|
255
|
+
|
245
256
|
q = (
|
246
257
|
Target
|
247
258
|
.select(
|
248
259
|
fn.Lower(Observatory.label),
|
249
260
|
AssignmentStatus.mjd,
|
261
|
+
Field.field_id,
|
250
262
|
)
|
263
|
+
.distinct()
|
251
264
|
.join(CartonToTarget)
|
252
265
|
.join(Assignment)
|
253
266
|
.join(AssignmentStatus)
|
254
267
|
.switch(Assignment)
|
255
268
|
.join(Hole)
|
256
269
|
.join(Observatory)
|
270
|
+
.switch(Assignment)
|
271
|
+
.join(Design)
|
272
|
+
.join(DesignToField)
|
273
|
+
.join(Field)
|
257
274
|
.where(
|
258
|
-
Target.catalogid.in_(tuple(
|
275
|
+
Target.catalogid.in_(tuple(catalogids))
|
259
276
|
& (AssignmentStatus.status == 1)
|
260
277
|
)
|
261
278
|
.tuples()
|
262
279
|
)
|
263
|
-
|
280
|
+
fields = {}
|
281
|
+
for obs, mjd, field_id in q:
|
282
|
+
mjd = int(mjd)
|
283
|
+
fields.setdefault((obs, mjd), set())
|
284
|
+
fields[(obs, mjd)].add(field_id)
|
264
285
|
|
265
286
|
console = Console()
|
266
287
|
|
267
|
-
title =
|
288
|
+
title = f"SDSS ID {sdss_id}"
|
268
289
|
|
269
|
-
|
270
|
-
|
290
|
+
rich_table = RichTable(
|
291
|
+
title=f"{title}",
|
292
|
+
title_style="bold blue",
|
293
|
+
show_header=True,
|
294
|
+
header_style="bold cyan"
|
295
|
+
)
|
271
296
|
|
272
|
-
for field_name in ("obs", "mjd", "exposure", "field", "fiber_id", "catalogid"):
|
297
|
+
for field_name in ("#", "obs", "mjd", "exposure", "field", "fiber_id", "catalogid"):
|
273
298
|
rich_table.add_column(field_name, justify="center")
|
274
299
|
|
275
|
-
|
276
|
-
with Live(rich_table, console=console, refresh_per_second=4
|
277
|
-
for exposure in chain(*starmap(get_exposures,
|
278
|
-
|
279
|
-
if
|
300
|
+
i = 1
|
301
|
+
with Live(rich_table, console=console, refresh_per_second=4) as live:
|
302
|
+
for exposure in chain(*starmap(get_exposures, fields.keys())):
|
303
|
+
field_ids = fields[(exposure.observatory, exposure.mjd)]
|
304
|
+
if exposure.field_id in field_ids:
|
280
305
|
for target in exposure.targets:
|
281
|
-
if target.catalogid in
|
282
|
-
fields[key] = exposure.field_id
|
306
|
+
if target.catalogid in catalogids:
|
283
307
|
rich_table.add_row(*list(map(str, (
|
308
|
+
i,
|
284
309
|
exposure.observatory,
|
285
310
|
exposure.mjd,
|
286
311
|
exposure.exposure,
|
@@ -288,8 +313,10 @@ def lookup(identifier, careful, **kwargs):
|
|
288
313
|
target.fiber_id,
|
289
314
|
target.catalogid
|
290
315
|
))))
|
316
|
+
i += 1
|
291
317
|
break
|
292
318
|
|
319
|
+
|
293
320
|
@main.group()
|
294
321
|
def add(**kwargs):
|
295
322
|
"""Add new information to an existing Almanac file."""
|
@@ -1,7 +1,7 @@
|
|
1
|
-
almanac/__init__.py,sha256=
|
1
|
+
almanac/__init__.py,sha256=nxyCJkPdw9Exgk2WWizLADkLFWCqT_I71kV6KSA_dRc,109
|
2
2
|
almanac/apogee.py,sha256=Q7juc7BJdnP56-4UZ4CSg6FCULr22KHinHly2d0KMt8,10390
|
3
3
|
almanac/catalog.py,sha256=tVwlLtVaUbSt1hoTpIPP2bMhgd4rpcUUP_zdr6uks2c,11633
|
4
|
-
almanac/cli.py,sha256=
|
4
|
+
almanac/cli.py,sha256=rntf3UgIRk-UK-DHu8qf1ZnJrQwUs3Xd3nnkO2cF8iw,30198
|
5
5
|
almanac/config.py,sha256=5oRO-mrtaCKIcqGxcrfeNHZIjHkULDRrI_Bv1CU5uxE,3259
|
6
6
|
almanac/database.py,sha256=6YeuRSFU5zfIen7zU-nI4pN_Z_fnYkglPcYxzVF4Xqo,758
|
7
7
|
almanac/display.py,sha256=IflM5Y3yOJEDkvyUYQe3bOFs1iEwoe3mUj8mbODsYDk,15388
|
@@ -20,9 +20,9 @@ almanac/etc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
20
|
almanac/etc/bad_exposures.csv,sha256=VQQoq6uXDhnnIyp6vw0cfeTaoyNqPi5dW0MwfKsDRCk,25394
|
21
21
|
almanac/stash/data_models.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
22
22
|
almanac/stash/plugmap_models.py,sha256=8yxw6ZXuLP1ZdFuT7wCW_Z5JSJll4uymiIWRb6WvSOk,8973
|
23
|
-
sdss_almanac-0.
|
24
|
-
sdss_almanac-0.
|
25
|
-
sdss_almanac-0.
|
26
|
-
sdss_almanac-0.
|
27
|
-
sdss_almanac-0.
|
28
|
-
sdss_almanac-0.
|
23
|
+
sdss_almanac-0.3.1.dist-info/licenses/LICENSE.md,sha256=_7dAUQQ5Ph_x1hcFXhi9aHBcqq9H11zco12eO4B3Cyg,1504
|
24
|
+
sdss_almanac-0.3.1.dist-info/METADATA,sha256=Utp6VykVy7C5cuGllPXDZOy9lM4puReK7Y4txy_HMC0,6994
|
25
|
+
sdss_almanac-0.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
26
|
+
sdss_almanac-0.3.1.dist-info/entry_points.txt,sha256=5Obfm-uaVxE3RnRm2W7dYaX_O_j5ggGvAW5UQG5AtuE,45
|
27
|
+
sdss_almanac-0.3.1.dist-info/top_level.txt,sha256=sWBGH9a-2-nFB2-rGqioyigbkcz14t1u8rqAs_RYe_w,8
|
28
|
+
sdss_almanac-0.3.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|