-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redesign #216
Redesign #216
Conversation
* Create a dataset module and convert to Grid Accessor xarray.Dataset accessor class * Convert Grid appearances to GridAccessor * Introduce api.py and dataset.py * Update test cases to reflect the redesign * Remove NestedSequence dependency * precommit fixes
* Create a dataset module and convert to Grid Accessor xarray.Dataset accessor class * Convert Grid appearances to GridAccessor * Introduce api.py and dataset.py * Update test cases to reflect the redesign * Remove NestedSequence dependency * precommit fixes * Fix grid.equals and add test_dataset
My current understanding is this_grid = uxarray.open_grid("gridfile.sh")
this_grid_dataset = uxarray.open_dataset(this_grid, "datasetfile.ds") If that so, my concerns will be:
Please let me know if I misunderstand or being unclear of anything |
Resolved in the meeting: 1. ux_ds = uxarray.open_dataset(grid_file, "datasetfile.ds")
2. ux_ds.uxgrid
3. ux_ds.dataset_wise_funcs()
4. ux_ds.uxgrid.grid_wise_funcs()
5. ux_ds.var1.uxgrid.dataarray_wise_funcs() |
EDIT (2/16/2023): @philipc2 @dcherian Now added |
Attempting to merge two uxds_v1 = ux.open_grid(gridfile_geoflow, dsfile_v1_geoflow)
uxds_v2 = ux.open_grid(gridfile_geoflow, dsfile_v2_geoflow)
# fails because of the grid accessor
uxds_pair = xr.merge([uxds_v1, uxds_v2]) |
Creating a shallow or deep copy using the uxds = ux.open_dataset(gridfile_geoflow, dsfile_v1_geoflow)
# uxgrid accessor cleared to None
uxds_copy = uxds.copy(deep=False) |
Similarly, calling a method such as |
FWIW I brought up this issue at the Xarray dev meeting. We're discussing here and it seems like we're converging to a solution. For this discussion the relevant piece is that if you created an xarray.Index object to store grid state, then all xarray operations will propagate these indexes; and any accessors can access state information in the Index. That particular discussion is about propagating the Index when a DataArray is extracted, this does not work currently.
You could hack this by using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For all my Algorithms implementing experience, I don't see any trouble using the current design.
The following algorithms' implementation is not heavily relied on the Xarray functionality. It uses more numpy features and are highly portable and self-robust
A major method that you are missing is Notice, that xarrays version calls Edit: Probably you also need |
I would like to reorganize a bit: add two folders:
|
… to lose uxgrid attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for putting these together. It looks awesome overall. Just left some comments about the documentation
I have updated our "Working with Unstructured Grid Data" notebook to reflect the comments in #181 and the work that we've done with the inheritance notebook. I have also added a small section to the "Grid Topology" notebook to describe how to access the Let me know if there is anything else I should add! |
…prototype_redesign
… into prototype_redesign
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your hard work! The documentation looks good to me now
Co-authored-by: Ian Franda <134353359+ifranda@users.noreply.github.com>
This PR introduces a prototype redesign of UXarray based on the conversation in Discussion #185 . This prototype's backbone is the
uxarray.core.Grid
object and a brand newuxarray.core.UxDataset
that inherits fromxarray.Dataset
.There were a lot of hesitation (including mine) and warnings against inheritance from xarray in Discussion #185., so one major goal of the prototype is to trigger the team and collaborators to point out potential drawbacks of the inheritance scheme.
Disclosure: I ended up finding the inheritance most suitable way for UXarray's case after figuring immediate issues with the dataset accessors and not being able to seeing robust implementations of xarray's custom indexes other than current.experiments/trials.
This PR does:
Create a new namespace
uxarray.core
that houses the existinggrid
as well as newapi
anddataset
modules.NOT change the
grid.py
functionality much but adds a newequals
function to check if any two grid topologies are the same. Other functions are kept the same for now; however, functions likeinterpolate
that can better be applied onUxDataset
instead of agrid
can be and should most likely be removed in the future if tis prototype gets hired.Create xarray-like
api.py
module to handle user API functions such asopen_dataset
,open_grid
, etc by wrapping xarray's functions.Create a new
uxarray.core.UxDataset
that inherits fromxarray.Dataset
(Likewise a DataArray version can be considered in the future).uxarray.core.Grid
object as property to itself at the initialization (similar to xarray's dataset accessor), so the connection between each uxarray dataset and grid topologyintegrate()
defined for now. Algorithm is the same, but function call is focused on the dataset instead of on the grid, e.g.:Add
test_api.py
to tests and update existing test cases to reflect the design changes@UXARRAY/uxarray-dev
EDIT (2/16/2023):
@philipc2 @dcherian Now added
UxDataArray
to this prototype and got allxr.DataArray
fields of anyUxDataset
to be represented asUxDataArray
.UxDataArray
also has auxgrid
property. So, whenever a function that generates a new dataset or a data array out ofUxDataset
is executed, the result is expected to be either a newUxDataset
andUxDataArray
instead ofxr.Dataset
orxr.DataArray
, respectively, so we can keep uxarray functionality valid on these new things.EDIT (3/30/2023):
Uxarray's new design can be tried out following the instructions in the How to test new design document.