Skip to content
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

Improvements to Bad Pixel Detection and Cleaning #194

Merged
merged 14 commits into from
Aug 8, 2024
Merged

Conversation

AarynnCarter
Copy link
Collaborator

This PR make some changes to the bad pixel detection and cleaning routines, specific updates include:

  • Splitting of pixel finding and fixing routines into separate function calls.
  • The addition of an early version of a new finding routine using an image gradient based method. Still requires further development.
  • The addition of a new fixing routine based on a 2D interpolation of nearby pixels.

This change will break backwards compatibility with previous versions of spaceKLIP, as the fix_bad_pixels() function has been fundamentally changed. While this isn't ideal, the new structure should allow for more flexibility moving forward, where further breaks to backwards compatibility are unlikely.

@AarynnCarter AarynnCarter marked this pull request as ready for review July 1, 2024 13:23
@AarynnCarter
Copy link
Collaborator Author

AarynnCarter commented Jul 1, 2024

TODO:

  • Convert function to clean_bad_pixels()
  • Add old fix_bad_pixels() function back in to preserve backwards compatibility.
  • Make sure any deprecated sub-functions are also accounted for.

@AarynnCarter AarynnCarter marked this pull request as draft July 1, 2024 16:30
@AarynnCarter AarynnCarter marked this pull request as ready for review July 9, 2024 23:29
@AarynnCarter AarynnCarter requested a review from kammerje July 9, 2024 23:30
@mperrin mperrin added this to the Release 2.1.0 milestone Jul 31, 2024
@kammerje
Copy link
Collaborator

kammerje commented Aug 5, 2024

Hi @AarynnCarter! I had a look at your changes and only found a few small things that I would like to discuss. The one additional important thing is that I cannot see any find_bad_pixels function yet, which would look similar to the clean_bad_pixels function and would call the various subroutines to find bad pixels. Did I miss it?

EDIT: I did miss it, never mind!

spaceKLIP/imagetools.py Outdated Show resolved Hide resolved
spaceKLIP/imagetools.py Show resolved Hide resolved
spaceKLIP/imagetools.py Outdated Show resolved Hide resolved
spaceKLIP/imagetools.py Show resolved Hide resolved
spaceKLIP/imagetools.py Show resolved Hide resolved
threshold = sigclip_kwargs['sigma'] * data_std
mask_new = diff > threshold

data_temp[i][mask_new] = np.nan
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems redundant to new line number 1303?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think so? The line numbers shuffled a little, but this can't be redundant as the mask_new is calculated on the line above.

log.info(' --> Unknown method ' + method_split[k] + ': skipped')

# The new DQ will just be the pxdq_temp we've been modifying
new_dq = pxdq_temp.astype(np.uint32)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need to be more carful here to ensure that subsequent routines will still be working correctly. The DQ array should remain as before, with the only change being the newly identified bad pixels getting DQ value 1 instead of 0. Everything else, like non-science pixels, shall remain.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think that's necessarily the case, as you might want to focus a routine on a certain collection of pixels flagged by a particular routine. I have added a toggle so that you can decide whether to start from an empty DQ array or adjust the existing one.

@AarynnCarter AarynnCarter merged commit 6f099b1 into develop Aug 8, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants