From e43b7fc6d83f91ae75378de657bf972e9bcd9c52 Mon Sep 17 00:00:00 2001 From: Brett Graham Date: Tue, 3 Dec 2024 16:07:23 -0500 Subject: [PATCH] Rename source_detection to source_catalog (#428) --- changes/428.feature.rst | 1 + pyproject.toml | 4 ++-- src/roman_datamodels/datamodels/_datamodels.py | 4 ++-- src/roman_datamodels/maker_utils/_common_meta.py | 8 ++++---- src/roman_datamodels/maker_utils/_datamodels.py | 8 ++++---- src/roman_datamodels/maker_utils/_tagged_nodes.py | 8 ++++---- tests/test_models.py | 8 ++++---- tests/test_open.py | 2 +- tests/test_stnode.py | 2 +- 9 files changed, 23 insertions(+), 22 deletions(-) create mode 100644 changes/428.feature.rst diff --git a/changes/428.feature.rst b/changes/428.feature.rst new file mode 100644 index 00000000..a63bfee2 --- /dev/null +++ b/changes/428.feature.rst @@ -0,0 +1 @@ +Rename source_detection to source_catalog to match romancal step. diff --git a/pyproject.toml b/pyproject.toml index cd100c12..5a80d32a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,8 +16,8 @@ dependencies = [ "gwcs >=0.19.0", "numpy >=1.24", "astropy >=5.3.0", - "rad >=0.22.0, <0.23.0", - # "rad @ git+https://github.com/spacetelescope/rad.git", + # "rad >=0.22.0, <0.23.0", + "rad @ git+https://github.com/spacetelescope/rad.git", "asdf-standard >=1.1.0", ] dynamic = ["version"] diff --git a/src/roman_datamodels/datamodels/_datamodels.py b/src/roman_datamodels/datamodels/_datamodels.py index 563f484c..64e7bc99 100644 --- a/src/roman_datamodels/datamodels/_datamodels.py +++ b/src/roman_datamodels/datamodels/_datamodels.py @@ -334,8 +334,8 @@ class MosaicSegmentationMapModel(_RomanDataModel): _node_type = stnode.MosaicSegmentationMap -class SourceCatalogModel(_RomanDataModel): - _node_type = stnode.SourceCatalog +class ImageSourceCatalogModel(_RomanDataModel): + _node_type = stnode.ImageSourceCatalog class SegmentationMapModel(_RomanDataModel): diff --git a/src/roman_datamodels/maker_utils/_common_meta.py b/src/roman_datamodels/maker_utils/_common_meta.py index f7f361f3..62e80155 100644 --- a/src/roman_datamodels/maker_utils/_common_meta.py +++ b/src/roman_datamodels/maker_utils/_common_meta.py @@ -10,7 +10,7 @@ from ._base import NONUM, NOSTR from ._basic_meta import mk_basic_meta -from ._tagged_nodes import mk_cal_logs, mk_photometry, mk_resample, mk_source_detection +from ._tagged_nodes import mk_cal_logs, mk_photometry, mk_resample, mk_source_catalog def mk_exposure(**kwargs): @@ -301,7 +301,7 @@ def mk_l2_cal_step(**kwargs): l2calstep["linearity"] = kwargs.get("linearity", "INCOMPLETE") l2calstep["outlier_detection"] = kwargs.get("outlier_detection", "INCOMPLETE") l2calstep["photom"] = kwargs.get("photom", "INCOMPLETE") - l2calstep["source_detection"] = kwargs.get("source_detection", "INCOMPLETE") + l2calstep["source_catalog"] = kwargs.get("source_catalog", "INCOMPLETE") l2calstep["ramp_fit"] = kwargs.get("ramp_fit", "INCOMPLETE") l2calstep["refpix"] = kwargs.get("refpix", "INCOMPLETE") l2calstep["saturation"] = kwargs.get("saturation", "INCOMPLETE") @@ -441,7 +441,7 @@ def mk_l2_meta(**kwargs): meta["photometry"] = mk_photometry(**kwargs.get("photometry", {})) meta["outlier_detection"] = mk_outlier_detection(**kwargs.get("outlier_detection", {})) meta["background"] = mk_sky_background(**kwargs.get("background", {})) - meta["source_detection"] = mk_source_detection(**kwargs.get("source_detection", {})) + meta["source_catalog"] = mk_source_catalog(**kwargs.get("source_catalog", {})) meta["cal_logs"] = mk_cal_logs(**kwargs) return meta @@ -851,7 +851,7 @@ def mk_individual_image_meta(**kwargs): # imm["program"] = kwargs.get("program", QTable(table_dct)) # imm["rcs"] = kwargs.get("rcs", QTable(table_dct)) # imm["ref_file"] = kwargs.get("ref_file", QTable(table_dct)) - # imm["source_detection"] = kwargs.get("source_detection", QTable(table_dct)) + # imm["source_catalog"] = kwargs.get("source_catalog", QTable(table_dct)) # imm["velocity_aberration"] = kwargs.get("velocity_aberration", QTable(table_dct)) # imm["visit"] = kwargs.get("visit", QTable(table_dct)) # imm["wcsinfo"] = kwargs.get("wcsinfo", QTable(table_dct)) diff --git a/src/roman_datamodels/maker_utils/_datamodels.py b/src/roman_datamodels/maker_utils/_datamodels.py index 32ed5260..99b2d2c3 100644 --- a/src/roman_datamodels/maker_utils/_datamodels.py +++ b/src/roman_datamodels/maker_utils/_datamodels.py @@ -423,7 +423,7 @@ def mk_mosaic_source_catalog(*, filepath=None, **kwargs): Returns ------- - roman_datamodels.stnode.SourceCatalog + roman_datamodels.stnode.MosaicSourceCatalog """ source_catalog = stnode.MosaicSourceCatalog() @@ -466,7 +466,7 @@ def mk_mosaic_segmentation_map(*, filepath=None, shape=(4096, 4096), **kwargs): return save_node(segmentation_map, filepath=filepath) -def mk_source_catalog(*, filepath=None, **kwargs): +def mk_image_source_catalog(*, filepath=None, **kwargs): """ Create a dummy Source Catalog instance (or file) with arrays and valid values for attributes required by the schema. @@ -478,9 +478,9 @@ def mk_source_catalog(*, filepath=None, **kwargs): Returns ------- - roman_datamodels.stnode.SourceCatalog + roman_datamodels.stnode.ImageSourceCatalog """ - source_catalog = stnode.SourceCatalog() + source_catalog = stnode.ImageSourceCatalog() source_catalog["source_catalog"] = kwargs.get("source_catalog", Table([range(3), range(3)], names=["a", "b"])) source_catalog["meta"] = mk_catalog_meta(**kwargs.get("meta", {})) diff --git a/src/roman_datamodels/maker_utils/_tagged_nodes.py b/src/roman_datamodels/maker_utils/_tagged_nodes.py index d439d8a0..6fc69ab6 100644 --- a/src/roman_datamodels/maker_utils/_tagged_nodes.py +++ b/src/roman_datamodels/maker_utils/_tagged_nodes.py @@ -61,16 +61,16 @@ def mk_cal_logs(**kwargs): ) -def mk_source_detection(**kwargs): +def mk_source_catalog(**kwargs): """ - Create a dummy Source Detection instance with valid values for attributes + Create a dummy Source Catalog instance with valid values for attributes required by the schema. Utilized by the model maker utilities below. Returns ------- - roman_datamodels.stnode.SourceDetection + roman_datamodels.stnode.SourceCatalog """ - sd = stnode.SourceDetection() + sd = stnode.SourceCatalog() sd["tweakreg_catalog_name"] = kwargs.get("tweakreg_catalog_name", "catalog") return sd diff --git a/tests/test_models.py b/tests/test_models.py index e1ee6f84..298e4bf1 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -26,7 +26,7 @@ stnode.IndividualImageMeta, stnode.Resample, stnode.SkyBackground, - stnode.SourceDetection, + stnode.SourceCatalog, ] @@ -778,9 +778,9 @@ def test_make_tvac(): assert tvac_model.validate() is None -def test_make_source_catalog(): - source_catalog = utils.mk_source_catalog() - source_catalog_model = datamodels.SourceCatalogModel(source_catalog) +def test_make_image_source_catalog(): + source_catalog = utils.mk_image_source_catalog() + source_catalog_model = datamodels.ImageSourceCatalogModel(source_catalog) assert isinstance(source_catalog_model.source_catalog, Table) diff --git a/tests/test_open.py b/tests/test_open.py index 170224ed..25ff59ed 100644 --- a/tests/test_open.py +++ b/tests/test_open.py @@ -211,7 +211,7 @@ def test_opening_model(tmp_path, node_class): assert model.asn_type == "image" elif node_class == stnode.WfiMosaic: assert model.meta.basic.optical_element == "F158" - elif node_class in (stnode.SegmentationMap, stnode.SourceCatalog): + elif node_class in (stnode.SegmentationMap, stnode.ImageSourceCatalog): assert model.meta.optical_element == "F158" elif node_class in (stnode.MosaicSegmentationMap, stnode.MosaicSourceCatalog): assert hasattr(model.meta, "basic") diff --git a/tests/test_stnode.py b/tests/test_stnode.py index 4f7e78cf..a9364774 100644 --- a/tests/test_stnode.py +++ b/tests/test_stnode.py @@ -289,7 +289,7 @@ def test_node_representation(model): assert mdl.meta.model_type == model_types[type(mdl)] assert mdl.meta.telescope == "ROMAN" assert mdl.meta.filename == NOFN - elif isinstance(mdl, datamodels.SegmentationMapModel | datamodels.SourceCatalogModel): + elif isinstance(mdl, datamodels.SegmentationMapModel | datamodels.ImageSourceCatalogModel): assert mdl.meta.optical_element == "F158" else: assert repr(mdl.meta.instrument) == repr(