当前位置: 首页>>代码示例>>Python>>正文


Python ShakeData.get_list_event_ids_from_folder方法代码示例

本文整理汇总了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
开发者ID:Mloweedgar,项目名称:inasafe,代码行数:73,代码来源:make_map.py


注:本文中的realtime.shake_data.ShakeData.get_list_event_ids_from_folder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。