當前位置: 首頁>>代碼示例>>Python>>正文


Python OqParam.intensity_measure_types_and_levels方法代碼示例

本文整理匯總了Python中openquake.commonlib.oqvalidation.OqParam.intensity_measure_types_and_levels方法的典型用法代碼示例。如果您正苦於以下問題:Python OqParam.intensity_measure_types_and_levels方法的具體用法?Python OqParam.intensity_measure_types_and_levels怎麽用?Python OqParam.intensity_measure_types_and_levels使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在openquake.commonlib.oqvalidation.OqParam的用法示例。


在下文中一共展示了OqParam.intensity_measure_types_and_levels方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: parse_config

# 需要導入模塊: from openquake.commonlib.oqvalidation import OqParam [as 別名]
# 或者: from openquake.commonlib.oqvalidation.OqParam import intensity_measure_types_and_levels [as 別名]
def parse_config(source, hazard_calculation_id=None, hazard_output_id=None):
    """
    Parse a dictionary of parameters from an INI-style config file.

    :param source:
        File-like object containing the config parameters.
    :param hazard_job_id:
        The ID of a previous calculation (or None)
    :param hazard_ouput_id:
        The output of a previous job (or None)
    :returns:
        An :class:`openquake.commonlib.oqvalidation.OqParam` instance
        containing the validate and casted parameters/values parsed from
        the job.ini file as well as a subdictionary 'inputs' containing
        absolute paths to all of the files referenced in the job.ini, keyed by
        the parameter name.
    """
    cp = ConfigParser.ConfigParser()
    cp.readfp(source)

    base_path = os.path.dirname(
        os.path.join(os.path.abspath('.'), source.name))
    params = dict(base_path=base_path, inputs={},
                  hazard_calculation_id=hazard_calculation_id,
                  hazard_output_id=hazard_output_id)

    # Directory containing the config file we're parsing.
    base_path = os.path.dirname(os.path.abspath(source.name))

    for sect in cp.sections():
        for key, value in cp.items(sect):
            if key == 'sites_csv' or key.endswith('_file'):
                input_type = key[:-5]
                path = value if os.path.isabs(value) else os.path.join(
                    base_path, value)
                params['inputs'][input_type] = path
            else:
                params[key] = value

    # load source inputs (the paths are the source_model_logic_tree)
    smlt = params['inputs'].get('source_model_logic_tree')
    if smlt:
        params['inputs']['source'] = [
            os.path.join(base_path, src_path)
            for src_path in _collect_source_model_paths(smlt)]

    # check for obsolete calculation_mode
    is_risk = hazard_calculation_id or hazard_output_id
    cmode = params['calculation_mode']
    if is_risk and cmode in ('classical', 'event_based', 'scenario'):
        raise ValueError('Please change calculation_mode=%s into %s_risk '
                         'in the .ini file' % (cmode, cmode))

    oqparam = OqParam(**params)

    # define the parameter `intensity measure types and levels` always
    oqparam.intensity_measure_types_and_levels = get_imtls(oqparam)

    # remove the redundant parameter `intensity_measure_types`
    if hasattr(oqparam, 'intensity_measure_types'):
        delattr(oqparam, 'intensity_measure_types')

    return oqparam
開發者ID:vup1120,項目名稱:oq-commonlib,代碼行數:65,代碼來源:readini.py


注:本文中的openquake.commonlib.oqvalidation.OqParam.intensity_measure_types_and_levels方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。