Class SunRelativePosition

java.lang.Object
edu.wisc.ssec.mcidasv.util.SunRelativePosition

public class SunRelativePosition extends Object
Calcule la position du soleil relativement à la position de l'observateur. Cette classe reçoit en entrés les coordonnées spatio-temporelles de l'observateur, soit:
 
  • La longitude (en degrées) de l'observateur;
  • La latitude (en degrées) de l'observateur;
  • La date et heure en heure universelle (GMT).
La position du soleil calculée en sortie comprend les valeurs suivantes:
  • L'azimuth du soleil (en degrés dans le sens des aiguilles d'une montre depuis le nord);
  • L'élévation du soleil (en degrés par rapport a l'horizon).
Les algorithmes utilisés dans cette classe sont des adaptations des algorithmes en javascript écrit par le "National Oceanic and Atmospheric Administration, Surface Radiation Research Branch". L'application original est le Solar Position Calculator.

The approximations used in these programs are very good for years between 1800 and 2100. Results should still be sufficiently accurate for the range from -1000 to 3000. Outside of this range, results will be given, but the potential for error is higher.

Since:
2.1
Version:
$Id$
Author:
Remi Eve, Martin Desruisseaux (IRD)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Elevation angle of astronomical twilight, in degrees.
    private double
    Azimuth du soleil, en degrés dans le sens des aiguilles d'une montre depuis le nord.
    static final double
    Elevation angle of civil twilight, in degrees.
    private static final double
    Valeur affectée lorsque un resultat n'est pas calculable du fait de la nuit.
    private static final int
    Number of milliseconds in a day.
    private double
    Elévation du soleil, en degrés par rapport a l'horizon.
    (package private) double
     
    private double
     
    private double
     
    private double
    Geographic coordinate where current elevation and azimuth were computed.
    private double
    Geographic coordinate where current elevation and azimuth were computed.
    static final double
    Elevation angle of nautical twilight, in degrees.
    private long
    Heure à laquelle le soleil est au plus haut dans la journée en millisecondes écoulées depuis le 1er janvier 1970.
    (package private) double
     
    private long
    Date and time when the current elevation and azimuth were computed.
    private boolean
     
    private double
    Sun's elevation angle at twilight, in degrees.
    private boolean
    true is the elevation and azimuth are computed, or false if they need to be computed.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a sun relative position calculator.
    SunRelativePosition(double twilight)
    Constructs a sun relative position calculator with the specified value for the sun elevation at twilight.
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    Calculates solar position for the current date, time and location.
    private static double
    Calculate the eccentricity of earth's orbit.
    private static double
    equationOfTime(double t)
    Calculate the difference between true solar time and mean.
    double
    Retourne l'azimuth en degrés.
    Returns the coordinate used for elevation and azimuth computation.
    static void
    getCosSolarZenith(float[] longitudes, float[] latitudes, Date dateTime, FlatField output)
     
    Returns the date used for elevation and azimuth computation.
    double
    Retourne l'élévation en degrés.
    Retourne la date à laquelle le soleil est au plus haut dans la journée.
    long
    Retourne l'heure à laquelle le soleil est au plus haut.
    double
     
    static float[]
    getSolarZenith(float[] longitudes, float[] latitudes, Date dateTime, float[] solzen)
     
    static void
    getSolarZenith(float[] longitudes, float[] latitudes, Date dateTime, FlatField output)
     
    double
    Returns the sun's elevation angle at twilight, in degrees.
    static void
    main(String[] args)
    Affiche la position du soleil à la date et coordonnées spécifiée.
    private static double
    Calculate the mean obliquity of the ecliptic.
    private static double
    Calculate the corrected obliquity of the ecliptic.
    private static double
    refractionCorrection(double zenith)
    Computes the refraction correction angle.
    void
    setCoordinate(double longitude, double latitude)
    Set the geographic coordinate where to compute the elevation and azimuth.
    void
    Set the geographic coordinate where to compute the elevation and azimuth.
    void
    setDate(Date date)
    Set the date and time when to compute the elevation and azimuth.
    void
    setTwilight(double twilight)
    Set the sun's elevation angle at twilight, in degrees.
    private static double
    solarNoonTime(double lon, double eqTime)
    Calculate the Universal Coordinated Time (UTC) of solar noon for the given day at the given location on earth.
    private static double
    Calculate the apparent longitude of the sun.
    private static double
    sunDeclination(double t)
    Calculate the declination of the sun.
    private static double
    Calculate the equation of center for the sun.
    private static double
    Calculate the Geometric Mean Anomaly of the Sun.
    private static double
    Calculate the Geometric Mean Longitude of the Sun.
    private static double
    sunRadiusVector(double t)
    Calculate the distance to the sun in Astronomical Units (AU).
    private static double
    Calculate the right ascension of the sun.
    private static double
    sunTrueAnomaly(double t)
    Calculate the true anamoly of the sun.
    private static double
    sunTrueLongitude(double t)
    Calculate the true longitude of the sun.

    Methods inherited from class java.lang.Object

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

    • DAY_MILLIS

      private static final int DAY_MILLIS
      Number of milliseconds in a day.
      See Also:
    • DARK

      private static final double DARK
      Valeur affectée lorsque un resultat n'est pas calculable du fait de la nuit. Cette valeur concerne les valeurs de sorties elevation et azimuth.
      See Also:
    • ASTRONOMICAL_TWILIGHT

      public static final double ASTRONOMICAL_TWILIGHT
      Elevation angle of astronomical twilight, in degrees. Astronomical twilight is the time of morning or evening when the sun is 18° below the horizon (solar elevation angle of -18°).
      See Also:
    • NAUTICAL_TWILIGHT

      public static final double NAUTICAL_TWILIGHT
      Elevation angle of nautical twilight, in degrees. Nautical twilight is the time of morning or evening when the sun is 12° below the horizon (solar elevation angle of -12°).
      See Also:
    • CIVIL_TWILIGHT

      public static final double CIVIL_TWILIGHT
      Elevation angle of civil twilight, in degrees. Civil twilight is the time of morning or evening when the sun is 6° below the horizon (solar elevation angle of -6°).
      See Also:
    • twilight

      private double twilight
      Sun's elevation angle at twilight, in degrees. Common values are defined for the astronomical twilight (-18°), nautical twilight (-12°) and civil twilight (-6°). If no twilight are defined, then this value is NaN. The elevation and azimuth are set to NaN when the sun elevation is below the twilight value (i.e. during night). The default value is CIVIL_TWILIGHT.
    • noonTime

      private long noonTime
      Heure à laquelle le soleil est au plus haut dans la journée en millisecondes écoulées depuis le 1er janvier 1970.
    • azimuth

      private double azimuth
      Azimuth du soleil, en degrés dans le sens des aiguilles d'une montre depuis le nord.
    • elevation

      private double elevation
      Elévation du soleil, en degrés par rapport a l'horizon.
    • latitude

      private double latitude
      Geographic coordinate where current elevation and azimuth were computed. Value are in degrees of longitude or latitude.
    • longitude

      private double longitude
      Geographic coordinate where current elevation and azimuth were computed. Value are in degrees of longitude or latitude.
    • time

      private long time
      Date and time when the current elevation and azimuth were computed. Value is in milliseconds ellapsed since midnight UTC, January 1st, 1970.
    • julianDay

      private double julianDay
    • jddate

      private double jddate
    • solarDec

      double solarDec
    • eqTime

      double eqTime
    • timeUpdated

      private boolean timeUpdated
    • updated

      private boolean updated
      true is the elevation and azimuth are computed, or false if they need to be computed. This flag is set to false when the date and/or the coordinate change.
  • Constructor Details

  • Method Details

    • sunEquationOfCenter

      private static double sunEquationOfCenter(double t)
      Calculate the equation of center for the sun. This value is a correction to add to the geometric mean longitude in order to get the "true" longitude of the sun.
      Parameters:
      t - number of Julian centuries since J2000.
      Returns:
      Equation of center in degrees.
    • sunGeometricMeanLongitude

      private static double sunGeometricMeanLongitude(double t)
      Calculate the Geometric Mean Longitude of the Sun. This value is close to 0° at the spring equinox, 90° at the summer solstice, 180° at the automne equinox and 270° at the winter solstice.
      Parameters:
      t - number of Julian centuries since J2000.
      Returns:
      Geometric Mean Longitude of the Sun in degrees, in the range 0° (inclusive) to 360° (exclusive).
    • sunTrueLongitude

      private static double sunTrueLongitude(double t)
      Calculate the true longitude of the sun. This the geometric mean longitude plus a correction factor ("equation of center" for the sun).
      Parameters:
      t - number of Julian centuries since J2000.
      Returns:
      Sun's true longitude in degrees.
    • sunApparentLongitude

      private static double sunApparentLongitude(double t)
      Calculate the apparent longitude of the sun.
      Parameters:
      t - number of Julian centuries since J2000.
      Returns:
      Sun's apparent longitude in degrees.
    • sunGeometricMeanAnomaly

      private static double sunGeometricMeanAnomaly(double t)
      Calculate the Geometric Mean Anomaly of the Sun.
      Parameters:
      t - number of Julian centuries since J2000.
      Returns:
      Geometric Mean Anomaly of the Sun in degrees.
    • sunTrueAnomaly

      private static double sunTrueAnomaly(double t)
      Calculate the true anamoly of the sun.
      Parameters:
      t - number of Julian centuries since J2000.
      Returns:
      Sun's true anamoly in degrees.
    • eccentricityEarthOrbit

      private static double eccentricityEarthOrbit(double t)
      Calculate the eccentricity of earth's orbit. This is the ratio (a-b)/a where a is the semi-major axis length and b is the semi-minor axis length. Value is 0 for a circular orbit.
      Parameters:
      t - number of Julian centuries since J2000.
      Returns:
      The unitless eccentricity.
    • sunRadiusVector

      private static double sunRadiusVector(double t)
      Calculate the distance to the sun in Astronomical Units (AU).
      Parameters:
      t - number of Julian centuries since J2000.
      Returns:
      Sun radius vector in AUs.
    • meanObliquityOfEcliptic

      private static double meanObliquityOfEcliptic(double t)
      Calculate the mean obliquity of the ecliptic.
      Parameters:
      t - number of Julian centuries since J2000.
      Returns:
      Mean obliquity in degrees.
    • obliquityCorrected

      private static double obliquityCorrected(double t)
      Calculate the corrected obliquity of the ecliptic.
      Parameters:
      t - number of Julian centuries since J2000.
      Returns:
      Corrected obliquity in degrees.
    • sunRightAscension

      private static double sunRightAscension(double t)
      Calculate the right ascension of the sun. Similar to the angular system used to define latitude and longitude on Earth's surface, right ascension is roughly analogous to longitude, and defines an angular offset from the meridian of the vernal equinox.

      Parameters:
      t - number of Julian centuries since J2000.
      Returns:
      Sun's right ascension in degrees.
    • sunDeclination

      private static double sunDeclination(double t)
      Calculate the declination of the sun. Declination is analogous to latitude on Earth's surface, and measures an angular displacement north or south from the projection of Earth's equator on the celestial sphere to the location of a celestial body.
      Parameters:
      t - number of Julian centuries since J2000.
      Returns:
      Sun's declination in degrees.
    • solarNoonTime

      private static double solarNoonTime(double lon, double eqTime)
      Calculate the Universal Coordinated Time (UTC) of solar noon for the given day at the given location on earth.
      Parameters:
      lon - longitude of observer in degrees.
      eqTime - Equation of time.
      Returns:
      Time in minutes from beginnning of day in UTC.
    • equationOfTime

      private static double equationOfTime(double t)
      Calculate the difference between true solar time and mean. The "equation of time" is a term accounting for changes in the time of solar noon for a given location over the course of a year. Earth's elliptical orbit and Kepler's law of equal areas in equal times are the culprits behind this phenomenon. See the Analemma page. Below is a plot of the equation of time versus the day of the year.

      Parameters:
      t - number of Julian centuries since J2000.
      Returns:
      Equation of time in minutes of time.
    • refractionCorrection

      private static double refractionCorrection(double zenith)
      Computes the refraction correction angle. The effects of the atmosphere vary with atmospheric pressure, humidity and other variables. Therefore the calculation is approximate. Errors can be expected to increase the further away you are from the equator, because the sun rises and sets at a very shallow angle. Small variations in the atmosphere can have a larger effect.
      Parameters:
      zenith - The sun zenith angle in degrees.
      Returns:
      The refraction correction in degrees.
    • compute

      private void compute()
      Calculates solar position for the current date, time and location. Results are reported in azimuth and elevation in degrees.
    • setCoordinate

      public void setCoordinate(double longitude, double latitude)
      Set the geographic coordinate where to compute the elevation and azimuth.
      Parameters:
      longitude - The longitude in degrees. Positive values are East; negative values are West.
      latitude - The latitude in degrees. Positive values are North, negative values are South.
    • setCoordinate

      public void setCoordinate(Point2D point)
      Set the geographic coordinate where to compute the elevation and azimuth.
      Parameters:
      point - The geographic coordinates in degrees of longitude and latitude.
    • getCoordinate

      Returns the coordinate used for elevation and azimuth computation. This is the coordinate specified during the last call to a setCoordinate(...) method.
    • setDate

      public void setDate(Date date)
      Set the date and time when to compute the elevation and azimuth.
      Parameters:
      date - The date and time.
    • getDate

      public Date getDate()
      Returns the date used for elevation and azimuth computation. This is the date specified during the last call to setDate(java.util.Date).
    • setTwilight

      public void setTwilight(double twilight) throws IllegalArgumentException
      Set the sun's elevation angle at twilight, in degrees. Common values are defined for the astronomical twilight (-18°), nautical twilight (-12°) and civil twilight (-6°). The elevation and azimuth are set to NaN when the sun elevation is below the twilight value (i.e. during night). The default value is CIVIL_TWILIGHT.
      Parameters:
      twilight - The new sun elevation at twilight, or Double.NaN if no twilight value should be taken in account.
      Throws:
      IllegalArgumentException - if the twilight value is illegal.
    • getTwilight

      public double getTwilight()
      Returns the sun's elevation angle at twilight, in degrees. This is the value set during the last call to setTwilight(double).
    • getAzimuth

      public double getAzimuth()
      Retourne l'azimuth en degrés.
      Returns:
      L'azimuth en degrés.
    • getElevation

      public double getElevation()
      Retourne l'élévation en degrés.
      Returns:
      L'élévation en degrés.
    • getSolarZenith

      public double getSolarZenith()
      Returns:
      solar zenith angle in degrees
    • getNoonTime

      public long getNoonTime()
      Retourne l'heure à laquelle le soleil est au plus haut. L'heure est retournée en nombre de millisecondes écoulées depuis le debut de la journée (minuit) en heure UTC.
    • getNoonDate

      public Date getNoonDate()
      Retourne la date à laquelle le soleil est au plus haut dans la journée. Cette méthode est équivalente à getNoonTime() mais inclue le jour de la date qui avait été spécifiée à la méthode compute().
    • getCosSolarZenith

      public static void getCosSolarZenith(float[] longitudes, float[] latitudes, Date dateTime, FlatField output) throws Exception
      Parameters:
      longitudes - float[] of degrees
      latitudes - float[] of degrees
      dateTime - java.util.Date
      output - FlatField of which computed angles (degrees) will be written into the range
      Throws:
      Exception
    • getSolarZenith

      public static void getSolarZenith(float[] longitudes, float[] latitudes, Date dateTime, FlatField output) throws Exception
      Parameters:
      longitudes - float[] of degrees
      latitudes - float[] of degrees
      dateTime - java.util.Date
      output - FlatField of which computed angles (degrees) will be written into the range
      Throws:
      Exception
    • getSolarZenith

      public static float[] getSolarZenith(float[] longitudes, float[] latitudes, Date dateTime, float[] solzen) throws Exception
      Parameters:
      longitudes - float[] of degrees
      latitudes - float[] of degrees
      dateTime - java.util.Date
      solzen - float[] of computed solar zenith angle (degrees). If null, array will be allocated.
      Returns:
      the compute values
      Throws:
      Exception
    • main

      public static void main(String[] args) throws ParseException
      Affiche la position du soleil à la date et coordonnées spécifiée. Cette application peut être lancée avec la syntaxe suivante:
      SunRelativePosition [longitude] [latitude] [date]
      où date est un argument optionel spécifiant la date et l'heure. Si cet argument est omis, la date et heure actuelles seront utilisées.
      Throws:
      ParseException