sdss-almanac 0.3__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 CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = "0.3"
1
+ __version__ = "0.3.1"
2
2
 
3
3
  from .config import config, get_config_path, ConfigManager
4
4
  from .logger import logger
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
 
@@ -258,40 +258,52 @@ def lookup(identifier, careful, **kwargs):
258
258
  .select(
259
259
  fn.Lower(Observatory.label),
260
260
  AssignmentStatus.mjd,
261
+ Field.field_id,
261
262
  )
263
+ .distinct()
262
264
  .join(CartonToTarget)
263
265
  .join(Assignment)
264
266
  .join(AssignmentStatus)
265
267
  .switch(Assignment)
266
268
  .join(Hole)
267
269
  .join(Observatory)
270
+ .switch(Assignment)
271
+ .join(Design)
272
+ .join(DesignToField)
273
+ .join(Field)
268
274
  .where(
269
275
  Target.catalogid.in_(tuple(catalogids))
270
276
  & (AssignmentStatus.status == 1)
271
277
  )
272
278
  .tuples()
273
279
  )
274
- q = tuple(set([(obs, int(mjd)) for obs, mjd in q]))
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)
275
285
 
276
286
  console = Console()
277
287
 
278
288
  title = f"SDSS ID {sdss_id}"
279
289
 
280
- # Create Rich table
281
- rich_table = RichTable(title=f"{title}", title_style="bold blue", show_header=True, header_style="bold cyan")
290
+ rich_table = RichTable(
291
+ title=f"{title}",
292
+ title_style="bold blue",
293
+ show_header=True,
294
+ header_style="bold cyan"
295
+ )
282
296
 
283
297
  for field_name in ("#", "obs", "mjd", "exposure", "field", "fiber_id", "catalogid"):
284
298
  rich_table.add_column(field_name, justify="center")
285
299
 
286
- fields = {}
287
300
  i = 1
288
301
  with Live(rich_table, console=console, refresh_per_second=4) as live:
289
- for exposure in chain(*starmap(get_exposures, q)):
290
- key = (exposure.observatory, exposure.mjd)
291
- if (key not in fields or fields[key] == exposure.field_id) or careful:
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:
292
305
  for target in exposure.targets:
293
306
  if target.catalogid in catalogids:
294
- fields[key] = exposure.field_id
295
307
  rich_table.add_row(*list(map(str, (
296
308
  i,
297
309
  exposure.observatory,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sdss-almanac
3
- Version: 0.3
3
+ Version: 0.3.1
4
4
  Summary: Everything we've got
5
5
  Author-email: Andy Casey <andrew.casey@monash.edu>
6
6
  License: BSD 3-Clause License
@@ -1,7 +1,7 @@
1
- almanac/__init__.py,sha256=IVYEfNRXAC4OOVay7i4tcf3qG76xQA4qXlHoStx8pRA,107
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=WuAFwfMeID4HJoUdQt0w7wrmrkdUBhFP5MBdYU7UL7M,30009
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.3.dist-info/licenses/LICENSE.md,sha256=_7dAUQQ5Ph_x1hcFXhi9aHBcqq9H11zco12eO4B3Cyg,1504
24
- sdss_almanac-0.3.dist-info/METADATA,sha256=ZGX1P4Vfs9n3Cbx0I9wdqrEKPRiyK1q8Tlb6XmLG11Y,6992
25
- sdss_almanac-0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
26
- sdss_almanac-0.3.dist-info/entry_points.txt,sha256=5Obfm-uaVxE3RnRm2W7dYaX_O_j5ggGvAW5UQG5AtuE,45
27
- sdss_almanac-0.3.dist-info/top_level.txt,sha256=sWBGH9a-2-nFB2-rGqioyigbkcz14t1u8rqAs_RYe_w,8
28
- sdss_almanac-0.3.dist-info/RECORD,,
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,,