cdm/src/main/java/ucar/nc2/dt/grid/GridCoordSys.java
public static boolean isGridCoordSys(Formatter sbuff, CoordinateSystem cs, VariableEnhanced v) {
    // must be at least 2 axes
    if (cs.getRankDomain() < 2) {
      if (sbuff != null) {
        sbuff.format("%s: domain rank < 2%n", cs.getName());
      }
      return false;
    }

    // must be lat/lon or have x,y and projecction
    if (!cs.isLatLon()) {
      // do check for GeoXY ourself
      if ((cs.getXaxis() == null) || (cs.getYaxis() == null)) {
        if (sbuff != null) {
          sbuff.format("%s: NO Lat,Lon or X,Y axis%n", cs.getName());
        }
        return false;
      }
      if (null == cs.getProjection()) {
        if (sbuff != null) {
          sbuff.format("%s: NO projection found%n", cs.getName());
        }
        return false;
      }
    }

    // obtain the x,y or lat/lon axes. x,y normally must be convertible to km
    CoordinateAxis xaxis, yaxis;
    if (cs.isGeoXY()) {
      xaxis = cs.getXaxis();
      yaxis = cs.getYaxis();

      // change to warning
      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());
          }
          //return false;
        }
        if (!SimpleUnit.kmUnit.isCompatible(yaxis.getUnitsString())) {
          if (sbuff != null) {
            sbuff.format("%s: Y axis units are not convertible to km%n", cs.getName());
          }
          //return false;
        }
      }
    } else {
      xaxis = cs.getLonAxis();
      yaxis = cs.getLatAxis();
    }

    // check x,y rank <= 2
    if ((xaxis.getRank() > 2) || (yaxis.getRank() > 2)) {
      if (sbuff != null)
        sbuff.format("%s: X or Y axis rank must be <= 2%n", cs.getName());
      return false;
    }

    // check that the x,y have at least 2 dimensions between them ( this eliminates point data)
    int xyDomainSize = CoordinateSystem.countDomain(new CoordinateAxis[]{xaxis, yaxis});
    if (xyDomainSize < 2) {
      if (sbuff != null)
        sbuff.format("%s: X and Y axis must have 2 or more dimensions%n", cs.getName());
      return false;
    }

    List<CoordinateAxis> testAxis = new ArrayList<>();
    testAxis.add(xaxis);
    testAxis.add(yaxis);

    //int countRangeRank = 2;

    CoordinateAxis z = cs.getHeightAxis();
    if ((z == null) || !(z instanceof CoordinateAxis1D)) z = cs.getPressureAxis();
    if ((z == null) || !(z instanceof CoordinateAxis1D)) z = cs.getZaxis();
    if ((z != null) && !(z instanceof CoordinateAxis1D)) {
      if (sbuff != null) {
        sbuff.format("%s: Z axis must be 1D%n", cs.getName());
      }
      return false;
    }
    if (z != null)
      testAxis.add(z);

    // tom margolis 3/2/2010
    // allow runtime independent of time
    CoordinateAxis t = cs.getTaxis();
    CoordinateAxis rt = cs.findAxis(AxisType.RunTime);

    // A runtime axis must be scalar or one-dimensional
    if (rt != null) {
      if (!rt.isScalar() && !(rt instanceof CoordinateAxis1D)) {
        if (sbuff != null) sbuff.format("%s: RunTime axis must be 1D%n", cs.getName());
          return false;
      }
    }

    // If time axis is two-dimensional...
    if ((t != null) && !(t instanceof CoordinateAxis1D) && (t.getRank() != 0)) {

      if (rt != null) {
        if (rt.getRank() != 1) {
          if (sbuff != null) sbuff.format("%s: Runtime axis must be 1D%n", cs.getName());
          return false;
        }

        // time first dimension must agree with runtime
        if (!rt.getDimension(0).equals(t.getDimension(0))) {
          if (sbuff != null) sbuff.format("%s: 2D Time axis first dimension must be runtime%n", cs.getName());
          return false;
        }
      }
    }

    if (t != null)
      testAxis.add(t);
    if (rt != null)
      testAxis.add(rt);

    CoordinateAxis ens = cs.getEnsembleAxis();
    if (ens != null)
      testAxis.add(ens);

    if (v != null) { // test to see that v doesnt have extra dimensions. LOOK RELAX THIS
      List<Dimension> testDomain = new ArrayList<>();
      for (CoordinateAxis axis : testAxis) {
        for (Dimension dim : axis.getDimensions()) {
          if (!testDomain.contains(dim))
            testDomain.add(dim);
        }
      }
      if (!CoordinateSystem.isSubset(v.getDimensionsAll(), testDomain)) {
        if (sbuff != null) sbuff.format(" NOT complete%n");
        return false;
      }
    }

    return true;
  }
