/** * debug * * @param args ignored * @throws java.io.IOException on io error */ public static void main(String args[]) throws IOException { String url = "cdmremote:http://localhost:8080/thredds/cdmremote/grib/NCDC/CFSR/NCDC-CFSR/PGB-LatLon0p5"; GridDataset ncd = ucar.nc2.dt.grid.GridDataset.open(url); GridDatasetInfo info = new GridDatasetInfo(ncd, null); FileOutputStream fos2 = new FileOutputStream("C:/tmp2/gridInfo.xml"); info.writeXML(info.makeGridForm(), fos2); fos2.close(); String infoString = info.writeXML(info.makeGridForm()); System.out.println(infoString); }
for (CoordinateAxis axis : getCoordAxes(gds)) { rootElem.addContent(writeAxis(axis)); Collections.sort(gridSets, new GridSetComparator()); for (GridDataset.Gridset gridset : gridSets) { rootElem.addContent(writeGridSet(gridset)); for (CoordinateTransform ct : getCoordTransforms(gds)) { rootElem.addContent(writeCoordTransform(ct)); rootElem.addContent(writeBoundingBox(bb)); addAcceptList(rootElem);
CoordinateAxis1D ens = gcs.getEnsembleAxis(); if(ens != null){ Element ensAxisEl = writeAxis2(ens, "ensemble"); rootElem.addContent(ensAxisEl); if ((i == 0) || !compareAxis(time, currentTime)) { timeElem = new Element("timeSet"); rootElem.addContent(timeElem); Element timeAxisElement = writeAxis2(time, "time"); if (timeAxisElement != null) timeElem.addContent(timeAxisElement); if (newTime || !compareAxis(vert, currentVert)) { vertElem = new Element("vertSet"); timeElem.addContent(vertElem); Element vertAxisElement = writeAxis2(vert, "vert"); if (vertAxisElement != null) vertElem.addContent(vertAxisElement); vertElem.addContent(writeGrid(grid)); rootElem.addContent(writeBoundingBox(bb)); addAcceptList(rootElem);
private Element writeAxis2(CoordinateAxis axis, String name) { if (axis == null) return null; NcMLWriter ncmlWriter = new NcMLWriter(); Element varElem = new Element(name); varElem.setAttribute("name", axis.getFullName()); varElem.setAttribute("shape", getShapeString(axis.getShape())); // axis.getDimensionsString()); DataType dt = axis.getDataType(); varElem.setAttribute("type", dt.toString()); AxisType axisType = axis.getAxisType(); if (null != axisType) varElem.setAttribute("axisType", axisType.toString()); // attributes for (Attribute att : axis.getAttributes()) varElem.addContent(ncmlWriter.makeAttributeElement(att)); try { Element values = ncmlWriter.makeValuesElement(axis, false); values.setAttribute("npts", Long.toString(axis.getSize())); varElem.addContent(values); } catch (IOException e) { String message = String.format( "Couldn't read values for %s. Omitting <values> element.", axis.getFullName()); logger.warn(message, e); } return varElem; }
for (CoordinateAxis axis : getCoordAxes(gds)) { rootElem.addContent(writeAxis(axis)); Collections.sort(gridSets, new GridSetComparator()); for (GridDataset.Gridset gridset : gridSets) { rootElem.addContent(writeGridSet(gridset)); for (CoordinateTransform ct : getCoordTransforms(gds)) { rootElem.addContent(writeCoordTransform(ct)); rootElem.addContent(writeBoundingBox(bb)); addAcceptList(rootElem);
CoordinateAxis1D ens = gcs.getEnsembleAxis(); if(ens != null){ Element ensAxisEl = writeAxis2(ens, "ensemble"); rootElem.addContent(ensAxisEl); if ((i == 0) || !compareAxis(time, currentTime)) { timeElem = new Element("timeSet"); rootElem.addContent(timeElem); Element timeAxisElement = writeAxis2(time, "time"); if (timeAxisElement != null) timeElem.addContent(timeAxisElement); if (newTime || !compareAxis(vert, currentVert)) { vertElem = new Element("vertSet"); timeElem.addContent(vertElem); Element vertAxisElement = writeAxis2(vert, "vert"); if (vertAxisElement != null) vertElem.addContent(vertAxisElement); vertElem.addContent(writeGrid(grid)); rootElem.addContent(writeBoundingBox(bb)); addAcceptList(rootElem);
private Element writeAxis(CoordinateAxis axis) { NcMLWriter ncmlWriter = new NcMLWriter(); Element varElem = new Element("axis"); varElem.setAttribute("name", axis.getFullName()); varElem.setAttribute("shape", getShapeString(axis.getShape())); // axis.getDimensionsString()); DataType dt = axis.getDataType(); varElem.setAttribute("type", dt.toString()); AxisType axisType = axis.getAxisType(); if (null != axisType) varElem.setAttribute("axisType", axisType.toString()); // attributes for (Attribute att : axis.getAttributes()) { varElem.addContent(ncmlWriter.makeAttributeElement(att)); } if (axis.getRank() == 1) { try { Element values = ncmlWriter.makeValuesElement(axis, true); varElem.addContent(values); } catch (IOException e) { String message = String.format( "Couldn't read values for %s. Omitting <values> element.", axis.getFullName()); logger.warn(message, e); } } return varElem; }
for (CoordinateAxis axis : getCoordAxes(gds)) { rootElem.addContent(writeAxis(axis)); Collections.sort(gridSets, new GridSetComparator()); for (GridDataset.Gridset gridset : gridSets) { rootElem.addContent(writeGridSet(gridset)); for (CoordinateTransform ct : getCoordTransforms(gds)) { rootElem.addContent(writeCoordTransform(ct)); rootElem.addContent(writeBoundingBox(bb)); addAcceptList(rootElem);
CoordinateAxis1D ens = gcs.getEnsembleAxis(); if(ens != null){ Element ensAxisEl = writeAxis2(ens, "ensemble"); rootElem.addContent(ensAxisEl); if ((i == 0) || !compareAxis(time, currentTime)) { timeElem = new Element("timeSet"); rootElem.addContent(timeElem); Element timeAxisElement = writeAxis2(time, "time"); if (timeAxisElement != null) timeElem.addContent(timeAxisElement); if (newTime || !compareAxis(vert, currentVert)) { vertElem = new Element("vertSet"); timeElem.addContent(vertElem); Element vertAxisElement = writeAxis2(vert, "vert"); if (vertAxisElement != null) vertElem.addContent(vertAxisElement); vertElem.addContent(writeGrid(grid)); rootElem.addContent(writeBoundingBox(bb)); addAcceptList(rootElem);
/** * debug * * @param args ignored * @throws java.io.IOException on io error */ public static void main(String args[]) throws IOException { String url = "cdmremote:http://localhost:8080/thredds/cdmremote/grib/NCDC/CFSR/NCDC-CFSR/PGB-LatLon0p5"; GridDataset ncd = ucar.nc2.dt.grid.GridDataset.open(url); GridDatasetInfo info = new GridDatasetInfo(ncd, null); FileOutputStream fos2 = new FileOutputStream("C:/tmp2/gridInfo.xml"); info.writeXML(info.makeGridForm(), fos2); fos2.close(); String infoString = info.writeXML(info.makeGridForm()); System.out.println(infoString); }
private Element writeAxis2(CoordinateAxis axis, String name) { if (axis == null) return null; Element varElem = new Element(name); varElem.setAttribute("name", axis.getFullName()); varElem.setAttribute("shape", getShapeString(axis.getShape())); // axis.getDimensionsString()); DataType dt = axis.getDataType(); varElem.setAttribute("type", dt.toString()); AxisType axisType = axis.getAxisType(); if (null != axisType) varElem.setAttribute("axisType", axisType.toString()); // attributes for (Attribute att : axis.getAttributes()) varElem.addContent(ucar.nc2.ncml.NcMLWriter.writeAttribute(att, "attribute", null)); Element values = ucar.nc2.ncml.NcMLWriter.writeValues(axis, null, false); values.setAttribute("npts", Long.toString(axis.getSize())); varElem.addContent(values); return varElem; }
/** * debug * * @param args ignored * @throws java.io.IOException on io error */ public static void main(String args[]) throws IOException { String url = "cdmremote:http://localhost:8080/thredds/cdmremote/grib/NCDC/CFSR/NCDC-CFSR/PGB-LatLon0p5"; GridDataset ncd = ucar.nc2.dt.grid.GridDataset.open(url); GridDatasetInfo info = new GridDatasetInfo(ncd, null); FileOutputStream fos2 = new FileOutputStream("C:/tmp2/gridInfo.xml"); info.writeXML(info.makeGridForm(), fos2); fos2.close(); String infoString = info.writeXML(info.makeGridForm()); System.out.println(infoString); }
private Element writeAxis2(CoordinateAxis axis, String name) { if (axis == null) return null; Element varElem = new Element(name); varElem.setAttribute("name", axis.getFullName()); varElem.setAttribute("shape", getShapeString(axis.getShape())); // axis.getDimensionsString()); DataType dt = axis.getDataType(); varElem.setAttribute("type", dt.toString()); AxisType axisType = axis.getAxisType(); if (null != axisType) varElem.setAttribute("axisType", axisType.toString()); // attributes for (Attribute att : axis.getAttributes()) varElem.addContent(ucar.nc2.ncml.NcMLWriter.writeAttribute(att, "attribute", null)); Element values = ucar.nc2.ncml.NcMLWriter.writeValues(axis, null, false); values.setAttribute("npts", Long.toString(axis.getSize())); varElem.addContent(values); return varElem; }
private Element writeAxis(CoordinateAxis axis) { Element varElem = new Element("axis"); varElem.setAttribute("name", axis.getFullName()); varElem.setAttribute("shape", getShapeString(axis.getShape())); // axis.getDimensionsString()); DataType dt = axis.getDataType(); varElem.setAttribute("type", dt.toString()); AxisType axisType = axis.getAxisType(); if (null != axisType) varElem.setAttribute("axisType", axisType.toString()); // attributes for (Attribute att : axis.getAttributes()) { varElem.addContent(ucar.nc2.ncml.NcMLWriter.writeAttribute(att, "attribute", null)); } if (axis.getRank() == 1) { Element values = ucar.nc2.ncml.NcMLWriter.writeValues(axis, null, true); //values.setAttribute("npts", Long.toString(axis.getSize())); varElem.addContent(values); } return varElem; }
private Element writeAxis(CoordinateAxis axis) { Element varElem = new Element("axis"); varElem.setAttribute("name", axis.getFullName()); varElem.setAttribute("shape", getShapeString(axis.getShape())); // axis.getDimensionsString()); DataType dt = axis.getDataType(); varElem.setAttribute("type", dt.toString()); AxisType axisType = axis.getAxisType(); if (null != axisType) varElem.setAttribute("axisType", axisType.toString()); // attributes for (Attribute att : axis.getAttributes()) { varElem.addContent(ucar.nc2.ncml.NcMLWriter.writeAttribute(att, "attribute", null)); } if (axis.getRank() == 1) { Element values = ucar.nc2.ncml.NcMLWriter.writeValues(axis, null, true); //values.setAttribute("npts", Long.toString(axis.getSize())); varElem.addContent(values); } return varElem; }