-
Notifications
You must be signed in to change notification settings - Fork 32
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-3737: Handle micrometeorite flashes #308
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #308 +/- ##
==========================================
- Coverage 86.21% 86.15% -0.06%
==========================================
Files 47 49 +2
Lines 8812 8885 +73
==========================================
+ Hits 7597 7655 +58
- Misses 1215 1230 +15 ☔ View full report in Codecov by Sentry. |
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.
There is some code called in two separate places due to a conditional, but can be moved outside the conditionals and called once, since they are called in both the if
and else
portion of the conditional.
There is also some formatting and style issues.
src/stcal/jump/jump.py
Outdated
@@ -338,6 +344,12 @@ def detect_jumps( | |||
) | |||
log.info("Total showers= %i", num_showers) | |||
number_extended_events = num_showers | |||
|
|||
# This is where we look for micrometeorite flashes if the triggering |
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.
Since this is done in both conditionals and done last, it should be moved out side the conditionals completely, instead of invoked twice.
The expand_large_events
and find_showers
can be moved outside the conditionals for the same reason.
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.
Done
src/stcal/jump/jump.py
Outdated
|
||
# This is where we look for micrometeorite flashes if the triggering | ||
# threshold is less than the entire array | ||
if (mmflashfrac < 1): |
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.
Since this is done in both conditionals and done last, it should be moved out side the conditionals completely, instead of invoked twice.
The expand_large_events
and find_showers
can be moved outside the conditionals for the same reason.
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.
Done
src/stcal/jump/jump.py
Outdated
# of groups. Do this by looking for cases where greater than mmflash_pct percent | ||
# of the array is flagged as 'JUMP_DET' and flag the entire array. | ||
def find_micrometeorite_flashes(gdq, jump_flag, mmflashfrac): | ||
npix = gdq.shape[2]*gdq.shape[3] # Number of pixels in array |
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.
Add spaces before and after *
.
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.
Done
src/stcal/jump/jump.py
Outdated
def find_micrometeorite_flashes(gdq, jump_flag, mmflashfrac): | ||
npix = gdq.shape[2]*gdq.shape[3] # Number of pixels in array | ||
# Loop over integrations | ||
for ii in range(0,gdq.shape[0]): |
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.
Add space after ,
.
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.
Done
src/stcal/jump/jump.py
Outdated
# Loop over integrations | ||
for ii in range(0,gdq.shape[0]): | ||
# Loop over groups | ||
for jj in range(0,gdq.shape[1]): |
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.
Add space after ,
.
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.
Done
src/stcal/jump/jump.py
Outdated
# Find micrometeorite flashes that light up the entire array in a small number | ||
# of groups. Do this by looking for cases where greater than mmflash_pct percent | ||
# of the array is flagged as 'JUMP_DET' and flag the entire array. | ||
def find_micrometeorite_flashes(gdq, jump_flag, mmflashfrac): |
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.
This is missing a docstring.
Also, start the function with nints, ngroups, nrows, ncols = gdq.shape
, then use these more descriptive variable names, rather than shape[k]
.
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.
Good point- done
src/stcal/jump/jump.py
Outdated
for ii in range(0,gdq.shape[0]): | ||
# Loop over groups | ||
for jj in range(0,gdq.shape[1]): | ||
indx = np.where(gdq[ii,jj,:,:] & jump_flag != 0) |
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.
Add spaces after all ,
.
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.
Done
src/stcal/jump/jump.py
Outdated
indx = np.where(gdq[ii,jj,:,:] & jump_flag != 0) | ||
fraction = float(len(indx[0])) / npix | ||
if (fraction > mmflashfrac): | ||
gdq[ii,jj,:,:] = gdq[ii,jj,:,:] | jump_flag |
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.
Add spaces after all ,
.
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.
Done
src/stcal/jump/jump.py
Outdated
fraction = float(len(indx[0])) / npix | ||
if (fraction > mmflashfrac): | ||
gdq[ii,jj,:,:] = gdq[ii,jj,:,:] | jump_flag | ||
log.info("Detected a micrometeorite flash in integ = %i, group= %i", ii, jj) |
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.
Why not use an f-string?
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.
If that's the convention I certainly can- done.
Things that remain to be determined:
Work ongoing to determine these. |
This PR addresses JP-3737 by adding an additional check in the jump step to look for micrometeorite flashes, which manifest as bursts of jumps across a large fraction of the detector.
Kept in draft form for now pending potential future modifications.
Tasks
docs/
pageno-changelog-entry-needed
)changes/
:echo "changed something" > changes/<PR#>.<changetype>.rst
(see below for change types)"git+https://github.com/<fork>/stcal@<branch>"
)jwst
regression testromancal
regression testnews fragment change types...
changes/<PR#>.apichange.rst
: change to public APIchanges/<PR#>.bugfix.rst
: fixes an issuechanges/<PR#>.general.rst
: infrastructure or miscellaneous change