How to account for observer elevation when calculating sunrise/sunset?
Calculating sunrise/set for any lat/longitude is no problem, but how to account for elevation instead of sea-level??? I've run out of combinations to try, and having spent over three days on this am putting my hand up for help
I'm using the excellent public domain C source by Paul Schlyter which seems to be the most common. It DOES let you set "altitude which the Sun should cross", eg -12 for nautical twilight or -35/60 etc, but I'm not sure how to modify that to account for observer elevation above sea level.
For example, Quito in Ecuador is one of the highest cities at 2850m above sea level.
Lat+Lon: -78.46784, -0.18065
Timezone: -5
Elev: 2850m
Using Casio's calculator (http://keisan.casio.com/exec/system/1224686065), one of the few I've found that does account for elevation, it returns the following (Date=Jan 1 2017):
Sunrise=6:14 Sunset=18:22 Elevation=0m <- i can already get this
Sunrise=6:05 Sunset=18:30 Elevation=2850m <- but how can i get this?
I'm able to get the first one (elev=0) by setting Altitude=-35/60 (-0.58333) UpperLimb=1.0 But how to get the second?
I'm using the following function:
int sunriset( int year, int month, int day, double lon, double lat,
double altit, int upper_limb, double *trise, double *tset )
/*************************************************************/
/* altit = the altitude which the Sun should cross */
/* Set to -35/60 degrees for rise/set, -6 degrees */
/* for civil, -12 degrees for nautical and -18 */
/* degrees for astronomical twilight. */
/* upper_limb: non-zero -> upper limb, zero -> center */
/* Set to non-zero (e.g. 1) when computing rise/set */
/* times, and to zero when computing start/end of */
/* twilight. */
/**************************************************************/
SUNRISE.C (i've made this READY-TO-RUN EXAMPLE): with hard-coded Quito lat/long/etc: https://pastebin.com/XSWR2Hby Compile: gcc sunrise.c -o sunrise.exe
alt = -0.8333 - -1.388
alt = -0.8333 + -101.378
alt = -0.8333 - (0.347 * Sqr(meters))
etc – Stephen J Jul 07 '17 at 08:38