コード例 #1
0
 /**
  * Sets the v-velocity file to be used by this class
  *
  * @param _velocityFile - the v-velocity NetCDF object
  * @param vName - the name of the v variable
  * @throws IOException
  */
 public void setVFile(String _velocityFile, String vName) throws IOException {
   this.vName = vName;
   vFile = NetcdfFile.open(_velocityFile);
   if (vFile != null) {
     vVar = vFile.findVariable(vName);
   }
 }
コード例 #2
0
  /**
   * Open a ucar.nc2.ft.PointFeatureCollection, write out in CF point format.
   *
   * @param fileIn open through TypedDatasetFactory.open(FeatureType.POINT, ..)
   * @param fileOut write to this netcdf-3 file
   * @param inMemory if true, read file into memory for efficiency
   * @return true on success
   * @throws IOException on read/write error
   */
  public static boolean rewritePointFeatureDataset(String fileIn, String fileOut, boolean inMemory)
      throws IOException {
    System.out.println(
        "Rewrite2 .nc files from " + fileIn + " to " + fileOut + " inMemory= " + inMemory);

    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;

    if (fd instanceof FeatureDatasetPoint) {
      writePointFeatureCollection((FeatureDatasetPoint) fd, fileOut);
      fd.close();
      long took = System.currentTimeMillis() - start;
      System.out.println(" that took " + (took - start) + " msecs");
      return true;
    }

    return false;
  }
コード例 #3
0
ファイル: FireInputer.java プロジェクト: hgenet/dostem
  void initTransientFire(boolean useseverity, String dir) {
    String filename = dir + "fire.nc";

    NetcdfFile ncfile = null;
    File spfile = new File(filename);
    if (spfile.exists()) {
      try {
        ncfile = NetcdfFile.open(filename);
        Variable fyearV = ncfile.findVariable("FIRE");
        trfireyearA = fyearV.read();

        Variable fseasonV = ncfile.findVariable("SEASON");
        trfireseasonA = fseasonV.read();

        if (useseverity) {
          Variable fsevV = ncfile.findVariable("SEVERITY");
          trseverityA = fsevV.read();
        }

      } catch (IOException ioe) {
        System.out.println(ioe.getMessage());
      } finally {
        if (ncfile != null) {
          try {
            ncfile.close();
          } catch (IOException ioee) {
            System.out.println(ioee.getMessage());
          }
        }
      }
    } else { // file not exist
      System.out.println("Input file: " + filename + " NOT existed");
      System.exit(-1);
    }
  };
コード例 #4
0
  @Test
  public void testForStructMetadata() throws IOException {
    System.out.printf("TestH4eosReadAll %s%n", filename);
    try (NetcdfFile ncfile = NetcdfFile.open(filename)) {
      Group root = ncfile.getRootGroup();
      Group g = root.findGroup("HDFEOS INFORMATION");
      if (g == null) g = ncfile.getRootGroup();

      Variable dset = g.findVariable("StructMetadata.0");
      assert (dset != null);
    }
  }
コード例 #5
0
  /* (non-Javadoc)
   * @see loci.formats.NetCDFService#setFile(java.lang.String)
   */
  public void setFile(String file) throws IOException {
    this.currentFile = file;

    String currentId = Location.getMappedId(currentFile);
    netCDFFile = NetcdfFile.open(currentId);
    root = netCDFFile.getRootGroup();

    attributeList = new Vector<String>();
    variableList = new Vector<String>();
    List<Group> groups = new ArrayList<Group>();
    groups.add(root);
    parseAttributesAndVariables(groups);
  }
コード例 #6
0
ファイル: TestStandardVar.java プロジェクト: kenkyu/thredds
  public void testReadStandardVar() throws Exception {
    ncfileRead = NetcdfFile.open(filename);
    dsRead = NetcdfDataset.openDataset(filename);

    readDouble();
    readByte2Short();
    readByte();
    readShortMissing();
    readShort2FloatMissing();

    readDoubleMissing();

    ncfileRead.close();
    dsRead.close();
  }
