Skip to content

Commit

Permalink
Rework visit-visit_system relationship.
Browse files Browse the repository at this point in the history
A visit can now belong to multiple visit_systems, as long as the set
of exposures computed by those visit_systems is the same.
  • Loading branch information
TallJimbo authored and timj committed Apr 11, 2022
1 parent acfe4d7 commit 4de102a
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 68 deletions.
28 changes: 25 additions & 3 deletions python/lsst/daf/butler/configs/dimensions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ elements:
type: string
length: 64
requires: [instrument]
implies: [physical_filter, visit_system]
implies: [physical_filter]
metadata:
-
name: day_obs
Expand Down Expand Up @@ -217,6 +217,14 @@ elements:
Can only be approximate since it is continuously changing during
an observation and multiple exposures can be combined from a
relatively long period.
-
name: visit_system_mask
type: int
doc: >
A bitwise OR of ``2**(visit_system.id)`` for the visit systems this
visit belongs to, provided to allow queries to sometimes avoid
joining in ``visit_system`` and ``visit_system_membership``.
storage:
cls: lsst.daf.butler.registry.dimensions.table.TableDimensionRecordStorage

Expand Down Expand Up @@ -435,6 +443,12 @@ elements:
doc: >
A system of self-consistent visit definitions, within which each
exposure should appear at most once.
A visit may belong to multiple visit systems, if the logical definitions
for those systems happen to result in the same set of exposures - the
main (and probably only) example is when a single-snap visit is observed,
for which both the "one-to-one" visit system and a "group by header metadata" visit
system will define the same single-exposure visit.
keys:
-
name: id
Expand All @@ -453,8 +467,16 @@ elements:
doc: >
A many-to-many join table that relates exposures to the visits they
belong to.
requires: [exposure, visit_system]
implies: [visit]
requires: [exposure, visit]
always_join: true
storage:
cls: lsst.daf.butler.registry.dimensions.table.TableDimensionRecordStorage

visit_system_membership:
doc: >
A many-to-many join table that relates visits to the visit_systems they
belong to.
requires: [visit, visit_system]
always_join: true
storage:
cls: lsst.daf.butler.registry.dimensions.table.TableDimensionRecordStorage
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/daf/butler/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def __init__(self, root, configFile):
id=423,
name="fourtwentythree",
physical_filter="d-r",
visit_system=1,
visit_system_mask=2, # 2**1
datetimeBegin=visitStart,
datetimeEnd=visitEnd,
),
Expand All @@ -251,7 +251,7 @@ def __init__(self, root, configFile):
id=424,
name="fourtwentyfour",
physical_filter="d-r",
visit_system=1,
visit_system_mask=2,
),
)

Expand Down
17 changes: 8 additions & 9 deletions tests/test_cliCmdQueryDataIds.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def testDimensions(self):
"""Test getting a dimension."""
res = self._queryDataIds(self.root, dimensions=("visit",))
expected = AstropyTable(
array((("R", "DummyCamComp", "d-r", 1, 423), ("R", "DummyCamComp", "d-r", 1, 424))),
names=("band", "instrument", "physical_filter", "visit_system", "visit"),
array((("R", "DummyCamComp", "d-r", 423), ("R", "DummyCamComp", "d-r", 424))),
names=("band", "instrument", "physical_filter", "visit"),
)
self.assertAstropyTablesEqual(res, expected)

Expand All @@ -81,8 +81,8 @@ def testWhere(self):
self.root, dimensions=("visit",), where="instrument='DummyCamComp' AND visit=423"
)
expected = AstropyTable(
array((("R", "DummyCamComp", "d-r", 1, 423),)),
names=("band", "instrument", "physical_filter", "visit_system", "visit"),
array((("R", "DummyCamComp", "d-r", 423),)),
names=("band", "instrument", "physical_filter", "visit"),
)
self.assertAstropyTablesEqual(res, expected)

Expand All @@ -98,7 +98,6 @@ def testDatasetsAndCollections(self):
"id": 425,
"name": "fourtwentyfive",
"physical_filter": "d-r",
"visit_system": 1,
},
)
self.repo.addDataset(dataId={"instrument": "DummyCamComp", "visit": 425}, run="foo")
Expand All @@ -108,8 +107,8 @@ def testDatasetsAndCollections(self):
repo=self.root, dimensions=("visit",), collections=("ingest/run",), datasets="test_metric_comp"
)
expected = AstropyTable(
array((("R", "DummyCamComp", "d-r", 1, 423), ("R", "DummyCamComp", "d-r", 1, 424))),
names=("band", "instrument", "physical_filter", "visit_system", "visit"),
array((("R", "DummyCamComp", "d-r", 423), ("R", "DummyCamComp", "d-r", 424))),
names=("band", "instrument", "physical_filter", "visit"),
)
self.assertAstropyTablesEqual(res, expected)

Expand All @@ -118,8 +117,8 @@ def testDatasetsAndCollections(self):
repo=self.root, dimensions=("visit",), collections=("foo",), datasets="test_metric_comp"
)
expected = AstropyTable(
array((("R", "DummyCamComp", "d-r", 1, 425),)),
names=("band", "instrument", "physical_filter", "visit_system", "visit"),
array((("R", "DummyCamComp", "d-r", 425),)),
names=("band", "instrument", "physical_filter", "visit"),
)
self.assertAstropyTablesEqual(res, expected)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_cliCmdQueryDatasetTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def testQueryDatasetTypes(self):
array(
(
"test",
"['band', 'instrument', 'physical_filter', 'visit_system', 'visit']",
"['band', 'instrument', 'physical_filter', 'visit']",
storageClassName,
)
),
Expand Down

0 comments on commit 4de102a

Please sign in to comment.