Example #1
0
  static void addBitmaskDefinitions(final Product product, final String flagsBandName) {
    for (final Flags flag : Flags.values()) {
      final String name =
          new StringBuilder(flagsBandName.split("flags")[0]).append(flag.name()).toString();

      final ProductNodeGroup<Mask> maskGroup = product.getMaskGroup();
      if (maskGroup.contains(name)) {
        continue;
      }

      final String expression =
          new StringBuilder(flagsBandName).append(".").append(flag.name()).toString();
      final int width = product.getSceneRasterWidth();
      final int height = product.getSceneRasterHeight();
      Mask mask =
          Mask.BandMathsType.create(
              name,
              flag.getDescription(),
              width,
              height,
              expression,
              flag.getColor(),
              flag.getTransparency());
      maskGroup.add(mask);
    }
  }
Example #2
0
  @Override
  protected void addCustomMetadata(Product product) throws IOException {
    // add bitmasks for ATSR active fires, see http://dup.esrin.esa.it/ionia/wfa/algorithm.asp
    final String nadirBand = EnvisatConstants.AATSR_L1B_BTEMP_NADIR_0370_BAND_NAME;
    final String fwardBand = EnvisatConstants.AATSR_L1B_BTEMP_FWARD_0370_BAND_NAME;

    ProductNodeGroup<Mask> maskGroup = product.getMaskGroup();
    if (product.containsBand(nadirBand)) {
      maskGroup.add(
          mask(
              "fire_nadir_1", "ATSR active fire (ALGO1)", nadirBand + " > 312.0", Color.RED, 0.5f));
      maskGroup.add(
          mask(
              "fire_nadir_2",
              "ATSR active fire (ALGO2)",
              nadirBand + " > 308.0",
              Color.RED.darker(),
              0.5f));
    }
    if (product.containsBand(fwardBand)) {
      maskGroup.add(
          mask(
              "fire_fward_1", "ATSR active fire (ALGO1)", fwardBand + " > 312.0", Color.RED, 0.5f));
      maskGroup.add(
          mask(
              "fire_fward_2",
              "ATSR active fire (ALGO2)",
              fwardBand + " > 308.0",
              Color.RED.darker(),
              0.5f));
    }
  }
