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
I opened a file with data specified on the ORCA grid (one of the ORCA grids... but the problem would probably be the same for data on any non rectilinear grid), with no bounds available in the file and got a long traceback instead of a friendly warning
Generating a file that will reproduce the traceback
Get a clean IPSL areacello file from ESGF. This file can be opened without any problem with open_dataset
Remove the references to the bounds, and remove the bounds variables
ncatted -a bounds,,d,, areacello_Ofx_IPSL-CM6A-LR_piControl_r1i2p1f1_gn.nc areacello_no_bounds_attributes.nc
ncks -vareacello,nav_lon,nav_lat areacello_no_bounds_attributes.nc areacello_no_bounds_at_all.nc
Reproducing the long traceback
Open the file with cdms2 and open_dataset
>>> nb_file = './areacello_no_bounds_at_all.nc'
>>> f_cdms2 = cdms2.open(nb_file)
>>> f_cdms2.listvariables()
['areacello', 'nav_lat', 'nav_lon']
>>> ds_nb = xc.open_dataset(nb_file)
Traceback (most recent call last):
File "/home/share/unix_files/cdat/miniconda3_21-02/envs/cdatm_py3/lib/python3.8/site-packages/xcdat/bounds.py", line 178, in get_bounds
bounds_key = coord_var.attrs["bounds"]
KeyError: 'bounds'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/share/unix_files/cdat/miniconda3_21-02/envs/cdatm_py3/lib/python3.8/site-packages/xcdat/bounds.py", line 145, in add_missing_bounds
self.get_bounds(axis)
File "/home/share/unix_files/cdat/miniconda3_21-02/envs/cdatm_py3/lib/python3.8/site-packages/xcdat/bounds.py", line 180, in get_bounds
raise KeyError(
KeyError: "The coordinate variable 'nav_lon' has no 'bounds' attr. Set the 'bounds' attr to the name of the bounds data variable."
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/share/unix_files/cdat/miniconda3_21-02/envs/cdatm_py3/lib/python3.8/site-packages/xcdat/bounds.py", line 178, in get_bounds
bounds_key = coord_var.attrs["bounds"]
KeyError: 'bounds'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/share/unix_files/cdat/miniconda3_21-02/envs/cdatm_py3/lib/python3.8/site-packages/xcdat/bounds.py", line 220, in add_bounds
self.get_bounds(axis)
File "/home/share/unix_files/cdat/miniconda3_21-02/envs/cdatm_py3/lib/python3.8/site-packages/xcdat/bounds.py", line 180, in get_bounds
raise KeyError(
KeyError: "The coordinate variable 'nav_lon' has no 'bounds' attr. Set the 'bounds' attr to the name of the bounds data variable."
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/share/unix_files/cdat/miniconda3_21-02/envs/cdatm_py3/lib/python3.8/site-packages/xcdat/dataset.py", line 95, in open_dataset
ds = _postprocess_dataset(ds, data_var, center_times, add_bounds, lon_orient)
File "/home/share/unix_files/cdat/miniconda3_21-02/envs/cdatm_py3/lib/python3.8/site-packages/xcdat/dataset.py", line 482, in _postprocess_dataset
dataset = dataset.bounds.add_missing_bounds()
File "/home/share/unix_files/cdat/miniconda3_21-02/envs/cdatm_py3/lib/python3.8/site-packages/xcdat/bounds.py", line 147, in add_missing_bounds
self._dataset = self.add_bounds(axis, width)
File "/home/share/unix_files/cdat/miniconda3_21-02/envs/cdatm_py3/lib/python3.8/site-packages/xcdat/bounds.py", line 225, in add_bounds
dataset = self._add_bounds(axis, width)
File "/home/share/unix_files/cdat/miniconda3_21-02/envs/cdatm_py3/lib/python3.8/site-packages/xcdat/bounds.py", line 269, in _add_bounds
raise ValueError("Cannot generate bounds for multidimensional coordinates.")
ValueError: Cannot generate bounds for multidimensional coordinates.
We can get rid of the traceback by overriding the default value of add_bounds
I expect a behavior that will not frighten the user away!
It was not too hard for me to identify what the problem was, and find the add_bounds=False option, but you can't really expect that from a casual user or beginning intern who has only read an example notebook.
open_dataset should be able to detect this missing data/information and print a nice warning (and suggest the add_bounds=False workaround)
Thank you for reporting this - I was able to reproduce this issue, which is now fixed in #278. I believe the goal is to produce a minor release in the next week with this fix. I will ping this thread when that is done.
@jypeter - I updated to the main branch and tried your code and did not hit any issues opening the dataset – so this is resolved. I think the plan is to do a "patch release" in the next week to address this issue and a few others. @tomvothecoder - is that timeline correct?
What happened?
[ Problem initially reported by @oliviermarti ]
I opened a file with data specified on the ORCA grid (one of the ORCA grids... but the problem would probably be the same for data on any non rectilinear grid), with no bounds available in the file and got a long traceback instead of a friendly warning
Generating a file that will reproduce the traceback
Get a clean IPSL
areacello
file from ESGF. This file can be opened without any problem withopen_dataset
wget https://vesg.ipsl.upmc.fr/thredds/fileServer/cmip6/CMIP/IPSL/IPSL-CM6A-LR/piControl/r1i2p1f1/Ofx/areacello/gn/v20190319/areacello_Ofx_IPSL-CM6A-LR_piControl_r1i2p1f1_gn.nc
Remove the references to the bounds, and remove the bounds variables
Reproducing the long traceback
Open the file with cdms2 and open_dataset
We can get rid of the traceback by overriding the default value of
add_bounds
What did you expect to happen?
I expect a behavior that will not frighten the user away!
It was not too hard for me to identify what the problem was, and find the
add_bounds=False
option, but you can't really expect that from a casual user or beginning intern who has only read an example notebook.open_dataset
should be able to detect this missing data/information and print a nice warning (and suggest theadd_bounds=False
workaround)Minimal Complete Verifiable Example
Relevant log output
No response
Anything else we need to know?
No response
Environment
The text was updated successfully, but these errors were encountered: