Skip to content
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

RCAL-895: allow updating source catalog with tweaked WCS when running ELP #1373

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

mairanteodoro
Copy link
Collaborator

@mairanteodoro mairanteodoro commented Aug 20, 2024

Resolves RCAL-895

This PR implements the update of the source catalog coordinates using the improved WCS calculated by TweakRegStep when processing data through the ELP.

When running the ELP, at the end of the TweakRegStep, the cat file produced by SourceCatalogStep (containing all the sources coordinates) will be read in, updated with the new WCS function, and saved back to disk (overwriting the file content).

Regression tests
All tests are passing: https://github.com/spacetelescope/RegressionTests/actions/runs/10892193910

Checklist

  • added entry in CHANGES.rst under the corresponding subsection
  • updated relevant tests
  • updated relevant documentation
  • updated relevant milestone(s)
  • added relevant label(s)
  • ran regression tests, post a link to the Jenkins job below. How to run regression tests on a PR

@mairanteodoro mairanteodoro added this to the 24Q4_B15 milestone Aug 20, 2024
@mairanteodoro mairanteodoro self-assigned this Aug 20, 2024
@mairanteodoro mairanteodoro changed the title Allow updating source catalog with tweaked WCS when running ELP. RCAL-895: allow updating source catalog with tweaked WCS when running ELP Aug 20, 2024
Copy link

codecov bot commented Aug 20, 2024

Codecov Report

Attention: Patch coverage is 78.57143% with 6 lines in your changes missing coverage. Please review.

Project coverage is 78.57%. Comparing base (96af8bb) to head (75fde2d).

Files with missing lines Patch % Lines
romancal/tweakreg/tweakreg_step.py 81.48% 5 Missing ⚠️
romancal/pipeline/exposure_pipeline.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1373      +/-   ##
==========================================
+ Coverage   78.52%   78.57%   +0.05%     
==========================================
  Files         117      117              
  Lines        7842     7857      +15     
==========================================
+ Hits         6158     6174      +16     
+ Misses       1684     1683       -1     
Flag Coverage Δ *Carryforward flag
nightly 62.29% <ø> (ø) Carriedforward from ff9c455

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mairanteodoro mairanteodoro marked this pull request as ready for review August 23, 2024 14:29
romancal/tweakreg/tweakreg_step.py Outdated Show resolved Hide resolved
romancal/tweakreg/tweakreg_step.py Outdated Show resolved Hide resolved
@@ -71,6 +71,8 @@ def process(self, input):

# make sure source_catalog returns the updated datamodel
self.source_catalog.return_updated_model = True
# make sure we update source catalog coordinates afer running TweakRegStep
self.tweakreg.update_source_catalog_coordinates = True
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like this attribute is set here and only here. Patching the step object like this is not a good idea.
It should be added to the step spec with a default value.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Mairan, Nadia and I chatted briefly about this earlier today, and I had gotten confused with the related self.source_catalog.return_updated_model above. Let's make this default False for now, but it could go into the spec I think?

romancal/tweakreg/tests/test_tweakreg.py Show resolved Hide resolved
romancal/tweakreg/tests/test_tweakreg.py Show resolved Hide resolved
Copy link
Collaborator

@schlafly schlafly left a comment

Choose a reason for hiding this comment

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

Thanks Mairan, looks, good, one comment inline.

romancal/tweakreg/tests/test_tweakreg.py Outdated Show resolved Hide resolved
CHANGES.rst Outdated Show resolved Hide resolved
@github-actions github-actions bot added the dependencies Pull requests that update a dependency file label Sep 17, 2024
@ddavis-stsci ddavis-stsci modified the milestones: 24Q4_B15, 25Q1_B16 Sep 19, 2024
Comment on lines +1293 to +1310
assert not filecmp.cmp("img_1_cat.asdf", "img_1_cat_original.asdf")
# compare coordinates using rtol=1e-07 and atol=0 (default)
np.testing.assert_allclose(
cat_original.source_catalog["ra_centroid"],
cat_updated.source_catalog["ra_centroid"],
)
np.testing.assert_allclose(
cat_original.source_catalog["dec_centroid"],
cat_updated.source_catalog["dec_centroid"],
)
np.testing.assert_allclose(
cat_original.source_catalog["ra_psf"],
cat_updated.source_catalog["ra_psf"],
)
np.testing.assert_allclose(
cat_original.source_catalog["dec_psf"],
cat_updated.source_catalog["dec_psf"],
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you help me with this test? The test is that the files are not bitwise identical, but the ras and decs didn't change meaningfully? I was kind of expecting this test to show that the ras and decs do change, and I read this test as showing the opposite; am I missing something?

I don't know what precision works, but I'd drop the filecmp.cmp test, and maybe make the tests look like:

for column in [ra, dec, centroid, psf]:
    assert np.allclose(orig.catalog[column], new.catalog[column], atol=1/60/60)  # assert nothing moved by more than an arcsecond
    assert not np.allclose(orig.catalog[column], new.catalog[column], atol=1/60/60/100)  # assert some things moved by at least a hundredth of an arcsecond

I'm kind of guessing what the right precisions are---it depends on how many stars are in the catalog, and how much you shifted their positions. But we want to be showing that we did tweak the positions, and I feel like the current test is kind of showing the opposite?

Note 1e-7 rtol corresponds to roughly 0.1" or 1 pixel. Do you know how big of a tweak you're applying?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file pipeline testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants