spacetelescope / jwst

Python library for science observations from the James Webb Space Telescope
https://jwst-pipeline.readthedocs.io/en/latest/
Other
570 stars 167 forks source link

Move common resample code to stcal #8695

Open mcara opened 3 months ago

mcara commented 3 months ago

This PR add the common resample code used by both JWST and Roman pipelines to stcal. Also, for the first time, this PR adopts the new drizzle API from https://github.com/spacetelescope/drizzle/pull/134 for the resample code used in the pipelines. For now only imaging mode was switched to the new code

This work is related to https://jira.stsci.edu/browse/AL-835

The code in this PR requires the code from https://github.com/spacetelescope/stcal/pull/279 and https://github.com/spacetelescope/drizzle/pull/134 be installed.

At this moment this is a very rough draft for illustration purpose. It should run with default arguments (except input_models and output file name can be specified; everything else is not guaranteed to work). There are no unit/regression tests and documentation may not match the code. Also, for now I kept the old ResampleData code to allow resampling of spectral data to work with the old code.

Example:

from stdatamodels.jwst.datamodels import ModelContainer
from jwst.resample import ResampleStep
from jwst import resample as jr
step = ResampleStep(ModelContainer(['jw01536070001_0210l_00001_nis_cal.fits']))
step.call(f, single=False)

Checklist for PR authors (skip items if you don't have permissions or they are not applicable)

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 4.38356% with 349 lines in your changes missing coverage. Please review.

Project coverage is 55.47%. Comparing base (1561909) to head (f6677e8). Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
jwst/resample/resample.py 3.37% 143 Missing :warning:
jwst/resample/resample_step.py 4.58% 104 Missing :warning:
jwst/resample/gwcs_drizzle.py 3.22% 90 Missing :warning:
jwst/resample/resample_utils.py 22.22% 7 Missing :warning:
jwst/resample/resample_spec_step.py 16.66% 5 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #8695 +/- ## ========================================== - Coverage 61.92% 55.47% -6.46% ========================================== Files 376 377 +1 Lines 38685 38962 +277 ========================================== - Hits 23957 21615 -2342 - Misses 14728 17347 +2619 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

braingram commented 1 month ago

Thanks for sharing this. I started to look at the changes but haven't made it all the way through yet. I started 2 branches off of yours: https://github.com/mcara/jwst/compare/new-resample-cls...braingram:jwst:resample_2p0_bjg?expand=1 https://github.com/mcara/stcal/compare/resample-common-code...braingram:stcal:resample_2p0_bjg?expand=1 I wanted to share them sooner (even though they're far from complete). The main changes are to simplify LibModelAccess removing all but the attribute list effectively untangling it from ModelLibrary. I left a number of notes (mostly for reminders for myself). I restored resample_utils from main as it contains a bug in this PR that makes make_output_wcs crash. This restore likely broke something else but as these branches are quite out-of-date it hopefully doesn't interfere with the prototype.

mcara commented 1 month ago

I will take care of pre-commit tests in a day.