Materialize ds before snow-index calcs to fix read-only buffer error#83
Closed
ZachHoppinen wants to merge 2 commits into
Closed
Materialize ds before snow-index calcs to fix read-only buffer error#83ZachHoppinen wants to merge 2 commits into
ZachHoppinen wants to merge 2 commits into
Conversation
calc_delta_cross_ratio and the other snow-index funcs do in-place .loc[time=...] writes. After the s1 preprocessing chain (generate_sentinel1_dataarray -> combine_close_images -> amplitude_to_dB -> s1_orbit_averaging -> s1_clip_outliers), the underlying numpy buffer for vv/vh ends up non-writeable, so the second-orbit write in calc_delta_cross_ratio fails with "assignment destination is read-only". Force materialization with ds.load() between s1 preprocessing and the snow-index step. Mirrors the same .load() already done in retrieval_from_parameters at the analogous point. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…itable PR #83's .load() alone fixed the snow-index read-only error for white_mtns 2025_2026 and fairbanks 2025_2026 but not for fairbanks 2024_2025: .load() materializes lazy/dask arrays but does NOT deep-copy already-in-memory arrays whose buffers happen to be read-only. Chain .copy(deep=True) after .load() to guarantee fresh writable buffers regardless of the upstream chain's state. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Updated: chained Memory note: |
3 tasks
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
calc_delta_cross_ratio(and the rest of the snow-index funcs) do in-placedataset['x'].loc[time=...]writes. After the s1 preprocessing chain leaves vv/vh wrapping a non-writeable numpy buffer, the second orbit's write fails with:```
ValueError: assignment destination is read-only
```
The author already hit this in
retrieval_from_parameters(retrieval.py:238) and fixed it withdataset = dataset.load(). The mainretrieve_snow_depthflow was missing the same line. This adds it betweens1_clip_outliersandcalc_delta_cross_ratio.Reproduces from a real run failure on Fairbanks 2024_2025 (
snow_index.py:102).Test plan
pytest tests/— 73/73 pass.fairbanks 2024_2025and confirm snow-index calcs succeed.🤖 Generated with Claude Code