本文整理汇总了Python中astral.Astral.moon_phase方法的典型用法代码示例。如果您正苦于以下问题:Python Astral.moon_phase方法的具体用法?Python Astral.moon_phase怎么用?Python Astral.moon_phase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astral.Astral
的用法示例。
在下文中一共展示了Astral.moon_phase方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from astral import Astral [as 别名]
# 或者: from astral.Astral import moon_phase [as 别名]
class plugin:
'''
A class to display the time of sunrise/sunset
Uses the astral library to retrieve information...
'''
def __init__(self, config):
'''
Initializations for the startup of the weather forecast
'''
# Get plugin name (according to the folder, it is contained in)
self.name = os.path.dirname(__file__).split('/')[-1]
self.astral_at_location = Astral()[config.get('plugin_' + self.name, 'location')]
# Choose language to display sunrise
language = config.get('plugin_time_default', 'language')
if language == 'german':
self.taw = wcp_time_german.time_german()
elif language == 'dutch':
self.taw = wcp_time_dutch.time_dutch()
elif language == 'swiss_german':
self.taw = wcp_swiss_german.time_swiss_german()
else:
print('Could not detect language: ' + language + '.')
print('Choosing default: german')
self.taw = wcp_time_german.time_german()
self.bg_color_index = 0 # default background color: black
self.word_color_index = 2 # default word color: warm white
self.minute_color_index = 2 # default minute color: warm white
def run(self, wcd, wci):
'''
Displaying current time for sunrise/sunset
'''
# Get data of sunrise
sun_data = self.astral_at_location.sun(date=datetime.datetime.now(), local=True)
# Display data of sunrise
wcd.animate(self.name, 'sunrise', invert=True)
wcd.setColorToAll(wcc.colors[self.bg_color_index], includeMinutes=True)
taw_indices = self.taw.get_time(sun_data['sunrise'], withPrefix=False)
wcd.setColorBy1DCoordinates(wcd.strip, taw_indices, wcc.colors[self.word_color_index])
wcd.show()
time.sleep(3)
# Display data of sunset
wcd.animate(self.name, 'sunrise')
wcd.setColorToAll(wcc.colors[self.bg_color_index], includeMinutes=True)
taw_indices = self.taw.get_time(sun_data['sunset'], withPrefix=False)
wcd.setColorBy1DCoordinates(wcd.strip, taw_indices, wcc.colors[self.word_color_index])
wcd.show()
time.sleep(3)
# Display current moon phase
moon_phase = int(self.astral_at_location.moon_phase(datetime.datetime.now()))
for i in range(0, moon_phase):
wcd.showIcon('sunrise', 'moon_'+str(i).zfill(2))
time.sleep(0.1)
time.sleep(3)
示例2: get_phase_segment
# 需要导入模块: from astral import Astral [as 别名]
# 或者: from astral.Astral import moon_phase [as 别名]
def get_phase_segment():
a = Astral()
moon_phase = a.moon_phase(datetime.datetime.now())
if 0 < moon_phase < 4:
return new_moon_icon
if 4 < moon_phase < 10:
return first_quarter_icon
if 10 < moon_phase < 17:
return full_moon_icon
if 17 < moon_phase < 26:
return last_quarter_icon
if 26 < moon_phase < 29:
return new_moon_icon
示例3: __init__
# 需要导入模块: from astral import Astral [as 别名]
# 或者: from astral.Astral import moon_phase [as 别名]
class plugin:
"""
A class to display the time of sunrise/sunset
Uses the astral library to retrieve information...
"""
def __init__(self, config):
"""
Initializations for the startup of the weather forecast
"""
# Get plugin name (according to the folder, it is contained in)
self.name = os.path.dirname(__file__).split('/')[-1]
self.pretty_name = "Sunrise"
self.description = "Displays the current times of sunrise and sunset."
self.astral_at_location = Astral()[config.get('plugin_' + self.name, 'location')]
self.bg_color_index = 0 # default background color: black
self.word_color_index = 2 # default word color: warm white
self.minute_color_index = 2 # default minute color: warm white
def run(self, wcd, wci):
"""
Displaying current time for sunrise/sunset
"""
# Get data of sunrise
sun_data = self.astral_at_location.sun(date=datetime.datetime.now(), local=True)
# Display data of sunrise
wcd.animate(self.name, 'sunrise', invert=True)
wcd.setColorToAll(wcc.colors[self.bg_color_index], includeMinutes=True)
taw_indices = wcd.taw.get_time(sun_data['sunrise'], purist=True)
wcd.setColorBy1DCoordinates(wcd.strip, taw_indices, wcc.colors[self.word_color_index])
wcd.show()
if wci.waitForExit(3.0):
return
# Display data of sunset
wcd.animate(self.name, 'sunrise')
wcd.setColorToAll(wcc.colors[self.bg_color_index], includeMinutes=True)
taw_indices = wcd.taw.get_time(sun_data['sunset'], purist=True)
wcd.setColorBy1DCoordinates(wcd.strip, taw_indices, wcc.colors[self.word_color_index])
wcd.show()
if wci.waitForExit(3.0):
return
# Display current moon phase
moon_phase = int(self.astral_at_location.moon_phase(datetime.datetime.now()))
for i in range(0, moon_phase):
wcd.showIcon('sunrise', 'moon_' + str(i).zfill(2))
if wci.waitForExit(0.1):
return
if wci.waitForExit(3.0):
return
示例4: testMoon
# 需要导入模块: from astral import Astral [as 别名]
# 或者: from astral.Astral import moon_phase [as 别名]
def testMoon():
dd = Astral()
dd.moon_phase(datetime.date(2011, 02, 24))