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

Jp 3861 refpix style #9234

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

Conversation

stscirij
Copy link
Contributor

Addresses JP-3861

Closes #

This PR applies style rules for the refpix step files

Tasks

  • request a review from someone specific, to avoid making the maintainers review every PR
  • add a build milestone, i.e. Build 11.3 (use the latest build if not sure)
  • Does this PR change user-facing code / API? (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)
    • update or add relevant tests
    • update relevant docstrings and / or docs/ page
    • start a regression test and include a link to the running job (click here for instructions)
      • Do truth files need to be updated ("okified")?
        • after the reviewer has approved these changes, run okify_regtests to update the truth files
  • if a JIRA ticket exists, make sure it is resolved properly
news fragment change types...
  • changes/<PR#>.general.rst: infrastructure or miscellaneous change
  • changes/<PR#>.docs.rst
  • changes/<PR#>.stpipe.rst
  • changes/<PR#>.datamodels.rst
  • changes/<PR#>.scripts.rst
  • changes/<PR#>.set_telescope_pointing.rst
  • changes/<PR#>.pipeline.rst

stage 1

  • changes/<PR#>.group_scale.rst
  • changes/<PR#>.dq_init.rst
  • changes/<PR#>.emicorr.rst
  • changes/<PR#>.saturation.rst
  • changes/<PR#>.ipc.rst
  • changes/<PR#>.firstframe.rst
  • changes/<PR#>.lastframe.rst
  • changes/<PR#>.reset.rst
  • changes/<PR#>.superbias.rst
  • changes/<PR#>.refpix.rst
  • changes/<PR#>.linearity.rst
  • changes/<PR#>.rscd.rst
  • changes/<PR#>.persistence.rst
  • changes/<PR#>.dark_current.rst
  • changes/<PR#>.charge_migration.rst
  • changes/<PR#>.jump.rst
  • changes/<PR#>.clean_flicker_noise.rst
  • changes/<PR#>.ramp_fitting.rst
  • changes/<PR#>.gain_scale.rst

stage 2

  • changes/<PR#>.assign_wcs.rst
  • changes/<PR#>.badpix_selfcal.rst
  • changes/<PR#>.msaflagopen.rst
  • changes/<PR#>.nsclean.rst
  • changes/<PR#>.imprint.rst
  • changes/<PR#>.background.rst
  • changes/<PR#>.extract_2d.rst
  • changes/<PR#>.master_background.rst
  • changes/<PR#>.wavecorr.rst
  • changes/<PR#>.srctype.rst
  • changes/<PR#>.straylight.rst
  • changes/<PR#>.wfss_contam.rst
  • changes/<PR#>.flatfield.rst
  • changes/<PR#>.fringe.rst
  • changes/<PR#>.pathloss.rst
  • changes/<PR#>.barshadow.rst
  • changes/<PR#>.photom.rst
  • changes/<PR#>.pixel_replace.rst
  • changes/<PR#>.resample_spec.rst
  • changes/<PR#>.residual_fringe.rst
  • changes/<PR#>.cube_build.rst
  • changes/<PR#>.extract_1d.rst
  • changes/<PR#>.resample.rst

stage 3

  • changes/<PR#>.assign_mtwcs.rst
  • changes/<PR#>.mrs_imatch.rst
  • changes/<PR#>.tweakreg.rst
  • changes/<PR#>.skymatch.rst
  • changes/<PR#>.exp_to_source.rst
  • changes/<PR#>.outlier_detection.rst
  • changes/<PR#>.tso_photometry.rst
  • changes/<PR#>.stack_refs.rst
  • changes/<PR#>.align_refs.rst
  • changes/<PR#>.klip.rst
  • changes/<PR#>.spectral_leak.rst
  • changes/<PR#>.source_catalog.rst
  • changes/<PR#>.combine_1d.rst
  • changes/<PR#>.ami.rst

other

  • changes/<PR#>.wfs_combine.rst
  • changes/<PR#>.white_light.rst
  • changes/<PR#>.cube_skymatch.rst
  • changes/<PR#>.engdb_tools.rst
  • changes/<PR#>.guider_cds.rst

