本文整理匯總了Python中realtime.shake_data.ShakeData.get_list_event_ids_from_folder方法的典型用法代碼示例。如果您正苦於以下問題:Python ShakeData.get_list_event_ids_from_folder方法的具體用法?Python ShakeData.get_list_event_ids_from_folder怎麽用?Python ShakeData.get_list_event_ids_from_folder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類realtime.shake_data.ShakeData
的用法示例。
在下文中一共展示了ShakeData.get_list_event_ids_from_folder方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_shake_events
# 需要導入模塊: from realtime.shake_data import ShakeData [as 別名]
# 或者: from realtime.shake_data.ShakeData import get_list_event_ids_from_folder [as 別名]
def create_shake_events(
event_id=None,
population_path=None,
working_dir=None,
locale='en',
force_flag=False):
"""
:param working_dir: The locale working dir where all the shakemaps are
located.
:type working_dir: str
:param event_id: (Optional) Id of the event. Will be used to
fetch the ShakeData for this event. The grid.xml file in the
unpacked event will be used to initialise the state of the a
ShakeGrid instance. If no event id is supplied, the most recent
event recorded on working dir will be used.
:type event_id: str
:param locale:(Optional) string for iso locale to use for outputs.
Defaults to en. Can also use 'id' or possibly more as translations
are added.
:type locale: str
:param force_flag: Whether to force retrieval of the dataset.
:type force_flag: bool
:return: Shake Events to process
:rtype: list[ShakeEvent]
"""
shake_events = []
if not os.path.exists(population_path):
population_path = None
# cron job executed this script minutely, so it is possible in one
# minute that we have more than one shake_event. We can resolve this
# by only retrieveng the shake id for that particular minute.
# retrieve all the shake ids
shake_ids = ShakeData.get_list_event_ids_from_folder(working_dir)
shake_ids.sort()
shake_ids.reverse()
if not shake_ids:
return []
if event_id:
shake_events.append(
ShakeEvent(
working_dir=working_dir,
event_id=event_id,
locale=locale,
force_flag=force_flag,
population_raster_path=population_path)
)
else:
last_int = int(shake_ids[0])
# sort descending
for shake_id in shake_ids:
if last_int - int(shake_id) < 100:
shake_event = ShakeEvent(
working_dir=working_dir,
event_id=shake_id,
locale=locale,
force_flag=force_flag,
population_raster_path=population_path)
shake_events.append(shake_event)
else:
break
return shake_events