Skip to content

CR-Rejection wrapper for calstis — crrej_from_raw()#159

Merged
sean-lockwood merged 7 commits into
masterfrom
sl_override_crrej
Feb 18, 2025
Merged

CR-Rejection wrapper for calstis — crrej_from_raw()#159
sean-lockwood merged 7 commits into
masterfrom
sl_override_crrej

Conversation

@sean-lockwood

Copy link
Copy Markdown
Member

This code does the following:

  • parse an input RAW STIS file for the CRREJTAB
  • determine the appropriate row from the default CRREJTAB
  • determine user overrides for the various CRREJTAB columns
  • write a temporary CRREJTAB
  • update the input RAW file to use the temporary CRREJTAB and add a HISTORY line
  • run calstis on the RAW file
  • revert the CRREJTAB and HISTORY in the RAW file

Note on testing:
The associated tests only check that input parameters do not fail immediately. The calls to calstis are terminated early by making the test data not contain a data table. So, output FITS products are not tested for the desired changes in the CRREJTAB.

@awfullerton: Let me know if you have any feedback on the interface or the routine name.

@sean-lockwood

sean-lockwood commented May 15, 2023

Copy link
Copy Markdown
Member Author

@sean-lockwood sean-lockwood changed the title CR-Rejection wrapper for calstis — override_crrej() CR-Rejection wrapper for calstis — crrej_from_raw() May 26, 2023
@sean-lockwood sean-lockwood marked this pull request as ready for review May 26, 2023 18:40
@sean-lockwood sean-lockwood requested a review from a team as a code owner May 26, 2023 18:40
@sean-lockwood

sean-lockwood commented May 26, 2023

Copy link
Copy Markdown
Member Author

@stscirij -
I wasn't able to get the test code to work in the tests/ directory on my system, likely due to the conftest.py conflicting with the bare tests generated to test this routine. It does work fine when moved to another location.

Any thoughts on how to get this working properly would be appreciated.

UPDATE:
Testing issues have been resolved in the repo. The tests now work on my system locally.

@sean-lockwood

Copy link
Copy Markdown
Member Author

Tests now look good:

pytest -vv test_crrej_from_raw.py

============================================================================= test session starts ==============================================================================
platform darwin -- Python 3.11.3, pytest-8.3.4, pluggy-1.5.0 -- /Users/lockwood/miniconda3/envs/stenv-macOS-ARM64-py3.11-2023.06.08/bin/python3
cachedir: .pytest_cache
rootdir: /Users/lockwood/git/stis/stistools-testing
configfile: pyproject.toml
plugins: asdf-2.15.0, jwst-1.10.2, ci_watson-0.8.0, xdist-3.3.1, anyio-3.7.0
collected 31 items

test_crrej_from_raw.py::Test_crrej_from_raw::test_user_crrejtab PASSED                                                                                                   [  3%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_meanexp_selection[1.2-4.4] PASSED                                                                                      [  6%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_meanexp_selection[4.4-4.4] PASSED                                                                                      [  9%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_bad_meanexp_selection PASSED                                                                                           [ 12%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_scalense PASSED                                                                                                        [ 16%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_initgues[minimum] PASSED                                                                                               [ 19%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_initgues[median] PASSED                                                                                                [ 22%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_bad_initgues PASSED                                                                                                    [ 25%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_skysub[none] PASSED                                                                                                    [ 29%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_skysub[mode] PASSED                                                                                                    [ 32%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_bad_skysub PASSED                                                                                                      [ 35%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_crsigmas[3] PASSED                                                                                                     [ 38%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_crsigmas[3,4] PASSED                                                                                                   [ 41%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_crsigmas[3,4.0] PASSED                                                                                                 [ 45%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_crsigmas[5] PASSED                                                                                                     [ 48%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_crsigmas[5.2] PASSED                                                                                                   [ 51%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_crradius PASSED                                                                                                        [ 54%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_crthresh[1.1] PASSED                                                                                                   [ 58%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_crthresh[3] PASSED                                                                                                     [ 61%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_crthresh[0] PASSED                                                                                                     [ 64%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_crthresh[-2.0] PASSED                                                                                                  [ 67%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_badinpdq[18] PASSED                                                                                                    [ 70%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_badinpdq[2.0001] PASSED                                                                                                [ 74%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_badinpdq[9600] PASSED                                                                                                  [ 77%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_crmask[True] PASSED                                                                                                    [ 80%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_crmask[False] PASSED                                                                                                   [ 83%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_crmask[None] PASSED                                                                                                    [ 87%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_crmask[1] PASSED                                                                                                       [ 90%]
test_crrej_from_raw.py::Test_crrej_from_raw::test_crmask[0] PASSED                                                                                                       [ 93%]
test_crrej_from_raw.py::Test_versions::test_version PASSED                                                                                                               [ 96%]
test_crrej_from_raw.py::Test_versions::test_revision PASSED                                                                                                              [100%]

=============================================================================== warnings summary ===============================================================================
../stistools/sshift.py:221
  /Users/lockwood/git/stis/stistools-testing/stistools/sshift.py:221: DeprecationWarning: invalid escape sequence '\.'
    outfile = re.sub('flt\.', 'sfl.', infile, count=1)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================================== 31 passed, 1 warning in 2.66s =========================================================================

The warning is unrelated to this code.

@sean-lockwood

sean-lockwood commented Feb 13, 2025

Copy link
Copy Markdown
Member Author

@stscirij, @Jackie-Brown -
This PR should be ready to review.

Update: Well, now after PEP8 updates.

@stscirij stscirij left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good.
Maybe add a unit test to verify that the input file is left unchanged after running, since it looks like there's some writing to and removing from the file

@sean-lockwood

Copy link
Copy Markdown
Member Author

@stscirij -
Thanks! I've added a test for that.

@stscirij stscirij left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@stscirij

Copy link
Copy Markdown
Contributor

Maybe also fix the deprecation warning? I think it turns into a syntax error in 3.12. Just need to turn the string into an r-string I think...

@sean-lockwood

sean-lockwood commented Feb 14, 2025

Copy link
Copy Markdown
Member Author

Oh, that should be an easy fix. Will do today.

Update: PR #175

@sean-lockwood sean-lockwood merged commit a564e57 into master Feb 18, 2025
@sean-lockwood sean-lockwood deleted the sl_override_crrej branch February 18, 2025 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants