spacetelescope / roman_datamodels

Datamodel support for the roman calibration pipeline
https://roman-datamodels.readthedocs.io
Other
7 stars 21 forks source link

Add WCS to metadata in create_wfi_image #134

Closed bmorris3 closed 1 year ago

bmorris3 commented 1 year ago

Over in jdaviz we're working on supporting Roman L2 data products (spacetelescope/jdaviz#1822). I've been testing our Roman ASDF support on some old SOC build files, but having smaller/artificial ImageModels would be helpful. Today I came across rdm.testing.factors.create_wfi_image, which nearly does what we need!

On main, the synthetic WFI image created by this method only has a photometry key in the metadata, but no wcs:

https://github.com/spacetelescope/roman_datamodels/blob/932afed416e02bf0e684973f03548eeefe973b9e/src/roman_datamodels/testing/factories.py#L1259

Would it be possible to add a simple WCS, too? We do something like this in jdaviz for testing.

Thanks!

bmorris3 commented 1 year ago

From some further reading, it looks like full WCS is stored for Level 2 products but not for Level 1. Are there other important subtleties that might make create_wfi_image inappropriate for use for synthetic test data generation?

PaulHuwe commented 1 year ago

The utilities you want for making models (and/or files) are located in maker_utils.py:

Level 1 https://github.com/spacetelescope/roman_datamodels/blob/main/src/roman_datamodels/maker_utils.py#L427

Level 2 https://github.com/spacetelescope/roman_datamodels/blob/main/src/roman_datamodels/maker_utils.py#L470

This file holds maker utilities for all sorts of models and meta objects, should you require them.

PaulHuwe commented 1 year ago

There are other subtleties - Level 1 files are simply the input to the pipeline, whereas Level 2 is output from any step from Ramp onwards (which may include models that lack WCS).

bmorris3 commented 1 year ago

Thanks for the background @PaulHuwe. I've got an example which generates synthetic gwcs and attaches them to an ImageModel for a test in jdaviz, see create_example_gwcs and https://github.com/spacetelescope/jdaviz/pull/1822#pullrequestreview-1351142503. Happy to add this to maker_utils.py if you like.

ddavis-stsci commented 1 year ago

I'm closing this issue since skymatch & jdaviz issues are closed.