cdm/src/main/java/ucar/nc2/dataset/CoordSysBuilder.java
protected void makeCoordinateSystemsMaximal(NetcdfDataset ncDataset) {

    boolean requireCompleteCoordSys = !ncDataset.getEnhanceMode().contains(NetcdfDataset.Enhance.IncompleteCoordSystems);

    for (VarProcess vp : varList) {
      VariableEnhanced ve = (VariableEnhanced) vp.v;

      if (vp.hasCoordinateSystem() || !vp.isData()) continue;

      // look through all axes that fit
      List<CoordinateAxis> axisList = new ArrayList<>();
      List<CoordinateAxis> axes = ncDataset.getCoordinateAxes();
      for (CoordinateAxis axis : axes) {
        if (isCoordinateAxisForVariable(axis, ve))
          axisList.add(axis);
      }

      if (axisList.size() < 2) continue;

      String csName = CoordinateSystem.makeName(axisList);
      CoordinateSystem cs = ncDataset.findCoordinateSystem(csName);
      boolean okToBuild = false;

      // do coordinate systems need to be complete?
      // default enhance mode is yes, they must be complete
      if (requireCompleteCoordSys) {
        if (cs != null) {
          // only build if coordinate system is complete
          okToBuild = cs.isComplete(ve);
        }
      } else {
        // coordinate system can be incomplete, so we're ok to build if we find something
        okToBuild = true;
      }

      if (cs != null && okToBuild) {
        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);
        // again, do coordinate systems need to be complete?
        // default enhance mode is yes, they must be complete
        if (requireCompleteCoordSys) {
          // only build if new coordinate system is complete
          okToBuild = csnew.isComplete(ve);
        }
        if (okToBuild) {
          csnew.setImplicit(true);
          ve.addCoordinateSystem(csnew);
          ncDataset.addCoordinateSystem(csnew);
          parseInfo.format(" created maximal CoordSystem '%s' for var= %s%n", csnew.getName(), ve.getFullName());
        }
      }
    }
  }
protected void makeCoordinateSystemsMaximal(NetcdfDataset ncDataset) {

    boolean requireCompleteCoordSys = !ncDataset.getEnhanceMode().contains(NetcdfDataset.Enhance.IncompleteCoordSystems);

    for (VarProcess vp : varList) {
      VariableEnhanced ve = (VariableEnhanced) vp.v;

      if (vp.hasCoordinateSystem() || !vp.isData()) continue;

      // look through all axes that fit
      List<CoordinateAxis> axisList = new ArrayList<>();
      List<CoordinateAxis> axes = ncDataset.getCoordinateAxes();
      for (CoordinateAxis axis : axes) {
        if (isCoordinateAxisForVariable(axis, ve))
          axisList.add(axis);
      }

      if (axisList.size() < 2) continue;

      String csName = CoordinateSystem.makeName(axisList);
      CoordinateSystem cs = ncDataset.findCoordinateSystem(csName);
      boolean okToBuild = false;

      // do coordinate systems need to be complete?
      // default enhance mode is yes, they must be complete
      if (requireCompleteCoordSys) {
        if (cs != null) {
          // only build if coordinate system is complete
          okToBuild = cs.isComplete(ve);
        }
      } else {
        // coordinate system can be incomplete, so we're ok to build if we find something
        okToBuild = true;
      }

      if (cs != null && okToBuild) {
        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);
        // again, do coordinate systems need to be complete?
        // default enhance mode is yes, they must be complete
        if (requireCompleteCoordSys) {
          // only build if new coordinate system is complete
          okToBuild = csnew.isComplete(ve);
        }
        if (okToBuild) {
          csnew.setImplicit(true);
          ve.addCoordinateSystem(csnew);
          ncDataset.addCoordinateSystem(csnew);
          parseInfo.format(" created maximal CoordSystem '%s' for var= %s%n", csnew.getName(), ve.getFullName());
        }
      }
    }
  }
protected void makeCoordinateSystemsMaximal ( NetcdfDataset ncDataset ) { boolean requireCompleteCoordSys = ! ncDataset . getEnhanceMode ( ) . contains ( NetcdfDataset . Enhance . IncompleteCoordSystems ) ; for ( VarProcess vp : varList ) { VariableEnhanced ve = ( VariableEnhanced ) vp . v ; if ( vp . hasCoordinateSystem ( ) || ! vp . isData ( ) ) continue ; // look through all axes that fit
 List < CoordinateAxis > axisList = new ArrayList <> ( ) ; List < CoordinateAxis > axes = ncDataset . getCoordinateAxes ( ) ; for ( CoordinateAxis axis : axes ) { if ( isCoordinateAxisForVariable ( axis , ve ) ) axisList . add ( axis ) ; } if ( axisList . size ( ) < 2 ) continue ; String csName = CoordinateSystem . makeName ( axisList ) ; CoordinateSystem cs = ncDataset . findCoordinateSystem ( csName ) ; boolean okToBuild = false ; // do coordinate systems need to be complete?
 // default enhance mode is yes, they must be complete
 if ( requireCompleteCoordSys ) { if ( cs != null ) { // only build if coordinate system is complete
 okToBuild = cs . isComplete ( ve ) ; } } else { // coordinate system can be incomplete, so we're ok to build if we find something
 okToBuild = true ; } if ( cs != null && okToBuild ) { 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 ) ; // again, do coordinate systems need to be complete?
 // default enhance mode is yes, they must be complete
 if ( requireCompleteCoordSys ) { // only build if new coordinate system is complete
 okToBuild = csnew . isComplete ( ve ) ; } if ( okToBuild ) { csnew . setImplicit ( true ) ; ve . addCoordinateSystem ( csnew ) ; ncDataset . addCoordinateSystem ( csnew ) ; parseInfo . format ( " created maximal CoordSystem '%s' for var= %s%n" , csnew . getName ( ) , ve . getFullName ( ) ) ; } } } }
If a variable still doesnt have a coordinate system, use hueristics to try to find one that was probably forgotten.
Examine existing CS. create a subset of axes that fits the variable. Choose the one with highest rank.
It must have X,Y or lat,lon. If so, add it.

@param ncDataset need this to see if incomplete coordinate systems are allowed
If a variable still doesnt have a coordinate system use hueristics to try to find one that was probably forgotten . Examine existing CS . create a subset of axes that fits the variable . Choose the one with highest rank . It must have X Y or lat lon . If so add it .