Re: Problem with GRIB files

I am resending the code below, without the '*'

John Caron wrote:

Adityarajsingh Santokhee wrote:

Hello,

I have a few questions concerning reading GRIB files using the netcdf2.2
library:

1. are there any problems when using the grib.jar library with jakarta tomcat server ? Netcdf files can be correctly read and data extracted. Grib files can be opened only but it is failing each time i wish to extract data (all data as
well as section of it).

most likely problem is you dont have write permission in the data directories, since we need to write an index file. however, on failure it should have defaulted over to writing in a temporary directory. probably theres no home directory for the tomcat user. If you cant fix those 2 problems, set the directory to something that the tomcat user has write privilege in, using:

ucar.nc2.util.FileCache.setRootDirectory()



2. Are there any easier ways to reading data for a particular variable using its internal name instead of the variable name. Currently, I have to get list of all variables and then for each variable get its attributes and thereafter
check the attribute name for GRIB_param_number.
I would make a HashMap

HashMap gribHashMap = new HashMap();
for (int i=0; i<myVarList.size(); i++) {
 Variable myVar = (Variable) myVarList.get(i);
String gribName = ncfile.findAttValueIgnoreCase(myVar, "GRIB_param_number", null);
 if (gribName != null)
   gribHashMap.put( gribName, myVar);
}

Then look it up via
Variable myVar = (Variable) gribHashMap.get( gribName);
if ( myVar != null) {
 do_something();
}