Open kyle-hinson opened 5 months ago
Hi! I'll try to take a look at this next week.
Hi @kyle-hinson! I investigated with some ROMS output I have available and didn't hit any errors. Here is the code I used, with some variation indicated in comments:
import xarray as xr
import xroms
# loc = "https://thredds.aoos.org/thredds/dodsC/AWS_CIOFS.nc"
loc = "http://xpublish-nwgoa.srv.axds.co/datasets/nwgoa_all/zarr/"
ds = xr.open_zarr(loc, chunks={"ocean_time": 1})
# ds = xr.open_zarr(loc, chunks={})
ds = xroms.roms_dataset(ds)
# with xarray v2024.6.0 didn't hit error
# try 2024.5.0, also ok
# see what happens for 2024.3.0, also ok
# only got warnings from xgcm
# /Users/kthyng/miniconda3/envs/fixxroms/lib/python3.12/site-packages/xgcm/grid_ufunc.py:832: FutureWarning: The return type of `Dataset.dims` will be changed to return a set of dimension names in future, in order to be more consistent with `DataArray.dims`. To access a mapping from dimension names to lengths, please use `Dataset.sizes`.
# out_dim: grid._ds.dims[out_dim] for arg in out_core_dims for out_dim in arg
I tried xarray 2024.6.0, 2024.5.0, and 2024.3.0, and two different chunking schemes and I had the same results each time. I started from a fresh environment so it's possible this is due to environment differences, but I think it's more likely due to differences in our model output. The roms_dataset
function is meant to account for these differences by adding attributes that might be missing, but it must be missing something. It's possible that our two datasets are going down two different pathways in the function so that mine didn't hit exactly the same set of conditions, too, though all functions eventually hit that order()
function to make sure arrays stay in the correct dimensional ordering (which often catches issues with attributes).
I think this will be difficult to debug given this information so I think for now you should go ahead with the older version of xarray that works for you, but please update this issue if you get more ideas or information about what is going on. Thanks for posting.
@kyle-hinson And let me know if the workaround stops working and this becomes a blocker for you.
I encountered the same issue as you. At first, I thought it was a problem with the xarray
library, so I updated xarray
from version 2024.2.0
to 2024.10.0
, but the issue was not resolved. Later, I discovered it was related to cf-xarray
. I had installed gsw-xarray
, which restricted the cf-xarray
version to a maximum of cf-xarray-0.7.9
. I manually updated cf-xarray
to version cf-xarray-0.10.0
, and the issue was resolved.
However, during the update process, I encountered the following message:
"ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. gsw-xarray 0.4.0 requires cf-xarray<0.8.0,>=0.7.4, but you have cf-xarray 0.10.0 which is incompatible."
I haven't yet tested whether gsw-xarray
works properly after the update, but after updating cf-xarray
, xroms
is functioning correctly.
Hi @dongmeng666666, thanks for the tip! Will try this out too.
Hello, I'm running into an issue when trying to run
roms_dataset
that I believe may be related to a recent upgrade of myxarray
package (version 2024.5.0
) and is hopefully useful for others. Below is an example of the relevant code that I'm running.The error that I am encountering is below:
ValueError: Dimensions {'X', 'T', 'Y', 'Z'} do not exist. Expected one or more of ('ocean_time', 'eta_rho', 'xi_rho', 's_w')
This code worked fine right before I upgradedxarray
(which I did because I was having issues reading in datasets with chunking), and seems to be encountering more issues related to xarray functions in the full error message below. My code seems to work without issue forxarray version 2024.3.0
but fails when usingxarray version 2024.5.0
. Not sure how to manage this in the future with additional package upgrades, but wanted to put it on people's radars. Thanks again,xroms
is great to work with!