Re: [netcdf-java] Unable to get a GeoGrid from a GridDataset

  • To: James Adams <monocongo@xxxxxxxxx>
  • Subject: Re: [netcdf-java] Unable to get a GeoGrid from a GridDataset
  • From: Sean Arms <sarms@xxxxxxxx>
  • Date: Wed, 29 Jun 2016 15:41:56 -0600
Greetings James,

I think you need to add the following attribute to the pet variable:

coordinates = "time lon lat"

If that does not work, would you have a sample file that you could share?

Thanks!

Sean


On Fri, Jun 24, 2016 at 1:28 PM, James Adams <monocongo@xxxxxxxxx> wrote:

> I have Java code which gets a GeoGrid object from a NetCDF GridDataset via
> the variable name. It normally works correctly but for the input NetCDF
> file I currently need to work with I get an error when this code runs, in
> that the GeoGrid is not found, even though you can see the variable in the
> NetCDF dataset using other tools such as ncdump and/or when stepping
> through the code with a debugger.
>
> This code works as expected with other NetCDF files so I assume that there
> must be something in the NetCDF file itself which is preventing the fetch
> of a variable's grid via a lookup of the variable name. When I view the
> NetCDF file I can see the variable and it displays as a Geo2D type in
> Panoply. The ncdump -h output for the file is below:
>
>     File "prism_nidis_pet.nc"
>     Dataset type: NetCDF-3/CDM
>
>     netcdf file:/C:/home/prism/prism_nidis_pet.nc {
>       dimensions:
>         lon = 1405;
>         lat = 621;
>         time = UNLIMITED;   // (1457 currently
>       variables:
>         int time(time=1457);
>           :long_name = "time";
>           :standard_name = "time";
>           :units = "days since 1800-1-1 00:00:00";
>           :calendar = "gregorian";
>
>         float lon(lon=1405);
>           :long_name = "longitude";
>           :standard_name = "longitude";
>           :units = "degrees_north";
>
>         float lat(lat=621);
>           :long_name = "latitude";
>           :standard_name = "latitude";
>           :units = "degrees_west";
>
>         float pet(time=1457, lon=1405, lat=621);
>           :calibration_start_year_month = "full";
>           :calibration_end_year_month = "full";
>           :_FillValue = -999.9f; // float
>           :missing_value = -999.9f; // float
>           :valid_min = 0.0f; // float
>           :valid_max = 3.4028235E38f; // float
>           :units = "millimeters";
>           :cell_methods = "time: potential evapotranspiration estimate,
> Thornthwaite equation";
>           :long_name = "Potential evapotranspiration estimate,
> Thornthwaite equation";
>           :standard_name = "Potential evapotranspiration estimate,
> Thornthwaite equation";
>
>       // global attributes:
>       :date_created = "2016-06-23  11:52:37";
>       :date_modified = "2016-06-23  11:52:37";
>       :standard_name_vocabulary = "CF Standard Name Table (v26, 08
> November 2013)";
>       :Conventions = "1.6";
>       :geospatial_lon_min = -125.0f; // float
>       :geospatial_lon_max = -66.5f; // float
>       :geospatial_lat_min = 24.083334f; // float
>       :geospatial_lat_max = 49.916668f; // float
>     }
>
> Is there anything about the file described above which would prevent being
> able to get a GeoGrid associated with the variable named "pet"?
>
> Below is the code which is failing when using the above file as input.
>
>
>         private GeoGrid getGrid(final String netcdfFile,
>                                 final String variableName)
>             throws IOException
>         {
>             // open the NetCDF data set
>             GridDataset gridDataset = GridDataset.open(netcdfFile);
>
>             // verify that we opened the GridDataset
>             if (gridDataset == null)
>             {
>                 String errorMessage = "Error opening the NetCDF data set
> using the file \'" + netcdfFile + "\'";
>                 logger.error(errorMessage);
>                 throw new RuntimeException(errorMessage);
>             }
>
>             // THIS IS WHERE THE PROBLEM OCCURS
>             // get the grid based on the associated variable name
>             GeoGrid geoGrid =
> gridDataset.findGridByShortName(variableName);
>
>             // verify that we found the GeoGrid
>             if (geoGrid == null)
>             {
>                 String errorMessage = "Error finding the NetCDF grid from
> the NetCDF file \'" + netcdfFile + "\' using the variable name \'" +
> variableName + "\'";
>                 logger.error(errorMessage);
>                 throw new RuntimeException(errorMessage);
>             }
>
>             // more code omitted...
>         }
>
> When the above code runs and fails the arguments are the NetCDF file name
> and "pet" which is the variable name in that NetCDF for which we're trying
> to get the corresponding grid.
>
> Can anyone suggest what's going wrong here? Thanks in advance...
>
> _______________________________________________
> NOTE: All exchanges posted to Unidata maintained email lists are
> recorded in the Unidata inquiry tracking system and made publicly
> available through the web.  Users who post to any of the lists we
> maintain are reminded to remove any personal information that they
> do not want to be made public.
>
>
> netcdf-java mailing list
> netcdf-java@xxxxxxxxxxxxxxxx
> For list information or to unsubscribe, visit:
> http://www.unidata.ucar.edu/mailing_lists/
>
  • 2016 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: