This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Many thanks John. I did the changes and came across a "new problem." Actually, after getting the data, I have to convert the array to 1D: Array arr = vari.read(); float[] data = (float[])arr.copyTo1DJavaArray(); The problem is that the copyTo1DJavaArray() is not working. I successfully tried with NetCDF files though. Cheers, Adit Quoting John Caron <address@hidden>: > 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(); > > } > > > > > > > > > ----------------------------------------------------------------------- Adityarajsingh Santokhee Tel: +44 118 378 5213 (direct line) eScience Data Manager Tel: +44 118 378 8741 (ESSC) Reading e-Science Centre Fax: +44 118 378 6413 ESSC Email: address@hidden University of Reading 3 Earley Gate Reading RG6 6AL, UK -----------------------------------------------------------------------