Calculate longitude based on latitude and sunrise time?

I calculate the longitude of the positions where the current height of the sun is currently ~ 0.0. This is done by iterating over the latitude of latitudes, calculating the time of sunrise at (0.0, latitude) , and then calculating longitude by multiplying the time difference (fractional hours) by 15 (the number of degrees that the sun "moves" over the surface of the earth).

When calculating sunrise times from computed coordinate tuples, the lowest latitudes show a time difference of several minutes with the highest latitudes. How to explain this difference?

IN:

 points=walk_the_earth() 

Of:

 [-66.53673944994807, -65.0] 2012-08-21 12:07:04.748893 [-67.13184367865324, -64.5] 2012-08-21 12:07:05.666852 [-67.70314011722803, -64.0] 2012-08-21 12:07:06.541521 ... [-119.24775995314121, 64.0] 2012-08-21 12:08:45.536679 [-119.93103107437491, 64.5] 2012-08-21 12:08:47.770382 [-120.64480075612664, 65.0] 2012-08-21 12:08:50.152224 

(UTC time). The code works up to a second.

What is the reason for this difference?

code

 import math import xephem def longitude_from_latitude(lat): """ Calculate the longitude at which Sun altitude is ~0.0. Args: lat: A float indicating the latitude to calculate longitude for. Returns: float """ now = xephem.julianday.now() meridian = xephem.Observer(now.midnight.dublin, 0.0, lat) sun = xephem.Sun.fromobserver(meridian) transit = sun.transit(-1) # Calculate time difference between sun position and local time. delta_t = ((now - transit['rs_risetm']) * 24.0) * 15.0 return delta_t def walk_the_earth(resolution=0.5, minlat=-65.0, maxlat=65.0): """ Calculate the coordinate at which Sun altitude is ~0.0 for a given range of latitudes. Args: resolution: A float indicating the number of points to return for the specified range of latitudes. 1.0 means that 1 longitude will be calculated for each real latitude, 0.5 means 2, etc. minlat: A float indicating the lowest latitude to start calculating. maxlat: A float indicating the highest latitude to calculate up to. Returns: list of longitude, latitude, xephem.Sun tuples. """ now = xephem.julianday.now() lat = minlat points = [] while True: if lat > maxlat: break lng = longitude_from_latitude(lat) # Create an Observer for longitude and latitude obs = xephem.Observer(now.dublin, lng, lat) sun = xephem.Sun.fromobserver(obs) points.append([lng, lat, sun]) # sun.transit() calculates the rising, transit and setting times # of the sun at Observers location. The -1 argument specifies # that we consider sunrise to occur when the upper limb touches # the horizon (0 indicates center, 1 indicates lower limb). print points[-1], sun.transit(-1)['rs_risetm'].datetime() lat += resolution return points 
+4
source share
3 answers

I checked the sunrise time for extreme points N and S in your NOAA solar calculator list. The feed in lat / long and today gave the sunrise time, which was the same as in the table that you published, provided that the calculator gives only the sunrise time to the nearest minute.

However, if your question was line by line What is wrong with my code? The answer is most likely nothing.

But if your question was really What do I not understand about the variation of sunrise time by position and date? then your question is seriously off topic for SO.

+1
source

I think that a more direct method will work for you, which will allow you to avoid the correction of 15 degrees per hour. After all, you have ephemeris, so you can use this.

  • Choose latitude and time
  • Choose two longitudes, a and b, so that the sun is above the horizon for one (altitude> 0, say a), and lower for the other (altitude <0, b)
  • Do a double search: select the longitude c halfway between a and b and calculate the height of the sun there.
  • If this height is close enough to zero, stop: c is the answer
  • If the height is less than 0, set b = c; otherwise set a = c.
  • Go to 3

Do this for each latitude you choose.

To verify that everything works, do the equinox calculation and the calculated longitudes should be almost equal (make sure you understand why). Do it again at any solstice, and longitudes must vary greatly, and the algorithm will fail when you reach 67 degrees north or south (can you understand why?).

+1
source

The position of the sun in the sky is uneven. The local apparent noon in December can be a few minutes before the average local noon, while the local noon June in June can come a few minutes β€œlate”. This β€œwobble” is predicted through the equation of time, which, if I understand this correctly, has a more pronounced effect further from the equator.

-1
source

All Articles