Package ucar.nc2.dataset

Examples of ucar.nc2.dataset.NetcdfDataset$VariableComparator


/** Test nc2 dods in the JUnit framework. */
public class TestOutstandingIssues extends TestCase {

  public void testByteAttribute() throws IOException {
    String filename = "dods://localhost:8080/thredds/dodsC/CdataScan/profiler/PROFILER_wind_06min_20070514_2354.nc";
    NetcdfDataset ncd = NetcdfDataset.openDataset(filename, true, null);
    assert ncd != null;
    VariableDS v = (VariableDS) ncd.findVariable("uvQualityCode");
    assert v != null;
    assert v.hasMissing();

    int count = 0;
    Array data = v.read();
View Full Code Here


        System.out.println(" skip " + m.getHeader());
        continue;
      }
      System.out.println(" read " + m.getHeader());

      NetcdfDataset ncd = null;
      try {
        byte[] mbytes = scan.getMessageBytes(m);
        NetcdfFile ncfile = NetcdfFile.openInMemory("test", mbytes);
        ncd = new NetcdfDataset(ncfile);
        Structure s = (Structure) ncd.findVariable(BufrIosp.obsRecord);
        assert s != null;
        readAll(s);

      } finally {
        if (ncd != null) ncd.close();
      }

      count++;
    }
  }
View Full Code Here

      "  <aggregation dimName='time' type='joinExisting'>\n" +
      "    <netcdf location='file:C:\\data\\work\\margolis\\f_0000000.nc'/>\n" +
      "    <netcdf location='file:C:\\data\\work\\margolis\\f_0032400.nc'/>\n" +
      "  </aggregation>\n" +
      "</netcdf>";
    NetcdfDataset aggregatedDataset = NcMLReader.readNcML( new ByteArrayInputStream(ncml.getBytes()), null );
    GridDataset emptyDataset = new GridDataset( aggregatedDataset );
    System.out.printf("empty= %s%n", emptyDataset.getGrids().size());

    assert emptyDataset.getGrids().size() == fullDataset.getGrids().size();
  }
View Full Code Here

    dataset.close();
  }

  public void utestSubsetCoordEdges() throws Exception {
    NetcdfDataset fooDataset = NetcdfDataset.openDataset(TestAll.cdmLocalTestDataDir + "dataset/subsetCoordEdges.ncml");

    try {
      GridDataset fooGridDataset = new GridDataset(fooDataset);
      GridDatatype fooGrid = fooGridDataset.findGridDatatype("foo");

      CoordinateAxis1D fooTimeAxis = fooGrid.getCoordinateSystem().getTimeAxis1D();
      CoordinateAxis1D fooLatAxis = (CoordinateAxis1D) fooGrid.getCoordinateSystem().getYHorizAxis();
      CoordinateAxis1D fooLonAxis = (CoordinateAxis1D) fooGrid.getCoordinateSystem().getXHorizAxis();

      // Expected: [0.0, 31.0, 59.0, 90.0, 120.0]
      // Actual:   [0.0, 31.0, 59.0, 90.0, 120.0]
      System.out.println("mid time= " + Arrays.toString(fooTimeAxis.getCoordValues()));
      System.out.println("edge time= " + Arrays.toString(fooTimeAxis.getCoordEdges()));
      System.out.println();

      // Expected: [-90.0, -18.0, 36.0, 72.0, 90.0]
      // Actual:   [-90.0, -18.0, 36.0, 72.0, 90.0]
      System.out.println("mid lat= " + Arrays.toString(fooLatAxis.getCoordValues()));
      System.out.println("edge lat= " + Arrays.toString(fooLatAxis.getCoordEdges()));
      System.out.println();

      // Expected: [0.0, 36.0, 108.0, 216.0, 360.0]
      // Actual:   [0.0, 36.0, 108.0, 216.0, 360.0]
      System.out.println("mid lon= " + Arrays.toString(fooLonAxis.getCoordValues()));
      System.out.println("edge lon= " + Arrays.toString(fooLonAxis.getCoordEdges()));
      System.out.println();


      Range middleRange = new Range(1, 2);
      GridDatatype fooSubGrid = fooGrid.makeSubset(null, null, middleRange, null, middleRange, middleRange);

      CoordinateAxis1D fooSubTimeAxis = fooSubGrid.getCoordinateSystem().getTimeAxis1D();
      CoordinateAxis1D fooSubLatAxis = (CoordinateAxis1D) fooSubGrid.getCoordinateSystem().getYHorizAxis();
      CoordinateAxis1D fooSubLonAxis = (CoordinateAxis1D) fooSubGrid.getCoordinateSystem().getXHorizAxis();

      // Expected: [31.0, 59.0, 90.0]
      // Actual:   [30.25, 59.75, 89.25]
      System.out.println("mid time= " + Arrays.toString(fooSubTimeAxis.getCoordValues()));
      System.out.println("edge time= " + Arrays.toString(fooSubTimeAxis.getCoordEdges()));
      compare(fooSubTimeAxis.getCoordEdges(), new double[] {31.0, 59.0, 90.0} );
      System.out.println();

      // Expected: [-18.0, 36.0, 72.0]
      // Actual:   [-13.5, 31.5, 76.5]
      System.out.println("mid lat= " + Arrays.toString(fooSubLatAxis.getCoordValues()));
      System.out.println("edge lat= " + Arrays.toString(fooSubLatAxis.getCoordEdges()));
      compare(fooSubLatAxis.getCoordEdges(), new double[] {-18.0, 36.0, 72.0} );
      System.out.println();

      // Expected: [36.0, 108.0, 216.0]
      // Actual:   [27.0, 117.0, 207.0]
      System.out.println("mid lon= " + Arrays.toString(fooSubLonAxis.getCoordValues()));
      System.out.println("edge lon= " + Arrays.toString(fooSubLonAxis.getCoordEdges()));
      compare(fooSubLonAxis.getCoordEdges(), new double[] {36.0, 108.0, 216.0} );
      System.out.println();

    } finally {
      fooDataset.close();
    }
  }
