private static void setSpectralBandIndex(final Element element, final Band band) { final String spectralBandIndex = element.getChildTextTrim(DimapProductConstants.TAG_SPECTRAL_BAND_INDEX); if (spectralBandIndex != null) { band.setSpectralBandIndex(Integer.parseInt(spectralBandIndex)); } else { band.setSpectralBandIndex(-1); } }
/** * Constructs a new <code>Band</code>. * * @param name the name of the new object * @param dataType the raster data type, must be one of the multiple <code>ProductData.TYPE_<i>X</i></code> * constants, with the exception of <code>ProductData.TYPE_UINT32</code> * @param width the width of the raster in pixels * @param height the height of the raster in pixels */ public Band(String name, int dataType, int width, int height) { super(name, dataType, width, height); // By default a band is not a spectral band, // so spectral band index must be -1 setSpectralBandIndex(-1); setModified(false); }
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++); } } }
@Override protected void setSpectralBand(Product product) { //todo Add units int spectralBandIndex = 0; for (String name : product.getBandNames()) { Band band = product.getBandAt(product.getBandIndex(name)); if (name.matches(".*\\w+_\\d+.*")) { String wvlstr = null; if (name.matches("IOP.*_\\d+.*")) { wvlstr = name.split("_")[2].split("nm")[0]; } else if (name.matches("nLw_\\d+nm")) { wvlstr = name.split("_")[1].split("nm")[0]; } if (wvlstr != null){ final float wavelength = Float.parseFloat(wvlstr); band.setSpectralWavelength(wavelength); band.setSpectralBandIndex(spectralBandIndex++); } } } }
private void setSpectralBandProperties(Band band) { if (band.getName().endsWith("REFL_BLUE")) { band.setSpectralBandIndex(0); band.setSpectralWavelength(462.0f); band.setSpectralBandwidth(48.0f); } else if (band.getName().endsWith("REFL_RED")) { band.setSpectralBandIndex(1); band.setSpectralWavelength(655.5f); band.setSpectralBandwidth(81.0f); } else if (band.getName().endsWith("REFL_NIR")) { band.setSpectralBandIndex(2); band.setSpectralWavelength(843.0f); band.setSpectralBandwidth(142.0f); } else if (band.getName().endsWith("REFL_SWIR")) { band.setSpectralBandIndex(3); band.setSpectralWavelength(1599.0f); band.setSpectralBandwidth(70.0f); } }
private void setSpectralProperties(Band band) { if (band.getName().endsWith("REFL_BLUE")) { band.setSpectralBandIndex(0); band.setSpectralWavelength(462.0f); band.setSpectralBandwidth(48.0f); } else if (band.getName().endsWith("REFL_RED")) { band.setSpectralBandIndex(1); band.setSpectralWavelength(655.5f); band.setSpectralBandwidth(81.0f); } else if (band.getName().endsWith("REFL_NIR")) { band.setSpectralBandIndex(2); band.setSpectralWavelength(843.0f); band.setSpectralBandwidth(142.0f); } else if (band.getName().endsWith("REFL_SWIR")) { band.setSpectralBandIndex(3); band.setSpectralWavelength(1599.0f); band.setSpectralBandwidth(70.0f); } }
private void addSpectralInfo(Product product, String name, int index, float min, float max, float solFlux) { Band spectralBand = product.getBand(name); if (spectralBand != null) { spectralBand.setSpectralBandIndex(index); spectralBand.setSpectralWavelength(min + 0.5f * (max - min)); spectralBand.setSpectralBandwidth(max - min); spectralBand.setSolarFlux(solFlux); spectralBand.setDescription(MessageFormat.format("{0} spectral band", name)); } }
static void setBandSpectralInformation(ModisBandDescription bandDesc, String bandNameExt, Band band) { if (bandDesc.isSpectral()) { if (bandDesc.hasSpectralInfo()) { final ModisSpectralInfo specInfo = bandDesc.getSpecInfo(); band.setSpectralWavelength(specInfo.getSpectralWavelength()); band.setSpectralBandwidth(specInfo.getSpectralBandwidth()); band.setSpectralBandIndex(specInfo.getSpectralBandIndex()); } else { final float[] data = ModisUtils.decodeSpectralInformation(bandNameExt, null); band.setSpectralWavelength(data[0]); band.setSpectralBandwidth(data[1]); band.setSpectralBandIndex((int) data[2]); } } else { band.setSpectralBandIndex(-1); } }
private void maybeApplySpectralIndexAndSolarFluxFromMetadata(Product p) { List<Band> bands = Arrays.asList(p.getBands()); int spectralIndex = 0; for (Band band : bands) { boolean isSpectralBand = band.getSpectralWavelength() != 0.0f; boolean isSpectralBandIndexSet = band.getSpectralBandIndex() != -1; if (isSpectralBand && !isSpectralBandIndexSet) { band.setSpectralBandIndex(spectralIndex); boolean isSolarFluxSet = band.getSolarFlux() != 0.0f; if (!isSolarFluxSet) { applySolarFluxFromMetadata(band, spectralIndex); } spectralIndex++; } } }
private void addRciAndMaskBands(final Product product) { final String units = chrisFile.getGlobalAttribute(ChrisConstants.ATTR_NAME_CALIBRATION_DATA_UNITS); for (int i = 0; i < spectralBandCount; ++i) { final String name = MessageFormat.format("radiance_{0}", i + 1); final Band band = product.addBand(name, ProductData.TYPE_INT32); band.setSpectralBandIndex(i); band.setSpectralWavelength(chrisFile.getWavelength(i)); band.setSpectralBandwidth(chrisFile.getBandwidth(i)); band.setUnit(units); band.setDescription(MessageFormat.format("Radiance for spectral band {0}", i + 1)); band.setValidPixelExpression(MessageFormat.format("mask_{0} != {1}", i + 1, Flags.DROPOUT.getMask())); rciBands[i] = band; } for (int i = 0; i < spectralBandCount; ++i) { final String name = MessageFormat.format("mask_{0}", i + 1); final Band band = product.addBand(name, ProductData.TYPE_INT16); band.setSpectralBandIndex(i); band.setSpectralWavelength(chrisFile.getWavelength(i)); band.setSpectralBandwidth(chrisFile.getBandwidth(i)); band.setDescription(MessageFormat.format("Quality mask for spectral band {0}", i + 1)); maskBands[i] = band; } product.setAutoGrouping("radiance:mask"); }
private Band addBand(Product product, BandReader bandReader, int channelIndex) { final Band band = product.addBand(bandReader.getBandName(), bandReader.getDataType()); band.setScalingFactor(bandReader.getScalingFactor()); band.setUnit(bandReader.getBandUnit()); band.setDescription(bandReader.getBandDescription()); band.setSpectralBandIndex(channelIndex + 1); band.setValidPixelExpression(band.getName() + " != NaN"); bandReaderMap.put(band, bandReader); return band; }
Band band = inputProduct.addBand("radiance_" + (i + 1), ProductData.TYPE_FLOAT32); band.setSpectralWavelength(wl[i]); band.setSpectralBandIndex(i);
private static void readBeamBandAttributes(Variable variable, Band band) { // todo se -- units for bandwidth and wavelength Attribute attribute = variable.findAttribute(BANDWIDTH); if (attribute != null) { band.setSpectralBandwidth(attribute.getNumericValue().floatValue()); } attribute = variable.findAttribute(WAVELENGTH); if (attribute != null) { band.setSpectralWavelength(attribute.getNumericValue().floatValue()); } attribute = variable.findAttribute(SPECTRAL_BAND_INDEX); if (attribute != null) { band.setSpectralBandIndex(attribute.getNumericValue().intValue()); } attribute = variable.findAttribute(VALID_PIXEL_EXPRESSION); if (attribute != null) { band.setValidPixelExpression(attribute.getStringValue()); } attribute = variable.findAttribute(SOLAR_FLUX); if (attribute != null) { band.setSolarFlux(attribute.getNumericValue().floatValue()); } band.setName(ReaderUtils.getRasterName(variable)); }
band.setDescription("Image component #" + (i + 1)); if ((numBands == 3 || numBands == 4) && i < 3) { band.setSpectralBandIndex(i); band.setSpectralWavelength(RGB_WAVELENGTHS[i]);
protected Band createBand(BandReader bandReader, int channel) { final Band band = new Band(bandReader.getBandName(), bandReader .getDataType(), avhrrFile.getProductWidth(), avhrrFile .getProductHeight()); band.setScalingFactor(bandReader.getScalingFactor()); band.setUnit(bandReader.getBandUnit()); band.setDescription(bandReader.getBandDescription()); band.setSpectralBandIndex(channel); band.setSpectralBandwidth(CH_BANDWIDTHS[channel]); band.setSpectralWavelength(CH_WAVELENGTHS[channel]); band.setValidPixelExpression(CH_VALID_MASK_EXPRESSIONS[channel]); band.setNoDataValue(NO_DATA_VALUE); band.setNoDataValueUsed(true); bandReaders.put(band, bandReader); return band; }
/** * Copies the spectral properties from source band to target band. These properties are: * <ul> * <li>{@link org.esa.beam.framework.datamodel.Band#getSpectralBandIndex() spectral band index},</li> * <li>{@link org.esa.beam.framework.datamodel.Band#getSpectralWavelength() the central wavelength},</li> * <li>{@link org.esa.beam.framework.datamodel.Band#getSpectralBandwidth() the spectral bandwidth} and</li> * <li>{@link org.esa.beam.framework.datamodel.Band#getSolarFlux() the solar spectral flux}.</li> * </ul> * * @param sourceBand the source band * @param targetBand the target band * * @see #copyRasterDataNodeProperties(org.esa.beam.framework.datamodel.RasterDataNode, org.esa.beam.framework.datamodel.RasterDataNode) */ public static void copySpectralBandProperties(Band sourceBand, Band targetBand) { Guardian.assertNotNull("source", sourceBand); Guardian.assertNotNull("target", targetBand); targetBand.setSpectralBandIndex(sourceBand.getSpectralBandIndex()); targetBand.setSpectralWavelength(sourceBand.getSpectralWavelength()); targetBand.setSpectralBandwidth(sourceBand.getSpectralBandwidth()); targetBand.setSolarFlux(sourceBand.getSolarFlux()); }
band.setSpectralBandIndex(bandDescriptor.spectralBandIndex);
private void addBand(final Product product) { final String bandName = "radiance_1"; // constant final Band band = new Band(bandName, ProductData.TYPE_UINT8, product.getSceneRasterWidth(), product.getSceneRasterHeight()); band.setSpectralBandIndex(0); // constant band.setSpectralWavelength(645); // constant band.setSpectralBandwidth(250); // constant band.setUnit("mw / (m^2*sr*nm)"); // constant band.setScalingFactor(leaderFile.getAncillary2Record().getAbsoluteCalibrationGain()); band.setScalingOffset(leaderFile.getAncillary2Record().getAbsoluteCalibrationOffset()); band.setNoDataValue(0.00); band.setNoDataValueUsed(true); product.addBand(band); }
private Band createBand(final Avnir2ImageFile avnir2ImageFile) throws IOException, IllegalCeosFormatException { final Band band = new Band(avnir2ImageFile.getBandName(), ProductData.TYPE_UINT8, sceneWidth, sceneHeight); final int bandIndex = avnir2ImageFile.getBandIndex(); band.setSpectralBandIndex(bandIndex - 1); band.setSpectralWavelength(avnir2ImageFile.getSpectralWavelength()); band.setSpectralBandwidth(avnir2ImageFile.getSpectralBandwidth()); band.setUnit(avnir2ImageFile.getGeophysicalUnit()); final double scalingFactor = leaderFile.getAbsoluteCalibrationGain(bandIndex); final double scalingOffset = leaderFile.getAbsoluteCalibrationOffset(bandIndex); band.setScalingFactor(scalingFactor); band.setScalingOffset(scalingOffset); band.setNoDataValueUsed(false); band.setDescription("Radiance band " + avnir2ImageFile.getBandIndex()); return band; }
band1.setSolarFlux(0.12f); band1.setSpectralWavelength(23.45f); band1.setSpectralBandIndex(0); band1.setValidPixelExpression("Flags1.Flag1C"); band1.setStx(createStx()); band2.setSolarFlux(0.23f); band2.setSpectralWavelength(243.56f); band2.setSpectralBandIndex(3); product.addBand(band2); flags1.setSpectralBandIndex(-1); product.addBand(flags1); flags2.setSpectralBandIndex(-1); product.addBand(flags2); index.setSpectralBandIndex(-1); product.addBand(index);