473,394 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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
http://perso.wanadoo.fr/jmrw/
Jul 23 '05 #1
2 2844
Eurydice wrote:
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.
Jul 23 '05 #2
Fox


Eurydice wrote:

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

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Dave | last post by:
Hi, I was just wondering if anyone knows whether it's possible to use the Python port to the Swiss Ephemeris with the latest version Python 2.3? I downloaded it from the vault, and it worked fine...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.