View Full Code Here

      checkIfChanged();
      return;
    }

    Element ncml = getNcmlElement();
    NetcdfDataset ncd = NcMLReader.readNcML(path, ncml, null);
    ncd.setFileCache( fileCache); // LOOK: this dataset never gets closed

    fmrc = new FmrcImpl( ncd);
    madeFmrc = true;
  }
View Full Code Here

              .append( name ).toString();
      return NetcdfDataset.acquireDataset( null, filename, null, -1, null, null); // no enhancement
    }

    makeFmrc();
    NetcdfDataset result = null;
    String location = path;

    if (path.endsWith(FMRC))
      result = fmrc.getFmrcDataset();

    else if (path.endsWith(BEST))
      result = fmrc.getBestTimeSeries();

    else {
      location = name;

      if (type.equals(OFFSET)) {
        int pos1 = name.indexOf(OFFSET_NAME);
        int pos2 = name.indexOf("hr");
        if ((pos1<0) || (pos2<0)) return null;
        String id = name.substring(pos1+OFFSET_NAME.length(), pos2);
        double hour = Double.parseDouble(id);
        result = fmrc.getForecastOffsetDataset( hour);

      } else if (type.equals(RUNS)) {
        int pos1 = name.indexOf(RUN_NAME);
        if (pos1<0) return null;
        String id = name.substring(pos1+RUN_NAME.length());

        DateFormatter formatter = new DateFormatter();
        Date date = formatter.getISODate(id);
        result = fmrc.getRunTimeDataset(date);

      } else if (type.equals(FORECAST)) {
        int pos1 = name.indexOf(FORECAST_NAME);
        if (pos1<0) return null;
        String id = name.substring(pos1+FORECAST_NAME.length());

        DateFormatter formatter = new DateFormatter();
        Date date = formatter.getISODate(id);
        result = fmrc.getForecastTimeDataset(date);
      }
    }

    if (null != result) result.setLocation( location);
    return result;
  }
View Full Code Here

  public void testTimeAxisEval() throws IOException {
    /**
     * The following tests BugFixes.evalTimeAxes, called by ucar.nc2.dt.grid.GridCoordSys.isGridCoordSys
     */
    String testFileFullPath = "E:/work/margolis/bugfix/echoTops_runtime.nc";
    GridDataset runtimeDataset = new GridDataset(new NetcdfDataset(NetcdfFile.open(testFileFullPath)));
    if (runtimeDataset.getGrids().isEmpty()) {
      throw new RuntimeException("Runtime data file did not generate a dataset with grids");
    }
    if (runtimeDataset.getGrids().get(0).getCoordinateSystem().getRunTimeAxis() == null) {
      throw new RuntimeException("Runtime data file did not generate a dataset with a RunTime axis");
View Full Code Here

     * @throws IOException Should never happen.
     */
    @Test
    public void testUCAR() throws IOException {
        final Metadata metadata;
        final Decoder input = new DecoderWrapper(TestCase.LISTENERS, new NetcdfDataset(open(NCEP)));
        try {
            metadata = new MetadataReader(input).read();
        } finally {
            input.close();
        }
View Full Code Here

    @Override
    public GridGeometry[] getGridGeometries() throws IOException {
        if (geometries == null) {
            List<CoordinateSystem> systems = null;
            if (file instanceof NetcdfDataset) {
                final NetcdfDataset ds = (NetcdfDataset) file;
                final EnumSet<NetcdfDataset.Enhance> mode = EnumSet.copyOf(ds.getEnhanceMode());
                if (mode.add(NetcdfDataset.Enhance.CoordSystems)) {
                    ds.enhance(mode);
                }
                systems = ds.getCoordinateSystems();
            }
            geometries = new GridGeometry[(systems != null) ? systems.size() : 0];
            for (int i=0; i<geometries.length; i++) {
                geometries[i] = new GridGeometryWrapper(systems.get(i));
            }
View Full Code Here

      //--- Add dataset subset catalog information to metadata
      dsMetadata.addContent(getDatasetSubset(ds));
     
      //--- For atomic dataset's add ncml for dataset to metadata
      if (!ds.hasNestedDatasets()) {
        NetcdfDataset ncD = NetcdfDataset.openDataset("thredds:"+ds.getCatalogUrl());
        NcMLWriter ncmlWriter = new NcMLWriter();
        Element ncml = Xml.loadString(ncmlWriter.writeXML(ncD),false);
        dsMetadata.addContent(ncml);
      }
View Full Code Here

TOP

Related Classes of ucar.nc2.dataset.NetcdfDataset$VariableComparator

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.