From cf3f85f854e20e85818273754b136fdf8d4d0251 Mon Sep 17 00:00:00 2001 From: Brett Graham Date: Wed, 4 Dec 2024 13:39:32 -0500 Subject: [PATCH] Add `CALIB` and wcsinfo to ami schema (#357) --- changes/357.feature.rst | 1 + .../jwst/datamodels/schemas/ami.schema.yaml | 34 +++++++++++++++++++ .../jwst/datamodels/schemas/amioi.schema.yaml | 1 + .../jwst/datamodels/tests/test_models.py | 6 ++++ .../jwst/datamodels/tests/test_schema.py | 18 ++++++++++ 5 files changed, 60 insertions(+) create mode 100644 changes/357.feature.rst create mode 100644 src/stdatamodels/jwst/datamodels/schemas/ami.schema.yaml diff --git a/changes/357.feature.rst b/changes/357.feature.rst new file mode 100644 index 00000000..724913e8 --- /dev/null +++ b/changes/357.feature.rst @@ -0,0 +1 @@ +Add CALIB and PA keywords to amioi schema diff --git a/src/stdatamodels/jwst/datamodels/schemas/ami.schema.yaml b/src/stdatamodels/jwst/datamodels/schemas/ami.schema.yaml new file mode 100644 index 00000000..ff5cd290 --- /dev/null +++ b/src/stdatamodels/jwst/datamodels/schemas/ami.schema.yaml @@ -0,0 +1,34 @@ +%YAML 1.1 +--- +$schema: "http://stsci.edu/schemas/fits-schema/fits-schema" +id: "http://stsci.edu/schemas/jwst_datamodel/ami.schema" +allOf: +- $ref: wcsinfo.schema +- type: object + properties: + meta: + type: object + properties: + ami: + type: object + properties: + calibrator_object_id: + title: "Calibration object identifier" + type: string + fits_keyword: CALIB + blend_table: True + roll_ref: + title: "[deg] V3 roll angle at the ref point (N over E)" + type: number + fits_keyword: ROLL_REF + blend_table: True + v3yangle: + title: "[deg] Angle from V3 axis to Ideal y axis" + type: number + fits_keyword: V3I_YANG + blend_table: True + vparity: + title: Relative sense of rotation between Ideal xy and V2V3 + type: integer + fits_keyword: VPARITY + blend_table: True diff --git a/src/stdatamodels/jwst/datamodels/schemas/amioi.schema.yaml b/src/stdatamodels/jwst/datamodels/schemas/amioi.schema.yaml index 32d85365..6f00db9c 100644 --- a/src/stdatamodels/jwst/datamodels/schemas/amioi.schema.yaml +++ b/src/stdatamodels/jwst/datamodels/schemas/amioi.schema.yaml @@ -5,3 +5,4 @@ id: "http://stsci.edu/schemas/jwst_datamodel/amioi.schema" title: AMI OIFITS analysis data model allOf: - $ref: oifits.schema +- $ref: ami.schema diff --git a/src/stdatamodels/jwst/datamodels/tests/test_models.py b/src/stdatamodels/jwst/datamodels/tests/test_models.py index 5a76a00b..83e65ff8 100644 --- a/src/stdatamodels/jwst/datamodels/tests/test_models.py +++ b/src/stdatamodels/jwst/datamodels/tests/test_models.py @@ -573,6 +573,12 @@ def test_amioi_model_oifits_extra_columns(tmp_path, oifits_ami_model, table_name oifits_ami_model.save(fn) +def test_amioi_model_extra_meta(tmp_path, oifits_ami_model): + oifits_ami_model.meta.ami.calibrator_object_id = "foo" + fn = tmp_path / "test.fits" + oifits_ami_model.save(fn) + + def test_dq_def_roundtrip(tmp_path): """ Open a MaskModel with a defined DQ array and dq_def that modifies the diff --git a/src/stdatamodels/jwst/datamodels/tests/test_schema.py b/src/stdatamodels/jwst/datamodels/tests/test_schema.py index 1bf642a6..7c331d77 100644 --- a/src/stdatamodels/jwst/datamodels/tests/test_schema.py +++ b/src/stdatamodels/jwst/datamodels/tests/test_schema.py @@ -92,3 +92,21 @@ def test_data_array(tmp_path): assert x == set( [('FOO', 2), ('FOO', 1), ('ASDF', None), ('DQ', 2), (None, None)]) + + +def test_ami_wcsinfo(): + """ + The ami and wcsinfo schemas contain duplicate information + since ami products don't otherwise contain a SCI extension. + This test checks that the schema entries for the duplicated + information stays in sync. + """ + wcsinfo_schema = mschema.load_schema("http://stsci.edu/schemas/jwst_datamodel/wcsinfo.schema") + ami_schema = mschema.load_schema("http://stsci.edu/schemas/jwst_datamodel/ami.schema") + ami_def = ami_schema["allOf"][1]["properties"]["meta"]["properties"]["ami"]["properties"] + wcsinfo_def = wcsinfo_schema["properties"]["meta"]["properties"]["wcsinfo"]["properties"] + for keyword in ("roll_ref", "v3yangle", "vparity"): + ami = ami_def[keyword] + wcsinfo = wcsinfo_def[keyword] + for key in set(ami.keys()) | set(wcsinfo.keys()) - {"fits_hdu"}: + assert ami[key] == wcsinfo[key]