ENH: Automatically reject bad frames due to cosmic rays#194
Draft
ENH: Automatically reject bad frames due to cosmic rays#194
Conversation
Comment on lines
+588
to
+590
| "[AMICAL] %i unusable frames have been identified in the data cube," | ||
| % (len(bad_frames)) | ||
| + " primarily due to cosmic rays or persistent bad pixels." |
Collaborator
There was a problem hiding this comment.
Suggested change
| "[AMICAL] %i unusable frames have been identified in the data cube," | |
| % (len(bad_frames)) | |
| + " primarily due to cosmic rays or persistent bad pixels." | |
| f"[AMICAL] {len(bad_frames)} unusable frames have been identified in the data cube," | |
| " primarily due to cosmic rays or persistent bad pixels.", | |
| file=sys.stderr, |
|
|
||
|
|
||
| def crop_max(img, dim, offx=0, offy=0, filtmed=True, f=3): | ||
| def crop_max(img, dim, iframe=0, offx=0, offy=0, filtmed=True, f=3): |
Collaborator
There was a problem hiding this comment.
this is an unwarranted breaking change: new arguments should always be added at the end of an existing signature, and preferably be made keyword-only
| ind_clip = [] | ||
| cube_cleaned_checked = np.array(good_fram) | ||
|
|
||
| cube_cleaned_checked = np.array(cube_cleaned_checked) |
Collaborator
There was a problem hiding this comment.
np.array unconditionally copies data, even if the input variable is already an array. Since the input and output variable are the same, it's clear you don't mean to copy, so np.asarray is better suited here
Suggested change
| cube_cleaned_checked = np.array(cube_cleaned_checked) | |
| cube_cleaned_checked = np.asarray(cube_cleaned_checked) |
|
|
||
| med_flux = np.median(fluxes_check) | ||
| std_flux = np.std(fluxes_check) | ||
| diffmm = 100 * abs(np.max(fluxes_check) - np.min(fluxes_check)) / med_flux |
Collaborator
There was a problem hiding this comment.
np.ptp(x) does the same as np.max(x) - np.min(x), but in a single data pass
Suggested change
| diffmm = 100 * abs(np.max(fluxes_check) - np.min(fluxes_check)) / med_flux | |
| diffmm = 100 * abs(np.ptp(fluxes_check)) / med_flux |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In some NIRISS data cases, we've detected problematic pixels (cosmic rays or other anomalous events) that can disrupt the centring step during cleaning, causing errors. These misbehaving pixels can pop up when only a few data groups are involved. To address this, we use a frame index list automatically generated by the centring function to identify and exclude these "bad frames."