Java Code Examples for ucar.unidata.io.RandomAccessFile#close()

The following examples show how to use ucar.unidata.io.RandomAccessFile#close() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AreaServiceProvider.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Open the service provider for reading.
 *
 * @param raf file to read from
 * @param ncfile netCDF file we are writing to (memory)
 * @param cancelTask task for cancelling
 * @throws IOException problem reading file
 */
public void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws IOException {
  super.open(raf, ncfile, cancelTask);

  if (areaReader == null)
    areaReader = new AreaReader();

  try {
    areaReader.init(raf.getLocation(), ncfile);

  } catch (Throwable e) {
    close(); // try not to leak files
    throw new IOException(e);

  } finally {
    raf.close(); // avoid leaks
  }

}
 
Example 2
Source File: NetcdfFile.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Open a RandomAccessFile as a NetcdfFile, if possible.
 *
 * @param raf The open raf, is not cloised by this method.
 * @param location human readable locatoin of this dataset.
 * @param cancelTask used to monitor user cancellation; may be null.
 * @param iospMessage send this message to iosp; may be null.
 * @return NetcdfFile or throw an Exception.
 * @throws IOException if cannot open as a CDM NetCDF.
 * @deprecated use NetcdfFiles.open
 */
@Deprecated
public static NetcdfFile open(RandomAccessFile raf, String location, CancelTask cancelTask, Object iospMessage)
    throws IOException {

  IOServiceProvider spi = getIosp(raf);
  if (spi == null) {
    raf.close();
    throw new IOException("Cant read " + location + ": not a valid CDM file.");
  }

  // send iospMessage before the iosp is opened
  if (iospMessage != null)
    spi.sendIospMessage(iospMessage);

  if (log.isDebugEnabled())
    log.debug("Using IOSP {}", spi.getClass().getName());

  NetcdfFile result = new NetcdfFile(spi, raf, location, cancelTask);

  // send iospMessage after iosp is opened
  if (iospMessage != null)
    spi.sendIospMessage(iospMessage);

  return result;
}
 
Example 3
Source File: NcStreamPanel.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 *
 */
public void setNcStreamFile(String filename) throws IOException {
  closeOpenFiles();

  List<MessBean> messages = new ArrayList<>();
  ncd = new NetcdfFileSubclass();
  iosp = new NcStreamIosp();
  try {
    raf = new RandomAccessFile(filename, "r");
    List<NcStreamIosp.NcsMess> ncm = new ArrayList<>();
    iosp.openDebug(raf, ncd, ncm);
    for (NcStreamIosp.NcsMess m : ncm) {
      messages.add(new MessBean(m));
    }
  } finally {
    if (raf != null) {
      raf.close();
    }
  }

  messTable.setBeans(messages);
  // System.out.printf("mess = %d%n", messages.size());
}
 
Example 4
Source File: Grib2ReportPanel.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void doDuplicatePds(Formatter f, MFile mfile) throws IOException {
  Set<Long> pdsMap = new HashSet<>();
  int dups = 0;
  int count = 0;

  RandomAccessFile raf = new RandomAccessFile(mfile.getPath(), "r");
  Grib2RecordScanner scan = new Grib2RecordScanner(raf);
  while (scan.hasNext()) {
    ucar.nc2.grib.grib2.Grib2Record gr = scan.next();
    Grib2SectionProductDefinition pds = gr.getPDSsection();
    long crc = pds.calcCRC();
    if (pdsMap.contains(crc))
      dups++;
    else
      pdsMap.add(crc);
    count++;
  }
  raf.close();

  f.format("PDS duplicates = %d / %d for %s%n%n", dups, count, mfile.getPath());
  countPDS += count;
  countPDSdup += dups;
}
 
