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

Pull common parts of skymatch from romancal and jwst into stcal #310

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

Conversation

WilliamJamieson
Copy link
Collaborator

@WilliamJamieson WilliamJamieson commented Oct 17, 2024

This PR pulls the common parts of skymatch from romancal and jwst into stcal to be shared.

Note, no tests are included because it is well tested by the step tests in both romancal and jwst.

Tasks

  • update or add relevant tests
  • update relevant docstrings and / or docs/ page
  • Does this PR change any API used downstream? (if not, label with no-changelog-entry-needed)
    • write news fragment(s) in changes/: echo "changed something" > changes/<PR#>.<changetype>.rst (see below for change types)
    • run regression tests with this branch installed ("git+https://github.com/<fork>/stcal@<branch>")
news fragment change types...
  • changes/<PR#>.apichange.rst: change to public API
  • changes/<PR#>.bugfix.rst: fixes an issue
  • changes/<PR#>.general.rst: infrastructure or miscellaneous change

Copy link

codecov bot commented Oct 17, 2024

Codecov Report

Attention: Patch coverage is 69.57774% with 317 lines in your changes missing coverage. Please review.

Project coverage is 85.05%. Comparing base (35726e9) to head (6202d38).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/stcal/skymatch/skyimage.py 61.09% 270 Missing ⚠️
src/stcal/skymatch/skymatch.py 83.90% 47 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #310       +/-   ##
===========================================
+ Coverage   29.57%   85.05%   +55.47%     
===========================================
  Files          36       53       +17     
  Lines        7949    10028     +2079     
===========================================
+ Hits         2351     8529     +6178     
+ Misses       5598     1499     -4099     

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

Copy link
Collaborator

@emolter emolter left a comment

Choose a reason for hiding this comment

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

This looks great, thanks William! I just had a few questions about whether some of the ruff and mypy problems could be fixed instead of ignored.

I also had a few questions about the code itself, but those also exist on jwst main, so they're technically beyond the scope of this PR. But I'm still curious to know the answers to those and I figure now is as good a time as any to ensure the code is written as cleanly as possible

pix_area=1.0,
convf=1.0,
mask=None,
id=None, # noqa: A002
Copy link
Collaborator

Choose a reason for hiding this comment

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

instead of hiding the style complaint could this be renamed?

Comment on lines +161 to +162
The functionality to support this conversion is not yet
implemented and at this moment `convf` is ignored.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are there plans to implement this? If not, perhaps now is a good time to remove the option

Comment on lines +327 to +328
@property
def id(self): # noqa: A003
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know you most likely just copied all of this from JWST, so not strictly in the scope of this PR, but is there a reason that getter-setter methods are being used here for id, pix_area, sky, is_sky_valid, radec, polygon, and skystat? These don't seem to add any functionality.

These do make it so that this class has the same underscore-protected variable names as SkyGroup, but is there any reason that has to be the case?


"""

def __init__(self, images, id=None, sky=0.0): # noqa: A002
Copy link
Collaborator

Choose a reason for hiding this comment

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

again here can id be renamed instead?

for im in self._images:
im.sky += sky

@property
Copy link
Collaborator

Choose a reason for hiding this comment

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

same question here RE why id, polygon, and radec go through the trouble to use @property

log.setLevel(logging.DEBUG)


def match(images, skymethod="global+match", match_down=True, subtract=False):
Copy link
Collaborator

Choose a reason for hiding this comment

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

this name also violates https://docs.astral.sh/ruff/rules/builtin-variable-shadowing/ and will likely be changed in JWST by spacetelescope/jwst#9053 to be skymatch()

from copy import deepcopy

# THIRD PARTY
from stsci.imagestats import ImageStats # type: ignore[import-untyped]
Copy link
Collaborator

Choose a reason for hiding this comment

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

might be worth considering making the relevant third-party type ignores global by putting them here

[[tool.mypy.overrides]]

Comment on lines +17 to +18
This is a superclass build on top of
:py:class:`stsci.imagestats.ImageStats`. Compared to
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment is confusing because the class doesn't actually inherit from ImageStats

@WilliamJamieson
Copy link
Collaborator Author

This looks great, thanks William! I just had a few questions about whether some of the ruff and mypy problems could be fixed instead of ignored.

I also had a few questions about the code itself, but those also exist on jwst main, so they're technically beyond the scope of this PR. But I'm still curious to know the answers to those and I figure now is as good a time as any to ensure the code is written as cleanly as possible

I agree they should be fixed. However, as you said they are beyond the scope of this PR. I think for making it possible to trace the history of changes it makes sense to move the code in as close a state as possible from JWST to stcal and then do a follow on PR making cleanups and addressing the issues uncovered here.

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.

2 participants