@Override public int compare(Band band1, Band band2) { final float v = band1.getSpectralWavelength() - band2.getSpectralWavelength(); return v < 0.0F ? -1 : v > 0.0F ? 1 : 0; } });
private boolean isSpectralBand(Band band) { return band.getSpectralWavelength() > 0.0; }
/** * Writes the wavelength value to the out stream if the given rasterDataNode is an instance of <code>BAND</code> * * @param out - the tream to write to * @param rasterDataNode the <code>RasterDataNode</code> */ private static void writeWavelength(PrintWriter out, RasterDataNode rasterDataNode) { if (rasterDataNode instanceof Band) { final Band band = (Band) rasterDataNode; final float spectralWavelength = band.getSpectralWavelength(); if (spectralWavelength != 0) { out.println("wavelength = {" + spectralWavelength + "}"); } } }
private String createBandDisplayName(Band band) { StringBuilder builder = new StringBuilder(band.getName()); if (!Float.isNaN(band.getSpectralWavelength())) { builder.append(" (") .append(band.getSpectralWavelength()) .append(" nm)"); } return builder.toString(); }
private static String getWavelengthLine(Product product, String[] standardColumnNames, String[] additionalColumnNames) { StringBuilder sb = new StringBuilder(); sb.append("# Wavelength:"); // --> Name for (String ignored : standardColumnNames) { sb.append("\t"); } sb.append("\t"); // --> Desc for (String additionalColumnName : additionalColumnNames) { Band band = product.getBand(additionalColumnName); float spectralWavelength = 0.0f; if (band != null) { spectralWavelength = band.getSpectralWavelength(); } sb.append("\t"); sb.append(spectralWavelength); } return sb.toString(); }
private String getDisplayDescription(RasterDataNode rasterDataNode) { final String fullName = multipleProducts ? rasterDataNode.getDisplayName() : rasterDataNode.getName(); final StringBuilder description = new StringBuilder(); description.setLength(0); description.append(fullName); description.append(rasterDataNode.getDescription() == null ? "" : " (" + rasterDataNode.getDescription()); if (rasterDataNode instanceof Band) { if (((Band) rasterDataNode).getSpectralWavelength() > 0.0) { description.append(" ("); description.append(((Band) rasterDataNode).getSpectralWavelength()); description.append(" nm)"); } } description.append(")"); return description.toString(); }
public static List<Band> getSpectralBands(Product product) { List<Band> bands = new ArrayList<>(); for (Band band : product.getBands()) { if (band.getSpectralWavelength() > 0.0 || band.getSpectralBandIndex() >= 0) { bands.add(band); } } Collections.sort(bands, new SpectralBandComparator()); return bands; }
@Override public int compare(Band b1, Band b2) { float deltaWl = b1.getSpectralWavelength() - b2.getSpectralWavelength(); if (Math.abs(deltaWl) > 1e-05) { return deltaWl < 0 ? -1 : 1; } int deltaSi = b1.getSpectralBandIndex() - b2.getSpectralBandIndex(); if (deltaSi != 0) { return deltaSi < 0 ? -1 : 1; } return b1.getName().compareTo(b2.getName()); } }
static String findBand(float minWavelength, float maxWavelength, Product product) { String bestBand = null; float bestBandLowerDelta = Float.MAX_VALUE; for (Band band : product.getBands()) { float bandWavelength = band.getSpectralWavelength(); if (bandWavelength != 0.0F) { float lowerDelta = bandWavelength - minWavelength; if (lowerDelta < bestBandLowerDelta && bandWavelength <= maxWavelength && bandWavelength >= minWavelength) { bestBand = band.getName(); bestBandLowerDelta = lowerDelta; } } } return bestBand; }
public ExpectedBand(Band band, Random random) { this(); this.name = band.getName(); this.description = band.getDescription(); this.geophysicalUnit = band.getUnit(); this.noDataValue = String.valueOf(band.getGeophysicalNoDataValue()); this.noDataValueUsed = String.valueOf(band.isNoDataValueUsed()); this.spectralWavelength = String.valueOf(band.getSpectralWavelength()); this.spectralBandwidth = String.valueOf(band.getSpectralBandwidth()); this.expectedPixels = createExpectedPixels(band, random); }
private float getWavelength(String bandName) { final Band band = sourceProduct.getBand(bandName); final float wavelength = band.getSpectralWavelength(); if (wavelength == 0.0f) { throw new OperatorException( "The band '" + band.getName() + "' is not a spectral band.\nPlease select a spectral band for processing."); } return wavelength; }
public void testWaveLength() { assertEquals(0.0F, _rsBand.getSpectralWavelength(), 1e-6F); _rsBand.setSpectralWavelength(1.2F); assertEquals(1.2F, _rsBand.getSpectralWavelength(), 1e-6F); }
@Override public void selectionChanged(SelectionChangeEvent event) { final Product selectedProduct = (Product) event.getSelection().getSelectedValue(); final String[] validNames; if (selectedProduct != null) { String[] bandNames = selectedProduct.getBandNames(); ArrayList<String> names = new ArrayList<String>(bandNames.length); for (String bandName : bandNames) { if (selectedProduct.getBand(bandName).getSpectralWavelength() > 0.0) { names.add(bandName); } } validNames = names.toArray(new String[names.size()]); } else { validNames = new String[0]; } final ValueSet valueSet = new ValueSet(validNames); propertyDescriptor.setValueSet(valueSet); formModel.setSourceProduct(selectedProduct); updateTargetProductName(selectedProduct); } };
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++; } } }
/** * Creates a string defining this band object. */ @Override public String toString() { return getClass().getName() + "[" + getName() + "," + ProductData.getTypeString(getDataType()) + "," + +getRasterWidth() + "," + +getRasterHeight() + "," + +getSpectralBandIndex() + "," + +getSpectralWavelength() + "," + +getSpectralBandwidth() + "," + +getSolarFlux() + "]"; }
private void fillDatasetWithCursorSeries(List<DisplayableSpectrum> spectra, XYSeriesCollection dataset, JFreeChart chart) { if (isShowingCursorSpectrum() && getCurrentView().isCurrentPixelPosValid()) { for (DisplayableSpectrum spectrum : spectra) { XYSeries series = new XYSeries(spectrum.getName()); final Band[] spectralBands = spectrum.getSelectedBands(); for (Band spectralBand : spectralBands) { final float wavelength = spectralBand.getSpectralWavelength(); final double energy = ProductUtils.getGeophysicalSampleDouble(spectralBand, pixelX, pixelY, level); if (energy != spectralBand.getGeophysicalNoDataValue()) { series.add(wavelength, energy); } } updateRenderer(dataset.getSeriesCount(), Color.BLACK, spectrum, chart); dataset.addSeries(series); } } }
public void testSetSpectralBandInfo_fromBandIndex() { final Band band = new Band("bla", ProductData.TYPE_FLOAT32, 3, 3); final ModisBandDescription description = new ModisBandDescription("", "true", "", "", "", "", "", ""); ModisFileReader.setBandSpectralInformation(description, "4", band); assertEquals(6, band.getSpectralBandIndex()); assertEquals(555.f, band.getSpectralWavelength(), 1e-8); assertEquals(20.f, band.getSpectralBandwidth(), 1e-8); }
public void testSetSpectralBandInfo_notSpectral() { final Band band = new Band("bla", ProductData.TYPE_FLOAT32, 3, 3); final ModisBandDescription description = new ModisBandDescription("", "false", "", "", "", "", "", ""); ModisFileReader.setBandSpectralInformation(description, "", band); assertEquals(-1, band.getSpectralBandIndex()); assertEquals(0.f, band.getSpectralWavelength(), 1e-8); assertEquals(0.f, band.getSpectralBandwidth(), 1e-8); }
private void initParamsForBand(Band band) { this.band = band; paramSpectralWavelength = new Parameter("SpectralWavelength", this.band.getSpectralWavelength()); paramSpectralWavelength.getProperties().setLabel("Spectral wavelength"); paramSpectralWavelength.getProperties().setPhysicalUnit("nm"); paramSpectralWavelength.getProperties().setDescription("Spectral wavelength in nanometers"); paramSpectralWavelength.getProperties().setNumCols(13); paramSpectralBandwidth = new Parameter("SpectralBandwidth", this.band.getSpectralBandwidth()); paramSpectralBandwidth.getProperties().setLabel("Spectral bandwidth"); paramSpectralBandwidth.getProperties().setPhysicalUnit("nm"); paramSpectralBandwidth.getProperties().setDescription("Spectral bandwidth in nanometers"); paramSpectralBandwidth.getProperties().setNumCols(13); }
public void testSetSpectralBandInfo_fromSpecInfo() { final Band band = new Band("bla", ProductData.TYPE_FLOAT32, 3, 3); final ModisBandDescription description = new ModisBandDescription("", "true", "", "", "", "", "", ""); final ModisSpectralInfo spectralInfo = new ModisSpectralInfo("2", "3", "4"); description.setSpecInfo(spectralInfo); ModisFileReader.setBandSpectralInformation(description, "", band); assertEquals(4, band.getSpectralBandIndex()); assertEquals(2.f, band.getSpectralWavelength(), 1e-8); assertEquals(3.f, band.getSpectralBandwidth(), 1e-8); }