コード例 #1
0
ファイル: scenario.py プロジェクト: gempa/caravan
def val_db(pkey, p, value):
    """
        Returns the scenario value of the value argument, already casted according to p=glb.params[pkey]
    """
    isdistrib = 'distrib' in p
    if isdistrib:
        dist_name = p['distrib'].lower().title()
        if prs.isscalar(value):
            #value is scalar, define how to set db value:
            if dist_name == "Uniform" :
                return [value, value]
            elif dist_name == "Normal":
                return [value, 0]
            else:
                raise Exception("{0} distribution not implemented in cast function (scenario.py). Please contact the administrator".format(dist_name))
                
    return value
コード例 #2
0
def val_db(pkey, p, value):
    """
        Returns the scenario value of the value argument, already casted according to p=glb.params[pkey]
    """
    isdistrib = 'distrib' in p
    if isdistrib:
        dist_name = p['distrib'].lower().title()
        if prs.isscalar(value):
            #value is scalar, define how to set db value:
            if dist_name == "Uniform":
                return [value, value]
            elif dist_name == "Normal":
                return [value, 0]
            else:
                raise Exception(
                    "{0} distribution not implemented in cast function (scenario.py). Please contact the administrator"
                    .format(dist_name))

    return value
コード例 #3
0
ファイル: scenario.py プロジェクト: gempa/caravan
def val_sc(pkey, p, value):
    """
        Returns the scenario value of the value argument, already casted according to p=glb.params[pkey]
    """
    
    if pkey == gk.IPE:
        return glb.def_gmpes[value]
    
    if pkey == gk.SOF:
        return glb.sof[value]
    
    isdistrib = 'distrib' in p
    if isdistrib:
        dist_name = p['distrib'].lower().title()
        if not prs.isscalar(value): #note that UncertainFunction is NOT scalar, 
            #but here we should have only numbers or array of numbers (according to params in glb)
            
            #try build a distribution with the given value(s)
            return mcerp.__dict__[dist_name](*value)
        
    return value
コード例 #4
0
def val_sc(pkey, p, value):
    """
        Returns the scenario value of the value argument, already casted according to p=glb.params[pkey]
    """

    if pkey == gk.IPE:
        return glb.def_gmpes[value]

    if pkey == gk.SOF:
        return glb.sof[value]

    isdistrib = 'distrib' in p
    if isdistrib:
        dist_name = p['distrib'].lower().title()
        if not prs.isscalar(
                value):  #note that UncertainFunction is NOT scalar,
            #but here we should have only numbers or array of numbers (according to params in glb)

            #try build a distribution with the given value(s)
            return mcerp.__dict__[dist_name](*value)

    return value