@Override public void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws IOException { super.open(raf, ncfile, cancelTask); scanner = new MessageScanner(raf); protoMessage = scanner.getFirstDataMessage(); if (protoMessage == null) throw new IOException("No data messages in the file= "+ncfile.getLocation()); // DataDescriptor dds = protoMessage.getRootDataDescriptor(); // construct the data descriptors, check for complete tables if (!protoMessage.isTablesComplete()) throw new IllegalStateException("BUFR file has incomplete tables"); // just get the fields config = BufrConfig.openFromMessage(raf, protoMessage, iospParam); // this fills the netcdf object Construct2 construct = new Construct2(protoMessage, config, ncfile); obsStructure = construct.getObsStructure(); ncfile.finish(); isSingle = false; }
private void scanBufrFile(RandomAccessFile raf) throws Exception { NetcdfFile ncd = null; countObs = 0; try { MessageScanner scanner = new MessageScanner(raf); Message protoMessage = scanner.getFirstDataMessage(); if (protoMessage == null) throw new IOException("No message found!"); messHash = protoMessage.hashCode(); standardFields = StandardFields.extract(protoMessage); rootConverter = new FieldConverter(protoMessage.ids.getCenterId(), protoMessage.getRootDataDescriptor()); if (standardFields.hasStation()) { hasStations = true; map = new HashMap<>(1000); } featureType = guessFeatureType(standardFields); hasDate = standardFields.hasTime(); //ncd = NetcdfDataset.openDataset(raf.getLocation(), BufrIosp2.enhance, -1, null, null); // LOOK opening another raf ncd = NetcdfFile.open(raf.getLocation()); // LOOK opening another raf Attribute centerAtt = ncd.findGlobalAttribute(BufrIosp2.centerId); int center = (centerAtt == null) ? 0 : centerAtt.getNumericValue().intValue(); Sequence seq = (Sequence) ncd.findVariable(null, BufrIosp2.obsRecord); extract = new StandardFields.StandardFieldsFromStructure(center, seq); StructureDataIterator iter = seq.getStructureIterator(); processSeq( iter, rootConverter, true); setStandardActions(rootConverter); } finally { if (ncd != null) ncd.close(); } System.out.printf("nobs = %d%n", countObs); }