sdss-almanac 0.2.5__tar.gz → 0.2.7__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.
Files changed (32) hide show
  1. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/PKG-INFO +1 -1
  2. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/pyproject.toml +1 -1
  3. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/almanac/__init__.py +1 -1
  4. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/almanac/data_models/exposure.py +25 -11
  5. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/almanac/data_models/types.py +5 -2
  6. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/almanac/data_models/utils.py +26 -3
  7. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/sdss_almanac.egg-info/PKG-INFO +1 -1
  8. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/LICENSE.md +0 -0
  9. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/README.md +0 -0
  10. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/setup.cfg +0 -0
  11. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/almanac/apogee.py +0 -0
  12. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/almanac/cli.py +0 -0
  13. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/almanac/config.py +0 -0
  14. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/almanac/data_models/__init__.py +0 -0
  15. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/almanac/data_models/fps.py +0 -0
  16. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/almanac/data_models/plate.py +0 -0
  17. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/almanac/database.py +0 -0
  18. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/almanac/display.py +0 -0
  19. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/almanac/etc/__init__.py +0 -0
  20. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/almanac/etc/bad_exposures.csv +0 -0
  21. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/almanac/io.py +0 -0
  22. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/almanac/logger.py +0 -0
  23. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/almanac/qa.py +0 -0
  24. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/almanac/stash/data_models.py +0 -0
  25. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/almanac/stash/plugmap_models.py +0 -0
  26. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/almanac/utils.py +0 -0
  27. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/sdss_almanac.egg-info/SOURCES.txt +0 -0
  28. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/sdss_almanac.egg-info/dependency_links.txt +0 -0
  29. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/sdss_almanac.egg-info/entry_points.txt +0 -0
  30. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/sdss_almanac.egg-info/not-zip-safe +0 -0
  31. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/sdss_almanac.egg-info/requires.txt +0 -0
  32. {sdss_almanac-0.2.5 → sdss_almanac-0.2.7}/src/sdss_almanac.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sdss-almanac
3
- Version: 0.2.5
3
+ Version: 0.2.7
4
4
  Summary: Everything we've got
5
5
  Author-email: Andy Casey <andrew.casey@monash.edu>
6
6
  License: BSD 3-Clause License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "sdss-almanac"
7
- version = "0.2.5"
7
+ version = "0.2.7"
8
8
  authors = [
9
9
  { name = "Andy Casey", email = "andrew.casey@monash.edu" }
10
10
  ]
@@ -1,4 +1,4 @@
1
- __version__ = "0.2.5"
1
+ __version__ = "0.2.7"
2
2
 
3
3
  from .config import config, get_config_path, ConfigManager
4
4
  from .logger import logger
@@ -79,7 +79,13 @@ class Exposure(BaseModel):
79
79
 
80
80
  @computed_field
81
81
  def flagged_bad(self) -> bool:
82
- return (self.observatory, self.mjd, self.exposure) in lookup_bad_exposures
82
+ marked_bad = (self.observatory, self.mjd, self.exposure) in lookup_bad_exposures
83
+ missing_plate_info = (
84
+ (self.image_type == "object")
85
+ & ((self.fps and self.config_id <= 0) or (not self.fps and self.plate_id <= 0))
86
+ )
87
+ return marked_bad or missing_plate_info
88
+
83
89
 
84
90
  @computed_field
85
91
  def chip_flags(self) -> int:
@@ -299,7 +305,6 @@ class Exposure(BaseModel):
299
305
  @cached_property
300
306
  def targets(self) -> Tuple[Union[FPSTarget, PlateTarget]]:
301
307
  if self._targets is None:
