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

Crop Step Function #278

Merged
merged 8 commits into from
Jan 18, 2025
Merged

Crop Step Function #278

merged 8 commits into from
Jan 18, 2025

Conversation

ell-bogat
Copy link
Contributor

@ell-bogat ell-bogat commented Jan 2, 2025

Describe your changes

Adds a new step function l3_to_l4.crop() to crop data and update relevant header values.

  • Can accept any data level.
  • Can handle 2D or 3D Image data, but if data is 3D we assume it is a stack of images and only crop the last two indices.
  • kwarg sizexy is the desired data shape in xy order. Currently required to be even. If a single value is provided we assume a square data shape. Defaults to 60 (a little bigger than the dark hole region).
  • kwarg centerxy is the pixel location to center the cropping on, should be the intersection of 4 pixels since we want an even data shape. Raises a warning if the provided center is not a half-integer, and centers on the nearest pixel intersection. Defaults to the star location in the extension header ("STARLOCX"/"STARLOCY") and will raise an exception if no value is provided but the location is missing from the header.
  • Updates axis sizes and various pixel locations that may be in the headers, but we'll need to make sure this function gets updated if new relevant header keywords get added.

Possible future additions (low priority):

  • Add option to crop to an odd data shape centered on a pixel
  • Add capability to handle regions outside the FOV by padding with nans.

Example:
Input dataset with a square "PSF" at the position of "STARLOCX/Y" in the header:
image
cropped_dataset = crop(input_dataset) automatically crops to 60 pixels around "STARLOCX/Y":
image

Type of change

  • New feature (non-breaking change which adds functionality)

Reference any relevant issues (don't forget the #)

Issue #261: Need a step function to crop data

Checklist before requesting a review

  • I have linted my code
  • I have verified that all unit tests pass in a clean environment and added new unit tests, as needed
  • I have verified that all docstrings are properly formatted and added new documentation, as needed

@ell-bogat ell-bogat changed the title Crop Crop Step Function Jan 2, 2025
@ell-bogat ell-bogat marked this pull request as ready for review January 2, 2025 16:52
@ell-bogat ell-bogat linked an issue Jan 6, 2025 that may be closed by this pull request
@maxwellmb maxwellmb removed the request for review from semaphoreP January 8, 2025 17:21
Copy link
Contributor

@maxwellmb maxwellmb left a comment

Choose a reason for hiding this comment

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

Some quick change requests/comments

@maxwellmb maxwellmb self-assigned this Jan 9, 2025
@maxwellmb maxwellmb self-requested a review January 18, 2025 04:37
Copy link
Contributor

@maxwellmb maxwellmb left a comment

Choose a reason for hiding this comment

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

Thanks for the changes!


# Require that mode is HLC for now
if not prihdr['MODE'] == 'HLC':
raise UserWarning('Crop function is currently only configured for mode HLC.')
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should make use the FSAMNAME keyword to define the crop region. I'm not sure what the header keyword value we want is, but the definition is "easily understand PAM configuration.", as seen on this page.

@maxwellmb maxwellmb merged commit aad3489 into develop Jan 18, 2025
1 check passed
@ell-bogat ell-bogat deleted the crop branch January 27, 2025 19:24
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.

Need a step function to crop data
2 participants