计算依赖于太阳位置的短暂位置模块DST

时间:2018-11-19 21:44:47

标签: python

我有这段代码来计算太阳的位置,但不依赖于DST。我必须在Sunset_time-5到Sunset_time-4之间的每个DST开关上进行更改 可以使用时区的某个模块来完成此操作吗? 谢谢。

class sunClass():
        def __init__(self):

                self.home = ephem.Observer()
                self.home.lat = '45.xxxxx'
                self.home.long = '-73.xxxxx'
                self.home.elevation = 35
                self.home.pressure = 0
                self.home.horizon = '-3' #'-6'  # civil twilight = -6 deg
                                                # nautical = -12
                                                # astronomical = -18
                self.sun = ephem.Sun(self.home)

        def getStat(self):
                return self.home.previous_rising(self.sun) > self.home.previous_setting(self.sun) # get sun position

        def getSunset(self):
                sunset_time = self.home.next_setting(self.sun)
                sunset_local_time = ephem.Date(sunset_time - 5 * ephem.hour) #local time
                return sunset_local_time

        def getSunrise(self):
                sunrise_time = self.home.previous_rising(self.sun)
                sunrise_local_time = ephem.Date(sunset_time - 5 * ephem.hour) #local time
                return sunrise_local_time

1 个答案:

答案 0 :(得分:0)

无法发表评论,因此即使是真正的评论,我也将其放在此处...

this answer对您有帮助吗?