-
Notifications
You must be signed in to change notification settings - Fork 7
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
ENH: Automatically reject bad frames due to cosmic rays #194
base: main
Are you sure you want to change the base?
Conversation
"[AMICAL] %i unusable frames have been identified in the data cube," | ||
% (len(bad_frames)) | ||
+ " primarily due to cosmic rays or persistent bad pixels." |
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.
"[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, |
@@ -79,7 +79,7 @@ def find_max(img, filtmed=True, f=3): | |||
return X, Y | |||
|
|||
|
|||
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): |
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 an unwarranted breaking change: new arguments should always be added at the end of an existing signature, and preferably be made keyword-only
@@ -117,13 +117,22 @@ def select_data(cube, clip_fact=0.5, clip=False, verbose=True, display=True): | |||
ind_clip = [] | |||
cube_cleaned_checked = np.array(good_fram) | |||
|
|||
cube_cleaned_checked = np.array(cube_cleaned_checked) |
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.
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
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 |
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.
np.ptp(x)
does the same as np.max(x) - np.min(x)
, but in a single data pass
diffmm = 100 * abs(np.max(fluxes_check) - np.min(fluxes_check)) / med_flux | |
diffmm = 100 * abs(np.ptp(fluxes_check)) / med_flux |
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."