Example #3
0
  private static RasterDataNode[] getReferencedNodes(final RasterDataNode node) {
    final Product product = node.getProduct();
    if (product != null) {
      final List<String> expressions = new ArrayList<String>(10);
      if (node.getValidPixelExpression() != null) {
        expressions.add(node.getValidPixelExpression());
      }
      final ProductNodeGroup<Mask> overlayMaskGroup = node.getOverlayMaskGroup();
      if (overlayMaskGroup.getNodeCount() > 0) {
        final Mask[] overlayMasks =
            overlayMaskGroup.toArray(new Mask[overlayMaskGroup.getNodeCount()]);
        for (final Mask overlayMask : overlayMasks) {
          final String expression;
          if (overlayMask.getImageType() == Mask.BandMathsType.INSTANCE) {
            expression = Mask.BandMathsType.getExpression(overlayMask);
          } else if (overlayMask.getImageType() == Mask.RangeType.INSTANCE) {
            expression = Mask.RangeType.getExpression(overlayMask);
          } else {
            expression = null;
          }
          if (expression != null) {
            expressions.add(expression);
          }
        }
      }
      if (node instanceof VirtualBand) {
        final VirtualBand virtualBand = (VirtualBand) node;
        expressions.add(virtualBand.getExpression());
      }

      final ArrayList<Term> termList = new ArrayList<Term>(10);
      for (final String expression : expressions) {
        try {
          final Term term = product.parseExpression(expression);
          if (term != null) {
            termList.add(term);
          }
        } catch (ParseException e) {
          // @todo se handle parse exception
          Debug.trace(e);
        }
      }

      final Term[] terms = termList.toArray(new Term[termList.size()]);
      final RasterDataSymbol[] refRasterDataSymbols = BandArithmetic.getRefRasterDataSymbols(terms);
      return BandArithmetic.getRefRasters(refRasterDataSymbols);
    }
    return new RasterDataNode[0];
  }
 private void addMask(
     MetadataAttribute metadataSample, String expression, Color color, Product product) {
   final ProductNodeGroup<Mask> maskGroup = product.getMaskGroup();
   final int width = product.getSceneRasterWidth();
   final int height = product.getSceneRasterHeight();
   Mask mask =
       Mask.BandMathsType.create(
           metadataSample.getName().toLowerCase(),
           metadataSample.getDescription(),
           width,
           height,
           expression,
           color,
           0.5);
   maskGroup.add(mask);
 }
  public static void addAerosolFlagBand(Product targetProduct, int rasterWidth, int rasterHeight) {
    FlagCoding aerosolFlagCoding = new FlagCoding(SynergyConstants.aerosolFlagCodingName);
    aerosolFlagCoding.addFlag(
        SynergyConstants.flagCloudyName,
        SynergyConstants.cloudyMask,
        SynergyConstants.flagCloudyDesc);
    aerosolFlagCoding.addFlag(
        SynergyConstants.flagOceanName, SynergyConstants.oceanMask, SynergyConstants.flagOceanDesc);
    aerosolFlagCoding.addFlag(
        SynergyConstants.flagSuccessName,
        SynergyConstants.successMask,
        SynergyConstants.flagSuccessDesc);
    aerosolFlagCoding.addFlag(
        SynergyConstants.flagBorderName,
        SynergyConstants.borderMask,
        SynergyConstants.flagBorderDesc);
    aerosolFlagCoding.addFlag(
        SynergyConstants.flagFilledName,
        SynergyConstants.filledMask,
        SynergyConstants.flagFilledDesc);
    aerosolFlagCoding.addFlag(
        SynergyConstants.flagNegMetricName,
        SynergyConstants.negMetricMask,
        SynergyConstants.flagNegMetricDesc);
    aerosolFlagCoding.addFlag(
        SynergyConstants.flagAotLowName,
        SynergyConstants.aotLowMask,
        SynergyConstants.flagAotLowDesc);
    aerosolFlagCoding.addFlag(
        SynergyConstants.flagErrHighName,
        SynergyConstants.errHighMask,
        SynergyConstants.flagErrHighDesc);
    aerosolFlagCoding.addFlag(
        SynergyConstants.flagCoastName, SynergyConstants.coastMask, SynergyConstants.flagCoastDesc);
    targetProduct.getFlagCodingGroup().add(aerosolFlagCoding);
    ProductNodeGroup<Mask> maskGroup = targetProduct.getMaskGroup();
    maskGroup.add(
        Mask.BandMathsType.create(
            SynergyConstants.flagCloudyName,
            SynergyConstants.flagCloudyDesc,
            rasterWidth,
            rasterHeight,
            SynergyConstants.aerosolFlagCodingName + "." + SynergyConstants.flagCloudyName,
            Color.lightGray,
            0.2f));
    maskGroup.add(
        Mask.BandMathsType.create(
            SynergyConstants.flagOceanName,
            SynergyConstants.flagOceanDesc,
            rasterWidth,
            rasterHeight,
            SynergyConstants.aerosolFlagCodingName + "." + SynergyConstants.flagOceanName,
            Color.blue,
            0.2f));
    maskGroup.add(
        Mask.BandMathsType.create(
            SynergyConstants.flagSuccessName,
            SynergyConstants.flagSuccessDesc,
            rasterWidth,
            rasterHeight,
            SynergyConstants.aerosolFlagCodingName + "." + SynergyConstants.flagSuccessName,
            Color.pink,
            0.2f));
    maskGroup.add(
        Mask.BandMathsType.create(
            SynergyConstants.flagBorderName,
            SynergyConstants.flagBorderDesc,
            rasterWidth,
            rasterHeight,
            SynergyConstants.aerosolFlagCodingName + "." + SynergyConstants.flagBorderName,
            Color.orange,
            0.2f));
    maskGroup.add(
        Mask.BandMathsType.create(
            SynergyConstants.flagFilledName,
            SynergyConstants.flagFilledDesc,
            rasterWidth,
            rasterHeight,
            SynergyConstants.aerosolFlagCodingName + "." + SynergyConstants.flagFilledName,
            Color.magenta,
            0.2f));
    maskGroup.add(
        Mask.BandMathsType.create(
            SynergyConstants.flagNegMetricName,
            SynergyConstants.flagNegMetricDesc,
            rasterWidth,
            rasterHeight,
            SynergyConstants.aerosolFlagCodingName + "." + SynergyConstants.flagNegMetricName,
            Color.magenta,
            0.2f));
    maskGroup.add(
        Mask.BandMathsType.create(
            SynergyConstants.flagAotLowName,
            SynergyConstants.flagAotLowDesc,
            rasterWidth,
            rasterHeight,
            SynergyConstants.aerosolFlagCodingName + "." + SynergyConstants.flagAotLowName,
            Color.magenta,
            0.2f));
    maskGroup.add(
        Mask.BandMathsType.create(
            SynergyConstants.flagErrHighName,
            SynergyConstants.flagErrHighDesc,
            rasterWidth,
            rasterHeight,
            SynergyConstants.aerosolFlagCodingName + "." + SynergyConstants.flagErrHighName,
            Color.magenta,
            0.2f));
    maskGroup.add(
        Mask.BandMathsType.create(
            SynergyConstants.flagCoastName,
            SynergyConstants.flagCoastDesc,
            rasterWidth,
            rasterHeight,
            SynergyConstants.aerosolFlagCodingName + "." + SynergyConstants.flagCoastName,
            Color.magenta,
            0.2f));

    Band targetBand =
        new Band(
            SynergyConstants.aerosolFlagCodingName,
            ProductData.TYPE_UINT16,
            rasterWidth,
            rasterHeight);
    targetBand.setDescription(SynergyConstants.aerosolFlagCodingDesc);
    targetBand.setSampleCoding(aerosolFlagCoding);
    targetProduct.addBand(targetBand);
  }