コード例 #7
0
 public static void main(String[] args) {
   String infile = " ";
   if (args.length == 1) {
     infile = args[0];
   } else {
     System.out.println("Usage: java SigmetIOServiceProvider inputFile");
     System.exit(0);
   }
   try {
     NetcdfFile.registerIOProvider(SigmetIOServiceProvider.class);
     NetcdfFile ncfile = NetcdfFile.open(infile);
     System.out.println("ncfile = \n" + ncfile);
   } catch (Exception e) {
     System.out.println("MAIN!!!   " + e.toString());
     e.printStackTrace();
   }
 }
コード例 #8
0
ファイル: ConvertNetCDF.java プロジェクト: jkachika/galileo
  public static Map<String, Metadata> readFile(String file) throws Exception {
    NetcdfFile n = NetcdfFile.open(file);
    System.out.println("Opened: " + file);

    /* Determine the size of our grid */
    int xLen = n.findDimension("x").getLength();
    int yLen = n.findDimension("y").getLength();
    System.out.println("Grid size: " + xLen + "x" + yLen);

    /* What time is this set of readings for? */
    Variable timeVar = n.findVariable("time");
    String timeStr = timeVar.getUnitsString().toUpperCase();
    timeStr = timeStr.replace("HOURS SINCE ", "");
    timeStr = timeStr.replace("HOUR SINCE ", "");

    /* Find the base date (the day) the reading was taken */
    Date baseDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX").parse(timeStr);

    /* Get the number of hours since the base date this reading was taken */
    int offset = timeVar.read().getInt(0);

    /* Generate the actual date for this reading */
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(baseDate);
    calendar.set(Calendar.HOUR, calendar.get(Calendar.HOUR) + offset);
    System.out.println("Time of collection: " + calendar.getTime());

    /* We'll keep a mapping of geolocations -> Galileo Metadata */
    Map<String, Metadata> metaMap = new HashMap<>();

    /* Determine the lat, lon coordinates for the grid points, and get each
     * reading at each grid point. */
    NetcdfDataset dataset = new NetcdfDataset(n);
    @SuppressWarnings("resource")
    GridDataset gridData = new GridDataset(dataset);
    for (GridDatatype g : gridData.getGrids()) {
      /* Let's look at 3D variables: these have WxH dimensions, plus a
       * single plane.  A 4D variable would contain elevation
       * and multiple planes as a result */
      if (g.getShape().length == 3) {
        convert3DVariable(g, calendar.getTime(), metaMap);
      }
    }

    return metaMap;
  }
コード例 #9
0
ファイル: NOWRadiosp.java プロジェクト: feihugis/NetCDF
  public static void main(String args[])
      throws Exception, IOException, InstantiationException, IllegalAccessException {
    String fileIn = "z:/nowrad/BREF_951207_2230";

    // String fileIn = "c:/data/image/Nids/n0r_20041013_1852";
    ucar.nc2.NetcdfFile.registerIOProvider(ucar.nc2.iosp.nowrad.NOWRadiosp.class);

    ucar.nc2.NetcdfFile ncf = ucar.nc2.NetcdfFile.open(fileIn);

    // List alist = ncf.getGlobalAttributes();
    ucar.nc2.Variable v = ncf.findVariable("BaseReflectivity");
    int[] origin = {0, 0};
    int[] shape = {300, 36};
    ArrayByte data = (ArrayByte) v.read(origin, shape);

    ncf.close();
  }
コード例 #10
0
  /** test */
  public static void main2(String[] args) throws IOException {
    File testDir = new File("C:/data/bad/radar2/");

    File[] files = testDir.listFiles();
    for (int i = 0; i < files.length; i++) {
      File file = files[i];
      if (!file.getPath().endsWith(".ar2v")) continue;
      System.out.println(file.getPath() + " " + file.length());
      long pos = testValid(file.getPath());
      if (pos == file.length()) {
        System.out.println("OK");
        try {
          NetcdfFile.open(file.getPath());
        } catch (Throwable t) {
          System.out.println("ERROR=  " + t);
        }
      } else System.out.println("NOT pos=" + pos);

      System.out.println();
    }
  }
