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++); } } }
protected void addBandsToProduct(Product product) { Debug.assertNotNull(getSourceProduct()); Debug.assertNotNull(product); for (int i = 0; i < getSourceProduct().getNumBands(); i++) { Band sourceBand = getSourceProduct().getBandAt(i); String bandName = sourceBand.getName(); if (isNodeAccepted(bandName)) { Band destBand; boolean treatVirtualBandsAsRealBands = false; if (getSubsetDef() != null && getSubsetDef().getTreatVirtualBandsAsRealBands()) { treatVirtualBandsAsRealBands = true; } // @todo 1 se/se - extract copy of a band or virtual band to create deep clone of band and // virtual band if (!treatVirtualBandsAsRealBands && sourceBand instanceof VirtualBand) { VirtualBand virtualSource = (VirtualBand) sourceBand; destBand = new VirtualBand( bandName, sourceBand.getDataType(), getSceneRasterWidth(), getSceneRasterHeight(), virtualSource.getExpression()); } else { destBand = new Band( bandName, sourceBand.getDataType(), getSceneRasterWidth(), getSceneRasterHeight()); } if (sourceBand.getUnit() != null) { destBand.setUnit(sourceBand.getUnit()); } if (sourceBand.getDescription() != null) { destBand.setDescription(sourceBand.getDescription()); } destBand.setScalingFactor(sourceBand.getScalingFactor()); destBand.setScalingOffset(sourceBand.getScalingOffset()); destBand.setLog10Scaled(sourceBand.isLog10Scaled()); destBand.setSpectralBandIndex(sourceBand.getSpectralBandIndex()); destBand.setSpectralWavelength(sourceBand.getSpectralWavelength()); destBand.setSpectralBandwidth(sourceBand.getSpectralBandwidth()); destBand.setSolarFlux(sourceBand.getSolarFlux()); if (sourceBand.isNoDataValueSet()) { destBand.setNoDataValue(sourceBand.getNoDataValue()); } destBand.setNoDataValueUsed(sourceBand.isNoDataValueUsed()); destBand.setValidPixelExpression(sourceBand.getValidPixelExpression()); FlagCoding sourceFlagCoding = sourceBand.getFlagCoding(); IndexCoding sourceIndexCoding = sourceBand.getIndexCoding(); if (sourceFlagCoding != null) { String flagCodingName = sourceFlagCoding.getName(); FlagCoding destFlagCoding = product.getFlagCodingGroup().get(flagCodingName); Debug.assertNotNull( destFlagCoding); // should not happen because flag codings should be already in // product destBand.setSampleCoding(destFlagCoding); } else if (sourceIndexCoding != null) { String indexCodingName = sourceIndexCoding.getName(); IndexCoding destIndexCoding = product.getIndexCodingGroup().get(indexCodingName); Debug.assertNotNull( destIndexCoding); // should not happen because index codings should be already in // product destBand.setSampleCoding(destIndexCoding); } else { destBand.setSampleCoding(null); } if (isFullScene(getSubsetDef()) && sourceBand.isStxSet()) { copyStx(sourceBand, destBand); } product.addBand(destBand); bandMap.put(destBand, sourceBand); } } for (final Map.Entry<Band, RasterDataNode> entry : bandMap.entrySet()) { copyImageInfo(entry.getValue(), entry.getKey()); } }