Copy link

codecov bot commented Feb 27, 2025

Codecov Report

Attention: Patch coverage is 3.35570% with 144 lines in your changes missing coverage. Please review.

Project coverage is 69.56%. Comparing base (666c231) to head (f403686).
Report is 35 commits behind head on main.

Files with missing lines Patch % Lines
jwst/refpix/irs2_subtract_reference.py 5.49% 86 Missing ⚠️
jwst/refpix/optimized_convolution.py 0.00% 31 Missing ⚠️
jwst/refpix/refpix_step.py 0.00% 27 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9234      +/-   ##
==========================================
- Coverage   73.66%   69.56%   -4.11%     
==========================================
  Files         368      367       -1     
  Lines       36393    35585     -808     
==========================================
- Hits        26809    24754    -2055     
- Misses       9584    10831    +1247     

☔ 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.

Thanks very much Robert, looks good overall! I left some comments.


return data0


def fft_interp_norm(dd0, mask0, row, hnorm, hnorm1, ny, ngroups, aa, n_iter_norm):

"""Do something FFT related."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Was this the line you mentioned at stand-up? If so just flagging this so Melanie has a chance to look at it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, one of them.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, this is obscure, isn't it? From the comments in fill_bad_regions, and some inspection of the code and inputs, it looks like it is doing an iterative filtering in FFT space of the normal pixels in each group.

Here's my best guess at the parameter values:
dd0: ndarray, Data array containing all groups, updated in place
mask0: ndarray, Mask for pixels to filter, with dimensions ny x nrow. 1 means use the pixel, 0 means do not use it.
row: int, Row size. Computed from the number of science pixels, reference pixels and padding in an amplifier.
hnorm: ndarray, Array of column indices for normal pixels.
hnorm1: ndarray, Shifted index values for normal pixels.
ny: int, Y size of data array.
ngroups: int, Number of groups.
aa: ndarray, Filter to apply.
n_iter_norm: int, Number of filtering iterations.

Comment on lines 1318 to 1319
#
# Just flip back
Copy link
Collaborator

Choose a reason for hiding this comment

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

can this comment be integrated into the docstring instead of having both?

Copy link
Collaborator

Choose a reason for hiding this comment

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

there are a few more in the lines below that this might apply to

Integration number
group : int
Group number
"""
#
# The inverse is to rotate 180 degrees, then flip over the line Y=X
self.group = np.swapaxes(self.group[::-1, ::-1], 0, 1)
self.restore_group(integration, group)


class NRCA1Dataset(NIRDataset):
Copy link
Collaborator

Choose a reason for hiding this comment

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

for all of these classes that inherit from a parent class and all have the same few functions defined, if the parent class also has the function defined, then Sphinx will automagically copy over the docstring from the parent class. In that case you could just use a noqa: statement to ignore the style checker for all of these repeated methods.

In this case, it doesn't look like NIRDataset has a dms_to_detector, dms_to_detector_dq, or detector_to_dms method. I'm not familiar enough with the intent of this code to know for sure if this suggestion makes sense, but a possible future improvement could be to make NIRDataset an abstract base class and require child classes to define those three methods. It looks like the similar class for MIRI does so below.

flag that controls whether odd and even-numbered columns are
Parameters
----------
input_model : jwst.datamodels.model
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
input_model : jwst.datamodels.model
input_model : jwst.datamodels.JWSTDataModel

Comment on lines +20 to 24
"""
Check that the correction is skipped for MIR subarray data.
"""
# For MIRI, no reference pixel correction is performed on subarray data
# No changes should be seen in the data arrays before and after correction
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as before, can these be both in the docstring?

Also as written currently it looks like this is a single-line docstring, in which case it should be on one line. Since this is in a file starting with test_, the style checker doesn't ensure this is the case.

Comment on lines +167 to +169
"""
Check that odd/even rows are applied when flag is set.
"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here, and other instances below - single-line docstrings should be on one line.

I consider it less important in the tests, so feel free to ignore this, but since you went to the trouble of changing these I figure it can't hurt to try to get them to match as closely as possible with the rules in the rest of the repo

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.

4 participants