Example 5
Source File: GribCdmIndex.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static GribCollectionImmutable openGribCollectionFromRaf(RandomAccessFile raf, FeatureCollectionConfig config,
    CollectionUpdateType updateType, org.slf4j.Logger logger) throws IOException {

  GribCollectionImmutable result;

  // check if its a plain ole GRIB1/2 data file
  boolean isGrib1 = false;
  boolean isGrib2 = Grib2RecordScanner.isValidFile(raf);
  if (!isGrib2)
    isGrib1 = Grib1RecordScanner.isValidFile(raf);

  if (isGrib1 || isGrib2) {
    result = openGribCollectionFromDataFile(isGrib1, raf, config, updateType, null, logger);
    // close the data file, the ncx raf file is managed by gribCollection
    raf.close();

  } else { // check its an ncx file
    result = openGribCollectionFromIndexFile(raf, config, logger);
  }

  return result;
}
 
Example 6
Source File: Grib2ReportPanel.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void doDrsSummaryScan(Formatter f, MFile mf, boolean extra, Counters counters) throws IOException {
  RandomAccessFile raf = new RandomAccessFile(mf.getPath(), "r");
  Grib2RecordScanner scan = new Grib2RecordScanner(raf);
  while (scan.hasNext()) {
    ucar.nc2.grib.grib2.Grib2Record gr = scan.next();
    doDrsSummary(gr, raf, extra, counters);
  }
  raf.close();
}
 
Example 7
Source File: Nc4Iosp.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void _open(RandomAccessFile raf, NetcdfFile ncfile, boolean readOnly) throws IOException {
  if (!isClibraryPresent()) {
    throw new UnsupportedOperationException("Couldn't load NetCDF C library (see log for details).");
  }

  if (raf != null)
    raf.close(); // not used

  // open
  // netcdf-c can't handle "file:" prefix. Must remove it.
  String location = NetcdfFile.canonicalizeUriString(ncfile.getLocation());
  log.debug("open {}", location);

  IntByReference ncidp = new IntByReference();
  int ret = nc4.nc_open(location, readOnly ? NC_NOWRITE : NC_WRITE, ncidp);
  if (ret != 0)
    throw new IOException(ret + ": " + nc4.nc_strerror(ret));

  isClosed = false;
  ncid = ncidp.getValue();

  // format
  IntByReference formatp = new IntByReference();
  ret = nc4.nc_inq_format(ncid, formatp);
  if (ret != 0)
    throw new IOException(ret + ": " + nc4.nc_strerror(ret));
  format = formatp.getValue();
  log.debug("open {} id={} format={}", ncfile.getLocation(), ncid, format);

  // read root group
  makeGroup(new Group4(ncid, ncfile.getRootGroup(), null));

  // check if its an HDF5-EOS file
  Group eosInfo = ncfile.getRootGroup().findGroupLocal(HdfEos.HDF5_GROUP);
  if (eosInfo != null && useHdfEos) {
    isEos = HdfEos.amendFromODL(ncfile, eosInfo);
  }

  ncfile.finish();
}
 
