Closed jpan84 closed 2 months ago
2024.04.0
Conda
Traceback (most recent call last): File "", line 1, in File "/glade/u/home/jpan/miniconda3/envs/240509ux/lib/python3.12/site-packages/xarray/core/dataarray.py", line 4085, in to_netcdf dataset = self.to_dataset(name=DATAARRAY_VARIABLE) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: UxDataArray.to_dataset() got an unexpected keyword argument 'name'
I tried to save the difference between two UxDataArray objects to a netcdf. The two objects had different names within their original datasets.
import uxarray as ux uxds1 = ux.open_dataset('/glade/p/cesmdata/inputdata/share/scripgrids/ne30pg3_scrip_170611.nc', '/glade/derecho/scratch/jpan/archive/20140801_FHIST_ne30pg3L58-ndg-ERA5-rectrl-memb1/atm/hist_onpres/20140801_FHIST_ne30pg3L58-ndg-ERA5-rectrl-memb1.cam.h1.2015-02-02-00000_onpres.nc') uxds2 = ux.open_dataset('/glade/p/cesmdata/inputdata/share/scripgrids/ne30pg3_scrip_170611.nc', '/glade/derecho/scratch/jpan/ERA5_ne30pg3_onpres/e5.oper.an.pl.128_129_z.ll025sc.2015020200_2015020223.nc') uxda1 = uxds1.Z3.sel(pres=500).mean(dim='time') uxda2 = uxds2.Z.sel(level=500).assign_coords(coords=dict(level='pres')).mean(dim='time') / 9.81 dif = uxda1 - uxda2 dif.to_netcdf('./testout.nc') ###can avoid the issue by casting to xarray DataArray import xarray as xr xr.DataArray(dif).to_netcdf('./testout.nc')
Hi @jpan84
Thanks for catching this! This appears to be due to the lack of parameters in our implementation. I'll get a fix out for this!
https://github.com/UXARRAY/uxarray/blob/46c4260d55b8a86e8737d084566402eec3645311/uxarray/core/dataarray.py#L248-L252
Once the fix is merged, I'll get an increment release out by EOD tomorrow.
Version
2024.04.0
How did you install UXarray?
Conda
What happened?
Traceback (most recent call last): File "", line 1, in
File "/glade/u/home/jpan/miniconda3/envs/240509ux/lib/python3.12/site-packages/xarray/core/dataarray.py", line 4085, in to_netcdf
dataset = self.to_dataset(name=DATAARRAY_VARIABLE)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: UxDataArray.to_dataset() got an unexpected keyword argument 'name'
What did you expect to happen?
I tried to save the difference between two UxDataArray objects to a netcdf. The two objects had different names within their original datasets.
Can you provide a MCVE to repoduce the bug?