EqualizationAlgorithm { public double performEqualization(double value, int spectralIndex, int detectorIndex) { Assert.argument(spectralIndex >= 0 && spectralIndex <= 14, "spectralIndex < 0 && spectralIndex > 14"); Assert.argument(detectorIndex >= 0, "detectorIndex < 0"); final double[] coefficients = equalizationLUT.getCoefficients(spectralIndex, detectorIndex); double cEq = coefficients[0] + coefficients[1] * julianDate + coefficients[2] * julianDate * julianDate; if (cEq == 0.0) { return value; } return value / cEq; } EqualizationAlgorithm(Product product, ReprocessingVersion version);  EqualizationAlgorithm(ProductData.UTC utc, EqualizationLUT equalizationLUT); double performEqualization(double value, int spectralIndex, int detectorIndex);  }
@Test public void testPerformEqualization() throws Exception { ProductData.UTC utc = ProductData.UTC.create(new Date(), 0); Reader[] readers = new Reader[]{ new StringReader("1.0 2.0 3.0\n4.0 5.0 6.0"), new StringReader("0.1 0.2 0.3\n0.4 0.5 0.6") }; EqualizationAlgorithm algorithm = new EqualizationAlgorithm(utc, new EqualizationLUT(readers)); long date = algorithm.getJulianDate(); double sample = 100.0; final long squareDate = date * date; assertEquals(sample / (1.0 + 2.0 * date + 3.0 * squareDate), algorithm.performEqualization(sample, 0, 0), 1.0e-6); assertEquals(sample / (4.0 + 5.0 * date + 6.0 * squareDate), algorithm.performEqualization(sample, 0, 1), 1.0e-6); assertEquals(sample / (0.1 + 0.2 * date + 0.3 * squareDate), algorithm.performEqualization(sample, 1, 0), 1.0e-6); assertEquals(sample / (0.4 + 0.5 * date + 0.6 * squareDate), algorithm.performEqualization(sample, 1, 1), 1.0e-6); }
@Test(expected = IllegalArgumentException.class) public void testExceptionSpectralIndexToSmall() throws Exception { EqualizationAlgorithm algorithm = new EqualizationAlgorithm(new ProductData.UTC(), new EqualizationLUT(new Reader[0])); algorithm.performEqualization(0.0, -1, 0); }
@Test(expected = IllegalArgumentException.class) public void testExceptionSpectralIndexToBig() throws Exception { EqualizationAlgorithm algorithm = new EqualizationAlgorithm(new ProductData.UTC(), new EqualizationLUT(new Reader[0])); algorithm.performEqualization(0.0, 15, 0); }
@Test(expected = IllegalArgumentException.class) public void testExceptionDetectorIndexToSmall() throws Exception { EqualizationAlgorithm algorithm = new EqualizationAlgorithm(new ProductData.UTC(), new EqualizationLUT(new Reader[0])); algorithm.performEqualization(0.0, 15, -1); }