/** * 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 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); }
static public void makeFileVersioned(String location, ucar.nc2.dt.GridDataset gds, List<String> gridList, LatLonRect llbb, CalendarDateRange dateRange, NetcdfFileWriter.Version version) throws IOException, InvalidRangeException { NetcdfCFWriter writer = new NetcdfCFWriter(); writer.makeOrTestSize(location, gds, gridList, llbb, 1, null, dateRange, 1, false, false, version); }
Range timeRange = makeTimeRange(dateRange, timeAxis, stride_time); Range zRangeUse = makeVerticalRange(zRange, vertAxis); addCoordinateAxis(gcs, varNameList, varList, axisList); addCoordinateTransform(gcs, ncd, varNameList, varList); total_size += processTransformationVars(varList, varNameList, ncd, gds, grid, timeRange, zRangeUse, llbb, 1, horizStride, horizStride, axisList ); Projection proj = gcs.getProjection(); if ((null != proj) && !(proj instanceof LatLonProjection)) { addLatLon2D(ncd, varList, proj, gcs.getXHorizAxis(), gcs.getYHorizAxis()); addLatLon = false; boolean isLargeFile = isLargeFile(total_size); writeGlobalAttributes(writer, gds, resultBB); fileWriter.addVariable(v); addCFAnnotations(writer, gds, gridList, ncd, axisList, addLatLon);
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, NetcdfFileWriter.Version version) throws IOException, InvalidRangeException { return makeOrTestSize(location, gds, gridList, llbb, horizStride, zRange, dateRange, stride_time, addLatLon, false, version); }
double scalef = AbstractCoordTransBuilder.getFalseEastingScaleFactor(ds, ctv); if (scalef != 1.0) { convertAttribute(ctv, east, scalef); convertAttribute(ctv, north, scalef);
convertProjectionCTV((NetcdfDataset) gds.getNetcdfFile(), v); ctvList.add(v);
Range timeRange = makeTimeRange(dateRange, timeAxis, stride_time); Range x_range = new Range(minxCoord, maxxCoord, horizStride); Range zRangeUse = makeVerticalRange(zRange, vertAxis); llrec = gcs.getLatLonBoundingBox(); addCoordinateAxis(gcs, varNameList, varList, axisList); addCoordinateTransform(gcs, ncd, varNameList, varList); total_size += processTransformationVars(varList, varNameList, ncd, gds, grid, timeRange, zRangeUse, y_range, x_range, 1, horizStride, horizStride ); Projection proj = gcs.getProjection(); if ((null != proj) && !(proj instanceof LatLonProjection)) { addLatLon2D(ncd, varList, proj, gcs.getXHorizAxis(), gcs.getYHorizAxis()); addLatLon = false; boolean isLargeFile = isLargeFile(total_size); writer.setLargeFile(isLargeFile); writeGlobalAttributes(writer, gds, resultBB); fileWriter.addVariable(v); addCFAnnotations(writer, gds, gridList, ncd, axisList, addLatLon);
public long makeFile(String location, ucar.nc2.dt.GridDataset gds, List<String> gridList, ProjectionRect llbb, int horizStride, Range zRange, CalendarDateRange dateRange, int stride_time, boolean addLatLon, NetcdfFileWriter.Version version) throws IOException, InvalidRangeException { return makeOrTestSize(location, gds, gridList, llbb, horizStride, zRange, dateRange, stride_time, addLatLon, false, version); }
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 long makeFile(String location, ucar.nc2.dt.GridDataset gds, List<String> gridList, ProjectionRect 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); }
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); }
/** * Write a netcdf-3 file from a subset of a grid dataset (projection coordinates), as long as it doesnt exceed a certain file size. * @param gds from this grid dataset * @param gridList just these grids * @param projBB horiz subset in Projection coords, may be null * @param zRange vertical subset, may be null * @param dateRange time subset, may be null * @param stride_time time may be strided, -1 if want all * @param addLatLon optionally add a lat/lon coordinate (if dataset uses projection coords) * @return file size * @throws IOException * @throws InvalidRangeException */ public long makeGridFileSizeEstimate(ucar.nc2.dt.GridDataset gds, List<String> gridList, ProjectionRect projBB, int horizStride, Range zRange, CalendarDateRange dateRange, int stride_time, boolean addLatLon) throws IOException, InvalidRangeException { return makeOrTestSize(null, gds, gridList, projBB, horizStride, zRange, dateRange, stride_time, addLatLon, true, NetcdfFileWriter.Version.netcdf3); }
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); }
/** * Write a netcdf-3 file from a subset of a grid dataset, as long as it doesnt exceed a certain file size. * * @param gds from this grid dataset * @param gridList just these grids * @param llbb horiz subset, may be null * @param zRange vertical subset, may be null * @param dateRange time subset, may be null * @param stride_time time may be strided, -1 if want all * @param addLatLon optionally add a lat/lon coordinate (if dataset uses projection coords) * @return file size * @throws IOException * @throws InvalidRangeException */ public long makeGridFileSizeEstimate(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(null, gds, gridList, llbb, horizStride, zRange, dateRange, stride_time, addLatLon, true, NetcdfFileWriter.Version.netcdf3); }
NetcdfCFWriter writer = new NetcdfCFWriter(); this.coordSys.getVerticalAxis().isNumeric(); writer.makeFile( ncFile.getPath(), this.dataset.getDataset(), rangeSubset, bboxLatLonRect, 1,
NetcdfCFWriter writer = new NetcdfCFWriter(); writer.makeFile( ncFile.getPath(), this.dataset.getDataset(), Collections.singletonList( this.coverage.getFullName() ), bboxLatLonRect, 1,