Extract independent cleanup fixes#151
Merged
Merged
Conversation
Contributor
Reviewer's GuideRefactors cosmic ray removal to be robust for NaNs and dask-backed cubes, simplifies velocity WCS construction for red/blue profile cubes, standardizes/shortens IRIS visualization slider labels, and adjusts runtime dependencies and tests accordingly. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
8354bdf to
9e13c50
Compare
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The astroscrappy code path eagerly converts each dask chunk to NumPy and stores results in preallocated NumPy arrays, so the output cube is no longer dask-backed; if preserving laziness is desired, consider returning a dask array (e.g. via map_blocks) or at least documenting that this operation materializes the full cube in memory.
- In
_shorten_slider_label,set(LON_LABELS + LAT_LABELS)is recomputed on every call; consider creating a module-levelSCAN_LABELSset instead to avoid repeated allocation on frequently updated sliders. - The new
_make_velocity_wcscreates a fresh WCS with only the velocity axis configured, dropping any contextual WCS information from the original cube; if some non-velocity axes metadata should be preserved (e.g. observer or coordinate frames), consider explicitly copying over the relevant parts from the input cube WCS.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The astroscrappy code path eagerly converts each dask chunk to NumPy and stores results in preallocated NumPy arrays, so the output cube is no longer dask-backed; if preserving laziness is desired, consider returning a dask array (e.g. via map_blocks) or at least documenting that this operation materializes the full cube in memory.
- In `_shorten_slider_label`, `set(LON_LABELS + LAT_LABELS)` is recomputed on every call; consider creating a module-level `SCAN_LABELS` set instead to avoid repeated allocation on frequently updated sliders.
- The new `_make_velocity_wcs` creates a fresh WCS with only the velocity axis configured, dropping any contextual WCS information from the original cube; if some non-velocity axes metadata should be preserved (e.g. observer or coordinate frames), consider explicitly copying over the relevant parts from the input cube WCS.
## Individual Comments
### Comment 1
<location path="irispy/utils/cosmic_rays.py" line_range="65-74" />
<code_context>
+ frame_mask = np.zeros(frame.shape, dtype=bool) if mask is None else np.asarray(mask[index], dtype=bool)
+ if np.issubdtype(frame.dtype, np.floating):
+ frame_mask = frame_mask | np.isnan(frame)
+ if inmask is not None:
+ frame_mask = frame_mask | np.asarray(inmask[index], dtype=bool)
+ frame[frame_mask] = 0.0
+ detected_mask, cleaned_frame = astroscrappy.detect_cosmics(frame, inmask=frame_mask, **method_kwargs)
</code_context>
<issue_to_address>
**issue (bug_risk):** Indexing `inmask` per frame changes semantics for 2D masks on >2D data and may break previous broadcasting behavior.
Previously, a 2D `inmask` was combined with `mask` without indexing, effectively applying the same mask to every frame in a higher‑dimensional cube. By indexing `inmask[index]`, a 2D `inmask` for an n>2D cube will now either fail or (worse) mask a different set of pixels than before. If you want to preserve the old behavior, consider checking `inmask.ndim`/shape and only index when it matches `data`’s leading dimensions, otherwise broadcast it explicitly across frames.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
9e13c50 to
d058228
Compare
d058228 to
8eec915
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Improve cosmic ray removal, WCS generation, and visualization slider labeling while adding dask support and updating dependencies.
New Features:
Bug Fixes:
Enhancements:
Build:
Tests: