Simplify DataArray dims - derive from geometry #893
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
Geometry0Dclass for time-series-only datadimsa derived property fromgeometry.spatial_dimsreduce()methods to geometries for spatial aggregations@cached_propertyfordimsand_has_time_axisfor performance optimizationBreaking changes
dimsparameter deprecated (FutureWarning) - dimensions now derived from geometrysqueeze()method deprecated (FutureWarning) - useisel()insteadValueErrorimmediately (DFS format compliance)GeometryUndefineddeprecated - useGeometry0DHistorical Context: The
dimsParameterThe
dimsparameter was introduced in January 2022 (commit1133864f) with a guessing heuristic:The original comment "This is not very robust, but is probably a reasonable guess" acknowledged this was always a heuristic, not a proper solution.
The Core Problem
The
dimsparameter was copied from xarray's API (for xarray integration), but created a false impression:("lat", "lon", "depth", "ensemble_member")time, xtime, y, xtime, z, y, xtime, elementAllowing users to pass custom
dimscreated an illusion of possibilities not supported by the DFS format. Custom dims wouldn't persist through write/read cycles.The Solution
This PR completes the work started in March 2024 to make dims truly derivable:
aa1afc15): Started delegating dims to geometry classes04e1e2d9,a7931470): Made dims a derived property, removed parameterDimensions are now always derived from geometry, eliminating the illusion that they could be arbitrary and ensuring they correctly represent the actual DFS file structure.