コード例 #11
0
  private void read(
      String filename, int ndims, int nvars, int ngatts, int natts, int nstructFields, int ngroups)
      throws IOException {
    NetcdfFile ncfile = NetcdfFile.open(filename);
    Counter c = new Counter();
    c.count(ncfile.getRootGroup());

    if (false) {
      filename = filename.substring(testDir.length());
      filename = StringUtil2.replace(filename, '\\', "/");
      System.out.println(
          "read(testDir+\""
              + filename
              + "\","
              + c.ndims
              + ","
              + c.nvars
              + ","
              + c.ngatts
              + ","
              + c.natts
              + ","
              + c.nstructFields
              + ","
              + c.ngroups
              + ");");
      ncfile.close();
      return;
    }

    print(ndims, c.ndims);
    print(nvars, c.nvars);
    print(ngatts, c.ngatts);
    print(natts, c.natts);
    print(nstructFields, c.nstructFields);
    print(ngroups, c.ngroups);
    System.out.println("   " + filename);
    ncfile.close();
  }
コード例 #12
0
  /**
   * Open a ucar.nc2.dt.PointObsDataset, write out in CF point format.
   *
   * @param fileIn open through TypedDatasetFactory.open(FeatureType.POINT, ..)
   * @param fileOut write to this netcdf-3 file
   * @param inMemory if true, read file into memory for efficiency
   * @return true on success
   * @throws IOException on read/write error
   */
  public static boolean rewritePointObsDataset(String fileIn, String fileOut, boolean inMemory)
      throws IOException {
    System.out.println(
        "Rewrite2 .nc files from " + fileIn + " to " + fileOut + " inMemory= " + inMemory);

    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;

    writePointObsDataset(pobsDataset, fileOut);
    pobsDataset.close();

    long took = System.currentTimeMillis() - start;
    System.out.println(" that took " + (took - start) + " msecs");
    return true;
  }
コード例 #13
0
 public ManipulatingNetCDF(String path) throws IOException {
   this.path = path;
   ncf = NetcdfFile.open(path);
   elementList = new CDFElement[ncf.getVariables().size()];
   initialize();
 }
コード例 #14
0
  public void read5kmlatlong() {
    NetcdfFile ncfile = null;
    try {
      ncfile = NetcdfFile.open("/home/kerryn/Desktop/Temp/treecover_30pts_lat.nc");
      String xrange = "Band1";
      Variable xrangeVar = ncfile.findVariable(xrange);
      Array xrangeData = xrangeVar.read();
      NCdump.printArray(xrangeData, xrange, System.out, null);

      String yrange = "GDAL_Geographics";
      Variable yrangeVar = ncfile.findVariable(yrange);
      Array yrangeData = yrangeVar.read();
      NCdump.printArray(yrangeData, yrange, System.out, null);

      List<ucar.nc2.Attribute> yattr = yrangeVar.getAttributes();
      for (ucar.nc2.Attribute attr : yattr) {
        String attrName = attr.getName();
        Array attrValue = attr.getValues();
        attrValue.getElementType();
        double value = attrValue.getDouble(0);

        System.out.println(attrName + "=" + value);
      }

      // [Northernmost_Northing = -37.51903101958847, Southernmost_Northing = -38.49309598467985,
      // Easternmost_Easting = 145.56979076552813, Westernmost_Easting = 144.4949604592204,
      // spatial_ref = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS
      // 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433],AUTHORITY[\"EPSG\",\"4326\"]]", GeoTransform = "144.495 0.0335884 0 -37.519 0 -0.0335884 ", grid_mapping_name = "Geographics Coordinate System", long_name = "Grid_latitude"]

      //			String zrange = "z_range";
      //			Variable zrangeVar = ncfile.findVariable(zrange);
      //			Array zrangeData = zrangeVar.read();
      //			NCdump.printArray(zrangeData, zrange, System.out, null);
      //
      //			String spacing = "spacing";
      //			Variable spacingVar = ncfile.findVariable(spacing);
      //			Array spacingData = spacingVar.read();
      //			NCdump.printArray(spacingData, spacing, System.out, null);
      //
      //			String dimension = "dimension";
      //			Variable dimensionVar = ncfile.findVariable(dimension);
      //			Array dimensionData = dimensionVar.read();
      //			NCdump.printArray(dimensionData, dimension, System.out, null);
      //
      //			String z = "z";
      //			Variable zVar = ncfile.findVariable(z);
      //			Array zData = zVar.read();
      //			NCdump.printArray(zData, z, System.out, null);

      //			int count = 0;
      //			//for (int x=0;x<94;x++)
      //			for (int x=0;x<30;x++)  // 106.92 km
      //			{
      //				//for (int y=0;y<108;y++)
      //				for (int y=0;y<30;y++) // 93.06 km
      //				{
      //					double item = zData.getDouble(count);
      //					long percent = Math.round(item * 100);
      //					if (percent < 0)
      //					{
      //						percent = 0;
      //					}
      //					String percentStr = new Integer((int)percent).toString();
      //					if (percentStr.length() == 1)
      //					{
      //						percentStr = "0" + percentStr;
      //					}
      //					if (percentStr.equals("00"))
      //					{
      //						percentStr = "  ";
      //					}
      //
      //					//System.out.println(x + " " + y + " " + item);
      //					System.out.print( " " + percentStr);
      //					count ++;
      //				}
      //				System.out.println();
      //			}

    } catch (IOException ioe) {
      ioe.printStackTrace();
    }
  }
