NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Hi, I am a newbie for NetCDF-Java library. I try to use this library 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, Enhance.CoordSystems); NetcdfDataset nc=NetcdfDataset.openDataset( "MY_THREDDS_URL", DATASET_ENHANCEMENTS, -1, null, null ); List<Variable> l=nc.getVariables(); //close NetcdfDataset before accessing data nc.close(); 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(); } ------------------------------------ Three questions regarding to the codes above: 1. Are the codes above the typical way to access THREDDS data? 2. If yes, it seems OK for reading the data from a variable after "NetcdfDataset" is closed. Is it valid? 3. If the THREDDS dataset is an archive (static, no update), can I cache the instance of Variable class as a member variable of the Servlet class? In other words, are the operations on Variable class thread-safe? Thanks a lot! Guan
netcdf-java
archives: