Take the 2-minute tour ×
Physics Stack Exchange is a question and answer site for active researchers, academics and students of physics. It's 100% free, no registration required.

I'm trying to improve a site that shows the region of the Earth currently under daylight, and I need a formula that, given the current time, tells where (latitude/longitude) the sun and moon are overhead, accurate to 1 mile. Can anyone come up with one?

Ideally I'm hoping to get something JavaScript can calculate at a "reasonable speed" without recursion, loops, or extra libraries.

I've tried several things (eg, Fourier series on the Sun/Moon's RA/DEC), but nothing seems quite accurate enough.

Note: I realize my calculations for sun/moon rise/set ignore refraction and lunar parallax: for now, I'm focusing on finding the overhead positions. I realize I can pull data from a non-JavaScript CGI program (and have tried that), but it seems like a lot of unnecessary network access.

EDIT: Thanks, Dustin and everyone.

Actually, I'm aware of http://ssd.jpl.nasa.gov/?horizons and even wrote programs to download and parse their data (https://github.com/barrycarter/bcapps/blob/master/bc-email-horizons.pl and https://github.com/barrycarter/bcapps/blob/master/bc-parse-horizons.pl) with the hope of finding simple formulas (https://github.com/barrycarter/bcapps/blob/master/bc-fourier-cont.m and others), but got nowhere.

I realize I could hardcode the data into my JavaScript but that would make the script unnecessarily large.

Currently, I rebuild the script every minute (https://github.com/barrycarter/bcapps/blob/master/bc-sun-always-shines.pl) using interpolated JPLs data (the sun/moonfakex/y.txt files in https://github.com/barrycarter/bcapps/tree/master/data), but this seems insanely complicated.

This may be an inherently difficult and/or pointless question: to get accuracy of 1 mile, you have to calculate the position within 52 seconds of arc, which is considerably smaller than the 30 minute (1800 seconds) width of the sun and moon themselves.

The ultimate goal is to let people zoom into their city on google maps and watch the sunset "sweep" over their city (ie, predict the sun is setting over a certain part of the city and have people in that part of the city confirm it), but given refraction and parallax, this may be impossible.

share|improve this question
    
Have you looked at ngc7000.org/astrotools/ephemtool.html ? –  Larry OBrien Sep 29 '11 at 21:50
2  
It might be easier to retrieve the data from an online database than to calculate it. –  JoeHobbit Oct 2 '11 at 4:18
    
The Jet Propulsion Lab at Cal Tech has an online ephemerides tool. I think you can set up a cron job to connect to it. JPL Cal Tech I just checked on it and it is called the telnet service. You can probably set something up through a linux machine. If you want, I can make this an answer. –  dustin Jun 2 '13 at 2:43

1 Answer 1

No one else has answered so I'll do so, but I'm going to ignore details and speak to the geometry. The latitude of the subsolar point is simply Sun's declination. You should easily be able to convince yourself of that. The longitude is a bit more challenging. You know that when Sun is at the zenith, it must also be on the local celestial meridian. That means its local hour angle (LHA) must be zero. You know that LHA is the difference between local sidereal time (LST) and Sun's right ascension (RA). For LHA to be zero, you must have LHA = RA. If you know LHA and the sidereal time at Greenwich (GST), the difference between the two is the required longitude. I neglected the difference between mean and apparent sidereal time and Sun's mean, apparent, and topocentric coordinates. You can account for these.

A similar process can be applied to Moon to find the sublunar point.

share|improve this answer
    
Thanks, @JoeH. The difficulty I'm having is finding a simple formula for the sun's (and especially the moon's) RA and DEC that's easy to calculate and accurate enough to find the subsolar/sublunar point to within 1 mile. There are several ways to estimate this, but none are super-accurate. –  barrycarter Jan 3 '13 at 15:04
    
@JoeH, Yeah! He's right! This is the method I thought when I first saw the question, but this is not accurate enough in the real world. The celestial motion is far more complex than they do it on paper –  Cheeku Mar 3 '13 at 23:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.