コード例 #15
0
  public void read() {
    NetcdfFile ncfile = null;
    try {
      ncfile = NetcdfFile.open(filename);
      String xrange = "x_range";
      Variable xrangeVar = ncfile.findVariable(xrange);
      Array xrangeData = xrangeVar.read();
      // NCdump.printArray(xrangeData, xrange, System.out, null);

      String yrange = "y_range";
      Variable yrangeVar = ncfile.findVariable(yrange);
      Array yrangeData = yrangeVar.read();
      // NCdump.printArray(yrangeData, yrange, System.out, null);

      String zrange = "z_range";
      Variable zrangeVar = ncfile.findVariable(zrange);
      Array zrangeData = zrangeVar.read();
      // NCdump.printArray(zrangeData, zrange, System.out, null);

      String spacing = "spacing";
      Variable spacingVar = ncfile.findVariable(spacing);
      Array spacingData = spacingVar.read();
      // NCdump.printArray(spacingData, spacing, System.out, null);

      String dimension = "dimension";
      Variable dimensionVar = ncfile.findVariable(dimension);
      Array dimensionData = dimensionVar.read();
      // NCdump.printArray(dimensionData, dimension, System.out, null);

      String z = "z";
      Variable zVar = ncfile.findVariable(z);
      Array zData = zVar.read();
      // NCdump.printArray(zData, z, System.out, null);

      int count = 0;
      // for (int x=0;x<94;x++)
      for (int x = 0; x < 108; x++) // 106.92 km
      {
        // for (int y=0;y<108;y++)
        for (int y = 0; y < 94; y++) // 93.06 km
        {
          double item = zData.getDouble(count);
          long percent = Math.round(item * 100);
          String percentStr = new Integer((int) percent).toString();
          if (percentStr.length() == 1) {
            percentStr = "0" + percentStr;
          }
          if (percentStr.equals("00")) {
            percentStr = "  ";
          }

          // System.out.println(x + " " + y + " " + item);
          System.out.print(" " + percentStr);
          count++;
        }
        System.out.println();
      }

    } catch (IOException ioe) {
      ioe.printStackTrace();
    }
  }
コード例 #16
0
 /**
  * Sets the u-velocity file to be used by this class
  *
  * @param _velocityFile - the u-velocity NetCDF object
  * @param uName - the name of the u variable
  * @throws IOException
  */
 public void setUFile(String _velocityFile, String uName) throws IOException {
   uFile = NetcdfFile.open(_velocityFile);
   uVar = uFile.findVariable(uName);
   this.uName = uName;
 }
