本文整理匯總了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