-
Notifications
You must be signed in to change notification settings - Fork 171
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-1887: Refactoring ols_ramp_fit
into smaller more manageable functions
#5819
JP-1887: Refactoring ols_ramp_fit
into smaller more manageable functions
#5819
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5819 +/- ##
==========================================
+ Coverage 75.66% 76.74% +1.08%
==========================================
Files 406 406
Lines 36323 37965 +1642
==========================================
+ Hits 27484 29137 +1653
+ Misses 8839 8828 -11
*This pull request uses carry forward flags. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good Ken. Just a couple questions below.
nreads: int | ||
Number of reads | ||
|
||
ngroups: int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable groups
is gotten from input_model.meta.exposure.ngroups
in the RampModel
passed to ramp_fit
. It is not part of the shape of data
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be very careful with the use and meaning of nreads
vs ngroups
. In the instruments, individual detector reads can be averaged on-board and then downlinked as a single group. When the data hit the ground they are 4-dimensional: [ncols, nrows, ngroups, nints] in conventional (e.g. FITS) notation, which is [nints, ngroups, nrows, ncols] in python array notation. The data in the ngroups
dimension can consist of 1 or more detector reads. So in this particular use in the ramp_fit
step I'm guessing nreads
refers to the actual number of detector readouts that took place in the instrument, which is not necessarily the same as ngroups
(because, as mentioned above, 1 or more reads can get averaged into a group). So nreads
can't reliably be determined from the shape of the 4-D data array. Only ngroups
can.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upon clarification, the use of nreads
and ngroups
are the same values taken from two different locations in the RampModel
class. in effect, these two variables are redundant that makes the code confusing. I will remove this redundancy and use the correct ngroups
variable name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. I think this is good to go then as is.
ols_ramp_fit
into smaller more manageable functionsols_ramp_fit
into smaller more manageable functions
Ran the regtests on this PR and all pass. I think this is good to merge. |
Addresses #5701 / JP-1887
This is one in a series of PR's designed to refactor ramp fitting to make it more readable, maintainable, and reusable.
This PR is used to break down the function
ols_ramp_fit
. It is over 700 lines long, but has four distinct steps, which have been encapsulated in four different functions thatols_ramp_fit
calls.ramp_fit_miri_multigroups()
, deals with the special case of MIRI data with multiples groups in an integration, resizing the data for discarded groups.ramp_fit_first_pass()
, does the "first pass" over the data to compute the initial values related to slope computation.ramp_fit_second_pass()
, does the "second pass" over the data using the intermediate results from the first pass to compute values related to variances of estimates.ramp_fit_overall_slopes_and_variances()
, uses the values computed in the first and second passes over the date to compute the overall slopes and variances for each pixel.