SdrAlgorithm implements Cloneable { public double computeSdr(double rhoNorm, double wavelength, double vza, double sza, double ada, double aot470, double aot660, double ang) { final double[] input = new double[9]; final double[] output = new double[1]; sza *= MathUtils.DTOR; vza *= MathUtils.DTOR; ada *= MathUtils.DTOR; input[0] = rhoNorm; input[1] = wavelength; input[2] = Math.cos(sza); input[3] = Math.sin(vza) * Math.cos(ada); input[4] = Math.sin(vza) * Math.sin(ada); input[5] = Math.cos(vza); input[6] = aot470; input[7] = aot660; input[8] = ang; computeSdr(input, output); return output[0]; } SdrAlgorithm(JnnNet neuralNet); double computeSdr(double rhoNorm,
                             double wavelength,
                             double vza,
                             double sza,
                             double ada,
                             double aot470,
                             double aot660,
                             double ang); void computeSdr(final double[] inputVector, final double[] outputVector); final JnnNet _neuralNet; }
@Test public void testSdaComputation() throws IOException, JnnException { final JnnNet neuralNet = readNeuralNet(); final SdrAlgorithm algorithm = new SdrAlgorithm(neuralNet); final double sdr = algorithm.computeSdr(+1.86672E-02, +4.12500E+02, +5.10563E+00, +3.86851E+01, -1.39682E+02, +4.96000E-01, +2.90000E-01, +1.58081E+00); assertEquals(2.42241E-02, sdr, EPS); }
@Test public void testNeuralNetFunction() throws IOException, JnnException { final JnnNet neuralNet = readNeuralNet(); final SdrAlgorithm algorithm = new SdrAlgorithm(neuralNet); final double[][] testVectors = readTestPixels(); for (double[] testVector : testVectors) { double[] input = new double[testVector.length - 1]; double[] actualOutput = new double[1]; double[] expectedOutput = new double[1]; System.arraycopy(testVector, 0, input, 0, input.length); expectedOutput[0] = testVector[testVector.length - 1]; algorithm.computeSdr(input, actualOutput); assertEquals(expectedOutput[0], actualOutput[0], EPS); } }