/**
  * Adds a land mask sample definition to a configurator used in a point operator
  *
  * @param configurator - the configurator
  * @param index - the sample index
  * @param sourceProduct - the source product
  */
 public static void setSeaiceMaskSourceSample(
     SampleConfigurer configurator, int index, Product sourceProduct) {
   BandMathsOp seaiceOp =
       BandMathsOp.createBooleanExpressionBand(
           AlbedoInversionConstants.seaiceMaskExpression, sourceProduct);
   Product seaiceProduct = seaiceOp.getTargetProduct();
   configurator.defineSample(index, seaiceProduct.getBandAt(0).getName(), seaiceProduct);
 }
Esempio n. 2
0
  private void metaMapPut(
      final String tag,
      final MetadataElement root,
      final Product product,
      final HashMap<Integer, CplxContainer> map)
      throws Exception {

    // pull out band names for this product
    final String[] bandNames = product.getBandNames();
    final int numOfBands = bandNames.length;

    // map key: ORBIT NUMBER
    int mapKey = root.getAttributeInt(AbstractMetadata.ABS_ORBIT);

    // metadata: construct classes and define bands
    final String date = OperatorUtils.getAcquisitionDate(root);
    final SLCImage meta = new SLCImage(root);
    final Orbit orbit = new Orbit(root, orbitDegree);

    // TODO: mlook factores are hard-coded for now
    meta.setMlAz(1);
    meta.setMlRg(1);

    Band bandReal = null;
    Band bandImag = null;

    for (int i = 0; i < numOfBands; i++) {
      String bandName = bandNames[i];
      if (bandName.contains(tag) && bandName.contains(date)) {
        final Band band = product.getBandAt(i);
        if (BandUtilsDoris.isBandReal(band)) {
          bandReal = band;
        } else if (product.getBandAt(i).getUnit().contains(Unit.ABS_PHASE)) {
          bandReal = band;
        } else if (BandUtilsDoris.isBandImag(band)) {
          bandImag = band;
        }
      }
    }
    try {
      map.put(mapKey, new CplxContainer(date, meta, orbit, bandReal, bandImag));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
 /**
  * Adds a land mask sample definition to a configurator used in a point operator
  *
  * @param configurator - the configurator
  * @param index - the sample index
  * @param sourceProduct - the source product
  */
 public static void setLandMaskSourceSample(
     SampleConfigurer configurator, int index, Product sourceProduct, boolean computeSeaice) {
   if ((sourceProduct.getProductType().startsWith("MER")
           || sourceProduct.getName().startsWith("MER"))
       || computeSeaice) {
     BandMathsOp landOp =
         BandMathsOp.createBooleanExpressionBand(
             AlbedoInversionConstants.merisLandMaskExpression, sourceProduct);
     Product landMaskProduct = landOp.getTargetProduct();
     configurator.defineSample(index, landMaskProduct.getBandAt(0).getName(), landMaskProduct);
   } else if ((sourceProduct.getProductType().startsWith("VGT")
       || sourceProduct.getName().startsWith("VGT"))) {
     configurator.defineSample(index, AlbedoInversionConstants.BBDR_VGT_SM_NAME, sourceProduct);
   } else {
     BandMathsOp landOp =
         BandMathsOp.createBooleanExpressionBand(
             AlbedoInversionConstants.aatsrLandMaskExpression, sourceProduct);
     Product landMaskProduct = landOp.getTargetProduct();
     configurator.defineSample(index, landMaskProduct.getBandAt(0).getName(), landMaskProduct);
   }
 }
Esempio n. 4
0
  /** Calls the given handler for all frames of the product the operator executor product. */
  public Object execute(Handler handler) throws Exception {
    int parallelism = Runtime.getRuntime().availableProcessors();
    System.out.println("parallelism = " + parallelism);
    JAI.getDefaultInstance().getTileScheduler().setParallelism(parallelism);
    Dimension frameSize = getFrameSize();
    int numXFrames = 1 + (product.getSceneRasterWidth() - 1) / frameSize.width;
    int numYFrames = 1 + (product.getSceneRasterHeight() - 1) / frameSize.height;

    Rectangle sceneRegion =
        new Rectangle(product.getSceneRasterWidth(), product.getSceneRasterHeight());

    for (int frameY = 0; frameY < numYFrames; frameY++) {
      for (int frameX = 0; frameX < numXFrames; frameX++) {

        Rectangle frameRegion =
            new Rectangle(
                    frameX * frameSize.width,
                    frameY * frameSize.height,
                    frameSize.width,
                    frameSize.height)
                .intersection(sceneRegion);

        int numBands = product.getNumBands();
        Band[] bandArray = new Band[numBands];
        ProductData[] dataArray = new ProductData[numBands];
        for (int b = 0; b < numBands; b++) {
          Band band = product.getBandAt(b);
          PlanarImage planarImage = band.getSourceImage();
          Point[] indices = planarImage.getTileIndices(null);
          System.out.println("indices = " + indices.length);
          TileRequest tileRequest = planarImage.queueTiles(indices);
          Raster raster = planarImage.getData();
          System.out.println("raster = " + raster);
          ProductData data = band.createCompatibleRasterData(frameRegion.width, frameRegion.height);
          band.readRasterData(
              frameRegion.x, frameRegion.y, frameRegion.width, frameRegion.height, data);
          bandArray[b] = band;
          dataArray[b] = data;
        }

        MyFrame frame = new MyFrame(frameRegion, bandArray, dataArray);
        handler.frameComputed(frame);
      }
    }

    return new Object();
  }
Esempio n. 5
0
 protected void setSpectralBand(Product product) {
   int spectralBandIndex = 0;
   for (String name : product.getBandNames()) {
     Band band = product.getBandAt(product.getBandIndex(name));
     if (name.matches("\\w+_\\d{3,}")) {
       String[] parts = name.split("_");
       String wvlstr = parts[parts.length - 1].trim();
       // Some bands have the wvl portion in the middle...
       if (!wvlstr.matches("^\\d{3,}")) {
         wvlstr = parts[parts.length - 2].trim();
       }
       final float wavelength = Float.parseFloat(wvlstr);
       band.setSpectralWavelength(wavelength);
       band.setSpectralBandIndex(spectralBandIndex++);
     }
   }
 }
Esempio n. 6
0
  private boolean checkFlagDatasetIncluded() {
    final String[] nodeNames = productSubsetDef.getNodeNames();
    final List<String> flagDsNameList = new ArrayList<String>(10);
    boolean flagDsInSubset = false;
    for (int i = 0; i < product.getNumBands(); i++) {
      Band band = product.getBandAt(i);
      if (band.getFlagCoding() != null) {
        flagDsNameList.add(band.getName());
        if (StringUtils.contains(nodeNames, band.getName())) {
          flagDsInSubset = true;
        }
        break;
      }
    }

    final int numFlagDs = flagDsNameList.size();
    boolean ok = true;
    if (numFlagDs > 0 && !flagDsInSubset) {
      int status =
          JOptionPane.showConfirmDialog(
              getJDialog(),
              "No flag dataset selected.\n\n"
                  + "If you do not include a flag dataset in the subset,\n"
                  + "you will not be able to create bitmask overlays.\n\n"
                  + "Do you wish to include the available flag dataset(s)\n"
                  + "in the current subset?\n",
              "No Flag Dataset Selected",
              JOptionPane.YES_NO_CANCEL_OPTION);
      if (status == JOptionPane.YES_OPTION) {
        productSubsetDef.addNodeNames(flagDsNameList.toArray(new String[numFlagDs]));
        ok = true;
      } else if (status == JOptionPane.NO_OPTION) {
        /* OK, no flag datasets wanted */
        ok = true;
      } else if (status == JOptionPane.CANCEL_OPTION) {
        ok = false;
      }
    }

    return ok;
  }
  /**
   * This method copies all bands which contain a flagcoding from the source product to the target
   * product.
   *
   * @param sourceProduct the source product
   * @param targetProduct the target product
   */
  public static void copyDownscaledFlagBands(
      Product sourceProduct, Product targetProduct, float scalingFactor) {
    Guardian.assertNotNull("source", sourceProduct);
    Guardian.assertNotNull("target", targetProduct);
    if (sourceProduct.getFlagCodingGroup().getNodeCount() > 0) {

      ProductUtils.copyFlagCodings(sourceProduct, targetProduct);
      ProductUtils.copyMasks(sourceProduct, targetProduct);

      // loop over bands and check if they have a flags coding attached
      for (int i = 0; i < sourceProduct.getNumBands(); i++) {
        Band sourceBand = sourceProduct.getBandAt(i);
        FlagCoding coding = sourceBand.getFlagCoding();
        if (coding != null) {
          Band targetBand = AerosolHelpers.downscaleBand(sourceBand, scalingFactor);
          targetBand.setSampleCoding(coding);
          targetProduct.addBand(targetBand);
        }
      }
    }
  }