Sun Rising/Setting Azimuths for Equinox/Solstice using Observer points in PyEphem

StackOverflow https://stackoverflow.com/questions/16111789

  •  11-04-2022
  •  | 
  •  

Question

Essentially what I am trying to do is:

  • Take an Observer point (using lat/lon)
  • Calculate the dates for the next equinox and solstice given a starting date
  • Find the Sunset Azimuth for each
  • Find the Sunrise Azimuth for each

*Please note, I am working in ArcGIS, so some of my values are pulling from an outside table

Here is kind of what I have:

sun = ephem.Sun()
final = ephem.Observer()
final.lon = row[1]
final.lat = row[2]
final.elevation = row[3]

equinoxDate = ephem.next_equinox('0001/01/01')
equinoxSetDate = final.next_setting(ephem.Sun(), start=equinoxDate, use_center=True)
final.date = equinoxSetDate
sun.compute(final)

print sun.az

I keep getting hung up on the "next_setting" part. I get NeverUpError... if I switch it to previous_setting, next_rising, previous_rising... it doesn't matter. I always get a NeverUpError or AlwaysUpError.

If someone can help me get it to find the Azimuth for an Equinox Sunset (on any date) then I can figure out the rest I am sure.

Let me know if something isn't clear.

THANKS!

Was it helpful?

Solution

I figured it out. I was getting errors because: final.lon, final.lat are treated as strings by pyephem. So I switched it by saying final.lon = str(row[1]) and went from there. Works great now! Brandon, you were on the right track with the values.

sun = ephem.Sun()
final = ephem.Observer()
final.lon = str(row[1])
final.lat = str(row[2])
final.elevation = row[3]

equinoxDate = ephem.next_equinox('0001/01/01')
equinoxSetDate = final.next_setting(ephem.Sun(), start=equinoxDate, use_center=True)
final.date = equinoxSetDate
sun.compute(final)

print sun.az
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top