@Override public List<CoordinateAxis> getCoordinateAxes() { return cs.getCoordinateAxes(); } }
CoordinateSystemAdapter(CoordinateSystem cs) { this.cs = cs; // Check if the Vertical axis is present if (cs.hasVerticalAxis()) { vertical = true; } else { // Check if any of the unsupported dimensions is present Set<String> unsupported = NetCDFUtilities.getUnsupportedDimensions(); boolean present = false; for (String dimension : unsupported) { if (cs.containsAxis(dimension)) { present = true; break; } } if (present) { vertical = true; } else { vertical = false; } } }
@Override public CoordinateAxis getYHorizAxis() { return cs.isLatLon() ? cs.getLatAxis() : cs.getYaxis(); }
public void setCoordMap(java.util.List<CoordinateSystem> csysList) { CoordinateSystem use = null; for (CoordinateSystem csys : csysList) { if (use == null) use = csys; else if (csys.getCoordinateAxes().size() > use.getCoordinateAxes().size()) use = csys; } coordMap = (use == null) ? "" : "f:D(" + use.getRankDomain() + ")->R(" + use.getRankRange() + ")"; }
if (cs.getRankDomain() < 2) { if (sbuff != null) { sbuff.format("%s: domain rank < 2%n", cs.getName()); if (!cs.isLatLon()) { if ((cs.getXaxis() == null) || (cs.getYaxis() == null)) { if (sbuff != null) { sbuff.format("%s: NO Lat,Lon or X,Y axis%n", cs.getName()); if (null == cs.getProjection()) { if (sbuff != null) { sbuff.format("%s: NO projection found%n", cs.getName()); if (cs.isGeoXY()) { xaxis = cs.getXaxis(); yaxis = cs.getYaxis(); ProjectionImpl p = cs.getProjection(); if (!(p instanceof RotatedPole)) { if (!SimpleUnit.kmUnit.isCompatible(xaxis.getUnitsString())) { if (sbuff != null) { sbuff.format("%s: X axis units are not convertible to km%n", cs.getName()); sbuff.format("%s: Y axis units are not convertible to km%n", cs.getName()); xaxis = cs.getLonAxis(); yaxis = cs.getLatAxis();
this.ds = cs.getNetcdfDataset(); if (cs.isGeoXY()) { horizXaxis = xAxis = cs.getXaxis(); horizYaxis = yAxis = cs.getYaxis(); ProjectionImpl p = cs.getProjection(); if (!(p instanceof RotatedPole) && !(p instanceof RotatedLatLon)) { } else if (cs.isLatLon()) { horizXaxis = lonAxis = cs.getLonAxis(); horizYaxis = latAxis = cs.getLatAxis(); isLatLon = true; ProjectionImpl projOrig = cs.getProjection(); if (projOrig != null) { proj = projOrig.constructCopy(); CoordinateAxis z_oneD = hAxis = cs.getHeightAxis(); if ((z_oneD == null) || !(z_oneD instanceof CoordinateAxis1D)) z_oneD = pAxis = cs.getPressureAxis(); if ((z_oneD == null) || !(z_oneD instanceof CoordinateAxis1D)) z_oneD = zAxis = cs.getZaxis(); if ((z_oneD != null) && !(z_oneD instanceof CoordinateAxis1D)) z_oneD = null; CoordinateAxis t = cs.getTaxis(); if (t != null) { ensembleAxis = (CoordinateAxis1D) cs.findAxis(AxisType.Ensemble); if (null != ensembleAxis) coordAxes.add(ensembleAxis);
if (cs.getRankDomain() < 2) { if (errlog != null) errlog.format("CoordinateSystem '%s': domain rank < 2%n", cs.getName()); return; if (!cs.isLatLon()) { if ((cs.getXaxis() == null) || (cs.getYaxis() == null)) { if (errlog != null) errlog.format("%s: NO Lat,Lon or X,Y axis%n", cs.getName()); return; if (null == cs.getProjection()) { if (errlog != null) errlog.format("%s: NO projection found%n", cs.getName()); return; if (cs.isGeoXY()) { xaxis = cs.getXaxis(); yaxis = cs.getYaxis(); ProjectionImpl p = cs.getProjection(); if (!(p instanceof RotatedPole)) { if (!SimpleUnit.kmUnit.isCompatible(xaxis.getUnitsString())) { if (errlog != null) errlog.format("%s: X axis units are not convertible to km%n", cs.getName()); if (errlog != null) errlog.format("%s: Y axis units are not convertible to km%n", cs.getName()); xaxis = cs.getLonAxis(); yaxis = cs.getLatAxis(); isLatLon = true;
/** Override Object.hashCode() to implement equals. */ public int hashCode() { if (hashCode == 0) { int result = 17; result = 37*result + getName().hashCode(); result = 37*result + getCoordinateAxes().hashCode(); result = 37*result + getCoordinateTransforms().hashCode(); hashCode = result; } return hashCode; } private volatile int hashCode = 0;
private CoordinateSystem findReplacementCs(CoordinateSystem protoCs, String timeDim, NetcdfDataset result) { CoordinateSystem replace = result.findCoordinateSystem(protoCs.getName()); if (replace != null) return replace; List<CoordinateAxis> axes = new ArrayList<>(); for (CoordinateAxis axis : protoCs.getCoordinateAxes()) { CoordinateAxis ra = result.findCoordinateAxis(axis.getFullNameEscaped()); axes.add(ra); } // coord transforms are immutable and can be shared CoordinateSystem cs = new CoordinateSystem(result, axes, protoCs.getCoordinateTransforms()); result.addCoordinateSystem(cs); return cs; }
static private boolean isGrid(java.util.List<CoordinateSystem> csysList) { CoordinateSystem use = null; for (CoordinateSystem csys : csysList) { if (use == null) use = csys; else if (csys.getCoordinateAxes().size() > use.getCoordinateAxes().size()) use = csys; } if (use == null) return false; CoordinateAxis lat = use.getLatAxis(); CoordinateAxis lon = use.getLonAxis(); if ((lat != null) && (lat.getSize() <= 1)) return false; // COARDS singletons if ((lon != null) && (lon.getSize() <= 1)) return false; // hueristics - cant say i like this, multidim point features could easily violate return (use.getRankDomain() > 2) && (use.getRankDomain() <= use.getRankRange()); }
private boolean isSwath(java.util.List<CoordinateSystem> csysList) { CoordinateSystem use = null; for (CoordinateSystem csys : csysList) { if (use == null) use = csys; else if (csys.getCoordinateAxes().size() > use.getCoordinateAxes().size()) use = csys; } if (use == null) return false; CoordinateAxis lat = use.getLatAxis(); CoordinateAxis lon = use.getLonAxis(); CoordinateAxis time = use.getTaxis(); if ((lat == null) || (lat.getRank() != 2)) return false; if ((lon == null) || (lon.getRank() != 2)) return false; if ((time == null)) return false; // must have time - otherwise it can be a grid // lat/lon must have the same dimensions if (!lat.getDimension(0).equals(lon.getDimension(0))) return false; if (!lat.getDimension(1).equals(lon.getDimension(1))) return false; Set<Dimension> dims = new HashSet<Dimension>(10); for (Dimension d : lat.getDimensions()) dims.add(d); for (Dimension d : lon.getDimensions()) dims.add(d); // diff with grid - time dimension(s) are a subset of lat/lon dimensions for (Dimension d : time.getDimensions()) { if (!dims.contains(d)) return false; } return true; }
/** Create a RadialCoordSys from an existing Coordinate System. */ public RadialCoordSys( CoordinateSystem cs) { super(); aziAxis = cs.getAzimuthAxis(); radialAxis = cs.getRadialAxis(); elevAxis = cs.getElevationAxis(); timeAxis = cs.getTaxis(); coordAxes.add( aziAxis); coordAxes.add( radialAxis); coordAxes.add( elevAxis); // make name based on coordinate Collections.sort( coordAxes, new CoordinateAxis.AxisComparator()); // canonical ordering of axes this.name = CoordinateSystem.makeName( coordAxes); }
if (ve.getCoordinateSystems().size() == 1) { existing = ve.getCoordinateSystems().get(0); if (!existing.isImplicit()) continue; // cant overrrride explicit if (existing.getRankRange() >= ve.getRank()) continue; // looks ok implicit = existing; if ((existing != null) && (axisList.size() <= existing.getRankRange())) continue; if (axisList.size() < 2) continue; String csName = CoordinateSystem.makeName(axisList); CoordinateSystem cs = ncDataset.findCoordinateSystem(csName); if (cs != null) { if (null != implicit) ve.removeCoordinateSystem(implicit); ve.addCoordinateSystem(cs); parseInfo.format(" assigned maximal CoordSystem '%s' for var= %s%n", cs.getName(), ve.getFullName()); } else { CoordinateSystem csnew = new CoordinateSystem(ncDataset, axisList, null); csnew.setImplicit(true); if (null != implicit) ve.removeCoordinateSystem(implicit); ve.addCoordinateSystem(csnew); ncDataset.addCoordinateSystem(csnew); parseInfo.format(" created maximal CoordSystem '%s' for var= %s%n", csnew.getName(), ve.getFullName());
public static Document genCoordRefSysAsGML( ucar.nc2.dataset.CoordinateSystem coordSys ) { if ( coordSys == null ) throw new IllegalArgumentException( "CoordinateSystem must be non-null."); if ( ! coordSys.isGeoReferencing()) throw new IllegalArgumentException( "CoordinateSystem must be a georeferencing CS."); Element xyCrsElem; if ( coordSys.isGeoXY()) { xyCrsElem = genProjectedCRS( coordSys.getProjection()); } else { coordSys.getLatAxis(); coordSys.getLonAxis(); } Element rootElem = new Element( "CompoundCRS", gmlNS ); rootElem.addContent( "" ); rootElem.addNamespaceDeclaration( gmlNS ); rootElem.addNamespaceDeclaration( xlinkNS ); // rootElem.setAttribute( "version", this.getVersion() ); return new Document( rootElem ); }
public CoordinateTransform makeCoordinateTransform (NetcdfDataset ds, Variable v) { VerticalCT.Type type = VerticalCT.Type.WRFEta; VerticalCT ct = new VerticalCT(type.toString(), getTransformName(), type, this); ct.addParameter(new Parameter("height formula", "height(x,y,z) = (PH(x,y,z) + PHB(x,y,z)) / 9.81")); ct.addParameter(new Parameter(WRFEta.PerturbationGeopotentialVariable, "PH")); ct.addParameter(new Parameter(WRFEta.BaseGeopotentialVariable, "PHB")); ct.addParameter(new Parameter("pressure formula", "pressure(x,y,z) = P(x,y,z) + PB(x,y,z)")); ct.addParameter(new Parameter(WRFEta.PerturbationPressureVariable, "P")); ct.addParameter(new Parameter(WRFEta.BasePressureVariable, "PB")); if (cs.getXaxis() != null) ct.addParameter(new Parameter(WRFEta.IsStaggeredX, ""+isStaggered(cs.getXaxis()))); else ct.addParameter(new Parameter(WRFEta.IsStaggeredX, ""+isStaggered2(cs.getLonAxis(), 1))); if (cs.getYaxis() != null) ct.addParameter(new Parameter(WRFEta.IsStaggeredY, ""+isStaggered(cs.getYaxis()))); else ct.addParameter(new Parameter(WRFEta.IsStaggeredY, ""+isStaggered2(cs.getLonAxis(), 0))); ct.addParameter(new Parameter(WRFEta.IsStaggeredZ, ""+isStaggered(cs.getZaxis()))); ct.addParameter(new Parameter("eta", ""+cs.getZaxis().getFullName())); return ct; }
/** * Returns the coordinate system name. The default implementation delegates to * {@link CoordinateSystem#getName()}. * * @see CoordinateSystem#getName() */ @Override public String getCode() { return cs.getName(); }
@Override public CoordinateAxis getTaxis() { return cs.getTaxis(); }
CoordinateAxis axis = georeferencing.isLonLat() ? cs.getLatAxis() : cs.getYaxis(); boolean flipYAxis = needFlipYAxis(axis);
@Override public CoordinateAxis2D getLatAxis() { return (CoordinateAxis2D) cs.getLatAxis(); }