String dataset = extractDatasetFromLocation(gds.getLocation()); if (dataset != null) { for (VariableRenamerBean r : mbean.newVars) {
@Test public void testNullHorizSubset2() throws IOException, InvalidRangeException { boolean addLatLon = false; LatLonRect llbb = null; Range zRange = null; CalendarDateRange dateRange = null; List<String> gridList = new ArrayList<>(); gridList.add("Temperature_surface"); int stride_time = 1; int horizStride = 1; File outFile = tempFolder.newFile(); NetcdfFileWriter writer = NetcdfFileWriter.createNew(NetcdfFileWriter.Version.netcdf3, outFile.getAbsolutePath()); CFGridWriter2.writeFile(gds, gridList, null, null, horizStride, zRange, dateRange, stride_time, addLatLon, writer); assert outFile.exists(); try ( GridDataset result = ucar.nc2.dt.grid.GridDataset.open(outFile.getAbsolutePath())) { System.out.printf("result = %s%n", result.getLocation()); } }
private void writeGlobalAttributes(NetcdfFileWriter writer, ucar.nc2.dt.GridDataset gds, LatLonRect llbb) { // global attributes for (Attribute att : gds.getGlobalAttributes()) { if (att.getShortName().equals(CDM.FILE_FORMAT)) continue; if (att.getShortName().equals(_Coordinate._CoordSysBuilder)) continue; writer.addGroupAttribute(null, att); } Attribute att = gds.findGlobalAttributeIgnoreCase(CDM.CONVENTIONS); if (att == null || !att.getStringValue().startsWith("CF-")) // preserve previous version of CF Convention if it exists writer.addGroupAttribute(null, new Attribute(CDM.CONVENTIONS, "CF-1.0")); writer.addGroupAttribute(null, new Attribute("History", "Translated to CF-1.0 Conventions by Netcdf-Java CDM (CFGridWriter)\n" + "Original Dataset = " + gds.getLocation() + "; Translation Date = " + CalendarDate.present())); // this will replace any existing writer.addGroupAttribute(null, new Attribute(ACDD.LAT_MIN, llbb.getLatMin())); writer.addGroupAttribute(null, new Attribute(ACDD.LAT_MAX, llbb.getLatMax())); writer.addGroupAttribute(null, new Attribute(ACDD.LON_MIN, llbb.getLonMin())); writer.addGroupAttribute(null, new Attribute(ACDD.LON_MAX, llbb.getLonMax())); }
private void addGlobalAttributes(NetcdfFileWriter writer, ucar.nc2.dt.GridDataset gds, LatLonRect llbb) { // global attributes for (Attribute att : gds.getGlobalAttributes()) { if (att.getShortName().equals(CDM.FILE_FORMAT)) continue; if (att.getShortName().equals(_Coordinate._CoordSysBuilder)) continue; writer.addGroupAttribute(null, att); } Attribute att = gds.findGlobalAttributeIgnoreCase(CDM.CONVENTIONS); if (att == null || !att.getStringValue().startsWith("CF-")) // preserve previous version of CF Convention if it exists writer.addGroupAttribute(null, new Attribute(CDM.CONVENTIONS, "CF-1.0")); writer.addGroupAttribute(null, new Attribute("History", "Translated to CF-1.0 Conventions by Netcdf-Java CDM (CFGridWriter2)\n" + "Original Dataset = " + gds.getLocation() + "; Translation Date = " + CalendarDate.present())); // this will replace any existing writer.addGroupAttribute(null, new Attribute(ACDD.LAT_MIN, llbb.getLatMin())); writer.addGroupAttribute(null, new Attribute(ACDD.LAT_MAX, llbb.getLatMax())); writer.addGroupAttribute(null, new Attribute(ACDD.LON_MIN, llbb.getLonMin())); writer.addGroupAttribute(null, new Attribute(ACDD.LON_MAX, llbb.getLonMax())); }
Variable newV = writer.findVariable(gridName); if (newV == null) { log.debug("NetcdfCFWriter cant find " + gridName + " in gds " + gds.getLocation()); continue;
Variable newV = writer.findVariable(gridName); if (newV == null) { log.warn("NetcdfCFWriter cant find " + gridName + " in gds " + gds.getLocation()); continue;
Element rootElem = new Element("gridForm"); Document doc = new Document(rootElem); rootElem.setAttribute("location", gds.getLocation()); if (null != path) rootElem.setAttribute("path", path);
Element rootElem = new Element("gridDataset"); Document doc = new Document(rootElem); rootElem.setAttribute("location", gds.getLocation()); if (null != path) rootElem.setAttribute("path", path);