// Path: src/main/java/org/esa/s3tbx/ArrayMath.java
// public static double[] a_div(double[] x, double[] y) {
//     Assert.argument(x.length == y.length);
//     double[] z = new double[x.length];
//     for (int i = 0; i < x.length; i++) {
//         z[i] = x[i] / y[i];
//     }
//     return z;
// }
// 
// Path: src/main/java/org/esa/s3tbx/ArrayMath.java
// public static double[] a_exp(double[] x) {
//     return DoubleStream.of(x).map(Math::exp).toArray();
// }
// 
// Path: src/main/java/org/esa/s3tbx/ArrayMath.java
// public static double a_max(double[] x) {
//     double max = Double.NEGATIVE_INFINITY;
//     for (double v : x) {
//         max = Math.max(max, v);
//     }
//     return max;
// }
// 
// Path: src/main/java/org/esa/s3tbx/ArrayMath.java
// public static double a_min(double[] x) {
//     double min = Double.POSITIVE_INFINITY;
//     for (double v : x) {
//         min = Math.min(min, v);
//     }
//     return min;
// }


import org.esa.snap.core.gpf.OperatorException;
import org.esa.snap.core.nn.NNffbpAlphaTabFast;
import org.esa.snap.core.util.BitSetter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import static java.lang.Math.acos;
import static java.lang.Math.cos;
import static java.lang.Math.log;
import static java.lang.Math.sin;
import static java.lang.Math.toDegrees;
import static java.lang.Math.toRadians;
import static org.esa.s3tbx.ArrayMath.a_div;
import static org.esa.s3tbx.ArrayMath.a_exp;
import static org.esa.s3tbx.ArrayMath.a_max;
import static org.esa.s3tbx.ArrayMath.a_min;
        }

        // (9.3.2) altitude pressure correction
        // this is only a very simplified formula, later use more exact one
        // also for larger lakes the dem_alt presently provideds the altitude of the lake bottom
        // will be changed later to altitude of the lake surface
        double alti_press;
        if (dem_alt > 10.0) {
            alti_press = atm_press * Math.exp(-dem_alt / 8000.0);
        } else {
            alti_press = atm_press;
        }

        // (9.4) )set input to all atmosphere NNs
        //nn_in=[sun_zeni,x,y,z,temperature, salinity, alti_press, log_rtosa];
        double[] nn_in = new double[7 + log_rtosa.length];
        nn_in[0] = sun_zeni;
        nn_in[1] = x;
        nn_in[2] = y;
        nn_in[3] = z;
        nn_in[4] = temperature;
        nn_in[5] = salinity;
        nn_in[6] = alti_press;
        System.arraycopy(log_rtosa, 0, nn_in, 7, log_rtosa.length);

        double[] log_rw = rtosa_rw_nn.get().calc(nn_in);
        double[] rw = a_exp(log_rw);

        // (9.5) test out of scope spectra with autoassociative neural network
        double[] log_rtosa_aann = aaNN_test_oos_rtosa.get().calc(nn_in);
// Path: src/main/java/org/esa/s3tbx/ArrayMath.java
// public static double[] a_div(double[] x, double[] y) {
//     Assert.argument(x.length == y.length);
//     double[] z = new double[x.length];
//     for (int i = 0; i < x.length; i++) {
//         z[i] = x[i] / y[i];
//     }
//     return z;
// }
// 
// Path: src/main/java/org/esa/s3tbx/ArrayMath.java
// public static double[] a_exp(double[] x) {
//     return DoubleStream.of(x).map(Math::exp).toArray();
// }
// 
// Path: src/main/java/org/esa/s3tbx/ArrayMath.java
// public static double a_max(double[] x) {
//     double max = Double.NEGATIVE_INFINITY;
//     for (double v : x) {
//         max = Math.max(max, v);
//     }
//     return max;
// }
// 
// Path: src/main/java/org/esa/s3tbx/ArrayMath.java
// public static double a_min(double[] x) {
//     double min = Double.POSITIVE_INFINITY;
//     for (double v : x) {
//         min = Math.min(min, v);
//     }
//     return min;
// }


// Path: src/main/java/org/esa/s3tbx/c2rcc/seawifs/C2rccSeaWiFSAlgorithm.java
import org.esa.snap.core.gpf.OperatorException;
import org.esa.snap.core.nn.NNffbpAlphaTabFast;
import org.esa.snap.core.util.BitSetter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import static java.lang.Math.acos;
import static java.lang.Math.cos;
import static java.lang.Math.log;
import static java.lang.Math.sin;
import static java.lang.Math.toDegrees;
import static java.lang.Math.toRadians;
import static org.esa.s3tbx.ArrayMath.a_div;
import static org.esa.s3tbx.ArrayMath.a_exp;
import static org.esa.s3tbx.ArrayMath.a_max;
import static org.esa.s3tbx.ArrayMath.a_min;

        }

        // (9.3.2) altitude pressure correction
        // this is only a very simplified formula, later use more exact one
        // also for larger lakes the dem_alt presently provideds the altitude of the lake bottom
        // will be changed later to altitude of the lake surface
        double alti_press;
        if (dem_alt > 10.0) {
            alti_press = atm_press * Math.exp(-dem_alt / 8000.0);
        } else {
            alti_press = atm_press;
        }

        // (9.4) )set input to all atmosphere NNs
        //nn_in=[sun_zeni,x,y,z,temperature, salinity, alti_press, log_rtosa];
        double[] nn_in = new double[7 + log_rtosa.length];
        nn_in[0] = sun_zeni;
        nn_in[1] = x;
        nn_in[2] = y;
        nn_in[3] = z;
        nn_in[4] = temperature;
        nn_in[5] = salinity;
        nn_in[6] = alti_press;
        System.arraycopy(log_rtosa, 0, nn_in, 7, log_rtosa.length);

        double[] log_rw = rtosa_rw_nn.get().calc(nn_in);
        double[] rw = a_exp(log_rw);

        // (9.5) test out of scope spectra with autoassociative neural network
        double[] log_rtosa_aann = aaNN_test_oos_rtosa.get().calc(nn_in);
        double[] rtosa_aann = a_exp(log_rtosa_aann);