Example 8
Source File: UspLightning1.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws IOException {
  int n;

  try {
    n = readAllData(raf);
  } catch (ParseException e) {
    e.printStackTrace();
    throw new IOException("bad data");
  }
  raf.close();

  Dimension recordDim = new Dimension("record", n, true);
  ncfile.addDimension(null, recordDim);

  Variable date = new Variable(ncfile, null, null, "date");
  date.setDimensions("record");
  date.setDataType(DataType.INT);
  String timeUnit = "seconds since 1970-01-01 00:00:00";
  date.addAttribute(new Attribute("long_name", "date of strike"));
  date.addAttribute(new Attribute("units", timeUnit));
  date.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Time.toString()));
  date.setCachedData(dateArray, false);
  ncfile.addVariable(null, date);

  Variable lat = new Variable(ncfile, null, null, "lat");
  lat.setDimensions("record");
  lat.setDataType(DataType.DOUBLE);
  lat.addAttribute(new Attribute("long_name", "latitude"));
  lat.addAttribute(new Attribute("units", "degrees_north"));
  lat.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lat.toString()));
  lat.setCachedData(latArray, false);
  ncfile.addVariable(null, lat);

  Variable lon = new Variable(ncfile, null, null, "lon");
  lon.setDimensions("record");
  lon.setDataType(DataType.DOUBLE);
  lon.addAttribute(new Attribute("long_name", "longitude"));
  lon.addAttribute(new Attribute("units", "degrees_east"));
  lon.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lon.toString()));
  lon.setCachedData(lonArray, false);
  ncfile.addVariable(null, lon);

  Variable amp = new Variable(ncfile, null, null, "strikeAmplitude");
  amp.setDimensions("record");
  amp.setDataType(DataType.DOUBLE);
  amp.addAttribute(new Attribute("long_name", "amplitude of strike"));
  amp.addAttribute(new Attribute("units", "kAmps"));
  amp.addAttribute(new Attribute("missing_value", new Double(999)));
  amp.setCachedData(ampArray, false);
  ncfile.addVariable(null, amp);

  Variable nstrokes = new Variable(ncfile, null, null, "strokeCount");
  nstrokes.setDimensions("record");
  nstrokes.setDataType(DataType.INT);
  nstrokes.addAttribute(new Attribute("long_name", "number of strokes per flash"));
  nstrokes.addAttribute(new Attribute("units", ""));
  nstrokes.setCachedData(nstrokesArray, false);
  ncfile.addVariable(null, nstrokes);

  ncfile.addAttribute(null, new Attribute("title", "USPN Lightning Data"));
  ncfile.addAttribute(null, new Attribute("history", "Read directly by Netcdf Java IOSP"));

  ncfile.addAttribute(null, new Attribute("Conventions", "Unidata Observation Dataset v1.0"));
  ncfile.addAttribute(null, new Attribute("cdm_data_type", "Point"));
  ncfile.addAttribute(null, new Attribute("observationDimension", "record"));

  MAMath.MinMax mm = MAMath.getMinMax(dateArray);
  ncfile.addAttribute(null, new Attribute("time_coverage_start", ((int) mm.min) + " " + timeUnit));
  ncfile.addAttribute(null, new Attribute("time_coverage_end", ((int) mm.max) + " " + timeUnit));

  mm = MAMath.getMinMax(latArray);
  ncfile.addAttribute(null, new Attribute("geospatial_lat_min", new Double(mm.min)));
  ncfile.addAttribute(null, new Attribute("geospatial_lat_max", new Double(mm.max)));

  mm = MAMath.getMinMax(lonArray);
  ncfile.addAttribute(null, new Attribute("geospatial_lon_min", new Double(mm.min)));
  ncfile.addAttribute(null, new Attribute("geospatial_lon_max", new Double(mm.max)));

  ncfile.finish();
}
 
