grib/src/main/java/ucar/nc2/grib/collection/GribCdmIndex.java
@Nullable
  public static GribCollectionImmutable openGribCollectionFromIndexFile(RandomAccessFile indexRaf, FeatureCollectionConfig config,
                                                                        org.slf4j.Logger logger) throws IOException {

    GribCollectionType type = getType(indexRaf);

    String location = indexRaf.getLocation();
    File f = new File(location);
    int pos = f.getName().lastIndexOf(".");
    String name = (pos > 0) ? f.getName().substring(0, pos) : f.getName(); // remove ".ncx2"

    switch (type) {
      case Partition1:
        return Grib1PartitionBuilderFromIndex.createTimePartitionFromIndex(name, indexRaf, config, logger);
      case GRIB1:
        return Grib1CollectionBuilderFromIndex.readFromIndex(name, indexRaf, config, logger);
      case Partition2:
        return Grib2PartitionBuilderFromIndex.createTimePartitionFromIndex(name, indexRaf, config, logger);
      case GRIB2:
        return Grib2CollectionBuilderFromIndex.readFromIndex(name, indexRaf, config, logger);
    }

    return null;
  }
@Nullable
  public static GribCollectionImmutable openGribCollectionFromIndexFile(RandomAccessFile indexRaf, FeatureCollectionConfig config,
                                                                        org.slf4j.Logger logger) throws IOException {

    GribCollectionType type = getType(indexRaf);

    String location = indexRaf.getLocation();
    File f = new File(location);
    int pos = f.getName().lastIndexOf(".");
    String name = (pos > 0) ? f.getName().substring(0, pos) : f.getName(); // remove ".ncx2"

    switch (type) {
      case Partition1:
        return Grib1PartitionBuilderFromIndex.createTimePartitionFromIndex(name, indexRaf, config, logger);
      case GRIB1:
        return Grib1CollectionBuilderFromIndex.readFromIndex(name, indexRaf, config, logger);
      case Partition2:
        return Grib2PartitionBuilderFromIndex.createTimePartitionFromIndex(name, indexRaf, config, logger);
      case GRIB2:
        return Grib2CollectionBuilderFromIndex.readFromIndex(name, indexRaf, config, logger);
    }

    return null;
  }
Create a grib collection / partition collection from an existing ncx2 file.
PartionCollection.partition.getGribCollection().

@param indexRaf the ncx2 file already open
@param config   special configuration
@return the resulting GribCollection, or null on failure
@throws IOException on io error