Skip to content

Conversation

@DrSoulain
Copy link
Collaborator

@DrSoulain DrSoulain commented Sep 12, 2023

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."

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."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):
Copy link
Collaborator

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

ind_clip = []
cube_cleaned_checked = np.array(good_fram)

cube_cleaned_checked = np.array(cube_cleaned_checked)
Copy link
Collaborator

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

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
Copy link
Collaborator

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

Suggested change
diffmm = 100 * abs(np.max(fluxes_check) - np.min(fluxes_check)) / med_flux
diffmm = 100 * abs(np.ptp(fluxes_check)) / med_flux

@DrSoulain DrSoulain added the enhancement New feature or request label Jan 3, 2024
@DrSoulain DrSoulain marked this pull request as draft January 3, 2024 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants