Class AstroUtils

java.lang.Object
gaiasky.util.coord.AstroUtils

public class AstroUtils extends Object
Some astronomical goodies to get the position of the Sun, Moon, work out Julian dates, etc.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
    Milliseconds of J2000 in the scale of java.util.Date
    static final double
    Julian date of J2000 epoch (julian days since January 1, 4713 BCE)
    static final double
    Julian date of the variable stars' epoch: 2010-01-01T00:00:00
    static final double
    Julian date of reference epoch J2015.0 = JD2455197.5 = 2015-01-01T00:00:00
    static final double
    Julian date of the Gaia DR2 reference epoch, J2015.5 = JD2455197.5 = 2015-01-01T00:00:00
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    apparentToAbsoluteMagnitude(double distPc, double appMag)
    Converts an apparent magnitude to an absolute magnitude given the distance in parsecs.
    static long[]
    getCalendarDay(double julianDate)
    Gets the Gregorian calendar quantities given the Julian date.
    static double
    getDayFraction(int hour, int min, int sec, int nanos)
    Gets the day fraction from the day quantities
    static long[]
    getDayQuantities(double dayFraction)
    Gets the day quantities from the day fraction
    static double
    getDaysSince(Instant date, double epoch_jd)
    Returns the elapsed days since the given julian date jd until the given date.
    static double
    Returns the elapsed days since the epoch J2000 until the given date.
    static Vector3b
    getEclipticCoordinates(String body, Instant instant, Vector3b out, boolean highAccuracy)
    Returns a vector with the heliocentric ecliptic latitude and longitude in radians and the distance in internal units.
    static double
    getJulianDate(double refEpoch)
    Get julian date from a double reference epoch
    static double
    getJulianDate(int year, int month, int day, int hour, int min, int sec, int nanos, boolean gregorian)
    Gets the Julian date number given the Gregorian calendar quantities.
    static double
     
    static double
    Gets the Julian Date for the given date.
    static double
    getJulianDayNumberBook(int year, int month, int day)
    Deprecated.
    This does not work well!
    static double
    getJulianDayNumberWikipediaGregorianCalendar(int year, int month, int day)
    Returns the Julian day number of a date in the Gregorian calendar.
    static double
    getJulianDayNumberWikipediaJulianCalendar(int year, int month, int day)
    Returns the Julian day number of a date in the Julian calendar.
    static double
    getMsSince(Instant date, double epoch_jd)
    Returns the elapsed milliseconds since the given julian date jd until the given date.
    static double
    Returns the elapsed milliseconds since the epoch J2000 until the given date.
    static double
    Returns the elapsed milliseconds since the epoch J2010 until the given date.
    static double
    Returns the elapsed milliseconds since the epoch J2015 until the given date.
    static double
    getSunDistance(double jd)
     
    static double
    Algorithm in "Astronomical Algorithms" book by Jean Meeus.
    static double
    Returns the Sun's ecliptic longitude in degrees for the given time.
    static double
    Gets the ecliptic longitude of the Sun in degrees as published in Wikipedia.
    static Instant
     
    static Vector3d
    moonEclipticCoordinates(double julianDate, Vector3d out)
    Algorithm in "Astronomical Algorithms" book by Jean Meeus.
    static Vector3d
    Algorithm in "Astronomical Algorithms" book by Jean Meeus.
    static Vector3b
    Algorithm in "Astronomical Algorithms" book by Jean Meeus.
    static void
    moonEquatorialCoordinates(Vector3d placeholder, double julianDate)
    Algorithm in "Astronomical Algorithms" book by Jean Meeus.
    static void
    Algorithm in "Astronomical Algorithms" book by Jean Meeus.
    static double
    obliquity(double julianDate)
    Returns the obliquity of the ecliptic (inclination of the Earth's axis of rotation) for a given date, in degrees
    static Vector3b
    Ecliptic coordinates of pluto at the given date
    static Vector3d
    properMotionsToCartesian(double mualphastar, double mudelta, double radvel, double ra, double dec, double distpc, Vector3d out)
    Converts proper motions + radial velocity into a cartesian vector.
    static double
    T(double julianDate)
    Time T measured in Julian centuries from the Epoch J2000.0
    static double
    tau(double julianDate)
     

    Methods inherited from class java.lang.Object

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

    • JD_J2000

      public static final double JD_J2000
      Julian date of J2000 epoch (julian days since January 1, 4713 BCE)
    • JD_J2015

      public static final double JD_J2015
      Julian date of reference epoch J2015.0 = JD2455197.5 = 2015-01-01T00:00:00
    • JD_J2015_5

      public static final double JD_J2015_5
      Julian date of the Gaia DR2 reference epoch, J2015.5 = JD2455197.5 = 2015-01-01T00:00:00
    • JD_J2010

      public static final double JD_J2010
      Julian date of the variable stars' epoch: 2010-01-01T00:00:00
    • J2000_MS

      public static final long J2000_MS
      Milliseconds of J2000 in the scale of java.util.Date
  • Constructor Details

    • AstroUtils

      public AstroUtils()
  • Method Details

    • getJulianDate

      public static double getJulianDate(double refEpoch)
      Get julian date from a double reference epoch
      Parameters:
      refEpoch - The reference epoch
      Returns:
      The julian date
    • getSunDistance

      public static double getSunDistance(Instant date)
      Algorithm in "Astronomical Algorithms" book by Jean Meeus. Finds out the distance from the Sun to the Earth in Km
      Parameters:
      date - The date
      Returns:
      The distance from the Sun to the Earth in Km
    • getSunDistance

      public static double getSunDistance(double jd)
    • getSunLongitude

      public static double getSunLongitude(Instant date)
      Returns the Sun's ecliptic longitude in degrees for the given time. Caches the last Sun's longitude for future use.
      Parameters:
      date - The time for which the longitude must be calculated
      Returns:
      The Sun's longitude in [deg]
    • getSunLongitudeWikipedia

      public static double getSunLongitudeWikipedia(double jd)
      Gets the ecliptic longitude of the Sun in degrees as published in Wikipedia.
      Parameters:
      jd - The Julian date for which to calculate the latitude.
      Returns:
      The ecliptic longitude of the Sun at the given Julian date, in degrees.
      See Also:
    • moonEquatorialCoordinates

      public static void moonEquatorialCoordinates(Vector3d placeholder, Instant date)
      Algorithm in "Astronomical Algorithms" book by Jean Meeus. Returns a vector with the equatorial longitude (α) in radians, the equatorial latitude (δ) in radians and the distance in kilometers.
      Parameters:
      date -
    • moonEquatorialCoordinates

      public static void moonEquatorialCoordinates(Vector3d placeholder, double julianDate)
      Algorithm in "Astronomical Algorithms" book by Jean Meeus. Returns a vector with the equatorial longitude (α) in radians, the equatorial latitude (δ) in radians and the distance in kilometers.
      Parameters:
      julianDate -
    • moonEclipticCoordinates

      public static Vector3d moonEclipticCoordinates(Instant date, Vector3d out)
      Algorithm in "Astronomical Algorithms" book by Jean Meeus. Returns a vector with the ecliptic longitude (λ) in radians, the ecliptic latitude (β) in radians and the distance in kilometers.
      Parameters:
      date -
      out - The output vector.
      Returns:
      The output vector, for chaining.
    • moonEclipticCoordinates

      public static Vector3b moonEclipticCoordinates(Instant date, Vector3d aux, Vector3b out)
      Algorithm in "Astronomical Algorithms" book by Jean Meeus. Returns a vector with the ecliptic longitude (λ) in radians, the ecliptic latitude (β) in radians and the distance in kilometers.
      Parameters:
      date - The instant date.
      aux - Auxiliary double vector.
      out - The output vector.
      Returns:
      The output vector, for chaining.
    • moonEclipticCoordinates

      public static Vector3d moonEclipticCoordinates(double julianDate, Vector3d out)
      Algorithm in "Astronomical Algorithms" book by Jean Meeus. Returns a vector with the ecliptic longitude (λ) in radians, the ecliptic latitude (β) in radians and the distance between the centers of the Earth and the Moon in kilometers.
      Parameters:
      julianDate - The julian days since J2000.
      out - The output vector with geocentric longitude (lambda) [rad], geocentric latitude (beta) [rad], distance between the centers of the Earth and the Moon [km]
      Returns:
      The output vector, for chaining.
    • plutoEclipticCoordinates

      public static Vector3b plutoEclipticCoordinates(Instant date, Vector3b out)
      Ecliptic coordinates of pluto at the given date
      Parameters:
      date - The date
      out - The out vector
      Returns:
      Ecliptic coordinates of Pluto at the given julian date
    • getEclipticCoordinates

      public static Vector3b getEclipticCoordinates(String body, Instant instant, Vector3b out, boolean highAccuracy)
      Returns a vector with the heliocentric ecliptic latitude and longitude in radians and the distance in internal units.
      Parameters:
      body - The body.
      instant - The date to get the position.
      out - The output vector
      highAccuracy - Whether to use the full precision algorithms or skip some terms for speed
      Returns:
      The output vector with L, B and R, for chaining.
    • getJulianDate

      public static double getJulianDate(int year, int month, int day, int hour, int min, int sec, int nanos, boolean gregorian)
      Gets the Julian date number given the Gregorian calendar quantities.
      Parameters:
      gregorian - Whether to use the Gregorian or the Julian calendar
      Returns:
      The julian date number
    • getJulianDateCache

      public static double getJulianDateCache(Instant instant)
      Gets the Julian Date for the given date. It uses a cache.
      Parameters:
      instant - The date.
      Returns:
      The Julian Date.
    • getJulianDate

      public static double getJulianDate(Instant instant)
    • getMsSinceJ2010

      public static double getMsSinceJ2010(Instant date)
      Returns the elapsed milliseconds since the epoch J2010 until the given date. Can be negative.
      Parameters:
      date - The date
      Returns:
      The elapsed milliseconds
    • getMsSinceJ2000

      public static double getMsSinceJ2000(Instant date)
      Returns the elapsed milliseconds since the epoch J2000 until the given date. Can be negavite.
      Parameters:
      date - The date
      Returns:
      The elapsed milliseconds
    • getDaysSinceJ2000

      public static double getDaysSinceJ2000(Instant date)
      Returns the elapsed days since the epoch J2000 until the given date. Can be negative.
      Parameters:
      date - The date
      Returns:
      The elapsed days
    • getMsSinceJ2015

      public static double getMsSinceJ2015(Instant date)
      Returns the elapsed milliseconds since the epoch J2015 until the given date. Can be negative.
      Parameters:
      date - The date
      Returns:
      The elapsed milliseconds
    • getMsSince

      public static double getMsSince(Instant date, double epoch_jd)
      Returns the elapsed milliseconds since the given julian date jd until the given date. Can be negative.
      Parameters:
      date - The date
      epoch_jd - The reference epoch in julian days
      Returns:
      The elapsed milliseconds
    • getDaysSince

      public static double getDaysSince(Instant date, double epoch_jd)
      Returns the elapsed days since the given julian date jd until the given date. Can be negative
      Parameters:
      date - The date
      epoch_jd - The reference epoch in julian days
      Returns:
      The elapsed days
    • getCalendarDay

      public static long[] getCalendarDay(double julianDate)
      Gets the Gregorian calendar quantities given the Julian date.
      Parameters:
      julianDate - The Julian date
      Returns:
      Vector with {year, month, day, hour, min, sec, nanos}
    • getJulianDayNumberBook

      @Deprecated public static double getJulianDayNumberBook(int year, int month, int day)
      Deprecated.
      This does not work well!
      Returns the Julian day number. Uses the method shown in "Astronomical Algorithms" by Jean Meeus.
      Parameters:
      year - The year
      month - The month in [1:12]
      day - The day in the month, starting at 1
      Returns:
      The Julian date
    • getJulianDayNumberWikipediaGregorianCalendar

      public static double getJulianDayNumberWikipediaGregorianCalendar(int year, int month, int day)
      Returns the Julian day number of a date in the Gregorian calendar. Uses Wikipedia's algorithm.
      Parameters:
      year - The year
      month - The month in [1:12]
      day - The day in the month, starting at 1
      Returns:
      The Julian date
      See Also:
    • getJulianDayNumberWikipediaJulianCalendar

      public static double getJulianDayNumberWikipediaJulianCalendar(int year, int month, int day)
      Returns the Julian day number of a date in the Julian calendar. Uses Wikipedia's algorithm.
      Parameters:
      year - The year
      month - The month in [1:12]
      day - The day in the month, starting at 1
      Returns:
      The Julian date
      See Also:
    • julianDateToInstant

      public static Instant julianDateToInstant(double jd)
    • getDayFraction

      public static double getDayFraction(int hour, int min, int sec, int nanos)
      Gets the day fraction from the day quantities
      Parameters:
      hour - The hour in 0-24
      min - The minute in 0-1440
      sec - The second in 0-86400
      nanos - The nanoseconds
      Returns:
      The day fraction
    • getDayQuantities

      public static long[] getDayQuantities(double dayFraction)
      Gets the day quantities from the day fraction
      Parameters:
      dayFraction -
      Returns:
      [hours, minutes, seconds, nanos]
    • obliquity

      public static double obliquity(double julianDate)
      Returns the obliquity of the ecliptic (inclination of the Earth's axis of rotation) for a given date, in degrees
      Returns:
      The obliquity in degrees
    • T

      public static double T(double julianDate)
      Time T measured in Julian centuries from the Epoch J2000.0
      Parameters:
      julianDate - The julian date
      Returns:
      The time in julian centuries
    • tau

      public static double tau(double julianDate)
    • properMotionsToCartesian

      public static Vector3d properMotionsToCartesian(double mualphastar, double mudelta, double radvel, double ra, double dec, double distpc, Vector3d out)
      Converts proper motions + radial velocity into a cartesian vector. See this article.
      Parameters:
      mualphastar - Mu alpha star, in mas/yr
      mudelta - Mu delta, in mas/yr
      radvel - Radial velocity in km/s
      ra - Right ascension in radians
      dec - Declination in radians
      distpc - Distance in parsecs to the star
      Returns:
      The proper motion vector in internal_units/year
    • apparentToAbsoluteMagnitude

      public static double apparentToAbsoluteMagnitude(double distPc, double appMag)
      Converts an apparent magnitude to an absolute magnitude given the distance in parsecs.
      Parameters:
      distPc - The distance to the star in parsecs
      appMag - The apparent magnitude
      Returns:
      The absolute magnitude