You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implement UxDataArray methods like zonal_mean() in UxDataset #1734
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 interestresult=ds2.zonal_mean() # this crashesresult.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.)
Activity