Skip to content
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

loadGridData fails to find named variable in netCDF file #19

Closed
cs2239 opened this issue Jun 15, 2021 · 7 comments
Closed

loadGridData fails to find named variable in netCDF file #19

cs2239 opened this issue Jun 15, 2021 · 7 comments

Comments

@cs2239
Copy link

cs2239 commented Jun 15, 2021

netcdf file in question:

netcdf file:/Users/dev/Downloads/MPI-ESM-LR_FWI_ET017_cal.nc {
  dimensions:
    time = UNLIMITED;   // (23741 currently)
    lon = 69;
    lat = 64;
  variables:
    double time(time=23741);
      :standard_name = "time";
      :long_name = "time";
      :units = "days since 1971-01-01 UTC";
      :calendar = "proleptic_gregorian";
      :axis = "T";
      :_ChunkSizes = 512U; // uint

    double lon(lon=69);
      :standard_name = "longitude";
      :long_name = "longitude";
      :units = "degrees_east";
      :axis = "X";

    double lat(lat=64);
      :standard_name = "latitude";
      :long_name = "latitude";
      :units = "degrees_north";
      :axis = "Y";

    float fwi(time=23741, lat=64, lon=69);
      :_FillValue = 1.0E20f; // float
      :missing_value = 1.0E20f; // float
      :description = "Fire Weather Index";
      :longname = "fwi";
      :units = "-";
      :_ChunkSizes = 1U, 64U, 69U; // uint
> x <- loadGridData(dataset = "MPI-ESM-LR_FWI_ET017_cal.nc", var = "fwi") 
Error: Variable requested not found
Check 'dataInventory' output and/or dictionary 'identifier'.
> dataInventory("MPI-ESM-LR_FWI_ET017_cal.nc")
[2021-06-15 12:03:44] Doing inventory ...
Error: No variables found

So loadGridData can't find the var named fwi... I should note this is take 2. The original calendar was gregorian (not proleptic_gregorian). Loading that file yielded:

Jun 15, 2021 12:05:57 PM ucar.nc2.dt.grid.GridCoordSys <init>
SEVERE: N/A: Error reading time coord= time
java.lang.IllegalArgumentException: days since 1971-01-01 utc does not match (\w*)\s*since\s*([\+\-\d]+)([ t]([\.\:\d]*)([ \+\-]\S*)?z?)?$
[snip]

I switched calendars with CDO and that has disappeared the var even though it is there per ncdump...

@AranJM
Copy link

AranJM commented Oct 12, 2021

I have the same issue with a netcdf file retrieved from the ipcc interactive atlas (which uses climate4R btw). Any chance on a reaction on this issue as it is quite cumbersome that some ncdf files can be read and others can't.

@cofinoa
Copy link
Member

cofinoa commented Oct 13, 2021

Dear @cs2239, can you provide access to the .nc file (MPI-ESM-LR_FWI_ET017_cal.nc) you are trying to open with?

@cofinoa
Copy link
Member

cofinoa commented Oct 13, 2021

@AranJM, there is an issue with metadata for the netcdf files generated by the interactive atlas.

These files are been parsed and generated by the backend that is using GDAL which is manipulating/truncating some attributes and coordinates of the original files.

@AranJM
Copy link

AranJM commented Oct 13, 2021

@cofinoa Thanks for the answer. Any workaround/solution you can think of perhaps?

@cofinoa
Copy link
Member

cofinoa commented Oct 13, 2021

@AranJM I can provide you a workaround ... please let me know which .nc file are you interested on ... and I would check exactly what is the metadata to be changed.

@cofinoa
Copy link
Member

cofinoa commented Oct 14, 2021

@AranJM, as workaround you can create a .ncml file, besides (i.e. same directory) the downloaded file from the interactive atlas, and with the following XML contente:

<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2" location="{{ FILE.nc }}">
  <variable name="{{ VARIABLE }}">
    <logicalReduce dimNames="baseline period time_filter" />
  </variable>
</netcdf>

you must replace {{ FILE.nc }} with the filename you have downloaded, and {{ VARIABLE }} with the name of the principal variable in the netCDF file.

@cofinoa
Copy link
Member

cofinoa commented Oct 21, 2021

@AranJM the interactive-atlas will solve the issues with the metadata, that the above .ncml fixes.

Meanwhile the fix it's deployed, you can uses the .ncml

Dear @cs2239, I will close this issue. You can re-open it if you face same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants