public long makeFile(String location, ucar.nc2.dt.GridDataset gds, List<String> gridList, LatLonRect llbb, int horizStride, Range zRange, CalendarDateRange dateRange, int stride_time, boolean addLatLon) throws IOException, InvalidRangeException { return makeOrTestSize(location, gds, gridList, llbb, horizStride, zRange, dateRange, stride_time, addLatLon, false, NetcdfFileWriter.Version.netcdf3); }
/** * Write a netcdf-3 file from a subset of a grid dataset * @param location write new file * @param gds from this grid dataset * @param gridList just these grids * @param llbb horiz subset, may be null * @param range time subset, may be null * @throws IOException * @throws InvalidRangeException */ static public void makeFile(String location, ucar.nc2.dt.GridDataset gds, List<String> gridList, LatLonRect llbb, CalendarDateRange range) throws IOException, InvalidRangeException { NetcdfCFWriter writer = new NetcdfCFWriter(); writer.makeFile(location, gds, gridList, llbb, range, false, 1, 1, 1); }
public File writeCoverageDataToFile() throws WcsException { try { File dir = new File( getDiskCache().getRootDirectory() ); File ncFile = File.createTempFile( "WCS", ".nc", dir ); NetcdfCFWriter writer = new NetcdfCFWriter(); writer.makeFile( ncFile.getPath(), dataset, Collections.singletonList( identifier ), null, null, // Collections.singletonList( req.getCoverage() ), // req.getBoundingBox(), dateRange, true, 1, 1, 1 ); return ncFile; } catch ( InvalidRangeException e ) { log.error( "writeCoverageDataToFile(): Failed to subset coverage <" + identifier + ">: " + e.getMessage()); throw new WcsException( WcsException.Code.UnsupportedCombination, "", "Failed to subset coverage <" + identifier + ">."); } catch ( IOException e ) { log.error( "writeCoverageDataToFile(): Failed to write file for requested coverage <" + identifier + ">: " + e.getMessage()); throw new WcsException( WcsException.Code.NoApplicableCode, "", "Problem creating coverage <" + identifier + ">." ); } }
public static void main(String args[]) throws IOException, InvalidRangeException, ParseException { String fileIn = "dods://motherlode.ucar.edu/repository/entry/show/output:data.opendap/entryid:c41a3a26-57e5-4b15-b8b1-a8762b6f02c7/dodsC/entry"; String fileOut = "C:/temp/testCF.nc"; ucar.nc2.dt.GridDataset gds = ucar.nc2.dt.grid.GridDataset.open(fileIn); NetcdfCFWriter writer = new NetcdfCFWriter(); List<String> gridList = new ArrayList<String>(); gridList.add("Z_sfc"); DateFormatter format = new DateFormatter(); Date start = format.getISODate("2003-06-01T03:00:00Z"); Date end = format.getISODate("2004-01-01T00:00:00Z"); writer.makeFile(fileOut, gds, gridList, null, // new LatLonRect(new LatLonPointImpl(30, -109), 10, 50), CalendarDateRange.of(start, end), true, 1, 1, 1); }
public static void test1() throws IOException, InvalidRangeException, ParseException { String fileIn = "C:/data/ncmodels/NAM_CONUS_80km_20051206_0000.nc"; String fileOut = "C:/temp/cf3.nc"; ucar.nc2.dt.GridDataset gds = ucar.nc2.dt.grid.GridDataset.open(fileIn); NetcdfCFWriter writer = new NetcdfCFWriter(); List<String> gridList = new ArrayList<String>(); gridList.add("RH"); gridList.add("T"); DateFormatter format = new DateFormatter(); Date start = format.getISODate("2005-12-06T18:00:00Z"); Date end = format.getISODate("2005-12-07T18:00:00Z"); writer.makeFile(fileOut, gds, gridList, new LatLonRect(new LatLonPointImpl(37, -109), 400, 7), CalendarDateRange.of(start, end), true, 1, 1, 1); }
writer.makeFile( ncFile.getPath(), this.dataset.getDataset(), rangeSubset, bboxLatLonRect, 1,
writer.makeFile( ncFile.getPath(), this.dataset.getDataset(), Collections.singletonList( this.coverage.getFullName() ), bboxLatLonRect, 1,