Class RsMathUtils

java.lang.Object
org.esa.snap.core.util.math.RsMathUtils

public class RsMathUtils extends Object
A utility class providing a set of mathematical functions frequently used in the fields of remote sensing.

All functions have been implemented with extreme caution in order to provide a maximum performance.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    A constant used for the barometric formula - normalize to input in hPa.
    static final double
    A constant used for radian/degree conversions.
    static final double
    The earth's gravity acceleration in m / s^2.
    static final float
    The constant in Koschmieder's Formula.
    static final double
    The Earth's mean radius in meters.
    static final double
    A constant used for degree/radian conversions.
    static final double
    The specific weight of air in kg / m^3 It's value is 1.26895.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    applyGeodeticCorrection(GeoPos gp, double h, double vz, double va)
    Applies a geodetic correction to the given geographical coordinate.
    static float
    elevationToZenith(float elevation)
    Converts an elevation angle to a zenith angle.
    static float[]
    elevationToZenith(float[] elevation, float[] recycle)
    Converts a vector of elevation angles to a vector of zenith angles.
    static float
    koschmieder(float visibility)
    Transforms horizontal visibility(km) to aerosol optical depth according to Koschmieder's formula.
    static float
    koschmiederInv(float opticalDepth)
    Transforms aerosol optical depth to horizontal visibility(km) according to Koschmieder's formula.
    static float[]
    radianceToReflectance(float[] rad, float[] sza, float e0, float[] recycle)
    Converts an array of radiance values to an array of reflectance values for given solar spectral flux and sun zenith angle.
    static float
    radianceToReflectance(float rad, float sza, float e0)
    Converts a radiance value to a reflectance value for given solar spectral flux and sun zenith angle.
    static float
    reflectanceToRadiance(float refl, float sza, float e0)
    Converts a reflectance value to a radiance value for given solar spectral flux and sun zenith angle.
    static float[]
    simpleBarometric(float[] seaPress, float[] height, float[] recycle)
    Calculates the air pressure in a given height given the sea level air pressure.
    static float
    simpleBarometric(float seaPress, float height)
    Calculates the air pressure in a given height given the sea level air pressure.
    static float
    zenithToElevation(float zenith)
    Converts a zenith angle to an elevation angle.
    static float[]
    zenithToElevation(float[] zenith, float[] recycle)
    Converts a vector of zenith angles to a vector of elevation angles.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SPEC_WEIGHT_AIR

      public static final double SPEC_WEIGHT_AIR
      The specific weight of air in kg / m^3 It's value is 1.26895.
      See Also:
    • GRAVITY_ACC

      public static final double GRAVITY_ACC
      The earth's gravity acceleration in m / s^2. It's value is 9.80665.
      See Also:
    • BAROMETRIC_CONST

      public static final double BAROMETRIC_CONST
      A constant used for the barometric formula - normalize to input in hPa. It's value is GRAVITY_ACC * SPEC_WEIGHT_AIR * 1e-2.
      See Also:
    • KOSCHMIEDER_CONST

      public static final float KOSCHMIEDER_CONST
      The constant in Koschmieder's Formula. It's value is 3.92 * 2.
      See Also:
    • RAD_PER_DEG

      public static final double RAD_PER_DEG
      A constant used for degree/radian conversions. It's value is Math.PI / 180.0.
      See Also:
    • DEG_PER_RAD

      public static final double DEG_PER_RAD
      A constant used for radian/degree conversions. It's value is 180.0 / Math.PI.
      See Also:
    • MEAN_EARTH_RADIUS

      public static final double MEAN_EARTH_RADIUS
      The Earth's mean radius in meters.
      See Also:
  • Constructor Details

    • RsMathUtils

      public RsMathUtils()
  • Method Details

    • reflectanceToRadiance

      public static float reflectanceToRadiance(float refl, float sza, float e0)
      Converts a reflectance value to a radiance value for given solar spectral flux and sun zenith angle. This is the inverse of radianceToReflectance.
      Parameters:
      refl - the reflectance
      sza - the sun zenith angle in decimal degrees
      e0 - the solar spectral flux in mW / (m^2 * sr * nm)
      Returns:
      the corresponding radiance in mW /(m^2 * sr * nm)
    • radianceToReflectance

      public static float radianceToReflectance(float rad, float sza, float e0)
      Converts a radiance value to a reflectance value for given solar spectral flux and sun zenith angle.
      Parameters:
      rad - the radiance in mW /(m^2 * sr * nm)
      sza - the sun zenith angle in decimal degrees
      e0 - the solar spectral flux in mW / (m^2 * sr * nm)
      Returns:
      the corresponding reflectance
    • radianceToReflectance

      public static float[] radianceToReflectance(float[] rad, float[] sza, float e0, float[] recycle)
      Converts an array of radiance values to an array of reflectance values for given solar spectral flux and sun zenith angle.

      If the recycle parameter is of the same size as the radiance array, this array will be filled with the results and returned. The returned result may contain reflectances <0 or >1.

      The method performs no plausability check on the conversion.

      Parameters:
      rad - the radiances in mW /(m^2 * sr * nm)
      sza - the sun zenith angle in decimal degrees
      e0 - the solar spectral flux
      recycle - optional array which will be filled with the results, can be null.
      Returns:
      the array of corresponding reflectance
    • zenithToElevation

      public static float zenithToElevation(float zenith)
      Converts a zenith angle to an elevation angle.
      Parameters:
      zenith - the zenith angle in decimal degrees
    • zenithToElevation

      public static float[] zenithToElevation(float[] zenith, float[] recycle)
      Converts a vector of zenith angles to a vector of elevation angles. If recycle is not null and has the same size as the zenith angle vector, recycle will be filled and returned to minimize the memory finmgerprint.
      Parameters:
      zenith - the zenith angle vector in decimal degrees
      recycle - optional array which will be filled with the results. can be null.
    • elevationToZenith

      public static float elevationToZenith(float elevation)
      Converts an elevation angle to a zenith angle. Convenience routine. Does the same as zenithToElevation but for code clarity ...
      Parameters:
      elevation - the lelevation angle in decimal degrees
    • elevationToZenith

      public static float[] elevationToZenith(float[] elevation, float[] recycle)
      Converts a vector of elevation angles to a vector of zenith angles. If recycle is not null and has the same size as the elevation angle vector, recycle will be filled and returned to minimize the memory fingerprint. Convenience routine. Does the same as zenithToElevation but for code clarity ...
      Parameters:
      elevation - a vector of elevation angles (in degree)
      recycle - optional array which will be filled with the results. can be null.
    • simpleBarometric

      public static float simpleBarometric(float seaPress, float height)
      Calculates the air pressure in a given height given the sea level air pressure. Simple version with no dependency on temperature etc...
      Parameters:
      seaPress - the sea level air pressure in hPa
      height - the height above sea level in m
    • simpleBarometric

      public static float[] simpleBarometric(float[] seaPress, float[] height, float[] recycle)
      Calculates the air pressure in a given height given the sea level air pressure. Simple version with no dependency on temperature etc... This method processes on vectors. If recycle is not null and has the same size as the sea pressure vector, recycle will be filled and returned to minimize the memory fingerprint.
      Parameters:
      seaPress - vector of sea level air pressure in hPa
      height - vector of height above sea level in m
      recycle - optional array which will be filled with the results. can be null.
    • koschmieder

      public static float koschmieder(float visibility)
      Transforms horizontal visibility(km) to aerosol optical depth according to Koschmieder's formula.
      Parameters:
      visibility - horizontal visibility in km
      Throws:
      IllegalArgumentException - if the given parameter is 0.f
    • koschmiederInv

      public static float koschmiederInv(float opticalDepth)
      Transforms aerosol optical depth to horizontal visibility(km) according to Koschmieder's formula.
      Parameters:
      opticalDepth - aerosol optical depth
      Throws:
      IllegalArgumentException - if the given parameter is 0.f
    • applyGeodeticCorrection

      public static void applyGeodeticCorrection(GeoPos gp, double h, double vz, double va)
      Applies a geodetic correction to the given geographical coordinate.

      The implementation assumes that the Earth is flat at the given coordinate point at elevetion zero and at the given elevation. Furthermore the earth is assumed to be a sphere with the fixed radius MEAN_EARTH_RADIUS.

      Parameters:
      gp - the geographical coordinate to be corrected and which will be corrected
      h - elevation above the Earth's sphere or ellipsoid surface in meters
      vz - satellite viewing zenith angle in degree
      va - satellite viewing azimuth angle in degree