Search is not available for this dataset
text
stringlengths
75
104k
def purge(calc_id): """ Remove the given calculation. If you want to remove all calculations, use oq reset. """ if calc_id < 0: try: calc_id = datastore.get_calc_ids(datadir)[calc_id] except IndexError: print('Calculation %d not found' % calc_id) r...
def PolygonPatch(polygon, **kwargs): """Constructs a matplotlib patch from a geometric object The `polygon` may be a Shapely or GeoJSON-like object possibly with holes. The `kwargs` are those supported by the matplotlib.patches.Polygon class constructor. Returns an instance of matplotlib.patches.PathPa...
def retreive_sigma_mu_data(self): """ For the general form of the GMPE this retrieves the sigma mu values from the hdf5 file using the "general" model, i.e. sigma mu factors that are independent of the choice of region or depth """ fle = h5py.File(os.path.join(BASE_PATH, ...
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 get_magnitude_scaling(self, C, mag): """ Returns the magnitude scaling term """ d_m = mag - self.CONSTANTS["Mh"] if mag < self.CONSTANTS["Mh"]: return C["e1"] + C["b1"] * d_m + C["b2"] * (d_m ** 2.0) else: return C["e1"] + C["b3"] * d_m
def get_distance_term(self, C, rup, rjb, imt): """ Returns the distance attenuation factor """ h = self._get_h(C, rup.hypo_depth) rval = np.sqrt(rjb ** 2. + h ** 2.) c3 = self.get_distance_coefficients(C, imt) f_r = (C["c1"] + C["c2"] * (rup.mag - self.CONSTANTS[...
def get_distance_coefficients(self, C, imt): """ Returns the c3 term """ c3 = self.c3[imt]["c3"] if self.c3 else C["c3"] return c3
def get_sigma_mu_adjustment(self, C, imt, rup, dists): """ Returns the sigma mu adjustment factor """ if imt.name in "PGA PGV": # PGA and PGV are 2D arrays of dimension [nmags, ndists] sigma_mu = getattr(self, imt.name.lower()) if rup.mag <= self.mags[...
def get_site_amplification(self, C, sites): """ Returns the linear site amplification term depending on whether the Vs30 is observed of inferred """ ampl = np.zeros(sites.vs30.shape) # For observed vs30 sites ampl[sites.vs30measured] = (C["d0_obs"] + C["d1_obs"] *...
def get_stddevs(self, C, stddev_shape, stddev_types, sites): """ Returns the standard deviations, with different site standard deviation for inferred vs. observed vs30 sites. """ stddevs = [] tau = C["tau_event"] sigma_s = np.zeros(sites.vs30measured.shape, dtype=...
def geodetic_distance(lons1, lats1, lons2, lats2, diameter=2*EARTH_RADIUS): """ Calculate the geodetic distance between two points or two collections of points. Parameters are coordinates in decimal degrees. They could be scalar float numbers or numpy arrays, in which case they should "broadcast ...
def azimuth(lons1, lats1, lons2, lats2): """ Calculate the azimuth between two points or two collections of points. Parameters are the same as for :func:`geodetic_distance`. Implements an "alternative formula" from http://williams.best.vwh.net/avform.htm#Crs :returns: Azimuth as an an...
def distance(lons1, lats1, depths1, lons2, lats2, depths2): """ Calculate a distance between two points (or collections of points) considering points' depth. Calls :func:`geodetic_distance`, finds the "vertical" distance between points by subtracting one depth from another and combine both using ...
def min_distance_to_segment(seglons, seglats, lons, lats): """ This function computes the shortest distance to a segment in a 2D reference system. :parameter seglons: A list or an array of floats specifying the longitude values of the two vertexes delimiting the segment. :parameter ...
def spherical_to_cartesian(lons, lats, depths=None): """ Return the position vectors (in Cartesian coordinates) of list of spherical coordinates. For equations see: http://mathworld.wolfram.com/SphericalCoordinates.html. Parameters are components of spherical coordinates in a form of scalars, ...
def min_geodetic_distance(a, b): """ Compute the minimum distance between first mesh and each point of the second mesh when both are defined on the earth surface. :param a: a pair of (lons, lats) or an array of cartesian coordinates :param b: a pair of (lons, lats) or an array of cartesian coordina...
def distance_matrix(lons, lats, diameter=2*EARTH_RADIUS): """ :param lons: array of m longitudes :param lats: array of m latitudes :returns: matrix of (m, m) distances """ m = len(lons) assert m == len(lats), (m, len(lats)) lons = numpy.radians(lons) lats = numpy.radians(lats) co...
def intervals_between(lon1, lat1, depth1, lon2, lat2, depth2, length): """ Find a list of points between two given ones that lie on the same great circle arc and are equally spaced by ``length`` km. :param float lon1, lat1, depth1: Coordinates of a point to start placing intervals from. The fir...
def npoints_between(lon1, lat1, depth1, lon2, lat2, depth2, npoints): """ Find a list of specified number of points between two given ones that are equally spaced along the great circle arc connecting given points. :param float lon1, lat1, depth1: Coordinates of a point to start from. The first...
def npoints_towards(lon, lat, depth, azimuth, hdist, vdist, npoints): """ Find a list of specified number of points starting from a given one along a great circle arc with a given azimuth measured in a given point. :param float lon, lat, depth: Coordinates of a point to start from. The first po...
def point_at(lon, lat, azimuth, distance): """ Perform a forward geodetic transformation: find a point lying at a given distance from a given one on a great circle arc defined by azimuth. :param float lon, lat: Coordinates of a reference point, in decimal degrees. :param azimuth: An...
def distance_to_semi_arc(alon, alat, aazimuth, plons, plats): """ In this method we use a reference system centerd on (alon, alat) and with the y-axis corresponding to aazimuth direction to calculate the minimum distance from a semiarc with generates in (alon, alat). Parameters are the same as for ...
def distance_to_arc(alon, alat, aazimuth, plons, plats): """ Calculate a closest distance between a great circle arc and a point (or a collection of points). :param float alon, alat: Arc reference point longitude and latitude, in decimal degrees. :param azimuth: Arc azimuth (an angl...
def _prepare_coords(lons1, lats1, lons2, lats2): """ Convert two pairs of spherical coordinates in decimal degrees to numpy arrays of radians. Makes sure that respective coordinates in pairs have the same shape. """ lons1 = numpy.radians(lons1) lats1 = numpy.radians(lats1) assert lons1.s...
def _check_seismogenic_depths(self, upper_depth, lower_depth): ''' Checks the seismic depths for physical consistency :param float upper_depth: Upper seismogenic depth (km) :param float lower_depth: Lower seismogenic depth (km) ''' # Simple check ...
def create_geometry(self, input_geometry, dip, upper_depth, lower_depth, 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_geo...
def select_catalogue(self, selector, distance, distance_metric='joyner-boore', upper_eq_depth=None, lower_eq_depth=None): ''' Selects earthquakes within a distance of the fault :param selector: Populated instance of :class: ...
def create_oqhazardlib_source(self, tom, mesh_spacing, use_defaults=False): """ Returns an instance of the :class: `openquake.hazardlib.source.simple_fault.SimpleFaultSource` :param tom: Temporal occurrance model :param float mesh_spacing: Mesh spacing ...
def plot_recurrence_models( configs, area, slip, msr, rake, shear_modulus=30.0, disp_length_ratio=1.25E-5, msr_sigma=0., figure_size=(8, 6), filename=None, filetype='png', dpi=300, ax=None): """ Plots a set of recurrence models :param list configs: List of configuration dict...
def build_area_source_geometry(area_source): """ Returns the area source geometry as a Node :param area_source: Area source model as an instance of the :class: `openquake.hazardlib.source.area.AreaSource` :returns: Instance of :class:`openquake.baselib.node.Node` """ geo...
def build_point_source_geometry(point_source): """ Returns the poing source geometry as a Node :param point_source: Point source model as an instance of the :class: `openquake.hazardlib.source.point.PointSource` :returns: Instance of :class:`openquake.baselib.node.Node` """ ...
def build_linestring_node(line, with_depth=False): """ Parses a line to a Node class :param line: Line as instance of :class:`openquake.hazardlib.geo.line.Line` :param bool with_depth: Include the depth values (True) or not (False): :returns: Instance of :class:`openquake.ba...
def build_simple_fault_geometry(fault_source): """ Returns the simple fault source geometry as a Node :param fault_source: Simple fault source model as an instance of the :class: `openquake.hazardlib.source.simple_fault.SimpleFaultSource` :returns: Instance of :class:`openquake....
def build_complex_fault_geometry(fault_source): """ Returns the complex fault source geometry as a Node :param fault_source: Complex fault source model as an instance of the :class: `openquake.hazardlib.source.complex_fault.ComplexFaultSource` :returns: Instance of :class:`openq...
def build_evenly_discretised_mfd(mfd): """ Returns the evenly discretized MFD as a Node :param mfd: MFD as instance of :class: `openquake.hazardlib.mfd.evenly_discretized.EvenlyDiscretizedMFD` :returns: Instance of :class:`openquake.baselib.node.Node` """ occur_rates = N...
def build_truncated_gr_mfd(mfd): """ Parses the truncated Gutenberg Richter MFD as a Node :param mfd: MFD as instance of :class: `openquake.hazardlib.mfd.truncated_gr.TruncatedGRMFD` :returns: Instance of :class:`openquake.baselib.node.Node` """ return Node("truncGutenbe...
def build_arbitrary_mfd(mfd): """ Parses the arbitrary MFD as a Node :param mfd: MFD as instance of :class: `openquake.hazardlib.mfd.arbitrary.ArbitraryMFD` :returns: Instance of :class:`openquake.baselib.node.Node` """ magnitudes = Node("magnitudes", text=mfd.magnitudes...
def build_youngs_coppersmith_mfd(mfd): """ Parses the Youngs & Coppersmith MFD as a node. Note that the MFD does not hold the total moment rate, but only the characteristic rate. Therefore the node is written to the characteristic rate version regardless of whether or not it was originally created f...
def build_multi_mfd(mfd): """ Parses the MultiMFD as a Node :param mfd: MFD as instance of :class: `openquake.hazardlib.mfd.multi_mfd.MultiMFD` :returns: Instance of :class:`openquake.baselib.node.Node` """ node = Node("multiMFD", dict(kind=mfd.kind, size=mfd.size)) ...
def build_nodal_plane_dist(npd): """ Returns the nodal plane distribution as a Node instance :param npd: Nodal plane distribution as instance of :class: `openquake.hazardlib.pmf.PMF` :returns: Instance of :class:`openquake.baselib.node.Node` """ npds = [] for prob, n...
def build_hypo_depth_dist(hdd): """ Returns the hypocentral depth distribution as a Node instance :param hdd: Hypocentral depth distribution as an instance of :class: `openquake.hzardlib.pmf.PMF` :returns: Instance of :class:`openquake.baselib.node.Node` """ hdds = [] ...
def get_distributed_seismicity_source_nodes(source): """ Returns list of nodes of attributes common to all distributed seismicity source classes :param source: Seismic source as instance of :class: `openquake.hazardlib.source.area.AreaSource` or :class: `openquake.hazardlib.sour...
def build_hypo_list_node(hypo_list): """ :param hypo_list: an array of shape (N, 3) with columns (alongStrike, downDip, weight) :returns: a hypoList node containing N hypo nodes """ hypolist = Node('hypoList', {}) for row in hypo_list: n = Node( 'hypo', dict(al...
def build_slip_list_node(slip_list): """ :param slip_list: an array of shape (N, 2) with columns (slip, weight) :returns: a hypoList node containing N slip nodes """ sliplist = Node('slipList', {}) for row in slip_list: sliplist.append( Node('slip', dict(weight...
def get_fault_source_nodes(source): """ Returns list of nodes of attributes common to all fault source classes :param source: Fault source as instance of :class: `openquake.hazardlib.source.simple_fault.SimpleFaultSource` or :class: `openquake.hazardlib.source.complex_fault.ComplexF...
def get_source_attributes(source): """ Retreives a dictionary of source attributes from the source class :param source: Seismic source as instance of :class: `openquake.hazardlib.source.base.BaseSeismicSource` :returns: Dictionary of source attributes """ attrs = {"id": ...
def build_area_source_node(area_source): """ Parses an area source to a Node class :param area_source: Area source as instance of :class: `openquake.hazardlib.source.area.AreaSource` :returns: Instance of :class:`openquake.baselib.node.Node` """ # parse geometry sour...
def build_rupture_node(rupt, probs_occur): """ :param rupt: a hazardlib rupture object :param probs_occur: a list of floats with sum 1 """ s = sum(probs_occur) if abs(s - 1) > pmf.PRECISION: raise ValueError('The sum of %s is not 1: %s' % (probs_occur, s)) h = rupt.hypocenter hp_...
def build_multi_point_source_node(multi_point_source): """ Parses a point source to a Node class :param point_source: MultiPoint source as instance of :class: `openquake.hazardlib.source.point.MultiPointSource` :returns: Instance of :class:`openquake.baselib.node.Node` """ ...
def build_point_source_node(point_source): """ Parses a point source to a Node class :param point_source: Point source as instance of :class: `openquake.hazardlib.source.point.PointSource` :returns: Instance of :class:`openquake.baselib.node.Node` """ # parse geometry ...
def build_simple_fault_source_node(fault_source): """ Parses a simple fault source to a Node class :param fault_source: Simple fault source as instance of :class: `openquake.hazardlib.source.simple_fault.SimpleFaultSource` :returns: Instance of :class:`openquake.baselib.node.Nod...
def build_complex_fault_source_node(fault_source): """ Parses a complex fault source to a Node class :param fault_source: Simple fault source as instance of :class: `openquake.hazardlib.source.complex_fault.ComplexFaultSource` :returns: Instance of :class:`openquake.baselib.node...
def write_source_model(dest, sources_or_groups, name=None, investigation_time=None): """ Writes a source model to XML. :param dest: Destination path :param sources_or_groups: Source model in different formats :param name: Name of the source model (if m...
def hdf5write(h5file, obj, root=''): """ Write a generic object serializable to a Node-like object into a :class: `openquake.baselib.hdf5.File` """ dic = node_to_dict(obj_to_node(obj)) h5file.save(dic, root)
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types): # pylint: disable=too-many-arguments """ See :meth:`superclass method <.base.GroundShakingIntensityModel.get_mean_and_stddevs>` for specification of input and result values. """ # extract dicti...
def _get_stddevs(self, coeffs, stddev_types, num_sites): """ Return total sigma as reported in Table 2, p. 1202. """ stddevs = [] for stddev_type in stddev_types: assert stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES stddevs.append(coeffs['sigma'...
def _compute_distance(cls, dists, coeffs): """ Compute third term of equation (1) on p. 1200: ``b3 * log(sqrt(Rjb ** 2 + b4 ** 2))`` """ return coeffs['b3']*np.log10(np.sqrt(dists.rjb**2. + coeffs['b4']**2.))
def _get_site_amplification(self, sites, coeffs): """ Compute fourth term of equation (1) on p. 1200: ``b5 * S`` """ is_rock = self.get_site_type_dummy_variables(sites) return coeffs['b5']*is_rock
def _get_mechanism(self, rup, coeffs): """ Compute fifth term of equation (1) on p. 1200: ``b6 * H`` """ is_strike_slip = self.get_fault_type_dummy_variables(rup) return coeffs['b6']*is_strike_slip
def get_site_type_dummy_variables(self, sites): """ Binary rock/soil classification dummy variable based on sites.vs30. "``S`` is 1 for a rock site and 0 otherwise" (p. 1201). """ is_rock = np.array(sites.vs30 > self.NEHRP_BC_BOUNDARY) return is_rock
def get_fault_type_dummy_variables(self, rup): """ Fault-type classification dummy variable based on rup.rake. "``H`` is 1 for a strike-slip mechanism and 0 for a reverse mechanism" (p. 1201). Note: UserWarning is raised if mechanism is determined to be normal ...
def read_data(self, scaling_factor=1E-9, strain_headers=None): ''' Reads the data from the csv file :param float scaling_factor: Scaling factor used for all strain values (default 1E-9 for nanostrain) :param list strain_headers: List of the variables...
def _check_invalid_longitudes(self): ''' Checks to ensure that all longitudes are in the range -180. to 180 ''' idlon = self.strain.data['longitude'] > 180. if np.any(idlon): self.strain.data['longitude'][idlon] = \ self.strain.data['longitude'][idlon]...
def write_file(self, strain, scaling_factor=1E-9): ''' Main writer function for the csv file :param strain: Instance of :class: openquake.hmtk.strain.geodetic_strain.GeodeticStrain :param float scaling_factor: Scaling factor used for all strain values (default 1E...
def slice_rates_to_data(self, strain): ''' For the strain data, checks to see if seismicity rates have been calculated. If so, each column in the array is sliced and stored as a single vector in the strain.data dictionary with the corresponding magnitude as a key. :param...
def read(*paths, **validators): """ Load the configuration, make each section available in a separate dict. The configuration location can specified via an environment variable: - OQ_CONFIG_FILE In the absence of this environment variable the following paths will be used: - sys.prefi...
def boolean(flag): """ Convert string in boolean """ s = flag.lower() if s in ('1', 'yes', 'true'): return True elif s in ('0', 'no', 'false'): return False raise ValueError('Unknown flag %r' % s)
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. """ mean = self._get_mean(sites.vs30, rup.mag, dists.rrup, imt, scale_fac=...
def _get_mean(self, vs30, mag, rrup, imt, scale_fac): """ Compute and return mean """ C_HR, C_BC, C_SR, SC = self._extract_coeffs(imt) rrup = self._clip_distances(rrup) f0 = self._compute_f0_factor(rrup) f1 = self._compute_f1_factor(rrup) f2 = self._comp...
def _get_pga_bc(self, f0, f1, f2, SC, mag, rrup, vs30, scale_fac): """ Compute and return PGA on BC boundary """ pga_bc = np.zeros_like(vs30) self._compute_mean(self.COEFFS_BC[PGA()], f0, f1, f2, SC, mag, rrup, vs30 < 2000.0, pga_bc, scale_fac) ...
def _extract_coeffs(self, imt): """ Extract dictionaries of coefficients specific to required intensity measure type. """ C_HR = self.COEFFS_HARD_ROCK[imt] C_BC = self.COEFFS_BC[imt] C_SR = self.COEFFS_SOIL_RESPONSE[imt] SC = self.COEFFS_STRESS[imt] ...
def _compute_f0_factor(self, rrup): """ Compute and return factor f0 - see equation (5), 6th term, p. 2191. """ # f0 = max(log10(R0/rrup),0) f0 = np.log10(self.COEFFS_IMT_INDEPENDENT['R0'] / rrup) f0[f0 < 0] = 0.0 return f0
def _compute_f1_factor(self, rrup): """ Compute and return factor f1 - see equation (5), 4th term, p. 2191 """ # f1 = min(log10(rrup),log10(R1)) f1 = np.log10(rrup) logR1 = np.log10(self.COEFFS_IMT_INDEPENDENT['R1']) f1[f1 > logR1] = logR1 return f1
def _compute_f2_factor(self, rrup): """ Compute and return factor f2, see equation (5), 5th term, pag 2191 """ # f2 = max(log10(rrup/R2),0) f2 = np.log10(rrup / self.COEFFS_IMT_INDEPENDENT['R2']) f2[f2 < 0] = 0.0 return f2
def _compute_stress_drop_adjustment(self, SC, mag, scale_fac): """ Compute equation (6) p. 2200 """ return scale_fac * np.minimum( SC['delta'] + 0.05, 0.05 + SC['delta'] * ( np.maximum(mag - SC['M1'], 0) / (SC['Mh'] - SC['M1']) ) ...
def _compute_mean(self, C, f0, f1, f2, SC, mag, rrup, idxs, mean, scale_fac): """ Compute mean value (for a set of indexes) without site amplification terms. This is equation (5), p. 2191, without S term. """ mean[idxs] = (C['c1'] + C['...
def _compute_soil_amplification(self, C, vs30, pga_bc, mean): """ Compute soil amplification, that is S term in equation (5), p. 2191, and add to mean values for non hard rock sites. """ # convert from base e (as defined in BA2008) to base 10 (as used in # AB2006) ...
def _get_stress_drop_scaling_factor(self, magnitude): """ Returns the magnitude dependent stress drop scaling factor defined in equation 6 (page 1128) of Atkinson & Boore (2011) """ stress_drop = 10.0 ** (3.45 - 0.2 * magnitude) cap = 10.0 ** (3.45 - 0.2 * 5.0) if...
def clip_mean(imt, mean): """ Clip GMPE mean value at 1.5 g for PGA and 3 g for short periods (0.02 < T < 0.55) """ if imt.period == 0: mean[mean > 0.405] = 0.405 if 0.02 < imt.period < 0.55: mean[mean > 1.099] = 1.099 return mean
def gen_rupture_getters(dstore, slc=slice(None), concurrent_tasks=1, hdf5cache=None): """ :yields: RuptureGetters """ if dstore.parent: dstore = dstore.parent csm_info = dstore['csm_info'] trt_by_grp = csm_info.grp_by("trt") samples = csm_info.get_samples_by_g...
def get_maxloss_rupture(dstore, loss_type): """ :param dstore: a DataStore instance :param loss_type: a loss type string :returns: EBRupture instance corresponding to the maximum loss for the given loss type """ lti = dstore['oqparam'].lti[loss_type] ridx = dstore.get_attr('r...
def init(self): """ Read the poes and set the .data attribute with the hazard curves """ if hasattr(self, 'data'): # already initialized return if isinstance(self.dstore, str): self.dstore = hdf5.File(self.dstore, 'r') else: self.dstor...
def pmap_by_grp(self): """ :returns: dictionary "grp-XXX" -> ProbabilityMap instance """ if hasattr(self, '_pmap_by_grp'): # already called return self._pmap_by_grp # populate _pmap_by_grp self._pmap_by_grp = {} if 'poes' in self.dstore: #...
def get(self, rlzi, grp=None): """ :param rlzi: a realization index :param grp: None (all groups) or a string of the form "grp-XX" :returns: the hazard curves for the given realization """ self.init() assert self.sids is not None pmap = probability_map.Pro...
def get_hcurves(self, imtls=None): """ :param imtls: intensity measure types and levels :returns: an array of (R, N) hazard curves """ self.init() if imtls is None: imtls = self.imtls pmaps = [pmap.convert2(imtls, self.sids) for pmap i...
def items(self, kind=''): """ Extract probability maps from the datastore, possibly generating on the fly the ones corresponding to the individual realizations. Yields pairs (tag, pmap). :param kind: the kind of PoEs to extract; if not given, returns the realization ...
def get_mean(self, grp=None): """ Compute the mean curve as a ProbabilityMap :param grp: if not None must be a string of the form "grp-XX"; in that case returns the mean considering only the contribution for group XX """ self.init() if len(self.we...
def init(self): """ Initialize the computers. Should be called on the workers """ if hasattr(self, 'computers'): # init already called return with hdf5.File(self.rupgetter.filename, 'r') as parent: self.weights = parent['weights'].value self.compu...
def gen_gmfs(self): """ Compute the GMFs for the given realization and yields arrays of the dtype (sid, eid, imti, gmv), one for rupture """ self.sig_eps = [] for computer in self.computers: rup = computer.rupture sids = computer.sids e...
def get_gmfdata(self): """ :returns: an array of the dtype (sid, eid, imti, gmv) """ alldata = list(self.gen_gmfs()) if not alldata: return numpy.zeros(0, self.gmv_dt) return numpy.concatenate(alldata)
def get_hazard(self, data=None): """ :param data: if given, an iterator of records of dtype gmf_dt :returns: sid -> records """ if data is None: data = self.get_gmfdata() return general.group_array(data, 'sid')
def compute_gmfs_curves(self, monitor): """ :returns: a dict with keys gmfdata, indices, hcurves """ oq = self.oqparam with monitor('GmfGetter.init', measuremem=True): self.init() hcurves = {} # key -> poes if oq.hazard_curves_from_gmfs: h...
def set_weights(self, src_filter, num_taxonomies_by_site): """ :returns: the weights of the ruptures in the getter """ weights = [] for rup in self.rup_array: sids = src_filter.close_sids(rup, self.trt, rup['mag']) weights.append(num_taxonomies_by_site[sid...
def split(self, maxweight): """ :yields: RuptureGetters with weight <= maxweight """ # NB: can be called only after .set_weights() has been called idx = {ri: i for i, ri in enumerate(self.rup_indices)} for rup_indices in general.block_splitter( self.rup_in...
def get_eid_rlz(self, monitor=None): """ :returns: a composite array with the associations eid->rlz """ eid_rlz = [] for rup in self.rup_array: ebr = EBRupture(mock.Mock(serial=rup['serial']), rup['srcidx'], self.grp_id, rup['n_occ'], self....
def get_rupdict(self): """ :returns: a dictionary with the parameters of the rupture """ assert len(self.rup_array) == 1, 'Please specify a slice of length 1' dic = {'trt': self.trt, 'samples': self.samples} with datastore.read(self.filename) as dstore: rupgeo...
def get_ruptures(self, srcfilter=calc.filters.nofilter): """ :returns: a list of EBRuptures filtered by bounding box """ ebrs = [] with datastore.read(self.filename) as dstore: rupgeoms = dstore['rupgeoms'] for rec in self.rup_array: if src...
def E2R(self, array, rlzi): """ :param array: an array of shape (E, ...) :param rlzi: an array of E realization indices :returns: an aggregated array of shape (R, ...) """ z = numpy.zeros((self.num_rlzs,) + array.shape[1:], array.dtype) for a, r in zip(array, rlzi...
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 _get_magnitude_scaling(self, C, mag): """ Implements the magnitude scaling function F(M) presented in equation 4 """ if mag < self.CONSTANTS["mh"]: return C["e1"] + C["b1"] * (mag - self.CONSTANTS["mref"]) +\ C["b2"] * ((mag - self.CONSTANTS["mref"]) ** 2....