ModisFileReader { 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); } } ModisFileReader(); void addRastersAndGeoCoding(final Product product, ModisGlobalAttributes globalAttribs, NetCDFVariables netCDFVariables); ModisBandReader getBandReader(final Band band); void close();  }
@Test 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); }
@Test 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); }
@Test 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); }