grib/src/main/java/ucar/nc2/grib/collection/GribCollectionWriter.java
public static GribCollectionProto.GribAxisType convertAxisType(Coordinate.Type type) {
    switch (type) {
      case runtime:
        return GribCollectionProto.GribAxisType.runtime;
      case time:
        return GribCollectionProto.GribAxisType.time;
      case time2D:
        return GribCollectionProto.GribAxisType.time2D;
      case timeIntv:
        return GribCollectionProto.GribAxisType.timeIntv;
      case ens:
        return GribCollectionProto.GribAxisType.ens;
      case vert:
        return GribCollectionProto.GribAxisType.vert;
    }
    throw new IllegalStateException("illegal axis type " + type);
  }
public static GribCollectionProto.GribAxisType convertAxisType(Coordinate.Type type) {
    switch (type) {
      case runtime:
        return GribCollectionProto.GribAxisType.runtime;
      case time:
        return GribCollectionProto.GribAxisType.time;
      case time2D:
        return GribCollectionProto.GribAxisType.time2D;
      case timeIntv:
        return GribCollectionProto.GribAxisType.timeIntv;
      case ens:
        return GribCollectionProto.GribAxisType.ens;
      case vert:
        return GribCollectionProto.GribAxisType.vert;
    }
    throw new IllegalStateException("illegal axis type " + type);
  }
/* not currently used

protected GribCollectionProto.FcConfig writeConfig(FeatureCollectionConfig config) throws IOException {
GribCollectionProto.FcConfig.Builder b = GribCollectionProto.FcConfig.newBuilder();
b.setName(config.collectionName);
b.setCollectionSpec(config.spec);
b.setPartitionType(config.ptype.toString());
if (config.dateFormatMark != null)
b.setDateFormatMark(config.dateFormatMark);

FeatureCollectionConfig.GribConfig gribConfig = config.gribConfig;
if (gribConfig.gdsHash != null) {
for (Map.Entry<Integer, Integer> entry : gribConfig.gdsHash.entrySet()) {
GribCollectionProto.IntMap.Builder bIntMap = GribCollectionProto.IntMap.newBuilder();
bIntMap.setFrom(entry.getKey());
bIntMap.setTo(entry.getValue());
b.addGdsConvert(bIntMap);
}
}

b.setPdsUseGenType(gribConfig.useGenType);
b.setPdsUseTableVersion(gribConfig.useTableVersion);
b.setPdsIntvMerge(gribConfig.intvMerge);
b.setPdsUseCenter(gribConfig.useCenter);

if (gribConfig.intvFilter != null) {
b.setIntvExcludeZero(gribConfig.intvFilter.isZeroExcluded());
for (FeatureCollectionConfig.GribIntvFilterParam intvFilter : gribConfig.intvFilter.filterList) {
GribCollectionProto.IntvFilter.Builder bIntv = GribCollectionProto.IntvFilter.newBuilder();
bIntv.setVariableId(intvFilter.id);
bIntv.setIntvLength(intvFilter.intvLength);
bIntv.setIntvProb(intvFilter.prob);
b.addIntvFilter(bIntv);
}
}

time unit convert
if (gribConfig.tuc != null) {
for (Map.Entry<Integer, Integer> entry : gribConfig.tuc.map.entrySet()) {
GribCollectionProto.IntMap.Builder bIntMap = GribCollectionProto.IntMap.newBuilder();
bIntMap.setFrom(entry.getKey());
bIntMap.setTo(entry.getValue());
b.addTimeUnitConvert(bIntMap);
}
}

if (gribConfig.userTimeUnit != null)
b.setUserTimeUnit(gribConfig.userTimeUnit.toString());

return b.build();
}

protected FeatureCollectionConfig readConfig(boolean isGrib1, GribCollectionProto.FcConfig pconfig) throws IOException {

FeatureCollectionConfig config = new FeatureCollectionConfig();
config.name = pconfig.getName();
config.collectionName = pconfig.getName();
config.type = isGrib1 ? FeatureCollectionType.GRIB1 : FeatureCollectionType.GRIB2;
config.spec = pconfig.getCollectionSpec();
config.ptype = FeatureCollectionConfig.PartitionType.valueOf(pconfig.getPartitionType());
if (pconfig.getDateFormatMark().length() > 0)
config.dateFormatMark = pconfig.getDateFormatMark();

if ( pconfig.getGdsConvertCount() > 0) {
config.gribConfig.gdsHash =  new HashMap<>();
for (GribCollectionProto.IntMap pIntMap : pconfig.getGdsConvertList()) {
config.gribConfig.gdsHash.put(pIntMap.getFrom(), pIntMap.getTo());
}
}

config.gribConfig.useGenType = pconfig.getPdsUseGenType();
config.gribConfig.useTableVersion = pconfig.getPdsUseTableVersion();
config.gribConfig.intvMerge = pconfig.getPdsIntvMerge();
config.gribConfig.useCenter = pconfig.getPdsUseCenter();

boolean isZeroExcluded = pconfig.getIntvExcludeZero();
if ( isZeroExcluded || pconfig.getIntvFilterCount() > 0) {
config.gribConfig.intvFilter =  new FeatureCollectionConfig.GribIntvFilter();
config.gribConfig.intvFilter.isZeroExcluded = isZeroExcluded;
config.gribConfig.intvFilter.filterList = new ArrayList<>();
for (GribCollectionProto.IntvFilter pi :  pconfig.getIntvFilterList()) {
int prob =  pi.getIntvProb();
config.gribConfig.intvFilter.filterList.add(new FeatureCollectionConfig.GribIntvFilterParam(pi.getVariableId(), pi.getIntvLength(), prob));
}
}

if ( pconfig.getTimeUnitConvertCount() > 0) {
config.gribConfig.tuc =  new FeatureCollectionConfig.TimeUnitConverterHash();
for (GribCollectionProto.IntMap pIntMap :  pconfig.getTimeUnitConvertList()) {
config.gribConfig.tuc.map.put(pIntMap.getFrom(), pIntMap.getTo());
}
}

if (pconfig.getDateFormatMark().length() > 0)
config.gribConfig.setUserTimeUnit(pconfig.getDateFormatMark());

return config;
}