public static boolean isGridCoordSys(Formatter sbuff, CoordinateSystem cs, VariableEnhanced v) {
    // must be at least 2 axes
    if (cs.getRankDomain() < 2) {
      if (sbuff != null) {
        sbuff.format("%s: domain rank < 2%n", cs.getName());
      }
      return false;
    }

    // must be lat/lon or have x,y and projecction
    if (!cs.isLatLon()) {
      // do check for GeoXY ourself
      if ((cs.getXaxis() == null) || (cs.getYaxis() == null)) {
        if (sbuff != null) {
          sbuff.format("%s: NO Lat,Lon or X,Y axis%n", cs.getName());
        }
        return false;
      }
      if (null == cs.getProjection()) {
        if (sbuff != null) {
          sbuff.format("%s: NO projection found%n", cs.getName());
        }
        return false;
      }
    }

    // obtain the x,y or lat/lon axes. x,y normally must be convertible to km
    CoordinateAxis xaxis, yaxis;
    if (cs.isGeoXY()) {
      xaxis = cs.getXaxis();
      yaxis = cs.getYaxis();

      // change to warning
      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());
          }
          //return false;
        }
        if (!SimpleUnit.kmUnit.isCompatible(yaxis.getUnitsString())) {
          if (sbuff != null) {
            sbuff.format("%s: Y axis units are not convertible to km%n", cs.getName());
          }
          //return false;
        }
      }
    } else {
      xaxis = cs.getLonAxis();
      yaxis = cs.getLatAxis();
    }

    // check x,y rank <= 2
    if ((xaxis.getRank() > 2) || (yaxis.getRank() > 2)) {
      if (sbuff != null)
        sbuff.format("%s: X or Y axis rank must be <= 2%n", cs.getName());
      return false;
    }

    // check that the x,y have at least 2 dimensions between them ( this eliminates point data)
    int xyDomainSize = CoordinateSystem.countDomain(new CoordinateAxis[]{xaxis, yaxis});
    if (xyDomainSize < 2) {
      if (sbuff != null)
        sbuff.format("%s: X and Y axis must have 2 or more dimensions%n", cs.getName());
      return false;
    }

    List<CoordinateAxis> testAxis = new ArrayList<>();
    testAxis.add(xaxis);
    testAxis.add(yaxis);

    //int countRangeRank = 2;

    CoordinateAxis z = cs.getHeightAxis();
    if ((z == null) || !(z instanceof CoordinateAxis1D)) z = cs.getPressureAxis();
    if ((z == null) || !(z instanceof CoordinateAxis1D)) z = cs.getZaxis();
    if ((z != null) && !(z instanceof CoordinateAxis1D)) {
      if (sbuff != null) {
        sbuff.format("%s: Z axis must be 1D%n", cs.getName());
      }
      return false;
    }
    if (z != null)
      testAxis.add(z);

    // tom margolis 3/2/2010
    // allow runtime independent of time
    CoordinateAxis t = cs.getTaxis();
    CoordinateAxis rt = cs.findAxis(AxisType.RunTime);

    // A runtime axis must be scalar or one-dimensional
    if (rt != null) {
      if (!rt.isScalar() && !(rt instanceof CoordinateAxis1D)) {
        if (sbuff != null) sbuff.format("%s: RunTime axis must be 1D%n", cs.getName());
          return false;
      }
    }

    // If time axis is two-dimensional...
    if ((t != null) && !(t instanceof CoordinateAxis1D) && (t.getRank() != 0)) {

      if (rt != null) {
        if (rt.getRank() != 1) {
          if (sbuff != null) sbuff.format("%s: Runtime axis must be 1D%n", cs.getName());
          return false;
        }

        // time first dimension must agree with runtime
        if (!rt.getDimension(0).equals(t.getDimension(0))) {
          if (sbuff != null) sbuff.format("%s: 2D Time axis first dimension must be runtime%n", cs.getName());
          return false;
        }
      }
    }

    if (t != null)
      testAxis.add(t);
    if (rt != null)
      testAxis.add(rt);

    CoordinateAxis ens = cs.getEnsembleAxis();
    if (ens != null)
      testAxis.add(ens);

    if (v != null) { // test to see that v doesnt have extra dimensions. LOOK RELAX THIS
      List<Dimension> testDomain = new ArrayList<>();
      for (CoordinateAxis axis : testAxis) {
        for (Dimension dim : axis.getDimensions()) {
          if (!testDomain.contains(dim))
            testDomain.add(dim);
        }
      }
      if (!CoordinateSystem.isSubset(v.getDimensionsAll(), testDomain)) {
        if (sbuff != null) sbuff.format(" NOT complete%n");
        return false;
      }
    }

    return true;
  }
