Add time_index to plot_variable; auto-squeeze extra dims before plotting#46
Merged
Conversation
… plotting Fixes ValueError when plotting MPAS variables with a Time dimension (shape [T, n_face]). Adds time_index=0 to the full call chain so callers can select any step; size-1 time dims are always squeezed.
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
plot_variable(and all layers below it) now acceptstime_index: int = 0uxda.plot.polygons(), any non-face dimensions (e.g.Time) are reduced: size-1 dims are always squeezed; larger dims usetime_indexValueError: Data Variable must be 1-dimensionalfor MPAS datasets wheret2mhas shape[1, 40962]Root cause
ux.open_dataseton an MPAS file preserves theTimedimension even with a single snapshot.to_geodataframe(called internally by.plot.polygons()) requires a strictly 1-D face array.Test plan
pytest: 248 passedplot_variableonhistory.2025-05-14_00.00.00.nc/t2m