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


Python OqParam.validate方法代碼示例

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


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

示例1: get_oqparam

# 需要導入模塊: from openquake.commonlib.oqvalidation import OqParam [as 別名]
# 或者: from openquake.commonlib.oqvalidation.OqParam import validate [as 別名]
def get_oqparam(job_ini, pkg=None, calculators=None):
    """
    Parse a dictionary of parameters from one or more INI-style config file.

    :param job_ini:
        Path to configuration file/archive or dictionary of parameters
    :param pkg:
        Python package where to find the configuration file (optional)
    :param calculators:
        Sequence of calculator names (optional) used to restrict the
        valid choices for `calculation_mode`
    :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.
    """
    # UGLY: this is here to avoid circular imports
    from openquake.commonlib.calculators import base

    OqParam.calculation_mode.validator.choices = tuple(
        calculators or base.calculators)

    if isinstance(job_ini, dict):
        oqparam = OqParam(**job_ini)
    else:
        basedir = os.path.dirname(pkg.__file__) if pkg else ''
        inis = [os.path.join(basedir, ini) for ini in job_ini.split(',')]
        oqparam = OqParam(**get_params(inis))

    oqparam.validate()
    return oqparam
開發者ID:raoanirudh,項目名稱:oq-risklib,代碼行數:35,代碼來源:readinput.py

示例2: test_imts_and_imtls

# 需要導入模塊: from openquake.commonlib.oqvalidation import OqParam [as 別名]
# 或者: from openquake.commonlib.oqvalidation.OqParam import validate [as 別名]
 def test_imts_and_imtls(self):
     oq = OqParam(
         calculation_mode='event_based', inputs={},
         intensity_measure_types_and_levels="{'PGA': [0.1, 0.2]}",
         intensity_measure_types='PGV', sites='0.1 0.2',
         maximum_distance=400)
     oq.validate()
     self.assertEqual(list(oq.imtls.keys()), ['PGA'])
開發者ID:CatalinaYepes,項目名稱:oq-risklib,代碼行數:10,代碼來源:oqvalidation_test.py

示例3: test_missing_export_dir

# 需要導入模塊: from openquake.commonlib.oqvalidation import OqParam [as 別名]
# 或者: from openquake.commonlib.oqvalidation.OqParam import validate [as 別名]
 def test_missing_export_dir(self):
     oq = OqParam(
         calculation_mode='event_based', inputs={},
         sites='0.1 0.2',
         intensity_measure_types='PGA',
         maximum_distance=400)
     oq.validate()
     self.assertEqual(oq.export_dir, os.path.expanduser('~'))
開發者ID:CatalinaYepes,項目名稱:oq-risklib,代碼行數:10,代碼來源:oqvalidation_test.py

示例4: test_missing_export_dir

# 需要導入模塊: from openquake.commonlib.oqvalidation import OqParam [as 別名]
# 或者: from openquake.commonlib.oqvalidation.OqParam import validate [as 別名]
 def test_missing_export_dir(self):
     oq = OqParam(
         calculation_mode='event_based', inputs=GST,
         sites='0.1 0.2',
         intensity_measure_types='PGA',
         reference_vs30_value='200',
         maximum_distance='400')
     oq.validate()
     self.assertEqual(oq.export_dir, os.getcwd())
開發者ID:digitalsatori,項目名稱:oq-engine,代碼行數:11,代碼來源:oqvalidation_test.py

示例5: get_oqparam

# 需要導入模塊: from openquake.commonlib.oqvalidation import OqParam [as 別名]
# 或者: from openquake.commonlib.oqvalidation.OqParam import validate [as 別名]
def get_oqparam(job_ini, pkg=None, calculators=None, hc_id=None, validate=1,
                **kw):
    """
    Parse a dictionary of parameters from an INI-style config file.

    :param job_ini:
        Path to configuration file/archive or dictionary of parameters
    :param pkg:
        Python package where to find the configuration file (optional)
    :param calculators:
        Sequence of calculator names (optional) used to restrict the
        valid choices for `calculation_mode`
    :param hc_id:
        Not None only when called from a post calculation
    :param validate:
        Flag. By default it is true and the parameters are validated
    :param kw:
        String-valued keyword arguments used to override the job.ini parameters
    :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.
    """
    # UGLY: this is here to avoid circular imports
    from openquake.calculators import base

    OqParam.calculation_mode.validator.choices = tuple(
        calculators or base.calculators)
    if not isinstance(job_ini, dict):
        basedir = os.path.dirname(pkg.__file__) if pkg else ''
        job_ini = get_params([os.path.join(basedir, job_ini)])
    if hc_id:
        job_ini.update(hazard_calculation_id=str(hc_id))
    job_ini.update(kw)
    oqparam = OqParam(**job_ini)
    if validate:
        oqparam.validate()
    return oqparam
開發者ID:digitalsatori,項目名稱:oq-engine,代碼行數:42,代碼來源:readinput.py


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