コード例 #1
0
  private void addNoiseAbstractedMetadata(final MetadataElement origProdRoot) throws IOException {

    MetadataElement noiseElement = origProdRoot.getElement("noise");
    if (noiseElement == null) {
      noiseElement = new MetadataElement("noise");
      origProdRoot.addElement(noiseElement);
    }
    final String calibFolder = getRootFolder() + "annotation" + '/' + "calibration";
    final String[] filenames = listFiles(calibFolder);

    if (filenames != null) {
      for (String metadataFile : filenames) {
        if (metadataFile.startsWith("noise")) {

          final Document xmlDoc =
              XMLSupport.LoadXML(getInputStream(calibFolder + '/' + metadataFile));
          final Element rootElement = xmlDoc.getRootElement();
          final String name = metadataFile.replace("noise-", "");
          final MetadataElement nameElem = new MetadataElement(name);
          noiseElement.addElement(nameElem);
          AbstractMetadataIO.AddXMLMetadata(rootElement, nameElem);
        }
      }
    }
  }
コード例 #2
0
  private static void addSRGRCoefficients(
      final MetadataElement absRoot, final MetadataElement coordinateConversion) {
    if (coordinateConversion == null) return;
    final MetadataElement coordinateConversionList =
        coordinateConversion.getElement("coordinateConversionList");
    if (coordinateConversionList == null) return;

    final MetadataElement srgrCoefficientsElem =
        absRoot.getElement(AbstractMetadata.srgr_coefficients);

    int listCnt = 1;
    for (MetadataElement elem : coordinateConversionList.getElements()) {
      final MetadataElement srgrListElem =
          new MetadataElement(AbstractMetadata.srgr_coef_list + '.' + listCnt);
      srgrCoefficientsElem.addElement(srgrListElem);
      ++listCnt;

      final ProductData.UTC utcTime = ReaderUtils.getTime(elem, "azimuthTime", standardDateFormat);
      srgrListElem.setAttributeUTC(AbstractMetadata.srgr_coef_time, utcTime);

      final double grOrigin = elem.getAttributeDouble("gr0", 0);
      AbstractMetadata.addAbstractedAttribute(
          srgrListElem,
          AbstractMetadata.ground_range_origin,
          ProductData.TYPE_FLOAT64,
          "m",
          "Ground Range Origin");
      AbstractMetadata.setAttribute(srgrListElem, AbstractMetadata.ground_range_origin, grOrigin);

      final String coeffStr =
          elem.getElement("grsrCoefficients").getAttributeString("grsrCoefficients", "");
      if (!coeffStr.isEmpty()) {
        final StringTokenizer st = new StringTokenizer(coeffStr);
        int cnt = 1;
        while (st.hasMoreTokens()) {
          final double coefValue = Double.parseDouble(st.nextToken());

          final MetadataElement coefElem =
              new MetadataElement(AbstractMetadata.coefficient + '.' + cnt);
          srgrListElem.addElement(coefElem);
          ++cnt;
          AbstractMetadata.addAbstractedAttribute(
              coefElem,
              AbstractMetadata.srgr_coef,
              ProductData.TYPE_FLOAT64,
              "",
              "SRGR Coefficient");
          AbstractMetadata.setAttribute(coefElem, AbstractMetadata.srgr_coef, coefValue);
        }
      }
    }
  }
コード例 #3
0
  private static void addDopplerCentroidCoefficients(
      final MetadataElement absRoot, final MetadataElement dopplerCentroid) {
    if (dopplerCentroid == null) return;
    final MetadataElement dcEstimateList = dopplerCentroid.getElement("dcEstimateList");
    if (dcEstimateList == null) return;

    final MetadataElement dopplerCentroidCoefficientsElem =
        absRoot.getElement(AbstractMetadata.dop_coefficients);

    int listCnt = 1;
    for (MetadataElement elem : dcEstimateList.getElements()) {
      final MetadataElement dopplerListElem =
          new MetadataElement(AbstractMetadata.dop_coef_list + '.' + listCnt);
      dopplerCentroidCoefficientsElem.addElement(dopplerListElem);
      ++listCnt;

      final ProductData.UTC utcTime = ReaderUtils.getTime(elem, "azimuthTime", standardDateFormat);
      dopplerListElem.setAttributeUTC(AbstractMetadata.dop_coef_time, utcTime);

      final double refTime = elem.getAttributeDouble("t0", 0) * 1e9; // s to ns
      AbstractMetadata.addAbstractedAttribute(
          dopplerListElem,
          AbstractMetadata.slant_range_time,
          ProductData.TYPE_FLOAT64,
          "ns",
          "Slant Range Time");
      AbstractMetadata.setAttribute(dopplerListElem, AbstractMetadata.slant_range_time, refTime);

      final String coeffStr =
          elem.getElement("geometryDcPolynomial").getAttributeString("geometryDcPolynomial", "");
      if (!coeffStr.isEmpty()) {
        final StringTokenizer st = new StringTokenizer(coeffStr);
        int cnt = 1;
        while (st.hasMoreTokens()) {
          final double coefValue = Double.parseDouble(st.nextToken());

          final MetadataElement coefElem =
              new MetadataElement(AbstractMetadata.coefficient + '.' + cnt);
          dopplerListElem.addElement(coefElem);
          ++cnt;
          AbstractMetadata.addAbstractedAttribute(
              coefElem,
              AbstractMetadata.dop_coef,
              ProductData.TYPE_FLOAT64,
              "",
              "Doppler Centroid Coefficient");
          AbstractMetadata.setAttribute(coefElem, AbstractMetadata.dop_coef, coefValue);
        }
      }
    }
  }
コード例 #4
0
  private static void addVector(
      final String name,
      final MetadataElement orbitVectorListElem,
      final MetadataElement orbitElem,
      final int num) {
    final MetadataElement orbitVectorElem = new MetadataElement(name + num);

    final MetadataElement positionElem = orbitElem.getElement("position");
    final MetadataElement velocityElem = orbitElem.getElement("velocity");

    orbitVectorElem.setAttributeUTC(
        AbstractMetadata.orbit_vector_time,
        ReaderUtils.getTime(orbitElem, "time", standardDateFormat));

    orbitVectorElem.setAttributeDouble(
        AbstractMetadata.orbit_vector_x_pos, positionElem.getAttributeDouble("x", 0));
    orbitVectorElem.setAttributeDouble(
        AbstractMetadata.orbit_vector_y_pos, positionElem.getAttributeDouble("y", 0));
    orbitVectorElem.setAttributeDouble(
        AbstractMetadata.orbit_vector_z_pos, positionElem.getAttributeDouble("z", 0));
    orbitVectorElem.setAttributeDouble(
        AbstractMetadata.orbit_vector_x_vel, velocityElem.getAttributeDouble("x", 0));
    orbitVectorElem.setAttributeDouble(
        AbstractMetadata.orbit_vector_y_vel, velocityElem.getAttributeDouble("y", 0));
    orbitVectorElem.setAttributeDouble(
        AbstractMetadata.orbit_vector_z_vel, velocityElem.getAttributeDouble("z", 0));

    orbitVectorListElem.addElement(orbitVectorElem);
  }
コード例 #5
0
  private MetadataElement getProcessingGraphMetadata() {
    final MetadataElement processingGraphMetadata = globalMetadata.asMetadataElement();

    final MetadataElement node_0 = processingGraphMetadata.getElement("node.0");
    node_0.addElement(metadataAggregator.getMetadata());
    return processingGraphMetadata;
  }
コード例 #6
0
  private void addBandAbstractedMetadata(
      final MetadataElement absRoot, final MetadataElement origProdRoot) throws IOException {

    MetadataElement annotationElement = origProdRoot.getElement("annotation");
    if (annotationElement == null) {
      annotationElement = new MetadataElement("annotation");
      origProdRoot.addElement(annotationElement);
    }

    // collect range and azimuth spacing
    double rangeSpacingTotal = 0;
    double azimuthSpacingTotal = 0;
    boolean commonMetadataRetrieved = false;

    double heightSum = 0.0;

    int numBands = 0;
    final String annotFolder = getRootFolder() + "annotation";
    final String[] filenames = listFiles(annotFolder);
    if (filenames != null) {
      for (String metadataFile : filenames) {

        final Document xmlDoc =
            XMLSupport.LoadXML(getInputStream(annotFolder + '/' + metadataFile));
        final Element rootElement = xmlDoc.getRootElement();
        final MetadataElement nameElem = new MetadataElement(metadataFile);
        annotationElement.addElement(nameElem);
        AbstractMetadataIO.AddXMLMetadata(rootElement, nameElem);

        final MetadataElement prodElem = nameElem.getElement("product");
        final MetadataElement adsHeader = prodElem.getElement("adsHeader");

        final String swath = adsHeader.getAttributeString("swath");
        final String pol = adsHeader.getAttributeString("polarisation");

        final ProductData.UTC startTime = getTime(adsHeader, "startTime");
        final ProductData.UTC stopTime = getTime(adsHeader, "stopTime");

        final String bandRootName = AbstractMetadata.BAND_PREFIX + swath + '_' + pol;
        final MetadataElement bandAbsRoot =
            AbstractMetadata.addBandAbstractedMetadata(absRoot, bandRootName);
        final String imgName = FileUtils.exchangeExtension(metadataFile, ".tiff");
        imgBandMetadataMap.put(imgName, bandRootName);

        AbstractMetadata.setAttribute(bandAbsRoot, AbstractMetadata.SWATH, swath);
        AbstractMetadata.setAttribute(bandAbsRoot, AbstractMetadata.polarization, pol);
        AbstractMetadata.setAttribute(bandAbsRoot, AbstractMetadata.annotation, metadataFile);
        AbstractMetadata.setAttribute(bandAbsRoot, AbstractMetadata.first_line_time, startTime);
        AbstractMetadata.setAttribute(bandAbsRoot, AbstractMetadata.last_line_time, stopTime);

        if (AbstractMetadata.isNoData(absRoot, AbstractMetadata.mds1_tx_rx_polar)) {
          AbstractMetadata.setAttribute(absRoot, AbstractMetadata.mds1_tx_rx_polar, pol);
        } else {
          AbstractMetadata.setAttribute(absRoot, AbstractMetadata.mds2_tx_rx_polar, pol);
        }

        final MetadataElement imageAnnotation = prodElem.getElement("imageAnnotation");
        final MetadataElement imageInformation = imageAnnotation.getElement("imageInformation");

        AbstractMetadata.setAttribute(
            absRoot,
            AbstractMetadata.data_take_id,
            Integer.parseInt(adsHeader.getAttributeString("missionDataTakeId")));
        AbstractMetadata.setAttribute(
            absRoot,
            AbstractMetadata.slice_num,
            Integer.parseInt(imageInformation.getAttributeString("sliceNumber")));

        rangeSpacingTotal += imageInformation.getAttributeDouble("rangePixelSpacing");
        azimuthSpacingTotal += imageInformation.getAttributeDouble("azimuthPixelSpacing");

        AbstractMetadata.setAttribute(
            bandAbsRoot,
            AbstractMetadata.line_time_interval,
            imageInformation.getAttributeDouble("azimuthTimeInterval"));
        AbstractMetadata.setAttribute(
            bandAbsRoot,
            AbstractMetadata.num_samples_per_line,
            imageInformation.getAttributeInt("numberOfSamples"));
        AbstractMetadata.setAttribute(
            bandAbsRoot,
            AbstractMetadata.num_output_lines,
            imageInformation.getAttributeInt("numberOfLines"));
        AbstractMetadata.setAttribute(
            bandAbsRoot,
            AbstractMetadata.sample_type,
            imageInformation.getAttributeString("pixelValue").toUpperCase());

        heightSum += getBandTerrainHeight(prodElem);

        if (!commonMetadataRetrieved) {
          // these should be the same for all swaths
          // set to absRoot

          final MetadataElement generalAnnotation = prodElem.getElement("generalAnnotation");
          final MetadataElement productInformation =
              generalAnnotation.getElement("productInformation");
          final MetadataElement processingInformation =
              imageAnnotation.getElement("processingInformation");
          final MetadataElement swathProcParamsList =
              processingInformation.getElement("swathProcParamsList");
          final MetadataElement swathProcParams = swathProcParamsList.getElement("swathProcParams");
          final MetadataElement rangeProcessing = swathProcParams.getElement("rangeProcessing");
          final MetadataElement azimuthProcessing = swathProcParams.getElement("azimuthProcessing");

          AbstractMetadata.setAttribute(
              absRoot,
              AbstractMetadata.range_sampling_rate,
              productInformation.getAttributeDouble("rangeSamplingRate") / Constants.oneMillion);
          AbstractMetadata.setAttribute(
              absRoot,
              AbstractMetadata.radar_frequency,
              productInformation.getAttributeDouble("radarFrequency") / Constants.oneMillion);
          AbstractMetadata.setAttribute(
              absRoot,
              AbstractMetadata.line_time_interval,
              imageInformation.getAttributeDouble("azimuthTimeInterval"));

          AbstractMetadata.setAttribute(
              absRoot,
              AbstractMetadata.slant_range_to_first_pixel,
              imageInformation.getAttributeDouble("slantRangeTime") * Constants.halfLightSpeed);

          final MetadataElement downlinkInformationList =
              generalAnnotation.getElement("downlinkInformationList");
          final MetadataElement downlinkInformation =
              downlinkInformationList.getElement("downlinkInformation");

          AbstractMetadata.setAttribute(
              absRoot,
              AbstractMetadata.pulse_repetition_frequency,
              downlinkInformation.getAttributeDouble("prf"));

          AbstractMetadata.setAttribute(
              absRoot,
              AbstractMetadata.range_bandwidth,
              rangeProcessing.getAttributeDouble("processingBandwidth") / Constants.oneMillion);
          AbstractMetadata.setAttribute(
              absRoot,
              AbstractMetadata.azimuth_bandwidth,
              azimuthProcessing.getAttributeDouble("processingBandwidth"));

          AbstractMetadata.setAttribute(
              absRoot,
              AbstractMetadata.range_looks,
              rangeProcessing.getAttributeDouble("numberOfLooks"));
          AbstractMetadata.setAttribute(
              absRoot,
              AbstractMetadata.azimuth_looks,
              azimuthProcessing.getAttributeDouble("numberOfLooks"));

          if (!isTOPSAR() || !isSLC()) {
            AbstractMetadata.setAttribute(
                absRoot,
                AbstractMetadata.num_output_lines,
                imageInformation.getAttributeInt("numberOfLines"));
            AbstractMetadata.setAttribute(
                absRoot,
                AbstractMetadata.num_samples_per_line,
                imageInformation.getAttributeInt("numberOfSamples"));
          }

          addOrbitStateVectors(absRoot, generalAnnotation.getElement("orbitList"));
          addSRGRCoefficients(absRoot, prodElem.getElement("coordinateConversion"));
          addDopplerCentroidCoefficients(absRoot, prodElem.getElement("dopplerCentroid"));

          commonMetadataRetrieved = true;
        }

        ++numBands;
      }
    }

    // set average to absRoot
    AbstractMetadata.setAttribute(
        absRoot, AbstractMetadata.range_spacing, rangeSpacingTotal / (double) numBands);
    AbstractMetadata.setAttribute(
        absRoot, AbstractMetadata.azimuth_spacing, azimuthSpacingTotal / (double) numBands);

    AbstractMetadata.setAttribute(
        absRoot, AbstractMetadata.avg_scene_height, heightSum / filenames.length);
  }