Ephem python paketini GNU / Debian Linux Sistemime kurdum ve QGIS'in Python Konsolunda kullanabilirim. Utah Gölü'nün (ABD) yakınında bir nokta için bir gözlemci oluşturdum ve '2010/6/21' günü için güneşin ve batan güneşin hesaplanmasıydı. Senaryo şuydu:
import ephem
#defining an observer
obs = ephem.Observer()
#defining position
long = '-112.092807'
lat = '40.135114'
obs.long = ephem.degrees(long)
obs.lat = ephem.degrees(lat)
print "long = ", obs.long, "lat = ", obs.lat
#defining date
date = '2010/6/21'
obs.date = ephem.Date(date)
#defining an astronomic object; Sun in this case
sun = ephem.Sun(obs)
r1 = obs.next_rising(sun)
s1 = obs.next_setting(sun)
print "rising sun (UTC time): ", r1
print "setting sun (UTC time): ", s1
r1_lt = ephem.Date(r1 - 6 * ephem.hour) #local time
(y, mn, d, h, min, s) = r1_lt.tuple()
print "rising sun: (local time): {:.2f}".format( h + min/60. + s/3600. )
s1_lt = ephem.Date(s1 - 6 * ephem.hour) #local time
(y, mn, d, h, min, s) = s1_lt.tuple()
print "setting sun (local time): {:.2f}".format( h + min/60. + s/3600. )
QGIS Python Konsolu'nda çalıştıktan sonra sonuç şuydu:
>>>execfile(u'/home/zeito/pyqgis_scripts/ephem.py'.encode('UTF-8'))
long = -112:05:34.1 lat = 40:08:06.4
rising sun (UTC time): 2010/6/21 11:58:58
setting sun (UTC time): 2010/6/21 03:01:14
rising sun: (local time): 5.98
setting sun (local time): 21.02
Cevap bu.
Notu düzenleme :
Yeni bir ufuk tanımlamak (örneğin 5 derece):
.
.
.
obs.horizon = '5'
sun = ephem.Sun(obs)
r1 = obs.next_rising(sun)
s1 = obs.next_setting(sun)
print "rising sun (UTC time): ", r1
print "setting sun (UTC time): ", s1
r1_lt = ephem.Date(r1 - 6 * ephem.hour) #local time
(y, mn, d, h, min, s) = r1_lt.tuple()
print "rising sun: (local time): {:.2f}".format( h + min/60. + s/3600. )
s1_lt = ephem.Date(s1 - 6 * ephem.hour) #local time
(y, mn, d, h, min, s) = s1_lt.tuple()
print "setting sun (local time): {:.2f}".format( h + min/60. + s/3600. )
sonuç:
>>>execfile(u'/home/zeito/pyqgis_scripts/ephem.py'.encode('UTF-8'))
long = -112:05:34.1 lat = 40:08:06.4
rising sun (UTC time): 2010/6/21 12:31:48
setting sun (UTC time): 2010/6/21 02:28:24
rising sun: (local time): 6.53
setting sun (local time): 20.47