Repository navigation
FIX: Preserve masks in saturation pressure/mixing ratio selection - #4169
Open
thaliamontreux wants to merge 1 commit into
Open
thaliamontreux wants to merge 1 commit into
thaliamontreux wants to merge 1 commit into
Conversation
The phase='auto' branch of saturation_vapor_pressure and the undefined- state branch of saturation_mixing_ratio both selected results with np.where, which evaluates on plain arrays and silently drops any mask carried by the inputs. A masked (missing) temperature therefore produced a finite, meaningless humidity or pressure instead of staying masked. Switch both sites to np.ma.where so masks on the condition and the selected operand propagate, converting back to a plain array when nothing ended up masked (matching the convention in units.concatenate). Fixes Unidata#4154
thaliamontreux
requested review from
dopplershift
and removed request for
a team
October 20, 2026 07:39
Author
|
Note for reviewers: the three failing macOS legs are pre-existing on |
This branch has not been deployed
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 Changes
Masked temperatures produce finite, meaningless values from
saturation_vapor_pressure(..., phase='auto')andsaturation_mixing_ratiobecause both selection sites usenp.where, which evaluates on plain arrays and silently drops the input mask. Explicitphase='liquid'/'solid'and the composedmixing_ratio(saturation_vapor_pressure(t), p)path preserve masks correctly.Both sites now select with
np.ma.where, which propagates masks from the condition and the selected operand, converting back to a plainndarraywhen nothing ended up masked (the same convention asunits.concatenate). Unmasked inputs are unchanged — same values, same type.Fixes #4154.
Checklist