private GribCollectionProto.Variable writeVariableProto(Grib2Rectilyser.VariableBag vb) throws IOException { GribCollectionProto.Variable.Builder b = GribCollectionProto.Variable.newBuilder(); b.setDiscipline(vb.first.getDiscipline()); Grib2Pds pds = vb.first.getPDS(); b.setCategory(pds.getParameterCategory()); b.setParameter(pds.getParameterNumber()); b.setLevelType(pds.getLevelType1()); b.setIsLayer(Grib2Utils.isLayer(vb.first)); b.setIntervalType(pds.getStatisticalProcessType()); b.setCdmHash(vb.first.cdmVariableHash(0)); b.setRecordsPos(vb.pos); b.setRecordsLen(vb.length); b.setTimeIdx(vb.timeCoordIndex); if (vb.vertCoordIndex >= 0) b.setVertIdx(vb.vertCoordIndex); if (vb.ensCoordIndex >= 0) b.setEnsIdx(vb.ensCoordIndex); if (pds.isEnsembleDerived()) { Grib2Pds.PdsEnsembleDerived pdsDerived = (Grib2Pds.PdsEnsembleDerived) pds; b.setEnsDerivedType(pdsDerived.getDerivedForecastType()); // derived type (table 4.7) } if (pds.isProbability()) { Grib2Pds.PdsProbability pdsProb = (Grib2Pds.PdsProbability) pds; b.setProbabilityName(pdsProb.getProbabilityName()); b.setProbabilityType(pdsProb.getProbabilityType()); } return b.build(); }
protected GribCollection.VariableIndex readVariable( GribCollectionProto.Variable pv, GribCollection.GroupHcs group) { int discipline = pv.getDiscipline(); int category = pv.getCategory(); int param = pv.getParameter(); int levelType = pv.getLevelType(); int intvType = pv.getIntervalType(); boolean isLayer = pv.getIsLayer(); int ensDerivedType = pv.getEnsDerivedType(); int probType = pv.getProbabilityType(); String probabilityName = pv.getProbabilityName(); int cdmHash = pv.getCdmHash(); long recordsPos = pv.getRecordsPos(); int recordsLen = pv.getRecordsLen(); int timeIdx = pv.getTimeIdx(); int vertIdx = pv.getVertIdx(); int ensIdx = pv.getEnsIdx(); int tableVersion = pv.getTableVersion(); return gc.makeVariableIndex( group, tableVersion, discipline, category, param, levelType, isLayer, intvType, ensDerivedType, probType, probabilityName, cdmHash, timeIdx, vertIdx, ensIdx, recordsPos, recordsLen); }