Javascript for ephemeris

E

Eurydice

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
http://perso.wanadoo.fr/jmrw/
 
R

Richard Cornford

Eurydice said:
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.

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 meanAnomilyToEccentricAnomaly (meanAnomaly, e){
var eccentricAnomaly = meanAnomaly;
var newValue;
var acceptableDiff = 1e-10; //precision of approximation
do{
newValue = eccentricAnomaly;
eccentricAnomaly = (meanAnomaly - (e*Math.sin(eccentricAnomaly)));
}while(Math.abs(newValue - eccentricAnomaly) > acceptableDiff);
return eccentricAnomaly;
}

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.
 
F

Fox

Eurydice said:
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.

NOAA has pretty good JS calculators:

sunrise/sunset/solor noon:
http://www.srrb.noaa.gov/highlights/sunrise/sunrise.html

solar position:
http://www.srrb.noaa.gov/highlights/sunrise/azel.html

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

--
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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top