Search is not available for this dataset
text
stringlengths
75
104k
def _get_stddevs(self, C, stddev_types, num_sites, mag_conversion_sigma): """ Return total standard deviation. """ assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES for stddev_type in stddev_types) sigma = np.zeros(num_sites) + C['sigma'] * n...
def _get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types, mag_conversion_sigma=0.0): """ See :meth:`superclass method <.base.GroundShakingIntensityModel.get_mean_and_stddevs>` for spec of input and result values. """ # extract dictionaries of coeffici...
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types): """ See :meth:`superclass method <.base.GroundShakingIntensityModel.get_mean_and_stddevs>` for spec of input and result values. """ # get original values hslab = 50 # See info in GMPEt_Inslab_...
def get_src_ids(sources): """ :returns: a string with the source IDs of the given sources, stripping the extension after the colon, if any """ src_ids = [] for src in sources: long_src_id = src.source_id try: src_id, ext = long_src_id.rsplit(':', 1) ...
def get_extreme_poe(array, imtls): """ :param array: array of shape (L, G) with L=num_levels, G=num_gsims :param imtls: DictArray imt -> levels :returns: the maximum PoE corresponding to the maximum level for IMTs and GSIMs """ return max(array[imtls(imt).stop - 1].max() for imt in imtls...
def classical_split_filter(srcs, srcfilter, gsims, params, monitor): """ Split the given sources, filter the subsources and the compute the PoEs. Yield back subtasks if the split sources contain more than maxweight ruptures. """ # first check if we are sampling the sources ss = int(os.enviro...
def build_hazard_stats(pgetter, N, hstats, individual_curves, monitor): """ :param pgetter: an :class:`openquake.commonlib.getters.PmapGetter` :param N: the total number of sites :param hstats: a list of pairs (statname, statfunc) :param individual_curves: if True, also build the individual curves ...
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types): """ See :meth:`superclass method <.base.GroundShakingIntensityModel.get_mean_and_stddevs>` for spec of input and result values. """ sites.vs30 = 700 * np.ones(len(sites.vs30)) mean, stddevs = ...
def _get_rupture_dimensions(src, mag, nodal_plane): """ Calculate and return the rupture length and width for given magnitude ``mag`` and nodal plane. :param src: a PointSource, AreaSource or MultiPointSource :param mag: a magnitude :param nodal_plane: Instance of :class...
def tensor_components_to_use(mrr, mtt, mpp, mrt, mrp, mtp): ''' Converts components to Up, South, East definition:: USE = [[mrr, mrt, mrp], [mtt, mtt, mtp], [mrp, mtp, mpp]] ''' return np.array([[mrr, mrt, mrp], [mrt, mtt, mtp], [mrp, mtp, mpp]])
def get_azimuth_plunge(vect, degrees=True): ''' For a given vector in USE format, retrieve the azimuth and plunge ''' if vect[0] > 0: vect = -1. * np.copy(vect) vect_hor = sqrt(vect[1] ** 2. + vect[2] ** 2.) plunge = atan2(-vect[0], vect_hor) azimuth = atan2(vect[2], -vect[1]) if...
def use_to_ned(tensor): ''' Converts a tensor in USE coordinate sytem to NED ''' return np.array(ROT_NED_USE.T * np.matrix(tensor) * ROT_NED_USE)
def ned_to_use(tensor): ''' Converts a tensor in NED coordinate sytem to USE ''' return np.array(ROT_NED_USE * np.matrix(tensor) * ROT_NED_USE.T)
def tensor_to_6component(tensor, frame='USE'): ''' Returns a tensor to six component vector [Mrr, Mtt, Mpp, Mrt, Mrp, Mtp] ''' if 'NED' in frame: tensor = ned_to_use(tensor) return [tensor[0, 0], tensor[1, 1], tensor[2, 2], tensor[0, 1], tensor[0, 2], tensor[1, 2]]
def normalise_tensor(tensor): ''' Normalise the tensor by dividing it by its norm, defined such that np.sqrt(X:X) ''' tensor_norm = np.linalg.norm(tensor) return tensor / tensor_norm, tensor_norm
def eigendecompose(tensor, normalise=False): ''' Performs and eigendecomposition of the tensor and orders into descending eigenvalues ''' if normalise: tensor, tensor_norm = normalise_tensor(tensor) else: tensor_norm = 1. eigvals, eigvects = np.linalg.eigh(tensor, UPLO='U') ...
def matrix_to_euler(rotmat): '''Inverse of euler_to_matrix().''' if not isinstance(rotmat, np.matrixlib.defmatrix.matrix): # As this calculation relies on np.matrix algebra - convert array to # matrix rotmat = np.matrix(rotmat) def cvec(x, y, z): return np.matrix([[x, y, z]]...
def unique_euler(alpha, beta, gamma): ''' Uniquify euler angle triplet. Put euler angles into ranges compatible with (dip,strike,-rake) in seismology: alpha (dip) : [0, pi/2] beta (strike) : [0, 2*pi) gamma (-rake) : [-pi, pi) If alpha is near to zero, beta is replaced by beta+gamma and ...
def moment_magnitude_scalar(moment): ''' Uses Hanks & Kanamori formula for calculating moment magnitude from a scalar moment (Nm) ''' if isinstance(moment, np.ndarray): return (2. / 3.) * (np.log10(moment) - 9.05) else: return (2. / 3.) * (log10(moment) - 9.05)
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types): """ See :meth:`superclass method <.base.GroundShakingIntensityModel.get_mean_and_stddevs>` for spec of input and result values. """ # extracting dictionary of coefficients specific to required #...
def _compute_distance_scaling(self, rup, dists, C): """ Compute distance-scaling term, equations (3) and (4), pag 107. """ Mref = 4.5 Rref = 1.0 R = np.sqrt(dists.rjb ** 2 + C['h'] ** 2) return (C['c1'] + C['c2'] * (rup.mag - Mref)) * np.log(R / Rref) + \ ...
def _compute_magnitude_scaling(self, rup, C): """ Compute magnitude-scaling term, equations (5a) and (5b), pag 107. """ U, SS, NS, RS = self._get_fault_type_dummy_variables(rup) if rup.mag <= C['Mh']: return C['e1'] * U + C['e2'] * SS + C['e3'] * NS + C['e4'] * RS + \...
def _get_pga_on_rock(self, rup, dists, _C): """ Compute and return PGA on rock conditions (that is vs30 = 760.0 m/s). This is needed to compute non-linear site amplification term """ # Median PGA in g for Vref = 760.0, without site amplification, # that is equation (1) pa...
def _get_site_amplification_non_linear(self, vs30, pga4nl, C): """ Compute site amplification non-linear term, equations (8a) to (13d), pag 108-109. """ # non linear slope bnl = self._compute_non_linear_slope(vs30, C) # compute the actual non-linear term r...
def _compute_non_linear_slope(self, vs30, C): """ Compute non-linear slope factor, equations (13a) to (13d), pag 108-109. """ V1 = 180.0 V2 = 300.0 Vref = 760.0 # equation (13d), values are zero for vs30 >= Vref = 760.0 bnl = np.zeros(vs30.shape) ...
def _compute_non_linear_term(self, pga4nl, bnl): """ Compute non-linear term, equation (8a) to (8c), pag 108. """ fnl = np.zeros(pga4nl.shape) a1 = 0.03 a2 = 0.09 pga_low = 0.06 # equation (8a) idx = pga4nl <= a1 fnl[idx] = bnl[id...
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types): """ Using a frequency dependent correction for the mean ground motion. Standard deviation is fixed. """ mean, stddevs = super().get_mean_and_stddevs(sites, rup, dists, ...
def _get_stddevs(self, C, stddev_types, num_sites): """ Return total standard deviation. """ assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES for stddev_type in stddev_types) # Using a frequency independent value of sigma as recommended ...
def accept_path(path, ref_path): """ :param path: a logic tree path (list or tuple of strings) :param ref_path: reference logic tree path :returns: True if `path` is consistent with `ref_path`, False otherwise >>> accept_path(['SM2'], ('SM2', 'a3b1')) False >>> accept_path(['SM2', '@'], ('S...
def get_rlzs_assoc(cinfo, sm_lt_path=None, trts=None): """ :param cinfo: a :class:`openquake.commonlib.source.CompositionInfo` :param sm_lt_path: logic tree path tuple used to select a source model :param trts: tectonic region types to accept """ assoc = RlzsAssoc(cinfo) offset = 0 trtse...
def get_rlzs_by_gsim(self, trt_or_grp_id, sm_id=None): """ :param trt_or_grp_id: a tectonic region type or a source group ID :param sm_id: source model ordinal (or None) :returns: a dictionary gsim -> rlzs """ if isinstance(trt_or_grp_id, (int, U16, U32)): # grp_id ...
def by_grp(self): """ :returns: a dictionary grp -> rlzis """ dic = {} # grp -> [(gsim_idx, rlzis), ...] for sm in self.csm_info.source_models: for sg in sm.src_groups: if not sg.eff_ruptures: continue rlzs_by_gsim ...
def _init(self): """ Finalize the initialization of the RlzsAssoc object by setting the (reduced) weights of the realizations. """ if self.num_samples: assert len(self.realizations) == self.num_samples, ( len(self.realizations), self.num_samples) ...
def combine_pmaps(self, pmap_by_grp): """ :param pmap_by_grp: dictionary group string -> probability map :returns: a list of probability maps, one per realization """ grp = list(pmap_by_grp)[0] # pmap_by_grp must be non-empty num_levels = pmap_by_grp[grp].shape_y ...
def get_rlz(self, rlzstr): r""" Get a Realization instance for a string of the form 'rlz-\d+' """ mo = re.match(r'rlz-(\d+)', rlzstr) if not mo: return return self.realizations[int(mo.group(1))]
def export(datastore_key, calc_id=-1, exports='csv', export_dir='.'): """ Export an output from the datastore. """ dstore = util.read(calc_id) parent_id = dstore['oqparam'].hazard_calculation_id if parent_id: dstore.parent = util.read(parent_id) dstore.export_dir = export_dir ...
def convert_UCERFSource(self, node): """ Converts the Ucerf Source node into an SES Control object """ dirname = os.path.dirname(self.fname) # where the source_model_file is source_file = os.path.join(dirname, node["filename"]) if "startDate" in node.attrib and "investigationTime" in node.attri...
def build_idx_set(branch_id, start_date): """ Builds a dictionary of keys based on the branch code """ code_set = branch_id.split("/") code_set.insert(3, "Rates") idx_set = { "sec": "/".join([code_set[0], code_set[1], "Sections"]), "mag": "/".join([code_set[0], code_set[1], code_...
def get_rupture_dimensions(mag, nodal_plane, msr, rupture_aspect_ratio, upper_seismogenic_depth, lower_seismogenic_depth): """ Calculate and return the rupture length and width for given magnitude ``mag`` and nodal plane. :param nodal_plane: Instance of :class:`openqu...
def get_rupture_surface(mag, nodal_plane, hypocenter, msr, rupture_aspect_ratio, upper_seismogenic_depth, lower_seismogenic_depth, mesh_spacing=1.0): """ Create and return rupture surface object with given properties. :param mag: Magnitude value, used...
def generate_background_ruptures(tom, locations, occurrence, mag, npd, hdd, upper_seismogenic_depth, lower_seismogenic_depth, msr=WC1994(), aspect=1.5, trt=DEFAULT_TRT): """ :param tom: Temporal occurrence...
def get_indices(self, src, ridx, mag): """ :param src: an UCERF source :param ridx: a set of rupture indices :param mag: magnitude to use to compute the integration distance :returns: array with the IDs of the sites close to the ruptures """ centroids = src.get_ce...
def new(self, grp_id, branch_id): """ :param grp_id: ordinal of the source group :param branch_name: name of the UCERF branch :param branch_id: string associated to the branch :returns: a new UCERFSource associated to the branch_id """ new = copy.copy(self) ...
def get_ridx(self, iloc): """List of rupture indices for the given iloc""" with h5py.File(self.source_file, "r") as hdf5: return hdf5[self.idx_set["geol"] + "/RuptureIndex"][iloc]
def get_centroids(self, ridx): """ :returns: array of centroids for the given rupture index """ centroids = [] with h5py.File(self.source_file, "r") as hdf5: for idx in ridx: trace = "{:s}/{:s}".format(self.idx_set["sec"], str(idx)) cen...
def gen_trace_planes(self, ridx): """ :yields: trace and rupture planes for the given rupture index """ with h5py.File(self.source_file, "r") as hdf5: for idx in ridx: trace = "{:s}/{:s}".format(self.idx_set["sec"], str(idx)) plane = hdf5[trace...
def get_background_sids(self, src_filter): """ We can apply the filtering of the background sites as a pre-processing step - this is done here rather than in the sampling of the ruptures themselves """ branch_key = self.idx_set["grid_key"] idist = src_filter.integ...
def get_ucerf_rupture(self, iloc, src_filter): """ :param iloc: Location of the rupture plane in the hdf5 file :param src_filter: Sites for consideration and maximum distance """ trt = self.tectonic_region_type ridx = self.get_ridx(iloc) ma...
def iter_ruptures(self): """ Yield ruptures for the current set of indices """ assert self.orig, '%s is not fully initialized' % self for ridx in range(self.start, self.stop): if self.orig.rate[ridx]: # ruptures may have have zero rate rup = self.get_...
def get_background_sources(self, src_filter, sample_factor=None): """ Turn the background model of a given branch into a set of point sources :param src_filter: SourceFilter instance :param sample_factor: Used to reduce the sources if OQ_SAMPLE_SOURCES is set ...
def split(src, chunksize=MINWEIGHT): """ Split a complex fault source in chunks """ for i, block in enumerate(block_splitter(src.iter_ruptures(), chunksize, key=operator.attrgetter('mag'))): rup = block[0] source_id = '%s:%d' % (src.source_id,...
def get_bounding_box(self, maxdist): """ Bounding box containing all the hypocenters, enlarged by the maximum distance """ locations = [rup.hypocenter for rup in self.ruptures] return get_bounding_box(locations, maxdist)
def show_attrs(key, calc_id=-1): """ Show the attributes of a HDF5 dataset in the datastore. """ ds = util.read(calc_id) try: attrs = h5py.File.__getitem__(ds.hdf5, key).attrs except KeyError: print('%r is not in %s' % (key, ds)) else: if len(attrs) == 0: ...
def compare_mean_curves(calc_ref, calc, nsigma=3): """ Compare the hazard curves coming from two different calculations. """ dstore_ref = datastore.read(calc_ref) dstore = datastore.read(calc) imtls = dstore_ref['oqparam'].imtls if dstore['oqparam'].imtls != imtls: raise RuntimeError...
def _get_mean(self, sites, C, ln_y_ref, exp1, exp2): """ Add site effects to an intensity. Implements eq. 13b. """ # we do not support estimating of basin depth and instead # rely on it being available (since we require it). # centered_z1pt0 centered_z1pt...
def _get_ln_y_ref(self, rup, dists, C): """ Get an intensity on a reference soil. Implements eq. 13a. """ # reverse faulting flag Frv = 1. if 30 <= rup.rake <= 150 else 0. # normal faulting flag Fnm = 1. if -120 <= rup.rake <= -60 else 0. # hangin...
def _get_centered_z1pt0(self, sites): """ Get z1pt0 centered on the Vs30- dependent avarage z1pt0(m) California and non-Japan regions """ #: California and non-Japan regions mean_z1pt0 = (-7.15 / 4.) * np.log(((sites.vs30) ** 4. + 570.94 ** 4.) ...
def _get_centered_ztor(self, rup, Frv): """ Get ztor centered on the M- dependent avarage ztor(km) by different fault types. """ if Frv == 1: mean_ztor = max(2.704 - 1.226 * max(rup.mag - 5.849, 0.0), 0.) ** 2 centered_ztor = rup.ztor - mean_ztor ...
def _get_stddevs(self, sites, rup, C, stddev_types, ln_y_ref, exp1, exp2): """ Returns the standard deviation, which is fixed at 0.65 for every site """ ret = [] for stddev_type in stddev_types: assert stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES ...
def fine_graining(points, steps): """ :param points: a list of floats :param int steps: expansion steps (>= 2) >>> fine_graining([0, 1], steps=0) [0, 1] >>> fine_graining([0, 1], steps=1) [0, 1] >>> fine_graining([0, 1], steps=2) array([0. , 0.5, 1. ]) >>> fine_graining([0, 1], ...
def build_imls(ff, continuous_fragility_discretization, steps_per_interval=0): """ Build intensity measure levels from a fragility function. If the function is continuous, they are produced simply as a linear space between minIML and maxIML. If the function is discrete, they are generated...
def make_epsilons(matrix, seed, correlation): """ Given a matrix N * R returns a matrix of the same shape N * R obtained by applying the multivariate_normal distribution to N points and R samples, by starting from the given seed and correlation. """ if seed is not None: numpy.random....
def scenario_damage(fragility_functions, gmvs): """ :param fragility_functions: a list of D - 1 fragility functions :param gmvs: an array of E ground motion values :returns: an array of (D, E) damage fractions """ lst = [numpy.ones_like(gmvs)] for f, ff in enumerate(fragility_functions): # ...
def annual_frequency_of_exceedence(poe, t_haz): """ :param poe: array of probabilities of exceedence :param t_haz: hazard investigation time :returns: array of frequencies (with +inf values where poe=1) """ with warnings.catch_warnings(): warnings.simplefilter("ignore") # avoid R...
def classical_damage( fragility_functions, hazard_imls, hazard_poes, investigation_time, risk_investigation_time): """ :param fragility_functions: a list of fragility functions for each damage state :param hazard_imls: Intensity Measure Levels :param hazard_poes: ...
def classical(vulnerability_function, hazard_imls, hazard_poes, loss_ratios): """ :param vulnerability_function: an instance of :py:class:`openquake.risklib.scientific.VulnerabilityFunction` representing the vulnerability function used to compute the curve. :param hazard_imls: ...
def conditional_loss_ratio(loss_ratios, poes, probability): """ Return the loss ratio corresponding to the given PoE (Probability of Exceendance). We can have four cases: 1. If `probability` is in `poes` it takes the bigger corresponding loss_ratios. 2. If it is in `(poe1, poe2)` wher...
def insured_losses(losses, deductible, insured_limit): """ :param losses: an array of ground-up loss ratios :param float deductible: the deductible limit in fraction form :param float insured_limit: the insured limit in fraction form Compute insured losses for the given asset and losses, from the p...
def insured_loss_curve(curve, deductible, insured_limit): """ Compute an insured loss ratio curve given a loss ratio curve :param curve: an array 2 x R (where R is the curve resolution) :param float deductible: the deductible limit in fraction form :param float insured_limit: the insured limit in f...
def bcr(eal_original, eal_retrofitted, interest_rate, asset_life_expectancy, asset_value, retrofitting_cost): """ Compute the Benefit-Cost Ratio. BCR = (EALo - EALr)(1-exp(-r*t))/(r*C) Where: * BCR -- Benefit cost ratio * EALo -- Expected annual loss for original asset * EALr -- E...
def pairwise_mean(values): "Averages between a value and the next value in a sequence" return numpy.array([numpy.mean(pair) for pair in pairwise(values)])
def pairwise_diff(values): "Differences between a value and the next value in a sequence" return numpy.array([x - y for x, y in pairwise(values)])
def mean_std(fractions): """ Given an N x M matrix, returns mean and std computed on the rows, i.e. two M-dimensional vectors. """ n = fractions.shape[0] if n == 1: # avoid warnings when computing the stddev return fractions[0], numpy.ones_like(fractions[0]) * numpy.nan return numpy...
def loss_maps(curves, conditional_loss_poes): """ :param curves: an array of loss curves :param conditional_loss_poes: a list of conditional loss poes :returns: a composite array of loss maps with the same shape """ loss_maps_dt = numpy.dtype([('poe-%s' % poe, F32) ...
def broadcast(func, composite_array, *args): """ Broadcast an array function over a composite array """ dic = {} dtypes = [] for name in composite_array.dtype.names: dic[name] = func(composite_array[name], *args) dtypes.append((name, dic[name].dtype)) res = numpy.zeros(dic[na...
def average_loss(lc): """ Given a loss curve array with `poe` and `loss` fields, computes the average loss on a period of time. :note: As the loss curve is supposed to be piecewise linear as it is a result of a linear interpolation, we compute an exact integral by using the trapei...
def normalize_curves_eb(curves): """ A more sophisticated version of normalize_curves, used in the event based calculator. :param curves: a list of pairs (losses, poes) :returns: first losses, all_poes """ # we assume non-decreasing losses, so losses[-1] is the maximum loss non_zero_cur...
def build_loss_curve_dt(curve_resolution, insured_losses=False): """ :param curve_resolution: dictionary loss_type -> curve_resolution :param insured_losses: configuration parameter :returns: loss_curve_dt """ lc_list = [] for lt in sorted(curve_resolution): C ...
def return_periods(eff_time, num_losses): """ :param eff_time: ses_per_logic_tree_path * investigation_time :param num_losses: used to determine the minimum period :returns: an array of 32 bit periods Here are a few examples: >>> return_periods(1, 1) Traceback (most recent call last): ...
def losses_by_period(losses, return_periods, num_events=None, eff_time=None): """ :param losses: array of simulated losses :param return_periods: return periods of interest :param num_events: the number of events (>= to the number of losses) :param eff_time: investigation_time * ses_per_logic_tree_p...
def interpolate(self, gmvs): """ :param gmvs: array of intensity measure levels :returns: (interpolated loss ratios, interpolated covs, indices > min) """ # gmvs are clipped to max(iml) gmvs_curve = numpy.piecewise( gmvs, [gmvs > self.iml...
def sample(self, means, covs, idxs, epsilons=None): """ Sample the epsilons and apply the corrections to the means. This method is called only if there are nonzero covs. :param means: array of E' loss ratios :param covs: array of E' floats :param id...
def strictly_increasing(self): """ :returns: a new vulnerability function that is strictly increasing. It is built by removing piece of the function where the mean loss ratio is constant. """ imls, mlrs, covs = [], [], [] previous_mlr = None ...
def mean_loss_ratios_with_steps(self, steps): """ Split the mean loss ratios, producing a new set of loss ratios. The new set of loss ratios always includes 0.0 and 1.0 :param int steps: the number of steps we make to go from one loss ratio to the next. For examp...
def _cov_for(self, imls): """ Clip `imls` to the range associated with the support of the vulnerability function and returns the corresponding covariance values by linear interpolation. For instance if the range is [0.005, 0.0269] and the imls are [0.0049, 0.006, 0.027], ...
def loss_ratio_exceedance_matrix(self, loss_ratios): """ Compute the LREM (Loss Ratio Exceedance Matrix). """ # LREM has number of rows equal to the number of loss ratios # and number of columns equal to the number of imls lrem = numpy.empty((len(loss_ratios), len(self.im...
def mean_imls(self): """ Compute the mean IMLs (Intensity Measure Level) for the given vulnerability function. :param vulnerability_function: the vulnerability function where the IMLs (Intensity Measure Level) are taken from. :type vuln_function: :py:class...
def interpolate(self, gmvs): """ :param gmvs: array of intensity measure levels :returns: (interpolated probabilities, zeros, indices > min) """ # gmvs are clipped to max(iml) gmvs_curve = numpy.piecewise( gmvs, [gmvs > self.imls[-1]], [s...
def sample(self, probs, _covs, idxs, epsilons): """ Sample the .loss_ratios with the given probabilities. :param probs: array of E' floats :param _covs: ignored, it is there only for API consistency :param idxs: array of E booleans with E >= E' ...
def build(self, limit_states, discretization, steps_per_interval): """ :param limit_states: a sequence of limit states :param discretization: continouos fragility discretization parameter :param steps_per_interval: steps_per_interval parameter :returns: a populated FragilityFunct...
def build(self, continuous_fragility_discretization, steps_per_interval): """ Return a new FragilityModel instance, in which the values have been replaced with FragilityFunctionList instances. :param continuous_fragility_discretization: configuration parameter :param...
def pair(self, array, stats): """ :return (array, array_stats) if stats, else (array, None) """ if len(self.weights) > 1 and stats: statnames, statfuncs = zip(*stats) array_stats = compute_stats2(array, statfuncs, self.weights) else: array_stat...
def build(self, losses_by_event, stats=()): """ :param losses_by_event: the aggregate loss table with shape R -> (E, L) :param stats: list of pairs [(statname, statfunc), ...] :returns: two arrays with shape (P, R, L) and (P, S, L) """ ...
def build_pair(self, losses, stats): """ :param losses: a list of lists with R elements :returns: two arrays of shape (P, R) and (P, S) respectively """ P, R = len(self.return_periods), len(self.weights) assert len(losses) == R, len(losses) array = numpy.zeros((P,...
def build_maps(self, losses, clp, stats=()): """ :param losses: an array of shape (A, R, P) :param clp: a list of C conditional loss poes :param stats: list of pairs [(statname, statfunc), ...] :returns: an array of loss_maps of shape (A, R, C, LI) """ shp = losse...
def build_loss_maps(self, losses, clp, stats=()): """ :param losses: an array of shape R, E :param clp: a list of C conditional loss poes :param stats: list of pairs [(statname, statfunc), ...] :returns: two arrays of shape (C, R) and (C, S) """ array = numpy.zero...
def store_rlzs_by_grp(dstore): """ Save in the datastore a composite array with fields (grp_id, gsim_id, rlzs) """ lst = [] assoc = dstore['csm_info'].get_rlzs_assoc() for grp, arr in assoc.by_grp().items(): for gsim_id, rlzs in enumerate(arr): lst.append((int(grp[4:]), gsim_...
def compute_gmfs(rupgetter, srcfilter, param, monitor): """ Compute GMFs and optionally hazard curves """ getter = GmfGetter(rupgetter, srcfilter, param['oqparam']) with monitor('getting ruptures'): getter.init() return getter.compute_gmfs_curves(monitor)
def combine_mean_curves(calc_big, calc_small): """ Combine the hazard curves coming from two different calculations. The result will be the hazard curves of calc_big, updated on the sites in common with calc_small with the PoEs of calc_small. For instance: calc_big = USA, calc_small = California ...
def create_geometry(self, input_geometry, mesh_spacing=1.0): ''' If geometry is defined as a numpy array then create instance of nhlib.geo.line.Line class, otherwise if already instance of class accept class :param input_geometry: List of at least two fault edges of...