コード例 #17
0
  public void initialize(String dir) throws IOException {
    // Set Time Zone to UTC
    formatUTC.setTimeZone(TimeZone.getTimeZone("UTC"));

    this.dir = dir;
    File f = new File(dir);

    // Ensure the path is a directory
    if (!f.isDirectory()) {
      throw new IllegalArgumentException(f.getName() + " is not a directory.");
    }

    // Filter the list of files

    File[] fa = f.listFiles(new FilenamePatternFilter(".*_[uvw].*\\.nc"));

    if (fa == null) {
      throw new IOException("File list is empty.");
    }

    for (File fil : fa) {

      String name = fil.getName();

      NetcdfFile ncf = NetcdfFile.open(fil.getPath());
      tVar = ncf.findVariable(tName);

      if (tVar == null) {
        System.out.println(
            "WARNING: Time variable "
                + tVar
                + " was not found in "
                + fil.getPath()
                + " when initializing the VelocityReader.  This file will be skipped.");
        continue;
      }

      Array arr = tVar.read();

      // Convert into a java array

      double[] ja = (double[]) arr.copyTo1DJavaArray();

      // Determine the minimum and maximum times

      long[] minmax = new long[2];

      minmax[0] = TimeConvert.HYCOMToMillis((long) ja[0]);
      minmax[1] = TimeConvert.HYCOMToMillis((long) ja[ja.length - 1]);

      // Put into an index linking start time with the associated file

      if (name.lastIndexOf("_u") > 0) {
        if (uFiles.containsKey(minmax[0])) {
          System.out.print(
              "WARNING:  Velocity files have duplicate time keys. "
                  + name
                  + "/"
                  + uFiles.get(minmax[0])
                  + " at "
                  + new Date(minmax[0]));
          System.out.println(" Skipping latter file.");
        } else {
          uFiles.put(minmax[0], ncf);
        }
      }

      if (name.lastIndexOf("_v") > 0) {
        if (vFiles.containsKey(minmax[0])) {
          System.out.print(
              "WARNING:  Velocity files have duplicate time keys. "
                  + name
                  + "/"
                  + vFiles.get(minmax[0])
                  + " at "
                  + new Date(minmax[0]));
          System.out.println(" Skipping latter file.");
        } else {
          vFiles.put(minmax[0], ncf);
        }
      }

      if (name.lastIndexOf("_w") > 0) {
        if (wFiles.containsKey(minmax[0])) {
          System.out.print(
              "WARNING:  Velocity files have duplicate time keys. "
                  + name
                  + "/"
                  + wFiles.get(minmax[0])
                  + " at "
                  + new Date(minmax[0]));
          System.out.println(" Skipping latter file.");
        } else {
          wFiles.put(minmax[0], ncf);
        }
      }
    }

    // If there are no files in one of the index collections, then exit.

    if (uFiles.size() == 0 || vFiles.size() == 0 || wFiles.size() == 0) {
      System.out.println(
          "Velocity directory is empty, or files/variables are not named properly."
              + "Files  must be named as *_u*, *_v*, and *_w*.");

      System.exit(0);
    }

    uKeys = new ArrayList<Long>(uFiles.keySet());
    vKeys = new ArrayList<Long>(vFiles.keySet());
    wKeys = new ArrayList<Long>(wFiles.keySet());

    // Populate uFile, vFile and wFile with the first entry so that they
    // are not null

    uFile = uFiles.get(uKeys.get(0));
    vFile = vFiles.get(vKeys.get(0));
    wFile = wFiles.get(wKeys.get(0));

    uVar = uFile.findVariable(uName);
    vVar = vFile.findVariable(vName);
    wVar = wFile.findVariable(wName);

    // Latitude and depth are read here because they should not change
    // and therefore can be input once only.

    latVar = uFile.findVariable(latName);
    lonVar = uFile.findVariable(lonName);
    zVar = uFile.findVariable(zName);

    setXLookup(lonName);
    setYLookup(latName);
    setZLookup(zName);

    if (positiveDown) {
      zloc.setNegate(true);
    }
    bounds[0][0] = uKeys.get(0);
    NetcdfFile lastfile = uFiles.get(uKeys.get(uKeys.size() - 1));
    Variable t = lastfile.findVariable(tName);
    double last;
    try {
      last = t.read(new int[] {t.getShape(0) - 1}, new int[] {1}).getDouble(0);
      bounds[0][1] = TimeConvert.HYCOMToMillis((long) last);
    } catch (InvalidRangeException e) {
      e.printStackTrace();
    }
  }