Example 9
Source File: UspLightning1.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws IOException {
  int n;

  try {
    n = readAllData(raf);
  } catch (ParseException e) {
    e.printStackTrace();
    throw new IOException("bad data");
  }
  raf.close();

  Dimension recordDim = new Dimension("record", n, true);
  ncfile.addDimension(null, recordDim);

  Variable date = new Variable(ncfile, null, null, "date");
  date.setDimensions("record");
  date.setDataType(DataType.INT);
  String timeUnit = "seconds since 1970-01-01 00:00:00";
  date.addAttribute(new Attribute("long_name", "date of strike"));
  date.addAttribute(new Attribute("units", timeUnit));
  date.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Time.toString()));
  date.setCachedData(dateArray, false);
  ncfile.addVariable(null, date);

  Variable lat = new Variable(ncfile, null, null, "lat");
  lat.setDimensions("record");
  lat.setDataType(DataType.DOUBLE);
  lat.addAttribute(new Attribute("long_name", "latitude"));
  lat.addAttribute(new Attribute("units", "degrees_north"));
  lat.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lat.toString()));
  lat.setCachedData(latArray, false);
  ncfile.addVariable(null, lat);

  Variable lon = new Variable(ncfile, null, null, "lon");
  lon.setDimensions("record");
  lon.setDataType(DataType.DOUBLE);
  lon.addAttribute(new Attribute("long_name", "longitude"));
  lon.addAttribute(new Attribute("units", "degrees_east"));
  lon.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lon.toString()));
  lon.setCachedData(lonArray, false);
  ncfile.addVariable(null, lon);

  Variable amp = new Variable(ncfile, null, null, "strikeAmplitude");
  amp.setDimensions("record");
  amp.setDataType(DataType.DOUBLE);
  amp.addAttribute(new Attribute("long_name", "amplitude of strike"));
  amp.addAttribute(new Attribute("units", "kAmps"));
  amp.addAttribute(new Attribute("missing_value", new Double(999)));
  amp.setCachedData(ampArray, false);
  ncfile.addVariable(null, amp);

  Variable nstrokes = new Variable(ncfile, null, null, "strokeCount");
  nstrokes.setDimensions("record");
  nstrokes.setDataType(DataType.INT);
  nstrokes.addAttribute(new Attribute("long_name", "number of strokes per flash"));
  nstrokes.addAttribute(new Attribute("units", ""));
  nstrokes.setCachedData(nstrokesArray, false);
  ncfile.addVariable(null, nstrokes);

  ncfile.addAttribute(null, new Attribute("title", "USPN Lightning Data"));
  ncfile.addAttribute(null, new Attribute("history", "Read directly by Netcdf Java IOSP"));

  ncfile.addAttribute(null, new Attribute("Conventions", "Unidata Observation Dataset v1.0"));
  ncfile.addAttribute(null, new Attribute("cdm_data_type", "Point"));
  ncfile.addAttribute(null, new Attribute("observationDimension", "record"));

  MAMath.MinMax mm = MAMath.getMinMax(dateArray);
  ncfile.addAttribute(null, new Attribute("time_coverage_start", ((int) mm.min) + " " + timeUnit));
  ncfile.addAttribute(null, new Attribute("time_coverage_end", ((int) mm.max) + " " + timeUnit));

  mm = MAMath.getMinMax(latArray);
  ncfile.addAttribute(null, new Attribute("geospatial_lat_min", new Double(mm.min)));
  ncfile.addAttribute(null, new Attribute("geospatial_lat_max", new Double(mm.max)));

  mm = MAMath.getMinMax(lonArray);
  ncfile.addAttribute(null, new Attribute("geospatial_lon_min", new Double(mm.min)));
  ncfile.addAttribute(null, new Attribute("geospatial_lon_max", new Double(mm.max)));

  ncfile.finish();
}
 
Example 10
Source File: GribDataReader.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Read all of the data records that have been added.
 * The full (x,y) record is read, the reciever will subset the (x, y) as needed.
 * 
 * @param dataReceiver send data here.
 */
private void read(DataReceiverIF dataReceiver) throws IOException {
  Collections.sort(records);

  int currFile = -1;
  RandomAccessFile rafData = null;
  try {
    for (DataRecord dr : records) {
      if (Grib.debugIndexOnly || Grib.debugGbxIndexOnly) {
        GribIosp.debugIndexOnlyCount++;
        currentDataRecord = dr.record;
        currentDataRafFilename = gribCollection.getDataRafFilename(dr.record.fileno);
        if (Grib.debugIndexOnlyShow)
          dr.show(gribCollection);
        dataReceiver.setDataToZero();
        continue;
      }

      if (dr.record.fileno != currFile) {
        if (rafData != null)
          rafData.close();
        rafData = gribCollection.getDataRaf(dr.record.fileno);
        currFile = dr.record.fileno;
      }

      if (dr.record.pos == GribCollectionMutable.MISSING_RECORD)
        continue;

      if (GribDataReader.validator != null && dr.validation != null && rafData != null) {
        GribDataReader.validator.validate(gribCollection.cust, rafData, dr.record.pos + dr.record.drsOffset,
            dr.validation);

      } else if (show && rafData != null) { // for validation
        show(dr.validation);
        show(rafData, dr.record.pos + dr.record.drsOffset);
      }

      float[] data = readData(rafData, dr);
      GdsHorizCoordSys hcs = vindex.group.getGdsHorizCoordSys();
      dataReceiver.addData(data, dr.resultIndex, hcs.nx);
    }

  } finally {
    if (rafData != null)
      rafData.close(); // make sure its closed even on exception
  }
}
 
