[netcdf-java] Using NetCDF Java in Servlet

Hi,
 
I am a newbie for NetCDF-Java library. I try to use this library directly in
the
Servlet environment to access THREDDS nc aggregation datasets. Here are some
codes I put together:
 
----------------------------------------------------------------------------
-
 
Set<Enhance> DATASET_ENHANCEMENTS =EnumSet.of(Enhance.ScaleMissingDefer);
 
NetcdfDataset nc=NetcdfDataset.openDataset(
 
                        "MY_THREDDS_URL",
DATASET_ENHANCEMENTS,
 
                        -1,                                       null, 
 
                        null 
 
                        );
 
List<Variable> l=nc.getVariables();
 
 
Variable vv=null;
 
for(Variable v:l)
 
{
 
    if(v.getName().equals("time"))
 
    {
 
        vv=v;
 
        break;                
 
    }
 
}
 
Array arr;
 
List<Range> ranges=new ArrayList<Range>();
 
try {
 
    r = new Range(8759,8759);
 
    ranges.add(r);
 
    arr=vv.read(ranges);
 
} catch (InvalidRangeException e) {
 
      e.printStackTrace();
 
}
nc.close();
 
 
 
My question is:
 
If all variables are defined locally, are these methods guaranteed to be
thread-safe?
 
If my approach is not appropriate, is there a preferred suite of
classes/methods that I should look into?
 
Thanks,
 
Guan

 

  • 2011 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: