Ejemplo n.º 1
0
 private ProductNodeSubsetPane createBandSubsetPane() {
   Band[] bands = product.getBands();
   if (bands.length == 0) {
     return null;
   }
   return new ProductNodeSubsetPane(product.getBands(), true);
 }
Ejemplo n.º 2
0
  private void createTargetProduct() {

    // construct target product
    targetProduct =
        new Product(
            PRODUCT_NAME,
            sourceProduct.getProductType(),
            sourceProduct.getSceneRasterWidth(),
            sourceProduct.getSceneRasterHeight());

    OperatorUtils.copyProductNodes(sourceProduct, targetProduct);

    for (final Band band : targetProduct.getBands()) {
      targetProduct.removeBand(band);
    }

    for (String key : targetMap.keySet()) {
      String bandName = targetMap.get(key).targetBandName_I;
      targetProduct.addBand(bandName, ProductData.TYPE_FLOAT32);
      targetProduct.getBand(bandName).setUnit(Unit.METERS);
    }

    //        targetProduct.setPreferredTileSize(1,1);

  }
Ejemplo n.º 3
0
  private void sortOutSourceProducts() {

    // check whether there are absolute phases bands in the product
    Band tempBand = null;
    for (Band band : sourceProduct.getBands()) {
      if (band.getUnit().equals(Unit.ABS_PHASE)) {
        tempBand = band;
      }
    }
    if (tempBand == null) {
      throw new OperatorException("Slant2HeightOp requires minimum one 'unwrapped' phase band");
    }
  }
Ejemplo n.º 4
0
  @Override
  public void initialize() throws OperatorException {
    if (computeErrorBands) {
      deactivateComputeTileMethod();
    }

    if (endmemberFile != null) {
      loadEndmemberFile();
    }

    if (sourceBandNames == null || sourceBandNames.length == 0) {
      Band[] bands = sourceProduct.getBands();
      ArrayList<String> bandNameList = new ArrayList<String>();
      for (Band band : bands) {
        if (band.getSpectralWavelength() > 0) {
          bandNameList.add(band.getName());
        }
      }
      sourceBandNames = bandNameList.toArray(new String[bandNameList.size()]);
    }

    validateParameters();

    sourceBands = new Band[sourceBandNames.length];
    for (int i = 0; i < sourceBandNames.length; i++) {
      String sourceBandName = sourceBandNames[i];
      Band sourceBand = sourceProduct.getBand(sourceBandName);
      if (sourceBand == null) {
        throw new OperatorException("Source band not found: " + sourceBandName);
      }
      if (sourceBand.getSpectralWavelength() <= 0) {
        throw new OperatorException("Source band without spectral wavelength: " + sourceBandName);
      }
      sourceBands[i] = sourceBand;
    }

    int numSourceBands = sourceBands.length;
    int numEndmembers = endmembers.length;

    if (numSourceBands < numEndmembers) {
      throw new OperatorException("Number of source bands must be >= number of endmembers.");
    }

    double[][] lsuMatrixElements = new double[numSourceBands][numEndmembers];
    for (int j = 0; j < numEndmembers; j++) {
      Endmember endmember = endmembers[j];
      double[] wavelengths = endmember.getWavelengths();
      double[] radiations = endmember.getRadiations();
      for (int i = 0; i < numSourceBands; i++) {
        Band sourceBand = sourceBands[i];
        float wavelength = sourceBand.getSpectralWavelength();
        float bandwidth = sourceBand.getSpectralBandwidth();
        int k =
            findEndmemberSpectralIndex(wavelengths, wavelength, Math.max(bandwidth, minBandwidth));
        if (k == -1) {
          throw new OperatorException(
              String.format(
                  "Band %s: No matching endmember wavelength found (%f nm)",
                  sourceBand.getName(), wavelength));
        }
        lsuMatrixElements[i][j] = radiations[k];
      }
    }

    if (UC_LSU.equals(unmixingModelName)) {
      spectralUnmixing = new UnconstrainedLSU(lsuMatrixElements);
    } else if (C_LSU.equals(unmixingModelName)) {
      spectralUnmixing = new ConstrainedLSU(lsuMatrixElements);
    } else if (FC_LSU.equals(unmixingModelName)) {
      spectralUnmixing = new FullyConstrainedLSU(lsuMatrixElements);
    } else if (unmixingModelName == null) {
      spectralUnmixing = new UnconstrainedLSU(lsuMatrixElements);
    }

    int width = sourceProduct.getSceneRasterWidth();
    int height = sourceProduct.getSceneRasterHeight();

    targetProduct =
        new Product(sourceProduct.getName() + "_unmixed", "SpectralUnmixing", width, height);

    abundanceBands = new Band[numEndmembers];
    for (int i = 0; i < numEndmembers; i++) {
      abundanceBands[i] =
          targetProduct.addBand(
              endmembers[i].getName() + abundanceBandNameSuffix, ProductData.TYPE_FLOAT32);
    }

    if (computeErrorBands) {
      errorBands = new Band[numSourceBands];
      for (int i = 0; i < errorBands.length; i++) {
        final String erroBandName = sourceBands[i].getName() + errorBandNameSuffix;
        errorBands[i] = targetProduct.addBand(erroBandName, ProductData.TYPE_FLOAT32);
        ProductUtils.copySpectralBandProperties(sourceBands[i], errorBands[i]);
      }
      summaryErrorBand = targetProduct.addBand("summary_error", ProductData.TYPE_FLOAT32);
      summaryErrorBand.setDescription("Root mean square error");
    }

    ProductUtils.copyMetadata(sourceProduct, targetProduct);
    ProductUtils.copyTiePointGrids(sourceProduct, targetProduct);
    ProductUtils.copyGeoCoding(sourceProduct, targetProduct);
  }