コード例 #18
0
ファイル: TestDorade.java プロジェクト: msdsoftware/thredds
  @Test
  public void testDoradeGround() throws IOException {

    System.out.println("**** Open " + groundDoradeFile);
    try (NetcdfFile ncfile = NetcdfFile.open(groundDoradeFile)) {

      for (Variable v : ncfile.getVariables()) {
        System.out.println(v.getFullName());
      }

      /* test both gate and radial dimension */
      Dimension gateDim = ncfile.getRootGroup().findDimension("gate_1");

      assert (gateDim.getLength() == 1008);

      Dimension radialDim = ncfile.getRootGroup().findDimension("radial");

      assert (radialDim.getLength() == 439);

      /* test some att  */
      Attribute testAtt = ncfile.getRootGroup().findAttribute("Conventions");
      assert (testAtt.getStringValue().equals(_Coordinate.Convention));

      testAtt = ncfile.getRootGroup().findAttribute("format");
      assert (testAtt.getStringValue().equals("Unidata/netCDF/Dorade"));

      testAtt = ncfile.getRootGroup().findAttribute("Project_name");
      assert (testAtt.getStringValue().equalsIgnoreCase("IHOP_2002"));

      testAtt = ncfile.getRootGroup().findAttribute("Radar_Name");
      assert (testAtt.getStringValue().equalsIgnoreCase("SPOL"));

      testAtt = ncfile.getRootGroup().findAttribute("VolumeCoveragePatternName");
      assert (testAtt.getStringValue().equalsIgnoreCase("SUR"));

      testAtt = ncfile.getRootGroup().findAttribute("Volume_Number");
      assert (testAtt.getStringValue().equalsIgnoreCase("1"));

      testAtt = ncfile.getRootGroup().findAttribute("Sweep_Number");
      assert (testAtt.getStringValue().equalsIgnoreCase("2"));

      testAtt = ncfile.getRootGroup().findAttribute("Sweep_Date");
      assert (testAtt.getStringValue().equalsIgnoreCase("2002-05-11 01:58:15Z"));

      Variable var;
      var = ncfile.findVariable("elevation");
      testReadData(var);
      var = ncfile.findVariable("azimuth");
      testReadData(var);
      var = ncfile.findVariable("distance_1");
      testReadData(var);
      var = ncfile.findVariable("latitudes_1");
      testReadData(var);
      var = ncfile.findVariable("longitudes_1");
      testReadData(var);
      var = ncfile.findVariable("altitudes_1");
      testReadData(var);
      var = ncfile.findVariable("rays_time");
      testReadData(var);
      var = ncfile.findVariable("Range_to_First_Cell");
      float t = testReadScalar(var);
      assert (t == (float) 150.0);

      var = ncfile.findVariable("Cell_Spacing");
      t = testReadScalar(var);
      assert (t == (float) 149.89624);
      var = ncfile.findVariable("Fixed_Angle");
      t = testReadScalar(var);
      assert (t == (float) 1.1975098);
      var = ncfile.findVariable("Nyquist_Velocity");
      t = testReadScalar(var);
      assert (t == (float) 25.618269);
      var = ncfile.findVariable("Unambiguous_Range");
      t = testReadScalar(var);
      assert (t == (float) 156.11694);
      var = ncfile.findVariable("Radar_Constant");
      t = testReadScalar(var);
      assert (t == (float) 70.325195);
      var = ncfile.findVariable("rcvr_gain");
      t = testReadScalar(var);
      assert (t == (float) 46.95);
      var = ncfile.findVariable("ant_gain");
      t = testReadScalar(var);
      assert (t == (float) 45.58);
      var = ncfile.findVariable("sys_gain");
      t = testReadScalar(var);
      assert (t == (float) 46.95);
      var = ncfile.findVariable("bm_width");
      t = testReadScalar(var);
      assert (t == (float) 0.92);

      var = ncfile.findVariable("VE");
      testReadData(var);
      var = ncfile.findVariable("DM");
      testReadData(var);
      var = ncfile.findVariable("NCP");
      testReadData(var);
      var = ncfile.findVariable("SW");
      testReadData(var);
      var = ncfile.findVariable("DZ");
      testReadData(var);
      var = ncfile.findVariable("DCZ");
      testReadData(var);
      var = ncfile.findVariable("LVDR");
      testReadData(var);
      var = ncfile.findVariable("NIQ");
      testReadData(var);
      var = ncfile.findVariable("AIQ");
      testReadData(var);
      var = ncfile.findVariable("CH");
      testReadData(var);
      var = ncfile.findVariable("AH");
      testReadData(var);
      var = ncfile.findVariable("CV");
      testReadData(var);
      var = ncfile.findVariable("AV");
      testReadData(var);
      var = ncfile.findVariable("RHOHV");
      testReadData(var);
      var = ncfile.findVariable("LDR");
      testReadData(var);
      var = ncfile.findVariable("DL");
      testReadData(var);
      var = ncfile.findVariable("DX");
      testReadData(var);
      var = ncfile.findVariable("ZDR");
      testReadData(var);
      var = ncfile.findVariable("PHI");
      testReadData(var);
      var = ncfile.findVariable("KDP");
      testReadData(var);

      assert (0 == var.findDimensionIndex("radial"));
      assert (1 == var.findDimensionIndex("gate_1"));
    }
  }
