Skip to content

Vignette masking and cosmic ray masking tasks - #33

Open
Yashvi-Sharma wants to merge 4 commits into
mainfrom
vignette_mask
Open

Yashvi-Sharma wants to merge 4 commits into
mainfrom
vignette_mask

Conversation

@Yashvi-Sharma

Copy link
Copy Markdown
Collaborator

Added two tasks in preprocessing.py following the structure of SigmaClipMasking task:

  • VignetteMasking : Finds vignetted regions per output (looks at image region only) by thresholding on a smoothed image and applies scipy binary morphology operations to smoothen jagged mask edges.
  • CosmicRayMasking : Uses lacosmic package to find and mask cosmics, either on full output data (simple method) or per region separately (for CCDs).

Added corresponding core functions and tests for both tasks.

Fixed minor rebase bugs.

Updated toml to include lacosmic as dependency.

Build a full mask from the individual output masks.
:return: True if a full mask was built, False otherwise.
"""
if self.masks is not None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good fix, I think we may hit a performance issue though since now every call to rebuilds the full mask from scratch

For performance improvement we could clear the cache when output masks change

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I'll put in something to avoid unnecessary mask rebuilding

Comment thread src/eregion/core/image_operations.py
Comment thread src/eregion/tasks/preprocessing.py Outdated
f"relative to the illumination level and assumes a zero-level corrected image.")
for out_id, output in img.outputs.items():
img.outputs[out_id] = self._mask_output(output)
img.image_type.update({"vignette_masked": True})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

VignetteMasking updates output.masks but never call build_full_mask() (unlike SigmaClipMasking), so img.masks goes stale, and has to read it directly

Possible fix here is to do img.image_type.update({"vignette_masked": img._build_full_mask()})

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

good catch, will fix

@Yashvi-Sharma
Yashvi-Sharma requested a review from prkrtg October 20, 2026 17:45

This branch has not been deployed

No deployments
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