### Install Development Dependencies Source: https://github.com/spacetelescope/roman_datamodels/blob/main/README.md Install additional dependencies required for running tests and building documentation within your development environment. Use this after performing an editable install. ```bash pip install -e " .[test]" pip install -e " .[docs]" pip install -e " .[test,docs]" ``` -------------------------------- ### Install Additional Development Tools Source: https://github.com/spacetelescope/roman_datamodels/blob/main/README.md Install useful auxiliary packages for development, such as IPython for interactive computing and pytest-xdist for parallel test execution. ```bash pip install ipython pytest-xdist ``` -------------------------------- ### Install Package with Specific Version Source: https://github.com/spacetelescope/roman_datamodels/wiki/Release-Process Use this command to test installing a specific version of the package from PyPI. ```shell pip install roman_datamodels==a.b.c ``` -------------------------------- ### Guidewindow Class Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels._stnode.Guidewindow.md The Guidewindow class represents the schema for a guide window. It inherits from TaggedObjectNode. ```APIDOC ## Class: Guidewindow ### Description Represents the schema for a guide window. ### Inheritance Bases: [`TaggedObjectNode`](roman_datamodels._stnode.TaggedObjectNode.md#roman_datamodels._stnode.TaggedObjectNode) ### Source Class generated from tag ‘asdf://stsci.edu/datamodels/roman/tags/guidewindow-1.3.0’ ### Initialization `__init__(node=None)` Initializes the Guidewindow object. ``` -------------------------------- ### Set Up Development Environment Source: https://github.com/spacetelescope/roman_datamodels/blob/main/README.md Steps to set up a local development environment for roman-datamodels. This involves cloning the repository and performing an editable install. Ensure your conda environment is active. ```bash cd git clone https://github.com/spacetelescope/roman_datamodels cd roman_datamodels pip install -e . ``` -------------------------------- ### Example of Flat Dictionary Output Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels._stnode.DNode.md Illustrates the expected output format of the to_flat_dict method, showing how nested schema elements are represented with dot-separated keys. ```text { "meta.observation.date": "2012-04-22T03:22:05.432" } ``` -------------------------------- ### Install Development Version from GitHub Source: https://github.com/spacetelescope/roman_datamodels/blob/main/README.md Install the latest, potentially unstable, development version directly from the main branch of the GitHub repository. This is useful for testing the newest features. Ensure your conda environment is active. ```bash conda create -n python conda activate pip install git+https://github.com/spacetelescope/roman_datamodels ``` -------------------------------- ### Build Changelog Entry with Towncrier Source: https://github.com/spacetelescope/roman_datamodels/wiki/Release-Process Builds the next changelog entry in CHANGES.rst from fragments in the 'changes/' directory. Ensure towncrier is installed before running. ```shell pip install towncrier towncrier build --version 0.17.0 ``` -------------------------------- ### Open a Roman ASDF Data File Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/general_structure.md Use this snippet to open a Roman ASDF data file. Ensure the 'roman_datamodels' library is installed and the file path is correct. ```python import roman_datamodels as rdm dm = rdm.open('some_roman_data.asdf') ``` -------------------------------- ### Tag Main Branch for Development Source: https://github.com/spacetelescope/roman_datamodels/wiki/Release-Process Tag the HEAD of the main branch with a development tag after a release, especially if the release branch has diverged. This ensures setuptools-scm shows the correct version for local installations. Replace 'a.b.d.dev' with the appropriate development version. ```shell git fetch upstream git checkout upstream/master git tag -a a.b.d.dev -m "development tag after divergence" git push upstream a.b.d.dev ``` -------------------------------- ### Install Specific Roman Datamodels Version Source: https://github.com/spacetelescope/roman_datamodels/blob/main/README.md Install a particular version of the roman-datamodels package, starting from version 0.1.0. This is useful for ensuring compatibility with specific project requirements. Activate your conda environment before running. ```bash conda create -n python conda activate pip install roman-datamodels==0.5.0 ``` -------------------------------- ### GuidewindowModel Constructor Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.GuidewindowModel.md The GuidewindowModel constructor handles cases where an already instantiated model is passed in. In such scenarios, the constructor directly returns the provided model. ```APIDOC ## GuidewindowModel(init=None, **kwargs) ### Description Handles the case where one passes in an already instantiated version of the model. In this case the constructor should just directly return the model. ### Method Constructor ### Parameters - **init**: Optional - The initial value for the model. - **kwargs**: Optional - Additional keyword arguments. ``` -------------------------------- ### Create Minimal ImageModel with Defaults Source: https://context7.com/spacetelescope/roman_datamodels/llms.txt Use `create_minimal` with the `defaults` argument to pre-fill specific fields, such as filename, file_date, and instrument details. ```python from astropy.time import Time dm = rdm.ImageModel.create_minimal( defaults={ "meta": { "filename": "output.asdf", "file_date": Time.now(), "instrument": {"optical_element": "F184", "detector": "WFI01"}, } } ) print(dm.meta.instrument.optical_element) ``` -------------------------------- ### L1FaceGuidewindowModel Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/developer_api.md Handles the case where one passes in an already instantiated version of the L1FaceGuidewindowModel. ```APIDOC ## L1FaceGuidewindowModel ### Description Handles the case where one passes in an already instantiated version of the model. ### Method N/A (Class constructor) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Install Latest Roman Datamodels Release Source: https://github.com/spacetelescope/roman_datamodels/blob/main/README.md Use this command to install the most recent stable release of the roman-datamodels package into your environment. Ensure you have a conda environment activated. ```bash conda create -n python conda activate pip install roman-datamodels ``` -------------------------------- ### get_crds_parameters Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.DataModel.md Get parameters used by CRDS to select references for this model. ```APIDOC ## get_crds_parameters() ### Description Get parameters used by CRDS to select references for this model. ### Method GET ### Endpoint /crds_parameters ``` -------------------------------- ### L1DetectorGuidewindowModel Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/developer_api.md Handles the case where one passes in an already instantiated version of the L1DetectorGuidewindowModel. ```APIDOC ## L1DetectorGuidewindowModel ### Description Handles the case where one passes in an already instantiated version of the model. ### Method N/A (Class constructor) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### WfiImgPhotomRefModel Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/developer_api.md Handles the case where one passes in an already instantiated version of the WfiImgPhotomRefModel. ```APIDOC ## WfiImgPhotomRefModel ### Description Handles the case where one passes in an already instantiated version of the model. ### Class WfiImgPhotomRefModel ### Initialization `WfiImgPhotomRefModel(init)` ``` -------------------------------- ### RefpixRefModel Class Initialization Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.RefpixRefModel.md This snippet shows how to instantiate the RefpixRefModel class. It handles cases where an already instantiated model is passed to the constructor. ```APIDOC ## roman_datamodels.datamodels.RefpixRefModel ### Description Handles the case where one passes in an already instantiated version of the model. In this case the constructor should just directly return the model. ### Class Signature `roman_datamodels.datamodels.RefpixRefModel(init=None, **kwargs)` ### Parameters - **init**: Optional - An already instantiated model to be returned directly. - **kwargs**: Optional - Additional keyword arguments. ``` -------------------------------- ### Pipeline Pattern: Build Output Model from Input Source: https://context7.com/spacetelescope/roman_datamodels/llms.txt Demonstrates a common pipeline pattern where an output model is created using `create_minimal` and populated with data from an input model. ```python input_dm = rdm.ScienceRawModel.create_fake_data(shape=(6, 4096, 4096)) output_dm = rdm.RampModel.create_minimal() output_dm.data = input_dm.data.astype("float32") output_dm.pixeldq = __import__("numpy").zeros(input_dm.data.shape[1:], dtype="uint32") output_dm.groupdq = __import__("numpy").zeros(input_dm.data.shape, dtype="uint8") output_dm.amp33 = input_dm.amp33.copy() ``` -------------------------------- ### MultibandSourceCatalogModel Constructor Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.MultibandSourceCatalogModel.md Initializes a MultibandSourceCatalogModel. If an already instantiated model is passed, it is returned directly. ```APIDOC ## MultibandSourceCatalogModel Constructor ### Description Handles the case where an already instantiated version of the model is passed in. In this case, the constructor should just directly return the model. ### Method __init__ ### Parameters - **init**: Optional - An already instantiated model. - **kwargs**: Optional - Additional keyword arguments. ``` -------------------------------- ### L1FaceGuidewindowModel Constructor Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.L1FaceGuidewindowModel.md Handles the case where an already instantiated version of the model is passed in. In this case, the constructor should just directly return the model. ```APIDOC ## L1FaceGuidewindowModel Constructor ### Description Handles the case where one passes in an already instantiated version of the model. In this case the constructor should just directly return the model. ### Signature `L1FaceGuidewindowModel(init=None, **kwargs)` ### Parameters - **init**: Optional - An already instantiated model. - **kwargs**: Optional - Additional keyword arguments. ``` -------------------------------- ### L1DetectorGuidewindowModel Constructor Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.L1DetectorGuidewindowModel.md The constructor for L1DetectorGuidewindowModel handles cases where an already instantiated version of the model is provided. In such scenarios, the constructor directly returns the existing model instance. ```APIDOC ## L1DetectorGuidewindowModel Constructor ### Description Handles the case where one passes in an already instantiated version of the model. In this case the constructor should just directly return the model. ### Signature `L1DetectorGuidewindowModel(init=None, **kwargs)` ### Parameters * **init**: Optional - An already instantiated model to be returned. * **kwargs**: Optional - Additional keyword arguments. ``` -------------------------------- ### Create Minimal WidgetModel Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/creating_datamodels.md Use `create_minimal` to instantiate a WidgetModel with only the mandatory 'meta.telescope' attribute set. Saving this model will fail validation due to missing 'meta.target' and 'data'. ```python # Example usage of create_minimal (assuming WidgetModel is defined) # widget_model = WidgetModel.create_minimal() # This would create a model with only meta.telescope = "ROMAN" ``` -------------------------------- ### Create Image Source Catalog Model Source: https://context7.com/spacetelescope/roman_datamodels/llms.txt Use `create_fake_data` to generate a source catalog model. ```python sc = rdm.ImageSourceCatalogModel.create_fake_data() print(type(sc.source_catalog)) print(sc.source_catalog.colnames[:3]) ``` -------------------------------- ### WfiImgPhotomRefModel Constructor Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.WfiImgPhotomRefModel.md The constructor for WfiImgPhotomRefModel handles cases where an already instantiated model is provided. In such scenarios, the constructor directly returns the existing model instance. ```APIDOC ## WfiImgPhotomRefModel Constructor ### Description Handles the case where one passes in an already instantiated version of the model. In this case the constructor should just directly return the model. ### Method Signature `roman_datamodels.datamodels.WfiImgPhotomRefModel(init=None, **kwargs)` ### Parameters - **init**: Optional - The initial model instance to use. - **kwargs**: Optional - Additional keyword arguments. ``` -------------------------------- ### WfiWcsModel.from_model_with_wcs Source: https://context7.com/spacetelescope/roman_datamodels/llms.txt Builds a WfiWcsModel from any post-assign_wcs model. It places the L2 WCS into wcs_l2 and a shifted L1 WCS into wcs_l1. WCS-related metadata is copied verbatim from the input. ```APIDOC ## WfiWcsModel.from_model_with_wcs ### Description Class method that builds a `WfiWcsModel` from any post-`assign_wcs` model. Places the L2 WCS into `wcs_l2` and a shifted L1 WCS (accounting for the reference pixel border) into `wcs_l1`. WCS-related metadata is copied verbatim from the input. ### Method `classmethod from_model_with_wcs(image_model: ImageModel, l1_border: int) -> WfiWcsModel` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from roman_datamodels import datamodels as rdm # Simulate a post-assign_wcs ImageModel img = rdm.ImageModel.create_fake_data(shape=(4096, 4096)) # (In real pipeline use, img.meta.wcs would be set by the assign_wcs step) wcs_model = rdm.WfiWcsModel.from_model_with_wcs(img, l1_border=4) print(type(wcs_model)) # # wcs_model.wcs_l2 — the Level 2 WCS object # wcs_model.wcs_l1 — the Level 1 WCS with extra 4-pixel border try: rdm.WfiWcsModel.from_model_with_wcs(rdm.RampModel.create_fake_data()) except ValueError as e: print(e) # Input must be an ImageModel ``` ### Response #### Success Response (200) - **wcs_model** (`WfiWcsModel`): The constructed WFI WCS model. #### Response Example ```json { "type": "WfiWcsModel", "wcs_l2": "...", "wcs_l1": "..." } ``` ``` -------------------------------- ### Initialize Empty WidgetModel Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/creating_datamodels.md Initializing a WidgetModel directly using its constructor creates an empty model. Saving this model will result in a validation error because all required attributes are missing. ```python # Example usage of Datamodel.__init__ (assuming WidgetModel is defined) # widget_model = WidgetModel() # This would create an empty model, failing validation on save. ``` -------------------------------- ### open Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/developer_api.md Datamodel open/create function. ```APIDOC ## open ### Description Datamodel open/create function. ### Signature `open(init[, memmap])` ``` -------------------------------- ### SerializationNode_Datamodels_1_3_0 Constructor Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels._stnode.SerializationNode_Datamodels__1_3_0.md Initializes a new instance of the SerializationNode_Datamodels_1_3_0 class. ```APIDOC ## class roman_datamodels._stnode.SerializationNode_Datamodels__1_3_0(data: _T, tag: str) ### Description Initializes a new instance of the SerializationNode_Datamodels_1_3_0 class. ### Parameters - **data** (_T) - The data to be serialized. - **tag** (str) - The tag associated with the serialization node. ``` -------------------------------- ### Extract WCS from calibrated image Source: https://context7.com/spacetelescope/roman_datamodels/llms.txt Use `WfiWcsModel.from_model_with_wcs` to build a WfiWcsModel from any post-assign_wcs model. It places the L2 WCS into `wcs_l2` and a shifted L1 WCS into `wcs_l1`. WCS-related metadata is copied verbatim. ```python from roman_datamodels import datamodels as rdm # Simulate a post-assign_wcs ImageModel img = rdm.ImageModel.create_fake_data(shape=(4096, 4096)) # (In real pipeline use, img.meta.wcs would be set by the assign_wcs step) wcs_model = rdm.WfiWcsModel.from_model_with_wcs(img, l1_border=4) print(type(wcs_model)) # # wcs_model.wcs_l2 — the Level 2 WCS object # wcs_model.wcs_l1 — the Level 1 WCS with extra 4-pixel border try: rdm.WfiWcsModel.from_model_with_wcs(rdm.RampModel.create_fake_data()) except ValueError as e: print(e) # Input must be an ImageModel ``` -------------------------------- ### Source Catalog models: Save and create empty Source: https://context7.com/spacetelescope/roman_datamodels/llms.txt Source catalog models support `to_parquet()` for saving with embedded metadata and `create_empty_catalog()` for building schema-compliant astropy Tables. `get_column_definition(name)` retrieves column details. ```python import pyarrow.parquet as pq import astropy.table as at from roman_datamodels import datamodels as rdm # --- Create a fake source catalog model --- sc = rdm.ImageSourceCatalogModel.create_fake_data() # --- Inspect the embedded table --- print(type(sc.source_catalog)) # astropy Table print(sc.source_catalog.colnames[:4]) # --- Query column definition --- first_col = sc.source_catalog.colnames[0] defn = sc.get_column_definition(first_col) print(defn) # {'unit': 'deg', 'description': 'Right ascension...', 'datatype': dtype('float64')} # --- Create an empty catalog with specific apertures and filters --- empty_cat = sc.create_empty_catalog(aperture_radii=[3, 5, 7], filters=["f106", "f184"]) print(empty_cat.colnames[:6]) # --- Save to Parquet (validates first, then writes) --- sc.to_parquet("/tmp/source_catalog.parquet") # --- Read back and check metadata --- schema = pq.read_schema("/tmp/source_catalog.parquet") print(schema.metadata[b"roman.meta.telescope"]) print(schema.field(first_col).metadata[b"unit"]) # --- Round-trip via astropy --- t = at.Table.read("/tmp/source_catalog.parquet", format="parquet") print(t[first_col].description) ``` -------------------------------- ### Source Catalog Models: to_parquet and create_empty_catalog Source: https://context7.com/spacetelescope/roman_datamodels/llms.txt Methods for handling source catalog models, including saving to Parquet format and creating empty, schema-compliant catalogs. ```APIDOC ## Source Catalog Models: `to_parquet` and `create_empty_catalog` ### Description `ImageSourceCatalogModel`, `MosaicSourceCatalogModel`, `ForcedImageSourceCatalogModel`, `ForcedMosaicSourceCatalogModel`, and `MultibandSourceCatalogModel` all inherit `to_parquet()` (save to Parquet with embedded metadata) and `create_empty_catalog()` (build an empty but schema-compliant `astropy.Table`). `get_column_definition(name)` returns the unit, description, and dtype for any catalog column by name. ### Methods - `to_parquet(path: str)`: Saves the source catalog to a Parquet file with embedded metadata. - `create_empty_catalog(aperture_radii: list, filters: list) -> astropy.table.Table`: Creates an empty `astropy.table.Table` that is schema-compliant with the catalog model, optionally specifying aperture radii and filters. - `get_column_definition(name: str) -> dict`: Returns the unit, description, and datatype for a given catalog column name. ### Request Example ```python import pyarrow.parquet as pq import astropy.table as at from roman_datamodels import datamodels as rdm # --- Create a fake source catalog model --- sc = rdm.ImageSourceCatalogModel.create_fake_data() # --- Inspect the embedded table --- print(type(sc.source_catalog)) # astropy Table print(sc.source_catalog.colnames[:4]) # --- Query column definition --- first_col = sc.source_catalog.colnames[0] defn = sc.get_column_definition(first_col) print(defn) # {'unit': 'deg', 'description': 'Right ascension...', 'datatype': dtype('float64')} # --- Create an empty catalog with specific apertures and filters --- empty_cat = sc.create_empty_catalog(aperture_radii=[3, 5, 7], filters=["f106", "f184"]) print(empty_cat.colnames[:6]) # --- Save to Parquet (validates first, then writes) --- sc.to_parquet("/tmp/source_catalog.parquet") # --- Read back and check metadata --- schema = pq.read_schema("/tmp/source_catalog.parquet") print(schema.metadata[b"roman.meta.telescope"]) # b'ROMAN' print(schema.field(first_col).metadata[b"unit"]) # --- Round-trip via astropy --- t = at.Table.read("/tmp/source_catalog.parquet", format="parquet") print(t[first_col].description) ``` ### Response #### Success Response (200) - **to_parquet**: Returns None, saves file to disk. - **create_empty_catalog**: Returns an `astropy.table.Table`. - **get_column_definition**: Returns a dictionary with column definition details. #### Response Example ```json { "to_parquet": null, "create_empty_catalog": "", "get_column_definition": { "unit": "deg", "description": "Right ascension...", "datatype": "float64" } } ``` ``` -------------------------------- ### Open and Inspect a Roman Datamodel Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/using_datamodels.md Demonstrates opening a datamodel file and accessing its basic properties like type, schema URI, and metadata. ```python >>> import roman_datamodels as rdm >>> dm = rdm.open('my_wonderful_roman_data.asdf') >>> type(dm) # Can view the associated schema >>> dm.schema_uri 'asdf://stsci.edu/datamodels/roman/schemas/wfi_science_raw-1.0.0' >>> print(dm.meta.instrument.optical_element) GRISM # Most nodes have special types >>> type(dm.meta.exposure) roman_datamodels.stnode.Exposure >>> print(dm.data.shape) (8, 4096, 4096) >>> print(dm.data.dtype) uint16 ``` -------------------------------- ### WfiWcsModel Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/developer_api.md Handles the case where one passes in an already instantiated version of the WfiWcsModel. ```APIDOC ## WfiWcsModel ### Description Handles the case where one passes in an already instantiated version of the model. ### Class WfiWcsModel ### Initialization `WfiWcsModel(init)` ``` -------------------------------- ### RampFitOutputModel Constructor Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.RampFitOutputModel.md Instantiates the RampFitOutputModel. If an already instantiated model is provided, it is returned directly. ```APIDOC ## RampFitOutputModel Constructor ### Description Handles the case where one passes in an already instantiated version of the model. In this case the constructor should just directly return the model. ### Method Signature `roman_datamodels.datamodels.RampFitOutputModel(init=None, **kwargs)` ### Parameters - **init**: Optional - An already instantiated model to be returned directly. - **kwargs**: Optional - Additional keyword arguments. ``` -------------------------------- ### DarkRefModel Constructor Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.DarkRefModel.md Initializes the DarkRefModel. If an already instantiated model is passed, it is directly returned. ```APIDOC ## roman_datamodels.datamodels.DarkRefModel ### Description Handles the case where one passes in an already instantiated version of the model. In this case the constructor should just directly return the model. ### Method __init__ ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python # Example usage (assuming DataModel and other necessary components are imported) # dark_ref_instance = DarkRefModel(init=existing_model_instance) ``` ### Response #### Success Response (200) Returns the instantiated DarkRefModel object. #### Response Example ```json { "example": "DarkRefModel object" } ``` ``` -------------------------------- ### MultibandSourceCatalogModel Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/developer_api.md Handles the case where one passes in an already instantiated version of the MultibandSourceCatalogModel. ```APIDOC ## MultibandSourceCatalogModel ### Description Handles the case where one passes in an already instantiated version of the model. ### Method N/A (Class constructor) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### AbvegaoffsetRefModel Constructor Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.AbvegaoffsetRefModel.md Handles the case where an already instantiated version of the model is passed in. In this case, the constructor should just directly return the model. ```APIDOC ## roman_datamodels.datamodels.AbvegaoffsetRefModel ### Description Handles the case where one passes in an already instantiated version of the model. In this case the constructor should just directly return the model. ### Class Signature `AbvegaoffsetRefModel(init=None, **kwargs)` ### Parameters * **init**: Optional - An already instantiated model to be returned directly. * **kwargs**: Optional - Additional keyword arguments. ``` -------------------------------- ### DarkdecaysignalRefModel Constructor Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.DarkdecaysignalRefModel.md Handles the case where an already instantiated version of the model is passed in. In this case, the constructor should just directly return the model. ```APIDOC ## roman_datamodels.datamodels.DarkdecaysignalRefModel ### Description Handles the case where one passes in an already instantiated version of the model. In this case the constructor should just directly return the model. ### Parameters * **init**: Optional - An already instantiated version of the model. * **kwargs**: Optional - Additional keyword arguments. ``` -------------------------------- ### SaturationRefModel Constructor Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.SaturationRefModel.md Instantiates the SaturationRefModel. If an existing model instance is passed, it is returned directly. ```APIDOC ## SaturationRefModel Constructor ### Description Handles the case where one passes in an already instantiated version of the model. In this case the constructor should just directly return the model. ### Method __init__ ### Parameters - **init**: Optional - An already instantiated model instance. - **kwargs**: Optional - Additional keyword arguments. ``` -------------------------------- ### RefpixRefModel Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/developer_api.md Handles the case where one passes in an already instantiated version of the RefpixRefModel. ```APIDOC ## RefpixRefModel ### Description Handles the case where one passes in an already instantiated version of the model. ### Class RefpixRefModel ### Initialization `RefpixRefModel(init)` ``` -------------------------------- ### IpcRefModel Constructor Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.IpcRefModel.md The constructor for IpcRefModel handles pre-instantiated models by returning them directly. ```APIDOC ## roman_datamodels.datamodels.IpcRefModel ### Description Handles the case where one passes in an already instantiated version of the model. In this case the constructor should just directly return the model. ### Method __init__ ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) Returns the instantiated model if one is passed in. #### Response Example None ``` -------------------------------- ### ImageModel Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/developer_api.md Handles the case where one passes in an already instantiated version of the ImageModel. ```APIDOC ## ImageModel ### Description Handles the case where one passes in an already instantiated version of the model. ### Method N/A (Class constructor) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### FileDate Class Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels._stnode.FileDate.md The FileDate class constructor and its inheritance. ```APIDOC ## Class roman_datamodels._stnode.FileDate ### Description The date and time this file was created. Class generated from tag ‘asdf://stsci.edu/datamodels/roman/tags/file_date-1.0.0’ ### Parameters - **val**: The primary value for the date/time. - **val2**: An optional secondary value for the date/time. - **format**: The format of the date/time value. - **scale**: The scale of the date/time value. - **precision**: The precision of the date/time value. - **in_subfmt**: The input sub-format. - **out_subfmt**: The output sub-format. - **location**: The location associated with the date/time. - **copy**: Boolean indicating whether to copy the input values. ``` -------------------------------- ### Create Dark Reference Model Source: https://context7.com/spacetelescope/roman_datamodels/llms.txt Use `create_fake_data` to generate a reference model with a specified shape. ```python dark = rdm.DarkRefModel.create_fake_data(shape=(6, 4096, 4096)) print(dark.data.shape) print(dark.meta.reftype) ``` -------------------------------- ### Create Fake WidgetModel Data Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/creating_datamodels.md Use `create_fake_data` to generate a valid WidgetModel with all required attributes populated with placeholder values. This model is ready for saving. ```python # Example usage of create_fake_data (assuming WidgetModel is defined) # widget_model = WidgetModel.create_fake_data() # This would create a model with meta.telescope="ROMAN", meta.target="?", and data filled with zeros. ``` -------------------------------- ### create_minimal Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.DataModel.md Class method that constructs an "minimal" model. ```APIDOC ## create_minimal(defaults=None, tag=None) ### Description Class method that constructs an "minimal" model. ### Parameters #### Query Parameters - **defaults** (dict) - Optional - Default values to use for the minimal model. - **tag** (str) - Optional - The tag to use for the model. ``` -------------------------------- ### Open Roman Datamodel with roman_datamodels.open Source: https://context7.com/spacetelescope/roman_datamodels/llms.txt Opens or creates a Roman datamodel from various sources like file paths, ASDF objects, or file-like objects. It handles filename mismatches and raises errors for non-Roman or unknown file types. Supports memory-mapping for large arrays and creating shallow copies of existing models. ```python import roman_datamodels as rdm from roman_datamodels.datamodels import FilenameMismatchWarning import warnings # --- Open from a file path --- with rdm.open("r0000101001001001001_01101_0001_WFI01_cal.asdf") as dm: print(type(dm)) # print(dm.schema_uri) # asdf://stsci.edu/datamodels/roman/schemas/wfi_image-1.x.x print(dm.meta.telescope) # ROMAN print(dm.data.shape) # (4096, 4096) ``` ```python import asdf from roman_datamodels._stnode import WfiImage # --- Open from an asdf.AsdfFile object --- tree = WfiImage.create_fake_data() with asdf.AsdfFile() as af: af.tree = {"roman": tree} dm = rdm.open(af) print(dm.meta.telescope) # ROMAN dm.close() ``` ```python # --- Open from a file-like object --- with open("image.asdf", "rb") as f: with rdm.open(f) as dm: print(dm.meta.instrument.optical_element) # e.g. F184 ``` ```python # --- Open with memory-mapping for large arrays --- with warnings.catch_warnings(): warnings.simplefilter("ignore", FilenameMismatchWarning) with rdm.open("large_ramp.asdf", memmap=True, mode="rw") as dm: dm.data[0, 100, 100] = 42 # written directly to disk ``` ```python # --- Re-open an existing model (shallow copy) --- original = rdm.open("image.asdf") copy = rdm.open(original) # returns a shallow copy; original can be closed safely original.close() print(copy.data.shape) copy.close() ``` ```python # --- Error cases --- try: rdm.open("not_roman.asdf") # raises ValueError: not a roman file except ValueError as e: print(e) try: rdm.open("missing.asdf") # raises FileNotFoundError except FileNotFoundError as e: print(e) ``` -------------------------------- ### L1DetectorGuidewindow Class Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels._stnode.L1DetectorGuidewindow.md The L1DetectorGuidewindow class is part of the roman_datamodels library and is generated from a specific ASDF tag. It inherits from TaggedObjectNode. ```APIDOC ## Class: roman_datamodels._stnode.L1DetectorGuidewindow ### Description Represents the Level 1 Detector Guide Star Window Information schema. ### Inheritance Bases: [`TaggedObjectNode`](roman_datamodels._stnode.TaggedObjectNode.md#roman_datamodels._stnode.TaggedObjectNode) ### Generation Class generated from tag ‘asdf://stsci.edu/datamodels/roman/tags/l1_detector_guidewindow-1.6.0’ ### Parameters * **node** (optional) - The node object to initialize the class with. ``` -------------------------------- ### Create Minimal ImageModel Skeleton Source: https://context7.com/spacetelescope/roman_datamodels/llms.txt Use `create_minimal` to construct a skeleton model for pipeline processing. This model is typically invalid and requires further population. Schema-mandated constants like telescope and origin are pre-filled. ```python from roman_datamodels import datamodels as rdm # --- Skeleton for pipeline code --- dm = rdm.ImageModel.create_minimal() print(dm.meta.telescope) print(dm.meta.origin) print(dm.meta.calibration_software_name) try: dm.validate() except Exception as e: print(type(e).__name__) ``` -------------------------------- ### IpcRefModel Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/developer_api.md Handles the case where one passes in an already instantiated version of the IpcRefModel. ```APIDOC ## IpcRefModel ### Description Handles the case where one passes in an already instantiated version of the model. ### Method N/A (Class constructor) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### ApcorrRefModel Constructor Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.ApcorrRefModel.md The ApcorrRefModel constructor handles the instantiation of the model. If an already instantiated version is passed, it is directly returned. ```APIDOC ## ApcorrRefModel(init=None, **kwargs) ### Description Handles the case where one passes in an already instantiated version of the model. In this case the constructor should just directly return the model. ### Parameters * **init**: Optional - The initial value for the model. * **kwargs**: Optional - Additional keyword arguments. ``` -------------------------------- ### SaturationRefModel Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/developer_api.md Handles the case where one passes in an already instantiated version of the SaturationRefModel. ```APIDOC ## SaturationRefModel ### Description Handles the case where one passes in an already instantiated version of the model. ### Class SaturationRefModel ### Initialization `SaturationRefModel(init)` ``` -------------------------------- ### MsosStackModel Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/developer_api.md Handles the case where one passes in an already instantiated version of the MsosStackModel. ```APIDOC ## MsosStackModel ### Description Handles the case where one passes in an already instantiated version of the model. ### Method N/A (Class constructor) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Configure IPython for Tab Completion Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/using_datamodels.md Add these lines to your IPython configuration to enable tab completion for dynamic attributes of datamodels. ```default c.IPCompleter.evaluation = "unsafe" c.IPCompleter.use_jedi = False ``` -------------------------------- ### ImageSourceCatalogModel Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/developer_api.md Handles the case where one passes in an already instantiated version of the ImageSourceCatalogModel. ```APIDOC ## ImageSourceCatalogModel ### Description Handles the case where one passes in an already instantiated version of the model. ### Method N/A (Class constructor) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### PixelareaRefModel Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/developer_api.md Handles the case where one passes in an already instantiated version of the PixelareaRefModel. ```APIDOC ## PixelareaRefModel ### Description Handles the case where one passes in an already instantiated version of the model. ### Method N/A (Class constructor) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### RampFitOutputModel Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/developer_api.md Handles the case where one passes in an already instantiated version of the RampFitOutputModel. ```APIDOC ## RampFitOutputModel ### Description Handles the case where one passes in an already instantiated version of the model. ### Class RampFitOutputModel ### Initialization `RampFitOutputModel(init)` ``` -------------------------------- ### TelescopeMixin Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/developer_api.md Mixin class for telescope-related functionality. ```APIDOC ## TelescopeMixin() ### Description Mixin class for telescope-related functionality. ### Method N/A ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### roman_datamodels.open Source: https://context7.com/spacetelescope/roman_datamodels/llms.txt Opens or creates a Roman datamodel from various sources like file paths, ASDF file objects, or file-like objects. It also supports shallow copying of existing DataModels and memory-mapping for large arrays. ```APIDOC ## roman_datamodels.open ### Description Reads an ASDF file (path, string, file-like object, or `asdf.AsdfFile`) and returns the appropriate `DataModel` subclass instance. Accepts an existing `DataModel` and returns a shallow copy. Automatically updates `meta.filename` in memory when the file name on disk does not match the stored value, emitting a `FilenameMismatchWarning`. Raises `ValueError` for non-Roman ASDF files and `TypeError` for unknown node types. ### Method `rdm.open(source, memmap=False, mode='r')` ### Parameters #### Path Parameters None #### Query Parameters - **memmap** (bool) - Optional - If True, memory-maps the file for large arrays. - **mode** (str) - Optional - The mode to open the file in (e.g., 'r', 'rw'). Defaults to 'r'. #### Request Body None ### Request Example ```python import roman_datamodels as rdm from roman_datamodels.datamodels import FilenameMismatchWarning import warnings # --- Open from a file path --- with rdm.open("r0000101001001001001_01101_0001_WFI01_cal.asdf") as dm: print(type(dm)) print(dm.schema_uri) print(dm.meta.telescope) print(dm.data.shape) # --- Open from an asdf.AsdfFile object --- import asdf from roman_datamodels._stnode import WfiImage tree = WfiImage.create_fake_data() with asdf.AsdfFile() as af: af.tree = {"roman": tree} dm = rdm.open(af) print(dm.meta.telescope) dm.close() # --- Open from a file-like object --- with open("image.asdf", "rb") as f: with rdm.open(f) as dm: print(dm.meta.instrument.optical_element) # --- Open with memory-mapping for large arrays --- with warnings.catch_warnings(): warnings.simplefilter("ignore", FilenameMismatchWarning) with rdm.open("large_ramp.asdf", memmap=True, mode="rw") as dm: dm.data[0, 100, 100] = 42 # --- Re-open an existing model (shallow copy) --- original = rdm.open("image.asdf") copy = rdm.open(original) original.close() print(copy.data.shape) copy.close() # --- Error cases --- try: rdm.open("not_roman.asdf") except ValueError as e: print(e) try: rdm.open("missing.asdf") except FileNotFoundError as e: print(e) ``` ### Response #### Success Response (200) Returns an instance of a `DataModel` subclass. #### Response Example ```json { "example": "" } ``` ``` -------------------------------- ### copy Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.DataModel.md Copies the DataModel instance. ```APIDOC ## copy(deepcopy=True, memo=None) ### Description Copies the DataModel instance. ### Parameters #### Query Parameters - **deepcopy** (bool) - Optional - Whether to perform a deep copy. Defaults to True. - **memo** (dict) - Optional - A dictionary to use for memoization during copying. ``` -------------------------------- ### Create ImageModel with Overridden Fields Source: https://context7.com/spacetelescope/roman_datamodels/llms.txt Use `create_fake_data` to generate a model and override specific metadata fields like filename and file_date. ```python from astropy.time import Time dm = rdm.ImageModel.create_fake_data( defaults={ "meta": { "filename": "r0000101001001001001_01101_0001_WFI01_cal.asdf", "file_date": Time("2024-01-15T10:30:00.0", format="isot", scale="utc"), } } ) print(dm.meta.filename) ``` -------------------------------- ### SegmentationMapModel Constructor Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.SegmentationMapModel.md Initializes a SegmentationMapModel. If an already instantiated model is passed, it is returned directly. ```APIDOC ## class roman_datamodels.datamodels.SegmentationMapModel(init=None, **kwargs) ### Description Handles the case where one passes in an already instantiated version of the model. In this case the constructor should just directly return the model. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **model** (SegmentationMapModel) - The instantiated model. ``` -------------------------------- ### DataModel.open_asdf Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.DataModel.md Opens an ASDF file, potentially with initialization parameters and other keyword arguments. ```APIDOC ## open_asdf(init=None, **kwargs) ``` -------------------------------- ### MultibandSegmentationMapModel Constructor Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.MultibandSegmentationMapModel.md The constructor for MultibandSegmentationMapModel accepts an optional initialized model or keyword arguments. If an initialized model is provided, it is directly returned. ```APIDOC ## MultibandSegmentationMapModel Constructor ### Description Handles the case where one passes in an already instantiated version of the model. In this case the constructor should just directly return the model. ### Method __init__ ### Parameters - **init** (optional) - The already instantiated model to return. - **kwargs** - Additional keyword arguments. ``` -------------------------------- ### DetectorstatusRefModel Constructor Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.DetectorstatusRefModel.md Instantiates the DetectorstatusRefModel. If an already instantiated model is provided, the constructor returns it directly. ```APIDOC ## DetectorstatusRefModel Constructor ### Description Handles the case where one passes in an already instantiated version of the model. In this case the constructor should just directly return the model. ### Method __init__ ### Parameters - **init**: Optional - An already instantiated model. - **kwargs**: Optional - Additional keyword arguments. ``` -------------------------------- ### FpsSdfSoftwareVersion Class Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels._stnode.FpsSdfSoftwareVersion.md Details about the FpsSdfSoftwareVersion class, which inherits from str and TaggedScalarNode. ```APIDOC ## Class: roman_datamodels._stnode.FpsSdfSoftwareVersion ### Description Represents the FPS SDF software version number. ### Inheritance - `str` - `TaggedScalarNode` ### Source Tag Generated from tag ‘asdf://stsci.edu/datamodels/roman/tags/fps/sdf_software_version-1.0.0’ ``` -------------------------------- ### EtcRefModel Constructor Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.EtcRefModel.md The constructor for EtcRefModel handles cases where an already instantiated model is provided. In such scenarios, the constructor directly returns the existing model instance. ```APIDOC ## roman_datamodels.datamodels.EtcRefModel ### Description Handles the case where one passes in an already instantiated version of the model. In this case the constructor should just directly return the model. ### Method __init__ ### Parameters - **init**: Optional - An already instantiated model object. - **kwargs**: Optional - Additional keyword arguments. ``` -------------------------------- ### DataModel Constructor Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.DataModel.md Initializes a DataModel instance. It can accept an already instantiated model to avoid re-initialization. ```APIDOC ## roman_datamodels.datamodels.DataModel ### Description Base class for all top level datamodels. Handles the case where one passes in an already instantiated version of the model. In this case the constructor should just directly return the model. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Attributes - **crds_observatory**: (type not specified) - Description not specified. - **override_handle** (type not specified) - override_handle identifies in-memory models where a filepath would normally be used. - **schema_uri** (type not specified) - Description not specified. - **shape** (type not specified) - Description not specified. ``` -------------------------------- ### RampModel Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/developer_api.md Handles the case where one passes in an already instantiated version of the RampModel. ```APIDOC ## RampModel ### Description Handles the case where one passes in an already instantiated version of the model. ### Class RampModel ### Initialization `RampModel(init)` ``` -------------------------------- ### IntegralnonlinearityRefModel Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/developer_api.md Handles the case where one passes in an already instantiated version of the IntegralnonlinearityRefModel. ```APIDOC ## IntegralnonlinearityRefModel ### Description Handles the case where one passes in an already instantiated version of the model. ### Method N/A (Class constructor) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### PixelareaRefModel Constructor Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/api/roman_datamodels.datamodels.PixelareaRefModel.md The constructor for PixelareaRefModel handles cases where an already instantiated version of the model is passed in. In such scenarios, the constructor directly returns the provided model. ```APIDOC ## PixelareaRefModel Constructor ### Description Handles the case where one passes in an already instantiated version of the model. In this case the constructor should just directly return the model. ### Method Signature `roman_datamodels.datamodels.PixelareaRefModel(init=None, **kwargs)` ### Parameters - **init**: Optional - An already instantiated model to be used for initialization. - **kwargs**: Arbitrary keyword arguments. ``` -------------------------------- ### MosaicModel Source: https://github.com/spacetelescope/roman_datamodels/blob/main/docs/roman_datamodels/datamodels/developer_api.md Handles the case where one passes in an already instantiated version of the MosaicModel. ```APIDOC ## MosaicModel ### Description Handles the case where one passes in an already instantiated version of the model. ### Method N/A (Class constructor) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ```