cdm/src/main/java/ucar/nc2/dataset/NetcdfDataset.java
static private CoordSysBuilderIF enhance(NetcdfDataset ds, Set<Enhance> mode, CancelTask cancelTask) throws IOException {
    if (mode == null) {
        mode = EnumSet.noneOf(Enhance.class);
    }

    // CoordSysBuilder may enhance dataset: add new variables, attributes, etc
    CoordSysBuilderIF builder = null;
    if (mode.contains(Enhance.CoordSystems) && !ds.enhanceMode.contains(Enhance.CoordSystems)) {
      builder = ucar.nc2.dataset.CoordSysBuilder.factory(ds, cancelTask);
      builder.augmentDataset(ds, cancelTask);
      ds.convUsed = builder.getConventionUsed();
    }

    // now enhance enum/scale/offset/unsigned, using augmented dataset
    if ((mode.contains(Enhance.ConvertEnums) && !ds.enhanceMode.contains(Enhance.ConvertEnums))
            || (mode.contains(Enhance.ConvertUnsigned) && !ds.enhanceMode.contains(Enhance.ConvertUnsigned))
            || (mode.contains(Enhance.ApplyScaleOffset) && !ds.enhanceMode.contains(Enhance.ApplyScaleOffset))
            || (mode.contains(Enhance.ConvertMissing) && !ds.enhanceMode.contains(Enhance.ConvertMissing))) {
      for (Variable v : ds.getVariables()) {
        VariableEnhanced ve = (VariableEnhanced) v;
        ve.enhance(mode);
        if ((cancelTask != null) && cancelTask.isCancel()) return null;
      }
    }

    // now find coord systems which may change some Variables to axes, etc
    if (builder != null) {
      // temporarily set enhanceMode if incomplete coordinate systems are allowed
      if (mode.contains(Enhance.IncompleteCoordSystems)) {
        ds.enhanceMode.add(Enhance.IncompleteCoordSystems);
        builder.buildCoordinateSystems(ds);
        ds.enhanceMode.remove(Enhance.IncompleteCoordSystems);
      } else {
        builder.buildCoordinateSystems(ds);
      }
    }

    /* timeTaxis must be CoordinateAxis1DTime
    for (CoordinateSystem cs : ds.getCoordinateSystems()) {
      cs.makeTimeAxis();
    } */


    ds.finish(); // recalc the global lists
    ds.enhanceMode.addAll(mode);

    return builder;
  }
static private CoordSysBuilderIF enhance(NetcdfDataset ds, Set<Enhance> mode, CancelTask cancelTask) throws IOException {
    if (mode == null) {
        mode = EnumSet.noneOf(Enhance.class);
    }

    // CoordSysBuilder may enhance dataset: add new variables, attributes, etc
    CoordSysBuilderIF builder = null;
    if (mode.contains(Enhance.CoordSystems) && !ds.enhanceMode.contains(Enhance.CoordSystems)) {
      builder = ucar.nc2.dataset.CoordSysBuilder.factory(ds, cancelTask);
      builder.augmentDataset(ds, cancelTask);
      ds.convUsed = builder.getConventionUsed();
    }

    // now enhance enum/scale/offset/unsigned, using augmented dataset
    if ((mode.contains(Enhance.ConvertEnums) && !ds.enhanceMode.contains(Enhance.ConvertEnums))
            || (mode.contains(Enhance.ConvertUnsigned) && !ds.enhanceMode.contains(Enhance.ConvertUnsigned))
            || (mode.contains(Enhance.ApplyScaleOffset) && !ds.enhanceMode.contains(Enhance.ApplyScaleOffset))
            || (mode.contains(Enhance.ConvertMissing) && !ds.enhanceMode.contains(Enhance.ConvertMissing))) {
      for (Variable v : ds.getVariables()) {
        VariableEnhanced ve = (VariableEnhanced) v;
        ve.enhance(mode);
        if ((cancelTask != null) && cancelTask.isCancel()) return null;
      }
    }

    // now find coord systems which may change some Variables to axes, etc
    if (builder != null) {
      // temporarily set enhanceMode if incomplete coordinate systems are allowed
      if (mode.contains(Enhance.IncompleteCoordSystems)) {
        ds.enhanceMode.add(Enhance.IncompleteCoordSystems);
        builder.buildCoordinateSystems(ds);
        ds.enhanceMode.remove(Enhance.IncompleteCoordSystems);
      } else {
        builder.buildCoordinateSystems(ds);
      }
    }

    /* timeTaxis must be CoordinateAxis1DTime
    for (CoordinateSystem cs : ds.getCoordinateSystems()) {
      cs.makeTimeAxis();
    } */


    ds.finish(); // recalc the global lists
    ds.enhanceMode.addAll(mode);

    return builder;
  }
static private CoordSysBuilderIF enhance ( NetcdfDataset ds , Set < Enhance > mode , CancelTask cancelTask ) throws IOException { if ( mode == null ) { mode = EnumSet . noneOf ( Enhance . class ) ; } // CoordSysBuilder may enhance dataset: add new variables, attributes, etc CoordSysBuilderIF builder = null ; if ( mode . contains ( Enhance . CoordSystems ) && ! ds . enhanceMode . contains ( Enhance . CoordSystems ) ) { builder = ucar . nc2 . dataset . CoordSysBuilder . factory ( ds , cancelTask ) ; builder . augmentDataset ( ds , cancelTask ) ; ds . convUsed = builder . getConventionUsed ( ) ; } // now enhance enum/scale/offset/unsigned, using augmented dataset if ( ( mode . contains ( Enhance . ConvertEnums ) && ! ds . enhanceMode . contains ( Enhance . ConvertEnums ) ) || ( mode . contains ( Enhance . ConvertUnsigned ) && ! ds . enhanceMode . contains ( Enhance . ConvertUnsigned ) ) || ( mode . contains ( Enhance . ApplyScaleOffset ) && ! ds . enhanceMode . contains ( Enhance . ApplyScaleOffset ) ) || ( mode . contains ( Enhance . ConvertMissing ) && ! ds . enhanceMode . contains ( Enhance . ConvertMissing ) ) ) { for ( Variable v : ds . getVariables ( ) ) { VariableEnhanced ve = ( VariableEnhanced ) v ; ve . enhance ( mode ) ; if ( ( cancelTask != null ) && cancelTask . isCancel ( ) ) return null ; } } // now find coord systems which may change some Variables to axes, etc if ( builder != null ) { // temporarily set enhanceMode if incomplete coordinate systems are allowed if ( mode . contains ( Enhance . IncompleteCoordSystems ) ) { ds . enhanceMode . add ( Enhance . IncompleteCoordSystems ) ; builder . buildCoordinateSystems ( ds ) ; ds . enhanceMode . remove ( Enhance . IncompleteCoordSystems ) ; } else { builder . buildCoordinateSystems ( ds ) ; } } /* timeTaxis must be CoordinateAxis1DTime
    for (CoordinateSystem cs : ds.getCoordinateSystems()) {
      cs.makeTimeAxis();
    } */ ds . finish ( ) ; // recalc the global lists ds . enhanceMode . addAll ( mode ) ; return builder ; }
/*
Enhancement use cases
1. open NetcdfDataset(enhance).
2. NcML - must create the NetcdfDataset, and enhance when its done.

Enhance mode is set when
1) the NetcdfDataset is opened
2) enhance(EnumSet<Enhance> mode) is called.

Possible remove all direct access to Variable.enhance
/ * Enhancement use cases 1 . open NetcdfDataset ( enhance ) . 2 . NcML - must create the NetcdfDataset and enhance when its done .