PINE LIBRARY

Ephemeris

Library "Ephemeris"
TODO: add library description here

mercuryElements()

mercuryRates()

venusElements()

venusRates()

earthElements()

earthRates()

marsElements()

marsRates()

jupiterElements()

jupiterRates()

saturnElements()

saturnRates()

uranusElements()

uranusRates()

neptuneElements()

neptuneRates()

rev360(x)
  Normalize degrees to within [0, 360)
  Parameters:
    x (float): degrees to be normalized
  Returns: Normalized degrees

scaleAngle(longitude, magnitude, harmonic)
  Scale angle in degrees
  Parameters:
    longitude (float)
    magnitude (float)
    harmonic (int)
  Returns: Scaled angle in degrees

julianCenturyInJulianDays()
  Constant Julian days per century
  Returns: 36525

julianEpochJ2000()
  Julian date on J2000 epoch start (2000-01-01)
  Returns: 2451545.0

meanObliquityForJ2000()
  Mean obliquity of the ecliptic on J2000 epoch start (2000-01-01)
  Returns: 23.43928

getJulianDate(Year, Month, Day, Hour, Minute)
  Convert calendar date to Julian date
  Parameters:
    Year (int): calendar year as integer (e.g. 2018)
    Month (int): calendar month (January = 1, December = 12)
    Day (int): calendar day of month (e.g. January valid days are 1-31)
    Hour (int): valid values 0-23
    Minute (int): valid values 0-60

julianCenturies(date, epoch_start)
  Centuries since Julian Epoch 2000-01-01
  Parameters:
    date (float): Julian date to conver to Julian centuries
    epoch_start (float): Julian date of epoch start (e.g. J2000 epoch = 2451545)
  Returns: Julian date converted to Julian centuries

julianCenturiesSinceEpochJ2000(julianDate)
  Calculate Julian centuries since epoch J2000 (2000-01-01)
  Parameters:
    julianDate (float): Julian Date in days
  Returns: Julian centuries since epoch J2000 (2000-01-01)

atan2(y, x)
  Specialized arctan function
  Parameters:
    y (float): radians
    x (float): radians
  Returns: special arctan of y/x

eccAnom(ec, m_param, dp)
  Compute eccentricity of the anomaly
  Parameters:
    ec (float): Eccentricity of Orbit
    m_param (float): Mean Anomaly ?
    dp (int): Decimal places to round to
  Returns: Eccentricity of the Anomaly

planetEphemerisCalc(TGen, planetElementId, planetRatesId)
  Compute planetary ephemeris (longtude relative to Earth or Sun) on a Julian date
  Parameters:
    TGen (float): Julian Date
    planetElementId (float[]): All planet orbital elements in an array. This index references a specific planet's elements.
    planetRatesId (float[]): All planet orbital rates in an array. This index references a specific planet's rates.
  Returns: [xGen, yGen, zGen, rGen] X,Y,Z ecliptic rectangular coordinates and R radius from reference body.

calculateRightAscensionAndDeclination(earthX, earthY, earthZ, planetX, planetY, planetZ)
  Calculate right ascension and declination for a planet relative to Earth
  Parameters:
    earthX (float): Earth X ecliptic rectangular coordinate relative to Sun
    earthY (float): Earth Y ecliptic rectangular coordinate relative to Sun
    earthZ (float): Earth Z ecliptic rectangular coordinate relative to Sun
    planetX (float): Planet X ecliptic rectangular coordinate relative to Sun
    planetY (float): Planet Y ecliptic rectangular coordinate relative to Sun
    planetZ (float): Planet Z ecliptic rectangular coordinate relative to Sun
  Returns: [distPlanet, raPlanetDegrees, decPlanet] Planet geocentric orbital radius, geocentric right ascension, and geocentric declination

mercuryHelio(T)
  Compute Mercury heliocentric longitude on date
  Parameters:
    T (float)
  Returns: Mercury heliocentric longitude on date

venusHelio(T)
  Compute Venus heliocentric longitude on date
  Parameters:
    T (float)
  Returns: Venus heliocentric longitude on date

earthHelio(T)
  Compute Earth heliocentric longitude on date
  Parameters:
    T (float)
  Returns: Earth heliocentric longitude on date

marsHelio(T)
  Compute Mars heliocentric longitude on date
  Parameters:
    T (float)
  Returns: Mars heliocentric longitude on date

jupiterHelio(T)
  Compute Jupiter heliocentric longitude on date
  Parameters:
    T (float)
  Returns: Jupiter heliocentric longitude on date

saturnHelio(T)
  Compute Saturn heliocentric longitude on date
  Parameters:
    T (float)
  Returns: Saturn heliocentric longitude on date

neptuneHelio(T)
  Compute Neptune heliocentric longitude on date
  Parameters:
    T (float)
  Returns: Neptune heliocentric longitude on date

uranusHelio(T)
  Compute Uranus heliocentric longitude on date
  Parameters:
    T (float)
  Returns: Uranus heliocentric longitude on date

sunGeo(T)
  Parameters:
    T (float)

mercuryGeo(T)
  Parameters:
    T (float)

venusGeo(T)
  Parameters:
    T (float)

marsGeo(T)
  Parameters:
    T (float)

jupiterGeo(T)
  Parameters:
    T (float)

saturnGeo(T)
  Parameters:
    T (float)

neptuneGeo(T)
  Parameters:
    T (float)

uranusGeo(T)
  Parameters:
    T (float)

moonGeo(T_JD)
  Parameters:
    T_JD (float)

mercuryOrbitalPeriod()
  Mercury orbital period in Earth days
  Returns: 87.9691

venusOrbitalPeriod()
  Venus orbital period in Earth days
  Returns: 224.701

earthOrbitalPeriod()
  Earth orbital period in Earth days
  Returns: 365.256363004

marsOrbitalPeriod()
  Mars orbital period in Earth days
  Returns: 686.980

jupiterOrbitalPeriod()
  Jupiter orbital period in Earth days
  Returns: 4332.59

saturnOrbitalPeriod()
  Saturn orbital period in Earth days
  Returns: 10759.22

uranusOrbitalPeriod()
  Uranus orbital period in Earth days
  Returns: 30688.5

neptuneOrbitalPeriod()
  Neptune orbital period in Earth days
  Returns: 60195.0

jupiterSaturnCompositePeriod()

jupiterNeptuneCompositePeriod()

jupiterUranusCompositePeriod()

saturnNeptuneCompositePeriod()

saturnUranusCompositePeriod()

planetSineWave(julianDateInCenturies, planetOrbitalPeriod, planetHelio)
  Convert heliocentric longitude of planet into a sine wave
  Parameters:
    julianDateInCenturies (float)
    planetOrbitalPeriod (float): Orbital period of planet in Earth days
    planetHelio (float): Heliocentric longitude of planet in degrees
  Returns: Sine of heliocentric longitude on a Julian date
MATH

Pine library

In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in a publication is governed by House rules.


Also on:

Disclaimer