-
Notifications
You must be signed in to change notification settings - Fork 291
Failing to load a NetCDF dataset #5067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @timo0thy, we're definitely interested in why this behaviour changed recently. But we can't proceed any further without the file. Are you able to share this? Or at the very least share the |
It looks like the From the looks of your xarray output I can see that your file contains a When Iris interprets a file, if it finds a Assuming the |
Hi both, Thank you very much for looking into this. Please see attached the fwi.nc file (it's renamed to fwi_extract.nc as I had to extract the first 1000 timesteps to pass the file size requirement). Same issue anyway. Yes I agree that it's a strangely formatted file, thanks for suggesting the workaround (haven't tried it though, as there's no issue with the older iris version). Tim |
@timo0thy thanks for the file. The change in behaviour was introduced in #4436. As @lbdreyer suspects: the file cell methods are an empty string (
We could actually cope with @lbdreyer presumably we should look at enabling a skip with a warning, rather than crashing out with an exception? |
I don't think so. Even attributes have a definite type, string or numeric, and 'None' is not a possible value. |
I ran your test file through one of the online CF checkers available (I used this particular one), and it indeed complained that the
CF-1.10 Section 7.3, fourth para begins:
The CF checker obviously interprets this as either the attribute is not present in which case the default kicks in, or the attribute is present, and its value has then to be properly formatted. Personally I think a slightly more relaxed, or lenient, approach might be helpful: to more focus on the presence of the method as such, i.e. the empty string is the same as no cell method present. A warning about this deviation from CF might then be helpful. |
@SciTools/peloton prefer a tolerant + warning approach |
I'm not keen on the lenient loading approach. The file is malformed, why should a user expect Iris to load it? I would prefer Iris raise a helpful, informative error and then the user could contact the data owner to get the file fixed, or fix it themself. |
In my opinion, and experience. there can be a variety of reasons why this approach is unhelpful to the user.
So, I feel that Iris loading "should have been" largely tolerant from the outset : It is usually possible to see where+how the code can fail to interpret in the usual way. And practically, if something can't be interpreted in the usual way, it is generally possible to ignore it (and maybe raise a warning). So far, we do actually do this for a bunch of common errors, all of which were raised in experience :
It feels like I should be writing this in a discussion. |
Yes, perhaps this should be discussed elsewhere. Most of the comments you raise are about lenient/tolerant loading in general rather than this specific issue so I'm not sure it makes sense to address them here? |
I'd be interested in that discussion, albeit rather abstractly |
The CF checker reported on several other problems with the test file. So, in this particular case I think that it might be useful to contact the xclim developers. But I know first hand that it is a struggle to squeeze climate indices (et al.) into CF. Nevertheless, things are slowly improving; just recently the More generally, it is not a viable option to always expect the data owners to fix the files. For example, there are literally tens of thousands of files on ESGF (CMIP5 and CORDEX) that are more or less malformated and they are never going to be fixed. Still they are a valuable resource. |
I believe #5126 should address this (among some other related problems) -- it seems to work for me. |
Works also for me: $ git status
On branch cellmethod_tolerance
Your branch is up to date with 'pp-mo/cellmethod_tolerance'.
nothing to commit, working tree clean $ python
Python 3.8.12 | packaged by conda-forge | (default, Oct 12 2021, 21:59:51)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import iris
>>> iris.__version__
'3.5.0.dev15'
>>> c = iris.load_cube("/home/a001257/Downloads/fwi_extract.nc")
>>> print(c)
Fire weather index / (unknown) (latitude: 26; longitude: 34; time: 1000)
Dimension coordinates:
latitude x - -
longitude - x -
time - - x
Attributes:
description 'Numeric rating of fire intensity.'
history 'tas: \npr: \nsfcWind: \nhurs: \nlat: \n[2022-11-18 10:46:26] fwi: FWI(tas=t2m, ...'
invalid_standard_name 'fire_weather_index'
>>> |
🐛 Bug Report
I am failing to load a NetCDF file, getting an 'index out of range' error. The properties of the dataset and the error code are provided in the screenshots below. This issue is unique to the latest version of iris as I tried with version 3.2.1 and it works.
How To Reproduce
Steps to reproduce the behaviour:
Expected behaviour
With version 3.2.1 I am able to load and plot the dataset as follows:


Screenshots
The dataset (opened and plotted using xarray):


The error code when loading the dataset using iris 3.3.1:



Environment
Additional context
Click to expand this section...
The text was updated successfully, but these errors were encountered: