Beispiel #1
0
  /**
   * Returns the array that contins the max dimension sizes of the dataset.
   *
   * @return the max dimension sizes of the dataset.
   */
  public final long[] getMaxDims() {
    if (rank < 0) init();

    if (maxDims == null) return dims;

    return maxDims;
  }
Beispiel #2
0
  /**
   * Returns the dimension size of the vertical axis.
   *
   * <p>This function is used by GUI applications such as HDFView. GUI applications display a
   * dataset in a 2D table or 2D image. The display order is specified by the index array of
   * selectedIndex as follow:
   *
   * <dl>
   *   <dt>selectedIndex[0] -- height
   *   <dd>The vertical axis
   *   <dt>selectedIndex[1] -- width
   *   <dd>The horizontal axis
   *   <dt>selectedIndex[2] -- depth
   *   <dd>The depth axis is used for 3 or more dimensional datasets.
   * </dl>
   *
   * Applications can use getSelectedIndex() to access and change the display order. For example, in
   * a 2D dataset of 200x50 (dim0=200, dim1=50), the following code will set the height=200 and
   * width=50.
   *
   * <pre>
   * long[] selectedIndex = dataset.getSelectedIndex();
   * selectedIndex[0] = 0;
   * selectedIndex[1] = 1;
   * </pre>
   *
   * @see #getSelectedIndex()
   * @see #getWidth()
   * @return the size of dimension of the vertical axis.
   */
  public final int getHeight() {
    if (rank < 0) init();

    if ((selectedDims == null) || (selectedIndex == null)) {
      return 0;
    }

    return (int) selectedDims[selectedIndex[0]];
  }
Beispiel #3
0
  /**
   * Returns the size of dimension of the horizontal axis.
   *
   * <p>This function is used by GUI applications such as HDFView. GUI applications display dataset
   * a 2D Table or 2D Image. The display order is specified by the index array of selectedIndex as
   * follow:
   *
   * <dl>
   *   <dt>selectedIndex[0] -- height
   *   <dd>The vertical axis
   *   <dt>selectedIndex[1] -- width
   *   <dd>The horizontal axis
   *   <dt>selectedIndex[2] -- depth
   *   <dd>The depth axis, which is used for 3 or more dimension datasets.
   * </dl>
   *
   * Applications can use getSelectedIndex() to access and change the display order. For example, in
   * a 2D dataset of 200x50 (dim0=200, dim1=50), the following code will set the height=200 and
   * width=100.
   *
   * <pre>
   * long[] selectedIndex = dataset.getSelectedIndex();
   * selectedIndex[0] = 0;
   * selectedIndex[1] = 1;
   * </pre>
   *
   * @see #getSelectedIndex()
   * @see #getHeight()
   * @return the size of dimension of the horizontal axis.
   */
  public final int getWidth() {
    if (rank < 0) init();

    if ((selectedDims == null) || (selectedIndex == null)) {
      return 0;
    }

    if ((selectedDims.length < 2) || (selectedIndex.length < 2)) {
      return 1;
    }

    return (int) selectedDims[selectedIndex[1]];
  }
Beispiel #4
0
  /**
   * Returns the selectedStride of the selected dataset.
   *
   * <p>Applications can use this array to change how many elements to move in each dimension.
   *
   * <p>Combined with the starting position and selected sizes, the subset of a rectangle selection
   * is defined.
   *
   * <p>For example, a 4 X 5 dataset
   *
   * <pre>
   *     0,  1,  2,  3,  4
   *    10, 11, 12, 13, 14
   *    20, 21, 22, 23, 24
   *    30, 31, 32, 33, 34
   * long[] dims = {4, 5};
   * long[] startDims = {0, 0};
   * long[] selectedDims = {2, 2};
   * long[] selectedStride = {2, 3};
   * then the following subset is selected by the startDims and selectedDims
   *     0,   3
   *     20, 23
   * </pre>
   */
  public final long[] getStride() {
    if (rank < 0) init();

    if (rank <= 0) {
      return null;
    }

    if (selectedStride == null) {
      selectedStride = new long[rank];
      for (int i = 0; i < rank; i++) {
        selectedStride[i] = 1;
      }
    }

    return selectedStride;
  }
  List<GeoPointCarbon> occurrencesToList(Document document, Region region) {

    String DATASETNAME_LAT = "RetrievalGeometry/retrieval_latitude";
    String DATASETNAME_LONG = "RetrievalGeometry/retrieval_longitude";
    String DATASETNAME_XCO2 = "RetrievalResults/xco2";
    String DATASETNAME_XCO2_INTERF = "RetrievalResults/xco2_uncert_interf";
    String DATASETNAME_XCO2_NOISE = "RetrievalResults/xco2_uncert_noise";
    String DATASETNAME_DATE = "Metadata/OrbitStartDate";

    H5File file = null;
    Dataset latitude = null;
    Dataset longitude = null;
    Dataset xco2 = null;
    Dataset xco2_interf = null;
    Dataset xco2_noise = null;
    H5ScalarDS orbitStartDate = null;
    int latitude_dataspace_id = -1;
    int longitude_dataspace_id = -1;
    int xco2_dataspace_id = -1;
    int xco2_interf_dataspace_id = -1;
    int xco2_noise_dataspace_id = -1;
    int latitude_dataset_id = -1;
    int longitude_dataset_id = -1;
    int xco2_dataset_id = -1;
    int xco2_interf_dataset_id = -1;
    int xco2_noise_dataset_id = -1;
    long[] latitude_dims = {1};
    long[] longitude_dims = {1};
    long[] xco2_dims = {1};
    long[] xco2_interf_dims = {1};
    long[] xco2_noise_dims = {1};
    float[] latitude_data;
    float[] longitude_data;
    float[] xco2_data;
    float[] xco2_interf_data;
    float[] xco2_noise_data;
    String[] date_data = {""};
    List<GeoPointCarbon> listOfPoints = new ArrayList<>();

    try {

      // Open an existing file in the folder it is located.
      file = new H5File(document.getFileName(), FileFormat.READ);
      file.open();

      // Open latitude dataset.
      latitude = (Dataset) file.get(DATASETNAME_LAT);
      latitude_dataset_id = latitude.open();

      // Open longitude dataset.
      longitude = (Dataset) file.get(DATASETNAME_LONG);
      longitude_dataset_id = longitude.open();

      // Open xco2 dataset.
      xco2 = (Dataset) file.get(DATASETNAME_XCO2);
      xco2_dataset_id = xco2.open();

      // Get orbitStartDate dataset.
      orbitStartDate = (H5ScalarDS) file.get(DATASETNAME_DATE);

      // Get latitude dataspace and allocate memory for the read buffer.
      if (latitude_dataset_id >= 0) latitude_dataspace_id = H5.H5Dget_space(latitude_dataset_id);
      if (latitude_dataspace_id >= 0)
        H5.H5Sget_simple_extent_dims(latitude_dataspace_id, latitude_dims, null);

      // Get longitude dataspace and allocate memory for the read buffer.
      if (longitude_dataset_id >= 0) longitude_dataspace_id = H5.H5Dget_space(longitude_dataset_id);
      if (longitude_dataset_id >= 0)
        H5.H5Sget_simple_extent_dims(longitude_dataspace_id, longitude_dims, null);

      // Get xco2 dataspace and allocate memory for the read buffer.
      if (xco2_dataset_id >= 0) xco2_dataspace_id = H5.H5Dget_space(xco2_dataset_id);
      if (xco2_dataset_id >= 0) H5.H5Sget_simple_extent_dims(xco2_dataspace_id, xco2_dims, null);

      // Allocate array of pointers to rows.
      latitude_data = new float[(int) latitude_dims[0]];
      longitude_data = new float[(int) longitude_dims[0]];
      xco2_data = new float[(int) xco2_dims[0]];

      // Read the data using the default properties.
      latitude.init();
      latitude_data = (float[]) latitude.getData();

      longitude.init();
      longitude_data = (float[]) longitude.getData();

      xco2.init();
      xco2_data = (float[]) xco2.getData();

      date_data = (String[]) orbitStartDate.read();

      // Process data
      for (int i = 0; i < latitude_data.length; i++) {

        if (region.inRegion(latitude_data[i], longitude_data[i])) {
          listOfPoints.add(
              new GeoPointCarbon(
                  latitude_data[i],
                  longitude_data[i],
                  date_data[0],
                  (float) (xco2_data[i] * Math.pow(10, 6))));
        }
      }

      // End access to the latitude dataset and release resources used by it.
      if (latitude_dataset_id >= 0) latitude.close(latitude_dataset_id);
      if (latitude_dataspace_id >= 0) H5.H5Sclose(latitude_dataspace_id);

      // End access to the longitude dataset and release resources used by it.
      if (longitude_dataset_id >= 0) longitude.close(longitude_dataset_id);
      if (longitude_dataspace_id >= 0) H5.H5Sclose(longitude_dataspace_id);

      // End access to the xco2 dataset and release resources used by it.
      if (xco2_dataset_id >= 0) xco2.close(xco2_dataset_id);
      if (xco2_dataspace_id >= 0) H5.H5Sclose(xco2_dataspace_id);

      // Close the file.
      file.close();

    } catch (Exception e) {
      e.printStackTrace();
    }

    return listOfPoints;
  }
Beispiel #6
0
  /**
   * Returns the array that contains the dimension sizes of the chunk of the dataset. Returns null
   * if the dataset is not chunked.
   *
   * @return the array of chunk sizes or returns null if the dataset is not chunked.
   */
  public final long[] getChunkSize() {
    if (rank < 0) init();

    return chunkSize;
  }