public static boolean isGridCoordSys ( Formatter sbuff , CoordinateSystem cs , VariableEnhanced v ) { // must be at least 2 axes
 if ( cs . getRankDomain ( ) < 2 ) { if ( sbuff != null ) { sbuff . format ( "%s: domain rank < 2%n" , cs . getName ( ) ) ; } return false ; } // must be lat/lon or have x,y and projecction
 if ( ! cs . isLatLon ( ) ) { // do check for GeoXY ourself
 if ( ( cs . getXaxis ( ) == null ) || ( cs . getYaxis ( ) == null ) ) { if ( sbuff != null ) { sbuff . format ( "%s: NO Lat,Lon or X,Y axis%n" , cs . getName ( ) ) ; } return false ; } if ( null == cs . getProjection ( ) ) { if ( sbuff != null ) { sbuff . format ( "%s: NO projection found%n" , cs . getName ( ) ) ; } return false ; } } // obtain the x,y or lat/lon axes. x,y normally must be convertible to km
 CoordinateAxis xaxis , yaxis ; if ( cs . isGeoXY ( ) ) { xaxis = cs . getXaxis ( ) ; yaxis = cs . getYaxis ( ) ; // change to warning
 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 ( ) ) ; } //return false;
 } if ( ! SimpleUnit . kmUnit . isCompatible ( yaxis . getUnitsString ( ) ) ) { if ( sbuff != null ) { sbuff . format ( "%s: Y axis units are not convertible to km%n" , cs . getName ( ) ) ; } //return false;
 } } } else { xaxis = cs . getLonAxis ( ) ; yaxis = cs . getLatAxis ( ) ; } // check x,y rank <= 2
 if ( ( xaxis . getRank ( ) > 2 ) || ( yaxis . getRank ( ) > 2 ) ) { if ( sbuff != null ) sbuff . format ( "%s: X or Y axis rank must be <= 2%n" , cs . getName ( ) ) ; return false ; } // check that the x,y have at least 2 dimensions between them ( this eliminates point data)
 int xyDomainSize = CoordinateSystem . countDomain ( new CoordinateAxis [ ] { xaxis , yaxis } ) ; if ( xyDomainSize < 2 ) { if ( sbuff != null ) sbuff . format ( "%s: X and Y axis must have 2 or more dimensions%n" , cs . getName ( ) ) ; return false ; } List < CoordinateAxis > testAxis = new ArrayList <> ( ) ; testAxis . add ( xaxis ) ; testAxis . add ( yaxis ) ; //int countRangeRank = 2;
 CoordinateAxis z = cs . getHeightAxis ( ) ; if ( ( z == null ) || ! ( z instanceof CoordinateAxis1D ) ) z = cs . getPressureAxis ( ) ; if ( ( z == null ) || ! ( z instanceof CoordinateAxis1D ) ) z = cs . getZaxis ( ) ; if ( ( z != null ) && ! ( z instanceof CoordinateAxis1D ) ) { if ( sbuff != null ) { sbuff . format ( "%s: Z axis must be 1D%n" , cs . getName ( ) ) ; } return false ; } if ( z != null ) testAxis . add ( z ) ; // tom margolis 3/2/2010
 // allow runtime independent of time
 CoordinateAxis t = cs . getTaxis ( ) ; CoordinateAxis rt = cs . findAxis ( AxisType . RunTime ) ; // A runtime axis must be scalar or one-dimensional
 if ( rt != null ) { if ( ! rt . isScalar ( ) && ! ( rt instanceof CoordinateAxis1D ) ) { if ( sbuff != null ) sbuff . format ( "%s: RunTime axis must be 1D%n" , cs . getName ( ) ) ; return false ; } } // If time axis is two-dimensional...
 if ( ( t != null ) && ! ( t instanceof CoordinateAxis1D ) && ( t . getRank ( ) != 0 ) ) { if ( rt != null ) { if ( rt . getRank ( ) != 1 ) { if ( sbuff != null ) sbuff . format ( "%s: Runtime axis must be 1D%n" , cs . getName ( ) ) ; return false ; } // time first dimension must agree with runtime
 if ( ! rt . getDimension ( 0 ) . equals ( t . getDimension ( 0 ) ) ) { if ( sbuff != null ) sbuff . format ( "%s: 2D Time axis first dimension must be runtime%n" , cs . getName ( ) ) ; return false ; } } } if ( t != null ) testAxis . add ( t ) ; if ( rt != null ) testAxis . add ( rt ) ; CoordinateAxis ens = cs . getEnsembleAxis ( ) ; if ( ens != null ) testAxis . add ( ens ) ; if ( v != null ) { // test to see that v doesnt have extra dimensions. LOOK RELAX THIS
 List < Dimension > testDomain = new ArrayList <> ( ) ; for ( CoordinateAxis axis : testAxis ) { for ( Dimension dim : axis . getDimensions ( ) ) { if ( ! testDomain . contains ( dim ) ) testDomain . add ( dim ) ; } } if ( ! CoordinateSystem . isSubset ( v . getDimensionsAll ( ) , testDomain ) ) { if ( sbuff != null ) sbuff . format ( " NOT complete%n" ) ; return false ; } } return true ; }
Determine if this CoordinateSystem can be made into a GridCoordSys. Optionally for a given variable.
This currently assumes that the CoordinateSystem:
<ol>
<li> is georeferencing (cs.isGeoReferencing())
<li> x, y are 1 or 2-dimensional axes.
<li> z, t, if they exist, are 1-dimensional axes.
<li> domain rank > 1
</ol>

@param sbuff place information messages here, may be null
@param cs    the CoordinateSystem to test
@param v     can it be used for this variable; v may be null
@return true if it can be made into a GridCoordSys.
@see CoordinateSystem#isGeoReferencing
Determine if this CoordinateSystem can be made into a GridCoordSys . Optionally for a given variable . This currently assumes that the CoordinateSystem : <ol > <li > is georeferencing ( cs . isGeoReferencing () ) <li > x y are 1 or 2 - dimensional axes . <li > z t if they exist are 1 - dimensional axes . <li > domain rank > 1 < / ol >