Skip to content

Implement UxDataArray methods like zonal_mean() in UxDataset #1734

Open
2 of 2 issues completed
Open

Description

@Sevans711

Proposed new feature or change:

I was trying to analyze 3 data variables, maybe do some zonal averaging and then create plots to show results over time. In xarray, I would do this by selecting just those 3 variables to make a smaller Dataset with just those variables, and then applying any averaging operations as needed. But, this isn't currently possible in uxarray because UxDataset does not have zonal_mean(). I can loop through variables individually and plot results individually, but it would feel much more natural / convenient to instead apply these computations directly to the UxDataset itself.

Example:

ds1 = ux.open_dataset(grid_file, data_file)
ds2 = ds1[['TS', 'PSL', 'PRECT']]   # select the variables of interest
result = ds2.zonal_mean()   # this crashes
result.to_dataarray().plot(col="variable")

Here, I would want result to be a dataset telling the result of zonal_mean() applied to each of the data_vars in ds1. If that got returned, then the last line would plot zonal means as a grid of 3 subplots, one for each variable.

zonal_mean() is just one example; really I would want UxDataset to fully implement any analogous methods from UxDataArray where the pattern is "loop through the data_vars and apply this method to each of them, and handle the bookkeeping appropriately to return a dataset result." (If the existing UxDataArray method returns xarray.DataArray, the UxDataset method should return xarray.Dataset; if it returns a UxDataArray then the UxDataset method should return a UxDataset.)

Sub-issues

Sub-issues

2 of 2 Issues completed
Loading 2 sub-issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

new feature

Type

No type

Fields

Priority

Medium

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions