Skip to content

Commit

Permalink
Rename source_detection to source_catalog (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram authored Dec 3, 2024
1 parent a672cb3 commit e43b7fc
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 22 deletions.
1 change: 1 addition & 0 deletions changes/428.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rename source_detection to source_catalog to match romancal step.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
4 changes: 2 additions & 2 deletions src/roman_datamodels/datamodels/_datamodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions src/roman_datamodels/maker_utils/_common_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
8 changes: 4 additions & 4 deletions src/roman_datamodels/maker_utils/_datamodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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.
Expand All @@ -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", {}))
Expand Down
8 changes: 4 additions & 4 deletions src/roman_datamodels/maker_utils/_tagged_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
stnode.IndividualImageMeta,
stnode.Resample,
stnode.SkyBackground,
stnode.SourceDetection,
stnode.SourceCatalog,
]


Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_stnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit e43b7fc

Please sign in to comment.