302
-
303
308
  if (
304
309
  (self.image_type == "object")
305
310
  & (
@@ -309,9 +314,18 @@ class Exposure(BaseModel):
309
314
  ):
310
315
  if self.fps:
311
316
  factory = FPSTarget
312
- targets = self.fiber_map
313
- keep = (targets["fiberType"] == "APOGEE") & (targets["fiberId"] > 0)
314
- targets = targets[keep]
317
+ rows = self.fiber_map
318
+ keep = (rows["fiberType"] == "APOGEE") & (rows["fiberId"] > 0)
319
+ rows = rows[keep]
320
+ missing = set(range(1, 301)) - set(rows["fiberId"])
321
+ for fiber_id in missing:
322
+ rows.add_row({
323
+ "fiberId": fiber_id,
324
+ "racat": np.nan,
325
+ "deccat": np.nan,
326
+ "category": "bonus",
327
+ })
328
+ rows.sort("fiberId")
315
329
  else:
316
330
  factory = PlateTarget
317
331
  bad_exposure_notes = (
@@ -320,16 +334,16 @@ class Exposure(BaseModel):
320
334
  .get("notes", None)
321
335
  )
322
336
  if bad_exposure_notes == "missing_plug_map_file":
323
- targets = []
337
+ rows = []
324
338
  else:
325
- targets = match_planned_to_plugged(self.plate_hole_map, self.plug_map)
326
- if targets:
339
+ rows = match_planned_to_plugged(self.plate_hole_map, self.plug_map)
340
+ if rows:
327
341
  # Plugged MJD is necessary to understand where the fiber mapping
328
342
  # went wrong in early plate era.
329
- targets["plugged_mjd"] = self.plugged_mjd
330
- targets["observatory"] = self.observatory
343
+ rows["plugged_mjd"] = self.plugged_mjd
344
+ rows["observatory"] = self.observatory
331
345
 
332
- self._targets = tuple([factory(**r) for r in targets])
346
+ self._targets = tuple([factory(**r) for r in rows])
333
347
  else:
334
348
  self._targets = tuple()
335
349
  return self._targets
@@ -28,12 +28,14 @@ ImageType = Literal[
28
28
  ]
29
29
  Category = Literal[
30
30
  "",
31
+ "bonus",
31
32
  "science",
32
33
  "sky_apogee",
33
34
  "sky_boss",
34
35
  "standard_apogee",
35
36
  "standard_boss",
36
- "open_fiber"
37
+ "open_fiber",
38
+ "unplugged",
37
39
  ]
38
40
 
39
41
  HoleType = Literal[
@@ -56,7 +58,8 @@ HoleType = Literal[
56
58
  "apogee_south",
57
59
  "bosshalf",
58
60
  "boss_shared",
59
- "fps"
61
+ "fps",
62
+ "unplugged",
60
63
  ]
61
64
 
62
65
  ObjType = Literal[
@@ -17,16 +17,33 @@ def sanitise_twomass_designation(v):
17
17
  return ""
18
18
  return v
19
19
 
20
- def match_planned_to_plugged(planned, plugged, tol=1e-5):
21
20
 
21
+ def match_planned_to_plugged(planned, plugged, tol=1e-5, enforce_300=True):
22
+
23
+ unplugged_dict = {
24
+ "holeType": "unplugged",
25
+ "holetype": "unplugged",
26
+ "targettype": "unplugged",
27
+ "ra": np.nan,
28
+ "dec": np.nan,
29
+ "objType": "na",
30
+ }
22
31
  is_apogee = (
23
32
  (planned["holetype"] == "APOGEE")
24
33
  | (planned["holetype"] == "APOGEE_SHARED")
25
34
  | (planned["holetype"] == "APOGEE_SOUTH")
26
35
  )
27
- if not any(is_apogee):
36
+ if not np.any(is_apogee) and not enforce_300:
28
37
  return []
29
38
 
39
+ elif not np.any(is_apogee):
40
+ rows = []
41
+ for i in range(1, 301):
42
+ unplugged_dict["fiberId"] = i
43
+ rows.append(unplugged_dict.copy())
44
+
45
+ return Table(rows=rows)
46
+
30
47
  planned = planned[is_apogee]
31
48
  plugged = plugged[plugged["spectrographId"] == 2]
32
49
 
@@ -50,7 +67,7 @@ def match_planned_to_plugged(planned, plugged, tol=1e-5):
50
67
  has_match = (n_matches_to_plugged_holes == 1)
51
68
  planned_hole_indices = np.argmin(dist[:, has_match], axis=0)
52
69
 
53
- return hstack(
70
+ rows = hstack(
54
71
  [
55
72
  plugged[has_match],
56
73
  planned[planned_hole_indices]
@@ -59,6 +76,12 @@ def match_planned_to_plugged(planned, plugged, tol=1e-5):
59
76
  uniq_col_name="{table_name}{col_name}",
60
77
  table_names=("", "planned_")
61
78
  )
79
+ if enforce_300 and len(rows) != 300:
80
+ for fiber_id in (set(range(1, 301)) - set(rows["fiberId"])):
81
+ rows.add_row({"fiberId": fiber_id, **unplugged_dict })
82
+ rows.sort("fiberId")
83
+
84
+ return rows
62
85
 
63
86
 
64
87
  def get_headers(path, head=20_000):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sdss-almanac
3
- Version: 0.2.5
3
+ Version: 0.2.7
4
4
  Summary: Everything we've got
5
5
  Author-email: Andy Casey <andrew.casey@monash.edu>
6
6
  License: BSD 3-Clause License
File without changes
File without changes
File without changes