/** This method creates the target product */
  private void createTargetProduct() {

    final String productType = synergyProduct.getProductType();
    final String productName = synergyProduct.getName();
    final int sceneWidth = synergyProduct.getSceneRasterWidth();
    final int sceneHeight = synergyProduct.getSceneRasterHeight();

    final int downscaledRasterWidth = (int) (Math.ceil((float) (sceneWidth / scalingFactor) - 0.5));
    final int downscaledRasterHeight =
        (int) (Math.ceil((float) (sceneHeight / scalingFactor) - 0.5));

    targetProduct =
        new Product(productName, productType, downscaledRasterWidth, downscaledRasterHeight);
    //        targetProduct.setPreferredTileSize(128, 128);

    ProductUtils.copyGeoCoding(synergyProduct, targetProduct);
    ProductUtils.copyMetadata(synergyProduct, targetProduct);
    AerosolHelpers.copyDownscaledTiePointGrids(synergyProduct, targetProduct, scalingFactor);
    AerosolHelpers.copyDownscaledFlagBands(synergyProduct, targetProduct, scalingFactor);

    //        AerosolHelpers.addAerosolFlagBand(targetProduct, downscaledRasterWidth,
    // downscaledRasterHeight);

    final BandMathsOp bandArithmeticOp =
        BandMathsOp.createBooleanExpressionBand(INVALID_EXPRESSION, synergyProduct);
    invalidBand = bandArithmeticOp.getTargetProduct().getBandAt(0);

    setTargetBands();
  }
 /**
  * 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);
 }
 /**
  * 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);
   }
 }