Example 11
Source File: GribDataReader.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void readPartitioned(DataReceiverIF dataReceiver) throws IOException {
  Collections.sort(records);

  PartitionCollectionImmutable.DataRecord lastRecord = null;
  RandomAccessFile rafData = null;
  try {

    for (DataRecord dr : records) {
      PartitionCollectionImmutable.DataRecord drp = (PartitionCollectionImmutable.DataRecord) dr;
      if (Grib.debugIndexOnly || Grib.debugGbxIndexOnly) {
        GribIosp.debugIndexOnlyCount++;
        if (Grib.debugIndexOnlyShow)
          drp.show();
        dataReceiver.setDataToZero();
        continue;
      }

      if ((rafData == null) || !drp.usesSameFile(lastRecord)) {
        if (rafData != null)
          rafData.close();
        rafData = drp.usePartition.getRaf(drp.partno, dr.record.fileno);
      }
      lastRecord = drp;

      if (dr.record.pos == GribCollectionMutable.MISSING_RECORD)
        continue;

      if (GribDataReader.validator != null && dr.validation != null) {
        GribDataReader.validator.validate(gribCollection.cust, rafData, dr.record.pos + dr.record.drsOffset,
            dr.validation);
      } else if (show) { // for validation
        show(dr.validation);
        show(rafData, dr.record.pos + dr.record.drsOffset);
      }

      float[] data = readData(rafData, dr);
      GdsHorizCoordSys hcs = dr.hcs;
      dataReceiver.addData(data, dr.resultIndex, hcs.nx);
    }

  } finally {
    if (rafData != null)
      rafData.close(); // make sure its closed even on exception
  }
}
 
