sdss-almanac 0.2.11__tar.gz → 0.2.12__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.
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/PKG-INFO +1 -1
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/pyproject.toml +1 -1
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/__init__.py +1 -1
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/cli.py +95 -1
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/sdss_almanac.egg-info/PKG-INFO +1 -1
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/LICENSE.md +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/README.md +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/setup.cfg +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/apogee.py +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/catalog.py +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/config.py +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/data_models/__init__.py +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/data_models/exposure.py +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/data_models/fps.py +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/data_models/metadata.py +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/data_models/plate.py +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/data_models/types.py +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/data_models/utils.py +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/database.py +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/display.py +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/etc/__init__.py +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/etc/bad_exposures.csv +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/io.py +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/logger.py +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/qa.py +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/stash/data_models.py +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/stash/plugmap_models.py +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/almanac/utils.py +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/sdss_almanac.egg-info/SOURCES.txt +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/sdss_almanac.egg-info/dependency_links.txt +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/sdss_almanac.egg-info/entry_points.txt +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/sdss_almanac.egg-info/not-zip-safe +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/sdss_almanac.egg-info/requires.txt +0 -0
- {sdss_almanac-0.2.11 → sdss_almanac-0.2.12}/src/sdss_almanac.egg-info/top_level.txt +0 -0
@@ -41,7 +41,12 @@ def main(
|
|
41
41
|
|
42
42
|
# This keeps the default behaviour as 'query mode' but allows for commands like 'config'.
|
43
43
|
if ctx.invoked_subcommand is not None:
|
44
|
-
command = dict(
|
44
|
+
command = dict(
|
45
|
+
config=config,
|
46
|
+
dump=dump,
|
47
|
+
add=add,
|
48
|
+
lookup=lookup
|
49
|
+
)[ctx.invoked_subcommand]
|
45
50
|
return ctx.invoke(command, **ctx.params)
|
46
51
|
|
47
52
|
import h5py as h5
|
@@ -196,6 +201,95 @@ def main(
|
|
196
201
|
for item in buffered_critical_logs:
|
197
202
|
logger.critical(item)
|
198
203
|
|
204
|
+
|
205
|
+
@main.command()
|
206
|
+
@click.argument("identifier", type=int)
|
207
|
+
@click.option("--careful", is_flag=True, help="Don't assume unique field for a given (obs, mjd, catalogid)")
|
208
|
+
def lookup(identifier, careful, **kwargs):
|
209
|
+
"""Lookup a target by catalog identifier or SDSS identifier."""
|
210
|
+
|
211
|
+
if not identifier:
|
212
|
+
return
|
213
|
+
|
214
|
+
from peewee import fn
|
215
|
+
from itertools import chain, starmap
|
216
|
+
from almanac.database import database
|
217
|
+
from almanac.apogee import get_exposures
|
218
|
+
from sdssdb.peewee.sdss5db.targetdb import (
|
219
|
+
Assignment, AssignmentStatus,CartonToTarget, Target, Hole, Observatory,
|
220
|
+
Design, DesignToField
|
221
|
+
)
|
222
|
+
from sdssdb.peewee.sdss5db.catalogdb import SDSS_ID_flat
|
223
|
+
|
224
|
+
from rich.table import Table as RichTable
|
225
|
+
from rich.console import Console
|
226
|
+
from rich.live import Live
|
227
|
+
|
228
|
+
identifiers = (
|
229
|
+
SDSS_ID_flat
|
230
|
+
.select(
|
231
|
+
SDSS_ID_flat.catalogid,
|
232
|
+
SDSS_ID_flat.sdss_id,
|
233
|
+
)
|
234
|
+
.where(
|
235
|
+
(SDSS_ID_flat.sdss_id == identifier)
|
236
|
+
| (SDSS_ID_flat.catalogid == identifier)
|
237
|
+
)
|
238
|
+
.tuples()
|
239
|
+
)
|
240
|
+
|
241
|
+
identifiers = { catalogid: sdss_id for catalogid, sdss_id in identifiers }
|
242
|
+
if not identifiers:
|
243
|
+
raise click.ClickException(f"Identifier {identifier} not found in SDSS-V database")
|
244
|
+
|
245
|
+
q = (
|
246
|
+
Target
|
247
|
+
.select(
|
248
|
+
fn.Lower(Observatory.label),
|
249
|
+
AssignmentStatus.mjd,
|
250
|
+
)
|
251
|
+
.join(CartonToTarget)
|
252
|
+
.join(Assignment)
|
253
|
+
.join(AssignmentStatus)
|
254
|
+
.switch(Assignment)
|
255
|
+
.join(Hole)
|
256
|
+
.join(Observatory)
|
257
|
+
.where(
|
258
|
+
Target.catalogid.in_(tuple(identifiers.keys()))
|
259
|
+
& (AssignmentStatus.status == 1)
|
260
|
+
)
|
261
|
+
.tuples()
|
262
|
+
)
|
263
|
+
q = tuple(set([(obs, int(mjd)) for obs, mjd in q]))
|
264
|
+
|
265
|
+
console = Console()
|
266
|
+
|
267
|
+
title = "; ".join([f"SDSS ID {sdss_id} / Catalog ID {catalogid}" for catalogid, sdss_id in identifiers.items()])
|
268
|
+
|
269
|
+
# Create Rich table
|
270
|
+
rich_table = RichTable(title=f"{title}", title_style="bold blue", show_header=True, header_style="bold cyan")
|
271
|
+
|
272
|
+
for field_name in ("obs", "mjd", "exposure", "field", "fiber_id", "catalogid"):
|
273
|
+
rich_table.add_column(field_name, justify="center")
|
274
|
+
|
275
|
+
fields = {}
|
276
|
+
with Live(rich_table, console=console, refresh_per_second=4, screen=False) as live:
|
277
|
+
for exposure in chain(*starmap(get_exposures, q)):
|
278
|
+
key = (exposure.observatory, exposure.mjd)
|
279
|
+
if (key not in fields or fields[key] == exposure.field_id) or careful:
|
280
|
+
for target in exposure.targets:
|
281
|
+
if target.catalogid in identifiers:
|
282
|
+
fields[key] = exposure.field_id
|
283
|
+
rich_table.add_row(*list(map(str, (
|
284
|
+
exposure.observatory,
|
285
|
+
exposure.mjd,
|
286
|
+
exposure.exposure,
|
287
|
+
exposure.field_id,
|
288
|
+
target.fiber_id,
|
289
|
+
target.catalogid
|
290
|
+
))))
|
291
|
+
break
|
292
|
+
|
199
293
|
@main.group()
|
200
294
|
def add(**kwargs):
|
201
295
|
"""Add new information to an existing Almanac file."""
|
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
|