Skip to content

Commit

Permalink
Group models by obs_id for steps that use grouping (#1448)
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram authored Oct 23, 2024
2 parents e215f87 + d139a4b commit 07d66cf
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
1 change: 1 addition & 0 deletions changes/1448.outlier_detection.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Group by obs_id
1 change: 1 addition & 0 deletions changes/1448.resample.2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Group by obs_id
1 change: 1 addition & 0 deletions changes/1448.tweakreg.0.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Group by obs_id
6 changes: 1 addition & 5 deletions romancal/datamodels/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,4 @@ def _mapping_to_group_id(mapping):
"""
Combine a number of file metadata values into a ``group_id`` string
"""
return (
"roman{program}{observation}{visit}"
"_{visit_file_group}{visit_file_sequence}{visit_file_activity}"
"_{exposure}"
).format_map(mapping)
return "{obs_id}".format_map(mapping)
2 changes: 1 addition & 1 deletion romancal/outlier_detection/tests/test_outlier_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def test_find_outliers(tmp_path, base_image, on_disk):
img.data[42, 72] = source_value
img.err[:] = err_value
img.meta.filename = str(tmp_path / f"img{i}_suffix.asdf")
img.meta.observation.exposure = i
img.meta.observation.obs_id = str(i)
img.meta.background.level = 0
imgs.append(img)

Expand Down
2 changes: 2 additions & 0 deletions romancal/resample/tests/test_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ def exposure_1(wfi_sca1, wfi_sca2, wfi_sca3):
"2020-02-01T00:02:30", format="isot", scale="utc"
)
sca.meta.observation["exposure"] = 1
sca.meta.observation["obs_id"] = "1"
return [wfi_sca1, wfi_sca2, wfi_sca3]


Expand All @@ -268,6 +269,7 @@ def exposure_2(wfi_sca4, wfi_sca5, wfi_sca6):
"2020-05-01T00:02:30", format="isot", scale="utc"
)
sca.meta.observation["exposure"] = 2
sca.meta.observation["obs_id"] = "2"
return [wfi_sca4, wfi_sca5, wfi_sca6]


Expand Down
7 changes: 3 additions & 4 deletions romancal/tweakreg/tests/test_tweakreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,9 @@ def test_tweakreg_handles_multiple_groups(tmp_path, base_image):
add_tweakreg_catalog_attribute(tmp_path, img2, catalog_filename="img2")

img1.meta.observation["program"] = "-program_id1"
img1.meta.observation["obs_id"] = "1"
img2.meta.observation["program"] = "-program_id2"
img2.meta.observation["obs_id"] = "2"

img1.meta["filename"] = "file1.asdf"
img2.meta["filename"] = "file2.asdf"
Expand All @@ -918,10 +920,7 @@ def test_tweakreg_handles_multiple_groups(tmp_path, base_image):
assert len(res.group_names) == 2
with res:
for r, i in zip(res, [img1, img2]):
assert (
r.meta.group_id.split("-")[1]
== i.meta.observation.program.split("-")[1]
)
assert r.meta.group_id == i.meta.observation.obs_id
res.shelve(r, modify=False)


Expand Down

0 comments on commit 07d66cf

Please sign in to comment.