utils/plot: handle empty data in auto_adjust_colormap_lut_and_disp_limit()#1419
Merged
yunjunz merged 3 commits intoinsarlab:mainfrom Nov 23, 2025
Merged
utils/plot: handle empty data in auto_adjust_colormap_lut_and_disp_limit()#1419yunjunz merged 3 commits intoinsarlab:mainfrom
auto_adjust_colormap_lut_and_disp_limit()#1419yunjunz merged 3 commits intoinsarlab:mainfrom
Conversation
Avoid ValueError when input has no finite values by returning neutral display limits [0.0, 0.0] and None LUT. This prevents crashes in view.py plotting when datasets are fully NaN or invalid.
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe PR updates auto_adjust_colormap_lut_and_disp_limit to gracefully handle cases where the input data contains no finite values by early exiting with default display limits and prevents crashes by refactoring the way unique values are extracted. File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Member
|
I was able to reproduce the error you have as below, and your PR fixed it. Thank you @frx08! colormap: jet
DESCENDING orbit -> flip left-right
figure title: velocity
figure size : [10.0, 6.0]
read mask from file: maskTest.h5
reading data ...
masking data
Traceback (most recent call last):
File "/Users/yunjunz/tools/mambaforge/envs/insar/bin/view.py", line 8, in <module>
sys.exit(main())
File "/Users/yunjunz/tools/MintPy/src/mintpy/cli/view.py", line 186, in main
obj.plot()
File "/Users/yunjunz/tools/MintPy/src/mintpy/view.py", line 1675, in plot
data, self = update_data_with_plot_inps(data, self.atr, self)
File "/Users/yunjunz/tools/MintPy/src/mintpy/view.py", line 324, in update_data_with_plot_inps
inps.unique_values) = pp.auto_adjust_colormap_lut_and_disp_limit(data, print_msg=inps.print_msg)
File "/Users/yunjunz/tools/MintPy/src/mintpy/utils/plot.py", line 403, in auto_adjust_colormap_lut_and_disp_limit
vstep = np.min(np.abs(np.diff(unique_values))).astype(float)
File "<__array_function__ internals>", line 200, in amin
File "/Users/yunjunz/tools/mambaforge/envs/insar/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 2946, in amin
return _wrapreduction(a, np.minimum, 'min', axis, None, out,
File "/Users/yunjunz/tools/mambaforge/envs/insar/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 84, in _wrapreduction
return reduction(axis=axis, out=out, **passkwargs)
File "/Users/yunjunz/tools/mambaforge/envs/insar/lib/python3.10/site-packages/numpy/ma/core.py", line 5804, in min
result = self.filled(fill_value).min(
File "/Users/yunjunz/tools/mambaforge/envs/insar/lib/python3.10/site-packages/numpy/core/_methods.py", line 45, in _amin
return umr_minimum(a, axis, None, out, keepdims, initial, where)
ValueError: zero-size array to reduction operation minimum which has no identity |
auto_adjust_colormap_lut_and_disp_limit()
yunjunz
approved these changes
Nov 23, 2025
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.
Description of proposed changes
Fix
ValueError: zero-size array to reduction operation minimuminauto_adjust_colormap_lut_and_disp_limit.[0.0, 0.0]andNoneLUT when no valid pixels are found.view.pyplotting when datasets are fully NaN/invalid.Reminders
Summary by Sourcery
Handle empty or fully invalid data in auto_adjust_colormap_lut_and_disp_limit by returning default neutral display limits and None LUT instead of crashing
Bug Fixes:
Enhancements: