private List<CoordinateTransform> getCoordTransforms(ucar.nc2.dt.GridDataset gds) { Set<CoordinateTransform> ctHash = new HashSet<>(); for (ucar.nc2.dt.GridDataset.Gridset gridset : gds.getGridsets()) { GridCoordSystem gcs = gridset.getGeoCoordSystem(); for (CoordinateTransform axe : gcs.getCoordinateTransforms()) ctHash.add(axe); } List<CoordinateTransform> list = Arrays.asList((CoordinateTransform[]) ctHash.toArray( new CoordinateTransform[ ctHash.size()])); Collections.sort(list); return list; }
private List<CoordinateTransform> getCoordTransforms(ucar.nc2.dt.GridDataset gds) { Set<CoordinateTransform> ctHash = new HashSet<CoordinateTransform>(); for (ucar.nc2.dt.GridDataset.Gridset gridset : gds.getGridsets()) { GridCoordSystem gcs = gridset.getGeoCoordSystem(); for (CoordinateTransform axe : gcs.getCoordinateTransforms()) ctHash.add(axe); } List<CoordinateTransform> list = Arrays.asList((CoordinateTransform[]) ctHash.toArray( new CoordinateTransform[ ctHash.size()])); Collections.sort(list); return list; }
private List<CoordinateTransform> getCoordTransforms(ucar.nc2.dt.GridDataset gds) { Set<CoordinateTransform> ctHash = new HashSet<>(); for (ucar.nc2.dt.GridDataset.Gridset gridset : gds.getGridsets()) { GridCoordSystem gcs = gridset.getGeoCoordSystem(); for (CoordinateTransform axe : gcs.getCoordinateTransforms()) ctHash.add(axe); } List<CoordinateTransform> list = Arrays.asList((CoordinateTransform[]) ctHash.toArray( new CoordinateTransform[ ctHash.size()])); Collections.sort(list); return list; }
private void addCoordinateTransform(GridCoordSystem gcs, NetcdfFile ncd, List<String> varNameList, List<Variable> varList) { for (CoordinateTransform ct : gcs.getCoordinateTransforms()) { Variable v = ncd.findVariable(ct.getName()); if (!varNameList.contains(ct.getName()) && (null != v)) { varNameList.add(ct.getName()); varList.add(v); } } }
private void addCoordinateTransform(GridCoordSystem gcs, NetcdfFile ncd, List<String> varNameList, List<Variable> varList) { for (CoordinateTransform ct : gcs.getCoordinateTransforms()) { Variable v = ncd.findVariable(ct.getName()); if (!varNameList.contains(ct.getName()) && (null != v)) { varNameList.add(ct.getName()); varList.add(v); } } }
private void addCoordinateTransform(GridCoordSystem gcs, NetcdfFile ncd, List<String> varNameList, List<Variable> varList) { for (CoordinateTransform ct : gcs.getCoordinateTransforms()) { Variable v = ncd.findVariable(ct.getName()); if (!varNameList.contains(ct.getName()) && (null != v)) { varNameList.add(ct.getName()); varList.add(v); } } }
private void addCoordinateTransform(GridCoordSystem gcs, NetcdfFile ncd, List<String> varNameList, List<Variable> varList) { for (CoordinateTransform ct : gcs.getCoordinateTransforms()) { Variable v = ncd.findVariable(ct.getName()); if (!varNameList.contains(ct.getName()) && (null != v)) { varNameList.add(ct.getName()); varList.add(v); } } }
private void addCoordinateTransform(GridCoordSystem gcs, NetcdfFile ncd, List<String> varNameList, List<Variable> varList) { List<String> coordTransformNames = new ArrayList<>(); // look for variables detected as coordinate transforms for (CoordinateTransform ct : gcs.getCoordinateTransforms()) { coordTransformNames.add(ct.getName()); } // At the very least, LatLon_Projection will not show up in the coordinate transforms, // so inspect the variables in varNameList for a grid_mapping attribute, and make sure it // gets picked up as well // see https://github.com/Unidata/python-workshop/issues/372 for (String varName : varNameList) { Variable v = ncd.findVariable(varName); Attribute gridMapping = v.findAttributeIgnoreCase(CF.GRID_MAPPING); if (gridMapping != null) { String gridMappingName = gridMapping.getStringValue(); if ((gridMappingName != null) && (!coordTransformNames.contains(gridMappingName))) { coordTransformNames.add(gridMappingName); } } } // add the coordinate transforms that we found for (String ctVarName : coordTransformNames) { Variable v = ncd.findVariable(ctVarName); if (!varNameList.contains(ctVarName) && (null != v)) { varNameList.add(ctVarName); varList.add(v); } } }
@Test public void testCF() throws IOException { try (GridDataset ds = GridDataset.open(TestDir.cdmUnitTestDir + "conventions/cf/twoGridMaps.nc")) { GeoGrid grid = ds.findGridByName("altitude"); GridCoordSystem gcs = grid.getCoordinateSystem(); assert 1 == gcs.getCoordinateTransforms().size(); CoordinateTransform ct = gcs.getCoordinateTransforms().get(0); assert ct.getTransformType() == TransformType.Projection; assert ct.getName().equals("projection_stere"); } }
private Element writeCoordSys(GridCoordSystem cs) { Element csElem = new Element("coordSys"); csElem.setAttribute("name", cs.getName()); List axes = cs.getCoordinateAxes(); for (int i = 0; i < axes.size(); i++) { CoordinateAxis axis = (CoordinateAxis) axes.get(i); Element axisElem = new Element("axisRef"); axisElem.setAttribute("name", axis.getFullName()); csElem.addContent(axisElem); } List cts = cs.getCoordinateTransforms(); for (int j = 0; j < cts.size(); j++) { CoordinateTransform ct = (CoordinateTransform) cts.get(j); Element elem = new Element("coordTransRef"); elem.setAttribute("name", ct.getName()); csElem.addContent(elem); } return csElem; }
private Element writeCoordSys(GridCoordSystem cs) { Element csElem = new Element("coordSys"); csElem.setAttribute("name", cs.getName()); List axes = cs.getCoordinateAxes(); for (int i = 0; i < axes.size(); i++) { CoordinateAxis axis = (CoordinateAxis) axes.get(i); Element axisElem = new Element("axisRef"); axisElem.setAttribute("name", axis.getFullName()); csElem.addContent(axisElem); } List cts = cs.getCoordinateTransforms(); for (int j = 0; j < cts.size(); j++) { CoordinateTransform ct = (CoordinateTransform) cts.get(j); Element elem = new Element("coordTransRef"); elem.setAttribute("name", ct.getName()); csElem.addContent(elem); } return csElem; }
private Element writeCoordSys(GridCoordSystem cs) { Element csElem = new Element("coordSys"); csElem.setAttribute("name", cs.getName()); List axes = cs.getCoordinateAxes(); for (int i = 0; i < axes.size(); i++) { CoordinateAxis axis = (CoordinateAxis) axes.get(i); Element axisElem = new Element("axisRef"); axisElem.setAttribute("name", axis.getFullName()); csElem.addContent(axisElem); } List cts = cs.getCoordinateTransforms(); for (int j = 0; j < cts.size(); j++) { CoordinateTransform ct = (CoordinateTransform) cts.get(j); Element elem = new Element("coordTransRef"); elem.setAttribute("name", ct.getName()); csElem.addContent(elem); } return csElem; }
List<CoordinateTransform> cctt = grid.getCoordinateSystem().getCoordinateTransforms(); for (CoordinateTransform ct : cctt) { Parameter param = ct.findParameterIgnoreCase(CF.FORMULA_TERMS);
List<CoordinateTransform> cctt = grid.getCoordinateSystem().getCoordinateTransforms(); for (CoordinateTransform ct : cctt) { Parameter param = ct.findParameterIgnoreCase(CF.FORMULA_TERMS);
private long processTransformationVars(ArrayList<Variable> varList, ArrayList<String> varNameList , NetcdfDataset ncd, ucar.nc2.dt.GridDataset gds, GridDatatype grid, Range timeRange, Range zRangeUse, Range yRange, Range xRange, int z_stride, int y_stride, int x_stride) throws InvalidRangeException { List<CoordinateTransform> cctt = grid.getCoordinateSystem().getCoordinateTransforms(); for(CoordinateTransform ct : cctt){ Parameter param = ct.findParameterIgnoreCase( CF.FORMULA_TERMS );
List<CoordinateTransform> cctt = grid.getCoordinateSystem().getCoordinateTransforms(); for (CoordinateTransform ct : cctt) { Parameter param = ct.findParameterIgnoreCase(CF.FORMULA_TERMS);
List<CoordinateTransform> cctt = grid.getCoordinateSystem().getCoordinateTransforms(); for (CoordinateTransform ct : cctt) { Parameter param = ct.findParameterIgnoreCase(CF.FORMULA_TERMS);
for (CoordinateTransform ct : cs.getCoordinateTransforms()) { Element elem = new Element("coordTransRef"); elem.setAttribute("name", ct.getName());
for (CoordinateTransform ct : cs.getCoordinateTransforms()) { Element elem = new Element("coordTransRef"); elem.setAttribute("name", ct.getName());
private void testCoordinates(String filename, double startLat, double startLon, double endLat, double endLon) throws IOException, InvalidRangeException { System.out.printf("%n***Open %s%n", filename); NetcdfDataset ncd = NetcdfDataset.openDataset(filename); GridDataset gds = new GridDataset(ncd); GridCoordSystem gsys = null; ProjectionImpl p = null; for (ucar.nc2.dt.GridDataset.Gridset g : gds.getGridsets()) { gsys = g.getGeoCoordSystem(); for (CoordinateTransform t : gsys.getCoordinateTransforms()) { if (t instanceof ProjectionCT) { p = ((ProjectionCT)t).getProjection(); break; } } } assert p != null; CoordinateAxis1D xaxis = (CoordinateAxis1D) gsys.getXHorizAxis(); CoordinateAxis1D yaxis = (CoordinateAxis1D) gsys.getYHorizAxis(); p.projToLatLon(xaxis.getCoordValue(0), yaxis.getCoordValue(0) ); LatLonPoint start1 = p.projToLatLon(xaxis.getCoordValue(0), yaxis.getCoordValue(0)); LatLonPoint start2 = p.projToLatLon(xaxis.getCoordValue((int)xaxis.getSize()-1), yaxis.getCoordValue((int)yaxis.getSize()-1)); System.out.printf( "start = %f %f%n", start1.getLatitude(), start1.getLongitude()); System.out.printf( "end = %f %f%n", start2.getLatitude(), start2.getLongitude()); assert start1.nearlyEquals(new LatLonPointImpl(startLat, startLon), 2.0E-4); assert start2.nearlyEquals(new LatLonPointImpl(endLat, endLon), 2.0E-4); ncd.close(); }