Beispiel #7
0
  /**
   * Returns the string representation of compression information.
   *
   * <p>For example, "SZIP: Pixels per block = 8: H5Z_FILTER_CONFIG_DECODE_ENABLED".
   *
   * @return the string representation of compression information.
   */
  public final String getCompression() {
    if (rank < 0) init();

    return compression;
  }
Beispiel #8
0
  /**
   * Returns the indices of display order.
   *
   * <p>selectedIndex[] is provided for two purpose:
   *
   * <OL>
   *   <LI>selectedIndex[] is used to indicate the order of dimensions for display. selectedIndex[0]
   *       is for the row, selectedIndex[1] is for the column and selectedIndex[2] for the depth.
   *       <p>For example, for a four dimesion dataset, if selectedIndex[] = {1, 2, 3}, then dim[1]
   *       is selected as row index, dim[2] is selected as column index and dim[3] is selected as
   *       depth index.
   *   <LI>selectedIndex[] is also used to select dimensions for display for datasets with three or
   *       more dimensions. We assume that applications such as HDFView can only display data values
   *       up to three dimension (2D spreadsheet/image with a third dimension which the 2D
   *       spreadsheet/image is selected from). For dataset with more than three dimensions, we need
   *       selectedIndex[] to tell applications which three dimensions are chosen for display. <br>
   *       For example, for a four dimesion dataset, if selectedIndex[] = {1, 2, 3}, then dim[1] is
   *       selected as row index, dim[2] is selected as column index and dim[3] is selected as depth
   *       index. dim[0] is not selected. Its location is fixed at 0 by default.
   * </OL>
   *
   * @return the array of the indices of display order.
   */
  public final int[] getSelectedIndex() {
    if (rank < 0) init();

    return selectedIndex;
  }
Beispiel #9
0
  /**
   * Returns the starting position of a selected subset.
   *
   * <p>Applications can use this array to change the starting position of a selection. Combined
   * with the selected dimensions, selected sizes and stride, the subset of a rectangle selection is
   * fully defined.
   *
   * <p>For example, a 4 X 5 dataset
   *
   * <pre>
   *     0,  1,  2,  3,  4
   *    10, 11, 12, 13, 14
   *    20, 21, 22, 23, 24
   *    30, 31, 32, 33, 34
   * long[] dims = {4, 5};
   * long[] startDims = {1, 2};
   * long[] selectedDims = {3, 3};
   * long[] selectedStride = {1, 1};
   * then the following subset is selected by the startDims and selectedDims
   *     12, 13, 14
   *     22, 23, 24
   *     32, 33, 34
   * </pre>
   *
   * @return the starting position of a selected subset.
   */
  public final long[] getStartDims() {
    if (rank < 0) init();

    return startDims;
  }
Beispiel #10
0
  /**
   * Returns the dimension sizes of the selected subset.
   *
   * <p>The SelectedDims is the number of data points of the selected subset. Applications can use
   * this array to change the size of selected subset.
   *
   * <p>The select size must be less than or equal to the current dimension size. Combined with the
   * starting position, selected sizes and stride, the subset of a rectangle selection is fully
   * defined.
   *
   * <p>For example, a 4 X 5 dataset
   *
   * <pre>
   *     0,  1,  2,  3,  4
   *    10, 11, 12, 13, 14
   *    20, 21, 22, 23, 24
   *    30, 31, 32, 33, 34
   * long[] dims = {4, 5};
   * long[] startDims = {1, 2};
   * long[] selectedDims = {3, 3};
   * long[] selectedStride = {1, 1};
   * then the following subset is selected by the startDims and selectedDims
   *     12, 13, 14
   *     22, 23, 24
   *     32, 33, 34
   * </pre>
   *
   * @return the dimension sizes of the selected subset.
   */
  public final long[] getSelectedDims() {
    if (rank < 0) init();

    return selectedDims;
  }
Beispiel #11
0
  /**
   * Returns the array that contins the dimension sizes of the dataset.
   *
   * @return the dimension sizes of the dataset.
   */
  public final long[] getDims() {
    if (rank < 0) init();

    return dims;
  }
Beispiel #12
0
  /**
   * Returns the rank (number of dimensions) of the dataset.
   *
   * @return the number of dimensions of the dataset.
   */
  public final int getRank() {
    if (rank < 0) init();

    return rank;
  }
Beispiel #13
0
  /**
   * Returns the array of strings that represent the dimension names. Returns null if there is no
   * dimension name.
   *
   * <p>Some datasets have pre-defined names for each dimension such as "Latitude" and "Longitude".
   * getDimNames() returns these pre-defined names.
   *
   * @return the names of dimensions, or null if there is no dimension name.
   */
  public final String[] getDimNames() {
    if (rank < 0) init();

    return dimNames;
  }