Package ucar.nc2.dataset

Examples of ucar.nc2.dataset.NetcdfDataset


    String wantName = (pos > -1) ? matchPath.substring(pos + 1) : matchPath;
    String hasName = StringUtil.replace(name, ' ', "_") + "_";

    try {
      if (wantType.equals(FILES)) {
        NetcdfDataset ncd = getNetcdfDataset(matchPath);
        return ncd == null ? null : new ucar.nc2.dt.grid.GridDataset(ncd);

      } else if (wantName.equals(hasName + FMRC) && wantDatasets.contains(FeatureCollectionConfig.FmrcDatasetType.TwoD)) {
        return fmrc.getDataset2D(null);
View Full Code Here


  }

  static public TrajectoryObsDataset open( String netcdfFileURI, ucar.nc2.util.CancelTask cancelTask)
          throws  IOException
  {
    NetcdfDataset ds = NetcdfDataset.acquireDataset( netcdfFileURI, cancelTask);
    if ( RafTrajectoryObsDataset.isValidFile( ds) )
      return new RafTrajectoryObsDataset( ds);
    else if ( SimpleTrajectoryObsDataset.isValidFile( ds))
      return new SimpleTrajectoryObsDataset( ds);
    else if ( Float10TrajectoryObsDataset.isValidFile( ds))
View Full Code Here

      DODSNetcdfFile.debugServerCall = true;
      DODSNetcdfFile.debugCE = true;
      DODSNetcdfFile.debugDataResult = true;
      DODSNetcdfFile.debugConvertData = true;

      NetcdfDataset ds = NetcdfDataset.openDataset("C:/data/ncml/oceanwatch.ncml");
      // System.out.println("ds= "+ ds.toString());

      new SequenceObsDataset(ds, null);

    }
View Full Code Here

    testEnhanceEquals("file:R:/testdata/2008TrainingWorkshop/tds/knmi/RAD___TEST_R_C_NL25PCP_L___20080720T000000_200807201T015500_0001_resampledto256x256.ncml");
  }

  private void testEquals(String ncmlLocation) throws  IOException {
    System.out.println("testEquals");
    NetcdfDataset ncd = NcMLReader.readNcML(ncmlLocation, null);

    String locref  = ncd.getReferencedFile().getLocation();
    NetcdfDataset ncdref = NetcdfDataset.openDataset(locref, false, null);

    CompareNetcdf.compareFiles(ncd, ncdref, false, true, false);

    ncd.close();
    ncdref.close();
  }
View Full Code Here

    ncdref.close();
  }

  private void testEnhanceEquals(String ncmlLocation) throws  IOException {
    System.out.println("testEnhanceEquals");
    NetcdfDataset ncml = NcMLReader.readNcML(ncmlLocation, null);
    NetcdfDataset ncmlEnhanced = new NetcdfDataset(ncml, true);

    String locref  = ncml.getReferencedFile().getLocation();
    NetcdfDataset ncdrefEnhanced = NetcdfDataset.openDataset(locref, true, null);

    CompareNetcdf.compareFiles(ncmlEnhanced, ncdrefEnhanced, false, true, false);

    ncml.close();
    ncdrefEnhanced.close();
  }
View Full Code Here

    List<VariableSimpleIF> dataVars = new ArrayList<VariableSimpleIF>();
    ucar.nc2.NetcdfFile ncfile = pfDataset.getNetcdfFile();
    if ((ncfile == null) || !(ncfile instanceof NetcdfDataset))  {
      dataVars.addAll(pfDataset.getDataVariables());
    } else {
      NetcdfDataset ncd = (NetcdfDataset) ncfile;
      for (VariableSimpleIF vs : pfDataset.getDataVariables()) {
        if (ncd.findCoordinateAxis(vs.getShortName()) == null)
          dataVars.add(vs);
      }
    }

    int count = 0;
View Full Code Here

    long start = System.currentTimeMillis();

    // do it in memory for speed
    NetcdfFile ncfile = inMemory ? NetcdfFile.openInMemory(fileIn) : NetcdfFile.open(fileIn);
    NetcdfDataset ncd = new NetcdfDataset(ncfile);

    StringBuilder errlog = new StringBuilder();
    PointObsDataset pobsDataset = (PointObsDataset) TypedDatasetFactory.open(FeatureType.POINT, ncd, null, errlog);

    FileOutputStream fos = new FileOutputStream(fileOut);
View Full Code Here

    long start = System.currentTimeMillis();

    // do it in memory for speed
    NetcdfFile ncfile = inMemory ? NetcdfFile.openInMemory(fileIn) : NetcdfFile.open(fileIn);
    NetcdfDataset ncd = new NetcdfDataset(ncfile);

    StringBuilder errlog = new StringBuilder();
    PointObsDataset pobsDataset = (PointObsDataset) TypedDatasetFactory.open(FeatureType.POINT, ncd, null, errlog);
    if (pobsDataset == null) return false;
View Full Code Here

    long start = System.currentTimeMillis();

    // do it in memory for speed
    NetcdfFile ncfile = inMemory ? NetcdfFile.openInMemory(fileIn) : NetcdfFile.open(fileIn);
    NetcdfDataset ncd = new NetcdfDataset(ncfile);

    Formatter errlog = new Formatter();
    FeatureDataset fd = FeatureDatasetFactoryManager.wrap(FeatureType.ANY_POINT, ncd, null, errlog);
    if (fd == null) return false;
View Full Code Here

  }


  public void testDatasetAddRecord() throws InvalidRangeException, IOException {
    NetcdfDataset nc = NetcdfDataset.openDataset(TestLocal.cdmTestDataDir + "testWriteRecord.nc", NetcdfDataset.getDefaultEnhanceMode(),
        -1, null, NetcdfFile.IOSP_MESSAGE_ADD_RECORD_STRUCTURE);

    // record variable
    Variable record = nc.findVariable("record");
    assert record instanceof StructureDS;
    StructureDS rs = (StructureDS) record;
    assert rs.getRank() == 1;
    assert rs.getDimension(0).getLength() == 2;

    /* Read a record */
    Array rsValues = rs.read("1:1:2");
    assert (rsValues instanceof ArrayStructure);
    assert rsValues.getRank() == 1;
    assert rsValues.getShape()[0] == 1;

    StructureData sdata = (StructureData) rsValues.getObject(rsValues.getIndex());
    Array gdata = sdata.getArray("time");
    assert gdata instanceof ArrayInt.D0 : gdata.getClass().getName();
    ArrayInt.D0 tdata = (ArrayInt.D0) gdata;
    int t = tdata.get();
    assert t == 18;

    int t2 = sdata.getScalarInt("time");
    assert t2 == 18;

    /* Read the times: unlimited dimension */
    Variable time = rs.findVariable("time");
    assert time != null;
    Array timeValues = time.read();
    assert (timeValues instanceof ArrayInt.D0);
    ArrayInt.D0 ta = (ArrayInt.D0) timeValues;
    assert (ta.get() == 6) : ta.get();

    nc.close();
  }
View Full Code Here

TOP

Related Classes of ucar.nc2.dataset.NetcdfDataset

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.