Update structured Field data ingestion transposing to 4D (TZYX) and add XGrid.from_dataset() - #2091
Merged
Conversation
VeckoTheGecko
marked this pull request as draft
July 17, 2025 17:25
VeckoTheGecko
force-pushed
the
4d-field-arrays
branch
2 times, most recently
from
July 17, 2025 17:31
0da120b to
1641273
Compare
XGrid.from_dataset() XGrid.from_dataset()
VeckoTheGecko
marked this pull request as ready for review
July 17, 2025 17:39
VeckoTheGecko
commented
Jul 18, 2025
erikvansebille
approved these changes
Jul 18, 2025
It's not necessary for us to have the Field data on the XGrid/xgcm.Grid object itself. It doesn't make a big difference in the end, but dropping the field data on grid ingestion would allow us to keep things logically separate.
Needed to update the tests because the time axis information was getting lost (due to xarray behaviour with keep_attrs). Fixes #2047
for more information, see https://pre-commit.ci
VeckoTheGecko
force-pushed
the
4d-field-arrays
branch
from
July 18, 2025 12:05
f42b923 to
ddb4b4a
Compare
VeckoTheGecko
enabled auto-merge (rebase)
July 18, 2025 12:05
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.
Changes:
Add
XGrid.from_dataset(rather than having to construct a xgcm grid first). This execution path drops all the Field data from the dataset before constructing the xgcm grid (and also makes it easier to call for devs as its 1 less import). Seeb73813c769aeaa92be181bf3fee1ba5275d317ce commit message for more infoUpdate Field init to transpose data to 4D array, inserting additional dummy axes where necessary
Chose the correct base branch (
v4-devfor v4 changes)Fixes Coerce StructuredGrid field data to 4D array of TZYX #2047 and works towards Testing and support for 2D fields in X-Z and Y-Z, and 1D fields in X, Y, or Z #2054
Added tests (for the transposing to 4D I didn't add a unit test, but added an integration test over all the generic datasets)
Added documentation
Will do a self review tomorrow then mark ready for review.