Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Computing sub-solar point

Tags:

pyephem

I am just getting started with PyEphem. My immediate task is, given a date and time compute the sub-solar point on Earth with latitude-longitude values. I'll dig into PyEphem to work this out but if someone has already done this, I'd appreciate sample code.

like image 220
Michael Zeiler Avatar asked Apr 25 '26 11:04

Michael Zeiler


1 Answers

I went looking for the same answer as the OP. Many posts "mention" how PyEphem is the way to go but without providing the actual example.

Here is my working example to calculate the subsolar point. Mapping everything to a longitude between -180 and + 180 degrees.

greenwich = ephem.Observer()
greenwich.lat = "0"
greenwich.lon = "0"
greenwich.date = datetime.utcnow()
sun = ephem.Sun(greenwich)
sun.compute(greenwich.date)
sun_lon = math.degrees(sun.ra - greenwich.sidereal_time() )
if sun_lon < -180.0 :
  sun_lon = 360.0 + sun_lon 
elif sun_lon > 180.0 :
  sun_lon = sun_lon - 360.0
sun_lat = math.degrees(sun.dec)
print "Subsolar Point Sun Lon:",sun_lon, "Lat:",sun_lat

I am no expert in PyEphem and there may be a better approach - but my testing so far has this work for my purposes.

p.s. yes.. Greenwich above is not actually set to the actual lat/lon... it's really only the Longitude of 0.0 that's needed to get the appropriate Sidereal time we need.

like image 89
Liam Kennedy Avatar answered Apr 28 '26 04:04

Liam Kennedy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!