-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add miri lrs spec wcs model #393
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #393 +/- ##
==========================================
+ Coverage 78.16% 78.28% +0.11%
==========================================
Files 115 110 -5
Lines 5144 5158 +14
==========================================
+ Hits 4021 4038 +17
+ Misses 1123 1120 -3 ☔ View full report in Codecov by Sentry. |
33a6407
to
f85885d
Compare
@braingram This PR is ready for another review |
This is ready to be merged so we can get the new reference file in CRDS |
Would you fix the failing style check? I think a few comments/suggestions were lost when this new PR was opened. Would you also add a unit test (re: #382 (comment))? Also:
Is there an example file yet for this reference model? If so, would you share it so I can test this PR? |
--- | ||
$schema: "http://stsci.edu/schemas/asdf/asdf-schema-1.1.0" | ||
id: "http://stsci.edu/schemas/jwst_datamodel/specwcs_miri_lrs.schema" | ||
title: MIRI LRS Spec Schema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
title: MIRI LRS Spec Schema | |
title: MIRI LRS Fixed Slit Specwcs Schema |
- $ref: keyword_exptype.schema | ||
- $ref: keyword_readpatt.schema | ||
- $ref: keyword_filter.schema | ||
- $ref: keyword_band.schema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are band
and readpatt
really necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think they are needed
type: number | ||
title: y coord of ref position of MIRIM_SLITLESS | ||
default: pixels | ||
fits_keyword: IMYSLTL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this schema going to be used for SLITLESS mode? Do we expect a slitless mode reference file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This schema is supposed to work for both FIX slit and slitless. The slitless data does not need the v2/v3 vertices just the FIXED slit case
class MiriLRSSpecwcsModel(ReferenceFileModel): | ||
""" | ||
A model for a reference file of type "specwcs" for MIRI LRS Slit. | ||
The model is for the specwcs for LRS Fixed Slit and LRSSlitless |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we expect an LRS slitless reference file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nden Let me clarify as understand it there is a reference file for FIXED slit and a reference file for SLITLESS. But Both of these files are read in with the same datamodel. The existing slitless reference on CRDS will be used.
A new reference file for FIXED SLIT LRS will have the v2,v3 vertices.
Do you see any problem with this. I tested reading in the new reference file for LRS FIXED slit and the existing slitless reference file using this 1 datamodel model and they are read in correctly
def populate_meta(self): | ||
self.meta.instrument.name = "MIRI" | ||
self.meta.instrument.detector = "MIRIMAGE" | ||
self.meta.reftype = self.reftype |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs more keywords to define a LRS fixed slit mode - filter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added self.meta.instrument.filter = 'P750L'
@braingram I have an example reference file. How should I share it with you ? |
Would you upload it to the linked jira ticket? The link in the description is broken, would you fix that as well? |
@braingram |
@braingram Sorry I am not tracking. This is how I am using the MIRILRS one: So do I need it in test_schema_against_crds.py ? |
@braingram I added a unit test for this new model. I wrote this to test it was working as expected - I am not sure if it is what you want for a unit test. |
b6a1bd6
to
3b7c32d
Compare
Yeah I would say so. I believe @tapastro wrote the test originally. I think it's a bug (or lack of coverage) that |
@braingram Sorry again "specwcs": dm.SpecwcsModel, dm.MiriLRSSpecwcsModel, |
@braingram Maybe I need to do something like cubepar_model_map does and then add it to |
@jemorrison It looks like your recent updates got you most of the way there - there was a typo in the NRC_WFSS exposure type, and once that is added it uncovered a bug in the NIRCam grism model that this test was designed to catch - so I added the schema reference to fix it. We'll see if tests pass now! |
src/stdatamodels/jwst/datamodels/tests/test_specwcs_mirilrs_datamodel.py
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the test updates and pointing me to the example file.
I left a few comments about:
- adding a call to validate in the unit test
- clarification of the
default
schema values - a comment/question about the reftype in the example file causing validation failure
try: | ||
assert self.meta.instrument.name == "MIRI" | ||
assert self.meta.instrument.detector == "MIRIMAGE" | ||
assert self.meta.reftype == self.reftype |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fails with the example file which has SPECWCS
instead of specwcs
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so is this really a failure of the reference file not having the correction retype ?
Is it ok to do this to account for that problem
assert self.meta.reftype == self.reftype.lower()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I have been using the example reference file and this model to read in the data. So how does it fail for you ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I ran was:
>> import stdatamodels.jwst.datamodels as dm
>> m = dm.MiriLRSSpecwcsModel("jwst_miri_specwcs_2025jan17.fits")
>> m.validate()
<ipython-input-5-6a8bfee86cf8>:1: ValidationWarning: Traceback (most recent call last):
File "/Users/bgraham/projects/src/stdatamodels/src/stdatamodels/jwst/datamodels/wcs_ref_models.py", line 500, in validate
assert self.meta.reftype == self.reftype
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
m.validate()
This might just be an issue with the example file. Presumably the model will be used to generate a new reference model. In that case reftype
will match (since it's set in populate_meta
). However if I make a blank reference model it also fails to validate:
>>> m = dm.MiriLRSSpecwcsModel()
>>> m.validate()
/Users/bgraham/projects/src/stdatamodels/src/stdatamodels/jwst/datamodels/reference.py:41: ValidationWarning: Model.meta is missing values for ['description', 'author', 'pedigree', 'useafter']
self.print_err(f"Model.meta is missing values for {to_fix}")
@tapastro is that expected? I'm not that familiar with how these reference models are used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure the reference model will be used to create the reference file. It is being created in IDL.
So my test is probably not as complete as yours
from stdatamodels.jwst import datamodels
file = 'jwst_miri_specwcs_2025jan17.fits'
model = datamodels.MiriLRSSpecwcsModel(file)
that seems to work fine
When I added this line to validate MiriLRSSpecwcs function in wcs_ref_models.py assert self.meta.reftype.lower() == self.reftype
It now validates - is that cheating ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that might be a crds question. @stscieisenhamer are there any special requirements for reference file reftype
(are they case sensitive)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at a number of other reference files currently in CRDS it looks like those too have capitalized reftype values; e.g., APCORR, CUBEPAR, GAIN, etc.
src/stdatamodels/jwst/datamodels/schemas/specwcs_miri_lrs.schema.yaml
Outdated
Show resolved
Hide resolved
@tapastro @braingram I am still getting an error when I run pytest test_schema_against_crds.py pytest test_schema_against_crds.py |
I had the same issue - stdatamodels has a test configuration file in the base test directory that doesn't get picked up if you run these JWST tests in their local directory. If cd to the stdatamodels base directory and run something like |
@tapastro running pytest -k selectors did the trick. Now I can get test_schema_against_crds.py @braingram I think all the changes have been made that are requested. We still need to determine about the reftype term and if it matters if it is SPECWCS or specwcs. I will ask at standup, but I can read the reference file and read in the contents so it works as expected and the retype in the reference file is SPECWCS so it seems fine to me |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These suggestions update the titles to follow the convention of having the unit in square brackets at the start of the title. This convention is followed by many of the existing keywords (see the core schema for some examples) and I suggest that we follow it for new keywords.
src/stdatamodels/jwst/datamodels/schemas/specwcs_miri_lrs.schema.yaml
Outdated
Show resolved
Hide resolved
src/stdatamodels/jwst/datamodels/schemas/specwcs_miri_lrs.schema.yaml
Outdated
Show resolved
Hide resolved
src/stdatamodels/jwst/datamodels/schemas/specwcs_miri_lrs.schema.yaml
Outdated
Show resolved
Hide resolved
src/stdatamodels/jwst/datamodels/schemas/specwcs_miri_lrs.schema.yaml
Outdated
Show resolved
Hide resolved
src/stdatamodels/jwst/datamodels/schemas/specwcs_miri_lrs.schema.yaml
Outdated
Show resolved
Hide resolved
src/stdatamodels/jwst/datamodels/schemas/specwcs_miri_lrs.schema.yaml
Outdated
Show resolved
Hide resolved
src/stdatamodels/jwst/datamodels/schemas/specwcs_miri_lrs.schema.yaml
Outdated
Show resolved
Hide resolved
src/stdatamodels/jwst/datamodels/schemas/specwcs_miri_lrs.schema.yaml
Outdated
Show resolved
Hide resolved
src/stdatamodels/jwst/datamodels/schemas/specwcs_miri_lrs.schema.yaml
Outdated
Show resolved
Hide resolved
src/stdatamodels/jwst/datamodels/schemas/specwcs_miri_lrs.schema.yaml
Outdated
Show resolved
Hide resolved
Thanks. The changes pushed in 823ee64 don't match the suggestions. They contain yaml syntax errors that are causing the CI failures and the failure you're seeing. There are also still "unit" keywords left in the table datatype that I suggested to remove. |
@braingram Ok thanks I missed the yaml errors and I misunderstood about units. I think I may finally have it. |
fd1e349
to
2306d45
Compare
src/stdatamodels/jwst/datamodels/schemas/specwcs_miri_lrs.schema.yaml
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the updates to this. The changes look good to me.
Would you run the regression tests with this PR?
Otherwise I'll leave the approval up to @nden
@braingram To run the regression tests on datamodels do I just select the JWST Calibration Pipeline workflow and set the git repo the spacetelescope/datamodels. Or is running a regression test on the jwst branch I have made that uses this datamodel model sufficient to test this ? |
4dfedb4
to
9c0fae9
Compare
I think the most useful run for this PR would be using |
@braingram results of regression test: |
Helps Resolve JP-3848
This PR replaces #382. There we too many conflicts to resolve easily after the code style changes were made.
Closes #
Corresponding jwst PR: spacetelescope/jwst#9193
This PR adds a datamodel of the reference file, specwcs, for MIRI LRS data. It can be used for fixed slit or slitless data. The reference file for fixed slit contains the V2,V3 corners of the slit. These values are not in the slitless reference file and default to None when the reference files are read in using the data models
Tasks
docs/
pageno-changelog-entry-needed
)changes/
:echo "changed something" > changes/<PR#>.<changetype>.rst
(see below for change types)jwst
regression tests with this branch installed ("git+https://github.com/<fork>/stdatamodels@<branch>"
)news fragment change types...
changes/<PR#>.feature.rst
: new featurechanges/<PR#>.bugfix.rst
: fixes an issuechanges/<PR#>.doc.rst
: documentation changechanges/<PR#>.removal.rst
: deprecation or removal of public APIchanges/<PR#>.misc.rst
: infrastructure or miscellaneous change