Example 12
Source File: UspLightning1.java    From tds with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws IOException {
  int n;

  try {
    n = readAllData(raf);
  } catch (ParseException e) {
    e.printStackTrace();
    throw new IOException("bad data");
  }
  raf.close();

  Dimension recordDim = new Dimension("record", n, true);
  ncfile.addDimension(null, recordDim);

  Variable date = new Variable(ncfile, null, null, "date");
  date.setDimensions("record");
  date.setDataType(DataType.INT);
  String timeUnit = "seconds since 1970-01-01 00:00:00";
  date.addAttribute(new Attribute("long_name", "date of strike"));
  date.addAttribute(new Attribute("units", timeUnit));
  date.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Time.toString()));
  date.setCachedData(dateArray, false);
  ncfile.addVariable(null, date);

  Variable lat = new Variable(ncfile, null, null, "lat");
  lat.setDimensions("record");
  lat.setDataType(DataType.DOUBLE);
  lat.addAttribute(new Attribute("long_name", "latitude"));
  lat.addAttribute(new Attribute("units", "degrees_north"));
  lat.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lat.toString()));
  lat.setCachedData(latArray, false);
  ncfile.addVariable(null, lat);

  Variable lon = new Variable(ncfile, null, null, "lon");
  lon.setDimensions("record");
  lon.setDataType(DataType.DOUBLE);
  lon.addAttribute(new Attribute("long_name", "longitude"));
  lon.addAttribute(new Attribute("units", "degrees_east"));
  lon.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lon.toString()));
  lon.setCachedData(lonArray, false);
  ncfile.addVariable(null, lon);

  Variable amp = new Variable(ncfile, null, null, "strikeAmplitude");
  amp.setDimensions("record");
  amp.setDataType(DataType.DOUBLE);
  amp.addAttribute(new Attribute("long_name", "amplitude of strike"));
  amp.addAttribute(new Attribute("units", "kAmps"));
  amp.addAttribute(new Attribute("missing_value", new Double(999)));
  amp.setCachedData(ampArray, false);
  ncfile.addVariable(null, amp);

  Variable nstrokes = new Variable(ncfile, null, null, "strokeCount");
  nstrokes.setDimensions("record");
  nstrokes.setDataType(DataType.INT);
  nstrokes.addAttribute(new Attribute("long_name", "number of strokes per flash"));
  nstrokes.addAttribute(new Attribute("units", ""));
  nstrokes.setCachedData(nstrokesArray, false);
  ncfile.addVariable(null, nstrokes);

  ncfile.addAttribute(null, new Attribute("title", "USPN Lightning Data"));
  ncfile.addAttribute(null, new Attribute("history", "Read directly by Netcdf Java IOSP"));

  ncfile.addAttribute(null, new Attribute("Conventions", "Unidata Observation Dataset v1.0"));
  ncfile.addAttribute(null, new Attribute("cdm_data_type", "Point"));
  ncfile.addAttribute(null, new Attribute("observationDimension", "record"));

  MAMath.MinMax mm = MAMath.getMinMax(dateArray);
  ncfile.addAttribute(null, new Attribute("time_coverage_start", ((int) mm.min) + " " + timeUnit));
  ncfile.addAttribute(null, new Attribute("time_coverage_end", ((int) mm.max) + " " + timeUnit));

  mm = MAMath.getMinMax(latArray);
  ncfile.addAttribute(null, new Attribute("geospatial_lat_min", new Double(mm.min)));
  ncfile.addAttribute(null, new Attribute("geospatial_lat_max", new Double(mm.max)));

  mm = MAMath.getMinMax(lonArray);
  ncfile.addAttribute(null, new Attribute("geospatial_lon_min", new Double(mm.min)));
  ncfile.addAttribute(null, new Attribute("geospatial_lon_max", new Double(mm.max)));

  ncfile.finish();
}
 
Example 13
Source File: NetcdfFile.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Open an existing file (read only), with option of cancelling, setting the RandomAccessFile buffer size for
 * efficiency,
 * with an optional special object for the iosp.
 *
 * @param location location of file. This may be a
 *        <ol>
 *        <li>local netcdf-3 filename (with a file: prefix or no prefix)
 *        <li>remote netcdf-3 filename (with an http: prefix)
 *        <li>local netcdf-4 filename (with a file: prefix or no prefix)
 *        <li>local hdf-5 filename (with a file: prefix or no prefix)
 *        <li>local iosp filename (with a file: prefix or no prefix)
 *        </ol>
 *        http://thredds.ucar.edu/thredds/fileServer/grib/NCEP/GFS/Alaska_191km/files/GFS_Alaska_191km_20130416_0600.grib1
 *        If file ends with ".Z", ".zip", ".gzip", ".gz", or ".bz2", it will uncompress/unzip and write to new file
 *        without the suffix,
 *        then use the uncompressed file. It will look for the uncompressed file before it does any of that. Generally
 *        it prefers to
 *        place the uncompressed file in the same directory as the original file. If it does not have write permission
 *        on that directory,
 *        it will use the directory defined by ucar.nc2.util.DiskCache class.
 * @param buffer_size RandomAccessFile buffer size, if <= 0, use default size
 * @param cancelTask allow task to be cancelled; may be null.
 * @param iospMessage special iosp tweaking (sent before open is called), may be null
 * @return NetcdfFile object, or null if cant find IOServiceProver
 * @throws IOException if error
 * @deprecated use NetcdfFiles.open
 */
@Deprecated
public static NetcdfFile open(String location, int buffer_size, CancelTask cancelTask, Object iospMessage)
    throws IOException {

  RandomAccessFile raf = getRaf(location, buffer_size);

  try {
    return open(raf, location, cancelTask, iospMessage);
  } catch (Throwable t) {
    raf.close();
    throw new IOException(t);
  }
}