-
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?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,7 @@ | |
min_diffs_single_pass=10, | ||
mask_persist_grps_next_int=True, | ||
persist_grps_flagged=25, | ||
mmflashfrac=1.0, | ||
): | ||
""" | ||
This is the high-level controlling routine for the jump detection process. | ||
|
@@ -221,6 +222,11 @@ | |
min_diffs_single_pass : int | ||
The minimum number of groups to switch to flagging all outliers in a single pass. | ||
|
||
mmflashfrac: float | ||
Fraction of the array in a given group that has to have a jump detected | ||
in order to flag the entire array as a jump. This is designed to deal with | ||
sporadic micrometeorite flashes. | ||
|
||
Returns | ||
------- | ||
gdq : int, 4D array | ||
|
@@ -338,6 +344,12 @@ | |
) | ||
log.info("Total showers= %i", num_showers) | ||
number_extended_events = num_showers | ||
|
||
# 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
gdq = find_micrometeorite_flashes(gdq, jump_flag, mmflashfrac) | ||
|
||
else: | ||
yinc = int(n_rows // n_slices) | ||
slices = [] | ||
|
@@ -503,6 +515,12 @@ | |
) | ||
log.info("Total showers= %i", num_showers) | ||
number_extended_events = num_showers | ||
|
||
# This is where we look for micrometeorite flashes if the triggering | ||
# threshold is less than the entire array | ||
if (mmflashfrac < 1): | ||
gdq = find_micrometeorite_flashes(gdq, jump_flag, mmflashfrac) | ||
|
||
elapsed = time.time() - start | ||
log.info("Total elapsed time = %g sec", elapsed) | ||
|
||
|
@@ -514,6 +532,21 @@ | |
# Return the updated data quality arrays | ||
return gdq, pdq, total_primary_crs, number_extended_events, stddev | ||
|
||
# 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 commentThe reason will be displayed to describe this comment to others. Learn more. This is missing a docstring. Also, start the function with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point- done |
||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
# Loop over integrations | ||
for ii in range(0,gdq.shape[0]): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
# Loop over groups | ||
for jj in range(0,gdq.shape[1]): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
indx = np.where(gdq[ii,jj,:,:] & jump_flag != 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. If that's the convention I certainly can- done. |
||
return gdq | ||
|
||
def flag_large_events( | ||
gdq, | ||
|
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
andfind_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