private void assertCreateRightGeneralFilterBand(Element xmlElement) {
    final Object object = _generalFilterBandPersistable.createObjectFromXml(xmlElement, _product);
    _product.addBand((Band) object);

    assertNotNull(object);
    assertTrue(object instanceof GeneralFilterBand);
    final GeneralFilterBand gfb = (GeneralFilterBand) object;
    assertEquals(1, _product.getBandIndex(gfb.getName()));
    assertEquals(-1, gfb.getSpectralBandIndex());
    assertEquals("filtered_coffee", gfb.getName());
    assertEquals("with milk & sugar", gfb.getDescription());
    assertEquals(_source.getGeophysicalDataType(), gfb.getDataType());
    assertEquals("l", gfb.getUnit());
    assertEquals(0.0, gfb.getSolarFlux(), EPS);
    assertEquals(0.0, gfb.getSpectralWavelength(), EPS);
    assertEquals(0.0, gfb.getSpectralBandwidth(), EPS);
    assertEquals(1.0, gfb.getScalingFactor(), EPS);
    assertEquals(0.0, gfb.getScalingOffset(), EPS);
    assertFalse(gfb.isLog10Scaled());
    assertEquals(gfb.getSource().getName(), _source.getName());
    assertEquals(5, gfb.getSubWindowSize());
    assertEquals(5, gfb.getSubWindowWidth());
    assertEquals(5, gfb.getSubWindowHeight());
    assertTrue(gfb.getOperator() instanceof GeneralFilterBand.Mean);
  }
  private Element createXmlElement(final String version) {
    final List<Element> contentList = new ArrayList<Element>(16);
    contentList.add(createElement(DimapProductConstants.TAG_BAND_INDEX, "1"));
    contentList.add(createElement(DimapProductConstants.TAG_BAND_NAME, "filtered_coffee"));
    contentList.add(createElement(DimapProductConstants.TAG_BAND_DESCRIPTION, "with milk & sugar"));
    final String typeString = ProductData.getTypeString(_source.getGeophysicalDataType());
    contentList.add(createElement(DimapProductConstants.TAG_DATA_TYPE, typeString));
    contentList.add(createElement(DimapProductConstants.TAG_PHYSICAL_UNIT, "l"));
    contentList.add(createElement(DimapProductConstants.TAG_SOLAR_FLUX, "0.0"));
    contentList.add(createElement(DimapProductConstants.TAG_BAND_WAVELEN, "0.0"));
    contentList.add(createElement(DimapProductConstants.TAG_BANDWIDTH, "0.0"));
    contentList.add(createElement(DimapProductConstants.TAG_SCALING_FACTOR, "1.0"));
    contentList.add(createElement(DimapProductConstants.TAG_SCALING_OFFSET, "0.0"));
    contentList.add(createElement(DimapProductConstants.TAG_SCALING_LOG_10, "false"));
    contentList.add(createElement(DimapProductConstants.TAG_NO_DATA_VALUE_USED, "true"));
    contentList.add(
        createElement(
            DimapProductConstants.TAG_NO_DATA_VALUE,
            String.valueOf(_source.getGeophysicalNoDataValue())));
    final List<Element> filterBandInfoList = new ArrayList<Element>(5);
    filterBandInfoList.add(createElement(DimapProductConstants.TAG_FILTER_SOURCE, "anyBand"));
    filterBandInfoList.add(
        createElement(
            DimapProductConstants.TAG_FILTER_OPERATOR_CLASS_NAME,
            "org.esa.beam.framework.datamodel.GeneralFilterBand$Mean"));
    final Element filterBandInfo = new Element(DimapProductConstants.TAG_FILTER_BAND_INFO);
    filterBandInfo.setAttribute(
        GeneralFilterBandPersistable.ATTRIBUTE_BAND_TYPE,
        GeneralFilterBandPersistable.GENERAL_FILTER_BAND_TYPE);
    if (GeneralFilterBandPersistable.VERSION_1_1.equals(version)) {
      filterBandInfoList.add(createElement(DimapProductConstants.TAG_FILTER_SUB_WINDOW_SIZE, "5"));
      filterBandInfo.setAttribute(
          GeneralFilterBandPersistable.ATTRIBUTE_VERSION, GeneralFilterBandPersistable.VERSION_1_1);
    } else {
      // Version 1.0
      filterBandInfoList.add(createElement(DimapProductConstants.TAG_FILTER_SUB_WINDOW_WIDTH, "5"));
      filterBandInfoList.add(
          createElement(DimapProductConstants.TAG_FILTER_SUB_WINDOW_HEIGHT, "2"));
    }
    filterBandInfo.addContent(filterBandInfoList);
    contentList.add(filterBandInfo);

    final Element root = new Element(DimapProductConstants.TAG_SPECTRAL_BAND_INFO);
    root.setContent(contentList);
    return root;
  }
Ejemplo n.º 3
0
  /**
   * Adds requested bands to the output product.
   *
   * @param description a description template for the new bands to be created
   * @param bConvertMerisName it set to true, the MERIS l1b band name is converted from
   *     <i>radiance_n</i> to <i>reflectance_n</i>
   */
  private void addBandsToOutput(String description, boolean bConvertMerisName) {

    for (Band inBand : _inputBandList) {
      String newBandName;
      String bandUnit;
      if (bConvertMerisName) {
        newBandName = convertMerisBandName(inBand);
        bandUnit = "dl";
      } else {
        newBandName = inBand.getName();
        bandUnit = inBand.getUnit();
      }
      Band outBand =
          new Band(
              newBandName,
              inBand.getGeophysicalDataType(),
              inBand.getSceneRasterWidth(),
              inBand.getSceneRasterHeight());
      outBand.setUnit(bandUnit);
      ProductUtils.copySpectralBandProperties(inBand, outBand);
      outBand.setDescription(description + inBand.getName());
      _outputProduct.addBand(outBand);
    }
  }