Javascript for ephemeris

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eurydice

    Javascript for ephemeris

    I would like to put a javascript code to obtain on my meteo page
    http://perso.wanadoo.fr/jmrw/Meteo/Meteo.shtml the time of the raise and the
    sunset of the sun according to the date.

    I have found nothing on the net up to now that satisfies me.

    Thanks if you can give me a link for this.


    --
    Faites que le rêve dévore votre vie afin que la vie ne dévore pas votre
    rêve.
    [Antoine de Saint Exupéry]
    email : Dalip at ifrance.com



  • Richard Cornford

    #2
    Re: Javascript for ephemeris

    Eurydice wrote:[color=blue]
    > I would like to put a javascript code to obtain on my meteo page
    > http://perso.wanadoo.fr/jmrw/Meteo/Meteo.shtml the time of the raise
    > and the sunset of the sun according to the date.
    >
    > I have found nothing on the net up to now that satisfies me.
    >
    > Thanks if you can give me a link for this.[/color]

    It is an interesting characteristic of orbital mechanics that you cannot
    directly evaluate orbital position from time. Instead an angle (from the
    planet to the centre of its elliptical orbit) called the 'Mean Anomaly'
    is calculated based on constant motion in a circular orbit (time
    directly relates to that angle) and the real angle to the planet (from
    the centre of its elliptical orbit) progressively approximated using
    code such as:-

    function meanAnomilyToEc centricAnomaly (meanAnomaly, e){
    var eccentricAnomal y = meanAnomaly;
    var newValue;
    var acceptableDiff = 1e-10; //precision of approximation
    do{
    newValue = eccentricAnomal y;
    eccentricAnomal y = (meanAnomaly - (e*Math.sin(ecc entricAnomaly)) );
    }while(Math.abs (newValue - eccentricAnomal y) > acceptableDiff) ;
    return eccentricAnomal y;
    }

    Where - e - is the elliptical eccentricity of the planet's orbit.
    (Angles in Radians, as is normal in javascript).

    The approximation works because planetary orbits are nearly circular.

    Working out the approximate position of the earth in relation to the sun
    at any given time would require knowing an angle at a moment in time.
    The exact moment of perihelion or aphelion (recently so as not to suffer
    too much from the approximations) .

    Unfortunately, working out the approximate location of the sun in
    relation to the earth at a particular moment in time is not enough. The
    orientation of the earth is also a factor; the orientation of its axis
    of rotation and the degree to which it is rotated. And then the exact
    times of sunrise and sunset are determined by the longitude and latitude
    of the observer on the surface of the earth.

    I would be very surprised to find that there was a client-side script
    that calculates this in existence (or that it would be accurate enough
    to be useful).

    Richard.


    Comment

    • Fox

      #3
      Re: Javascript for ephemeris



      Eurydice wrote:[color=blue]
      >
      > I would like to put a javascript code to obtain on my meteo page
      > http://perso.wanadoo.fr/jmrw/Meteo/Meteo.shtml the time of the raise and the
      > sunset of the sun according to the date.
      >
      > I have found nothing on the net up to now that satisfies me.
      >
      > Thanks if you can give me a link for this.[/color]

      NOAA has pretty good JS calculators:

      sunrise/sunset/solor noon:


      solar position:


      the Jet Propulsion Laboratory @ NASA claims this calculator is accurate
      from 1000BCE to 3000CE

      [color=blue]
      >
      > --
      > Faites que le rêve dévore votre vie afin que la vie ne dévore pas votre
      > rêve.
      > [Antoine de Saint Exupéry]
      > email : Dalip at ifrance.com
      > http://perso.wanadoo.fr/jmrw/[/color]

      Comment

      Working...