コード例 #19
0
ファイル: TestDorade.java プロジェクト: msdsoftware/thredds
  @Test
  public void testDoradeAir() throws IOException {
    System.out.println("**** Open " + airDoradeFile);
    try (NetcdfFile ncfile = NetcdfFile.open(airDoradeFile)) {

      for (Variable v : ncfile.getVariables()) {
        System.out.println(v.getFullName());
      }

      Dimension gateDim = ncfile.getRootGroup().findDimension("gate_1");
      assert (gateDim.getLength() == 320);
      Dimension radialDim = ncfile.getRootGroup().findDimension("radial");
      assert (radialDim.getLength() == 274);

      Variable var;
      var = ncfile.findVariable("elevation");
      testReadData(var);
      var = ncfile.findVariable("azimuth");
      testReadData(var);
      var = ncfile.findVariable("distance_1");
      testReadData(var);
      var = ncfile.findVariable("latitudes_1");
      testReadData(var);
      var = ncfile.findVariable("longitudes_1");
      testReadData(var);
      var = ncfile.findVariable("altitudes_1");
      testReadData(var);
      var = ncfile.findVariable("rays_time");
      testReadData(var);

      var = ncfile.findVariable("Range_to_First_Cell");
      float t = testReadScalar(var);
      assert (t == (float) -2.0);
      var = ncfile.findVariable("Cell_Spacing");
      t = testReadScalar(var);
      assert (t == (float) 150.0);
      var = ncfile.findVariable("Fixed_Angle");
      t = testReadScalar(var);
      assert (t == (float) -16.53);
      var = ncfile.findVariable("Nyquist_Velocity");
      t = testReadScalar(var);
      assert (t == (float) 78.03032);
      var = ncfile.findVariable("Unambiguous_Range");
      t = testReadScalar(var);
      assert (t == (float) 60.0);
      var = ncfile.findVariable("Radar_Constant");
      t = testReadScalar(var);
      assert (t == (float) -81.17389);
      var = ncfile.findVariable("rcvr_gain");
      t = testReadScalar(var);
      assert (t == (float) 32.64);
      var = ncfile.findVariable("ant_gain");
      t = testReadScalar(var);
      assert (t == (float) 39.35);
      var = ncfile.findVariable("sys_gain");
      t = testReadScalar(var);
      assert (t == (float) 52.34);
      var = ncfile.findVariable("bm_width");
      t = testReadScalar(var);
      assert (t == (float) 1.79);

      var = ncfile.findVariable("VS");
      testReadData(var);
      var = ncfile.findVariable("VL");
      testReadData(var);
      var = ncfile.findVariable("SW");
      testReadData(var);
      var = ncfile.findVariable("VR");
      testReadData(var);
      var = ncfile.findVariable("NCP");
      testReadData(var);
      var = ncfile.findVariable("DBZ");
      testReadData(var);
      var = ncfile.findVariable("VG");
      testReadData(var);
      var = ncfile.findVariable("VT");
      testReadData(var);
      assert (null != var.getDimension(0));
      assert (null != var.getDimension(1));
    }
  }
コード例 #20
0
 /**
  * Sets the w-velocity ffile to be used by this class
  *
  * @param _velocityFile - the w-velocity NetCDF object
  * @param wName - the name of the w variable
  * @throws IOException
  */
 public void setWFile(String _velocityFile, String wName) throws IOException {
   wFile = NetcdfFile.open(_velocityFile);
   wVar = wFile.findVariable(wName);
   this.wName = wName;
 }