Example #1
0
def calc_gmfs_fast(oqparam, sitecol):
    """
    Build all the ground motion fields for the whole site collection in
    a single step.
    """
    max_dist = oqparam.maximum_distance
    correl_model = get_correl_model(oqparam)
    seed = oqparam.random_seed
    imts = get_imts(oqparam)
    [gsim] = get_gsims(oqparam)
    trunc_level = oqparam.truncation_level
    n_gmfs = oqparam.number_of_ground_motion_fields
    rupture = get_rupture(oqparam)
    res = gmf.ground_motion_fields(
        rupture,
        sitecol,
        imts,
        gsim,
        trunc_level,
        n_gmfs,
        correl_model,
        filters.rupture_site_distance_filter(max_dist),
        seed,
    )
    return {str(imt): matrix for imt, matrix in res.items()}
Example #2
0
 def pre_execute(self):
     self.sitecol = readinput.get_site_collection(self.oqparam)
     self.gsim = readinput.get_gsim(self.oqparam)
     self.imts = readinput.get_imts(self.oqparam)
     self.rupture = readinput.get_rupture(self.oqparam)
     self.rupture_tags = [  # used in the export phase
         'tag%d' % i
         for i in range(self.oqparam.number_of_ground_motion_fields)]
Example #3
0
 def pre_execute(self):
     self.sitecol = readinput.get_site_collection(self.oqparam)
     [self.gsim] = readinput.get_gsims(self.oqparam)
     self.imts = readinput.get_imts(self.oqparam)
     self.rupture = readinput.get_rupture(self.oqparam)
     self.rupture_tags = [  # used in the export phase
         'tag%d' % i
         for i in range(self.oqparam.number_of_ground_motion_fields)]
Example #4
0
    def _init_tags(self):
        self.imts = readinput.get_imts(self.oqparam)
        gsim = readinput.get_gsim(self.oqparam)
        trunc_level = getattr(self.oqparam, 'truncation_level', None)
        correl_model = readinput.get_correl_model(self.oqparam)
        n_gmfs = self.oqparam.number_of_ground_motion_fields
        rupture = readinput.get_rupture(self.oqparam)

        self.tags = ['scenario-%010d' % i for i in xrange(n_gmfs)]
        self.computer = GmfComputer(rupture, self.sitecol, self.imts, gsim,
                                    trunc_level, correl_model)
        rnd = random.Random(getattr(self.oqparam, 'random_seed', 42))
        self.tag_seed_pairs = [(tag, rnd.randint(0, calc.MAX_INT))
                               for tag in self.tags]
Example #5
0
 def __init__(self, oqparam, sites_col, correlation_model):
     self.oqparam = oqparam
     self.ssm_lt = get_source_model_lt(oqparam) # Read the SSC logic tree
     self.hc = mdhc.MultiDimensionalHazardCurve(oqparam.imtls,
                                                sites_col, correlation_model,
                                                oqparam.maximum_distance)
     self.ndims = len(oqparam.imtls.keys())
     self.periods = get_imts(oqparam)
     self.sites = sites_col
     self.cm = correlation_model
     self.srcfilter = SourceFilter(sites_col, oqparam.maximum_distance)
     self.integration_prms = {'truncation_level': oqparam.truncation_level,
                              'abseps': 0.0001,  # Documentation: Optimal value is 1E-6
                              'maxpts': self.ndims*10  # Documentation: Optimal value is len(lnSA)*1000
                             }
     self.integration_prms.update({'trunc_norm': self._truncation_normalization_factor()})
Example #6
0
def calc_gmfs_fast(oqparam, sitecol):
    """
    Build all the ground motion fields for the whole site collection in
    a single step.
    """
    max_dist = oqparam.maximum_distance
    correl_model = get_correl_model(oqparam)
    seed = oqparam.random_seed
    imts = get_imts(oqparam)
    [gsim] = get_gsims(oqparam)
    trunc_level = oqparam.truncation_level
    n_gmfs = oqparam.number_of_ground_motion_fields
    rupture = get_rupture(oqparam)
    res = gmf.ground_motion_fields(
        rupture, sitecol, imts, gsim, trunc_level, n_gmfs, correl_model,
        filters.rupture_site_distance_filter(max_dist), seed)
    return {str(imt): matrix for imt, matrix in res.items()}
Example #7
0
def calc_gmfs(oqparam, sitecol):
    """
    Build all the ground motion fields for the whole site collection
    """
    correl_model = get_correl_model(oqparam)
    rnd = random.Random()
    rnd.seed(getattr(oqparam, 'random_seed', 42))
    imts = get_imts(oqparam)
    gsim = get_gsim(oqparam)
    trunc_level = getattr(oqparam, 'truncation_level', None)
    n_gmfs = getattr(oqparam, 'number_of_ground_motion_fields', 1)
    rupture = get_rupture(oqparam)
    computer = gmf.GmfComputer(rupture, sitecol, imts, gsim, trunc_level,
                               correl_model)
    seeds = [rnd.randint(0, MAX_INT) for _ in xrange(n_gmfs)]
    res = AccumDict()  # imt -> gmf
    for seed in seeds:
        for imt, gmfield in computer.compute(seed):
            res += {imt: [gmfield]}
    # res[imt] is a matrix R x N
    return {imt: numpy.array(matrix).T for imt, matrix in res.iteritems()}