Skip to content

Commit 59d9bb3

Browse files
Merge pull request #58 from lsst/tickets/DM-53363
DM-53363: Default to zero weight
2 parents d545008 + 5212ed1 commit 59d9bb3

3 files changed

Lines changed: 39 additions & 8 deletions

File tree

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
pyver: ["3.12"]
15+
pyver: ["3.13"]
1616

1717
runs-on: "ubuntu-latest"
1818

python/lsst/cell_coadds/_fits.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
from ._uniform_grid import UniformGrid
115115
from .typing_helpers import SingleCellCoaddApCorrMap
116116

117-
FILE_FORMAT_VERSION = "0.7"
117+
FILE_FORMAT_VERSION = "0.8"
118118
"""Version number for the file format as persisted, presented as a string of
119119
the form M.m, where M is the major version, m is the minor version.
120120
"""
@@ -298,13 +298,22 @@ def readAsMultipleCellCoadd(self) -> MultipleCellCoadd:
298298
)
299299
visit_polygons = {}
300300
if written_version >= version.parse("0.3"):
301+
if written_version >= version.parse("0.6"):
302+
visit_hdu = hdu_list[hdu_list.index_of("VISIT_SUMMARY")].data
303+
else:
304+
visit_hdu = hdu_list[hdu_list.index_of("VISIT")].data
305+
301306
visit_dict = {
302307
row["visit"]: VisitRecord(
303308
visit=row["visit"],
304-
physical_filter=row["physical_filter"],
305-
day_obs=row["day_obs"],
309+
physical_filter=(
310+
row["physical_filter"]
311+
if written_version >= version.parse("0.8")
312+
else header["FILTER"]
313+
),
314+
day_obs=row["day_obs"] if written_version >= version.parse("0.8") else 00000000,
306315
)
307-
for row in hdu_list[hdu_list.index_of("VISIT")].data
316+
for row in visit_hdu
308317
}
309318
link_table = hdu_list[hdu_list.index_of("CELL")].data
310319

@@ -678,10 +687,20 @@ def writeMultipleCellCoaddAsFits(
678687
format="I",
679688
array=[obs_id.detector for obs_id in multiple_cell_coadd.common.visit_polygons],
680689
)
690+
physical_filter_column = fits.Column(
691+
name="physical_filter",
692+
format="32A",
693+
array=[obs_id.physical_filter for obs_id in multiple_cell_coadd.common.visit_polygons],
694+
)
695+
day_obs_column = fits.Column(
696+
name="day_obs",
697+
format="K",
698+
array=[obs_id.day_obs for obs_id in multiple_cell_coadd.common.visit_polygons],
699+
)
681700
number_of_vertices = []
682701
polygon_vertices_array = []
683702
for obs_id, poly in multiple_cell_coadd.common.visit_polygons.items():
684-
if num_vertices := len(poly.getVertices()) > MAX_POLYGON_VERTICES:
703+
if (num_vertices := len(poly.getVertices())) > MAX_POLYGON_VERTICES:
685704
logger.warning(
686705
"Visit %d, detector %d has a polygon with %d vertices. "
687706
"This geometry should be impossible for two intersecting "
@@ -708,7 +727,14 @@ def writeMultipleCellCoaddAsFits(
708727
array=number_of_vertices,
709728
)
710729
visit_summary_hdu = fits.BinTableHDU.from_columns(
711-
[visit_column, detector_column, number_of_vertices_column, polygon_column],
730+
[
731+
visit_column,
732+
detector_column,
733+
physical_filter_column,
734+
day_obs_column,
735+
number_of_vertices_column,
736+
polygon_column,
737+
],
712738
name="VISIT_SUMMARY",
713739
)
714740
visit_summary_hdu.header["POLYVERT"] = MAX_POLYGON_VERTICES

python/lsst/cell_coadds/_stitched_coadd.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,12 @@ def _make_coadd_inputs(self) -> CoaddInputs:
203203
ccd_record = coadd_inputs.ccds.addNew()
204204
ccd_record["visit"] = obs_id.visit
205205
ccd_record["ccd"] = obs_id.detector
206-
ccd_record["weight"] = weights[obs_id]
206+
# ObservationIdentifiers in the inputs is a proper subset of those
207+
# denoting the visit polygons. For edgeless coadds, some
208+
# identifiers may not be present in weights and we take that to
209+
# mean that they were excluded from the coadds (and hence have
210+
# zero weight).
211+
ccd_record["weight"] = weights.get(obs_id, 0.0)
207212
ccd_record.setBBox(Box2I()) # Dummy bbox; not used.
208213
ccd_record.validPolygon = polygon
209214

0 commit comments

Comments
 (0)