Skip to content

Commit 80afb1c

Browse files
committed
adding segmentation map
1 parent 889cbde commit 80afb1c

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

src/roman_datamodels/datamodels/_datamodels.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,3 +291,7 @@ class RefpixRefModel(_DataModel):
291291

292292
class SourceCatalogModel(_DataModel):
293293
_node_type = stnode.SourceCatalog
294+
295+
296+
class SegmentationMapModel(_DataModel):
297+
_node_type = stnode.SegmentationMap

src/roman_datamodels/maker_utils/_datamodels.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,33 @@ def mk_source_catalog(*, filepath=None, **kwargs):
448448
roman_datamodels.stnode.SourceCatalog
449449
"""
450450
source_catalog = stnode.SourceCatalog()
451-
# There currently is no meta attribute for SourceCatalog
452-
# This is likely to change once metadata has been added
453-
# source_catalog["meta"] = kwargs.get("meta", {})
451+
454452
source_catalog["source_catalog"] = kwargs.get("source_catalog", Table([range(3), range(3)], names=["a", "b"]))
453+
source_catalog["meta"] = mk_common_meta()
454+
source_catalog["meta"].update(kwargs.get("meta", dict(segmentation_map='')))
455455

456456
return save_node(source_catalog, filepath=filepath)
457+
458+
459+
def mk_segmentation_map(*, filepath=None, shape=(4096, 4096), **kwargs):
460+
"""
461+
Create a dummy Segmentation Map (or file) with arrays and valid values
462+
for attributes required by the schema.
463+
464+
Parameters
465+
----------
466+
filepath
467+
(optional, keyword-only) File name and path to write model to.
468+
469+
Returns
470+
-------
471+
roman_datamodels.stnode.SegmentationMap
472+
"""
473+
segmentation_map = stnode.SegmentationMap()
474+
475+
segmentation_map["data"] = kwargs.get("data", np.zeros(shape, dtype=np.uint32))
476+
segmentation_map["meta"] = mk_common_meta()
477+
segmentation_map["meta"].update(kwargs.get("meta", dict(filename='')))
478+
479+
return save_node(segmentation_map, filepath=filepath)
480+

0 commit comments

Comments
 (0)