Search is not available for this dataset
text
stringlengths
75
104k
def _get_distance_scaling(self, C, dists, mag): """ Implements the distance scaling function F(M, R) presented in equations 2 and 3. In the case of Joyner-Boore distance then the fixed-depth term h is required """ r_h = self._get_rh(C, dists) return (C["c1"] + C["...
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. """ # Distance term R = np.sqrt(dists.rjb ** 2 + 11.29 ** 2) ...
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. """ # assign constant log10e = np.log10(np.e) # Distance...
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(self, rup, dists, C): """ equation 3 pag 1960: ``c31 * logR + c32 * (R-Rref)`` """ rref = 1.0 c31 = -1.7 return (c31 * np.log10(dists.rhypo) + C['c32'] * (dists.rhypo - rref))
def _compute_magnitude(self, rup, C): """ equation 3 pag 1960: c1 + c2(M-5.5) """ m_h = 5.5 return C['c1'] + (C['c2'] * (rup.mag - m_h))
def _get_site_amplification(self, sites, C): """ Compute the fourth term of the equation 3: The functional form Fs in Eq. (1) represents the site amplification and it is given by FS = c61*S + c62*SS , where c61 and c62 are the coefficients to be determined through the regression ...
def _get_site_type_dummy_variables(self, sites): """ Get site type dummy variables, three different site classes, based on the shear wave velocity intervals in the uppermost 30 m, Vs30, according to the NEHRP: class A-B: Vs30 > 760 m/s class C: Vs30 = 360 − 760 m/s ...
def _compute_forearc_backarc_term(self, C, sites, dists, rup): """ Compute back-arc term of Equation 3 """ # flag 1 (R < 335 & R >= 205) flag1 = np.zeros(len(dists.rhypo)) ind1 = np.logical_and((dists.rhypo < 335), (dists.rhypo >= 205)) flag1[ind1] = 1.0 ...
def _build_data(self, amplification_group): """ Creates the numpy array tables from the hdf5 tables """ # Determine shape of the tables n_levels = len(amplification_group) # Checks the first group in the amplification group and returns the # shape of the SA array ...
def get_amplification_factors(self, imt, sctx, rctx, dists, stddev_types): """ Returns the amplification factors for the given rupture and site conditions. :param imt: Intensity measure type as an instance of the :class: `openquake.hazardlib.imt` :param s...
def get_mean_table(self, imt, rctx): """ Returns amplification factors for the mean, given the rupture and intensity measure type. :returns: amplification table as an array of [Number Distances, Number Levels] """ # Levels by Distances if ...
def get_sigma_tables(self, imt, rctx, stddev_types): """ Returns modification factors for the standard deviations, given the rupture and intensity measure type. :returns: List of standard deviation modification tables, each as an array of [Number Distances, Numbe...
def init(self, fle=None): """ Executes the preprocessing steps at the instantiation stage to read in the tables from hdf5 and hold them in memory. """ if fle is None: fname = self.kwargs.get('gmpe_table', self.GMPE_TABLE) if fname is None: ...
def _setup_standard_deviations(self, fle): """ Reads the standard deviation tables from hdf5 and stores them in memory :param fle: HDF5 Tables as instance of :class:`h5py.File` """ # Load in total standard deviation self.stddevs = {} self.stdde...
def _setup_amplification(self, fle): """ If amplification data is specified then reads into memory and updates the required rupture and site parameters """ self.amplification = AmplificationTable(fle["Amplification"], self.m_w, ...
def _supported_imts(self): """ Updates the list of supported IMTs from the tables """ imt_list = [] for key in self.imls: if "SA" in key: imt_list.append(imt_module.SA) elif key == "T": continue else: ...
def get_mean_and_stddevs(self, sctx, rctx, dctx, imt, stddev_types): """ Returns the mean and standard deviations """ # Return Distance Tables imls = self._return_tables(rctx.mag, imt, "IMLs") # Get distance vector for the given magnitude idx = numpy.searchsorted(...
def _get_mean(self, data, dctx, dists): """ Returns the mean intensity measure level from the tables :param data: The intensity measure level vector for the given magnitude and IMT :param key: The distance type :param distances: The distance ve...
def _get_stddevs(self, dists, mag, dctx, imt, stddev_types): """ Returns the total standard deviation of the intensity measure level from the tables. :param fle: HDF5 data stream as instance of :class:`h5py.File` :param distances: The distance vector for ...
def _return_tables(self, mag, imt, val_type): """ Returns the vector of ground motions or standard deviations corresponding to the specific magnitude and intensity measure type. :param val_type: String indicating the type of data {"IMLs", "Total", "Inter" etc} """ ...
def apply_magnitude_interpolation(self, mag, iml_table): """ Interpolates the tables to the required magnitude level :param float mag: Magnitude :param iml_table: Intensity measure level table """ # do not allow "mag" to exceed maximum table magni...
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. """ assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES ...
def _get_mean_deep_soil(self, mag, rake, rrup, is_reverse, imt): """ Calculate and return the mean intensity for deep soil sites. Implements an equation from table 4. """ if mag <= self.NEAR_FIELD_SATURATION_MAG: c4 = self.COEFFS_SOIL_IMT_INDEPENDENT['c4lowmag'] ...
def _get_mean_rock(self, mag, _rake, rrup, is_reverse, imt): """ Calculate and return the mean intensity for rock sites. Implements an equation from table 2. """ if mag <= self.NEAR_FIELD_SATURATION_MAG: C = self.COEFFS_ROCK_LOWMAG[imt] else: C = ...
def _get_stddev_rock(self, mag, imt): """ Calculate and return total standard deviation for rock sites. Implements formulae from table 3. """ C = self.COEFFS_ROCK_STDDERR[imt] if mag > C['maxmag']: return C['maxsigma'] else: return C['sigm...
def _get_stddev_deep_soil(self, mag, imt): """ Calculate and return total standard deviation for deep soil sites. Implements formulae from the last column of table 4. """ # footnote from table 4 says that stderr for magnitudes over 7 # is equal to one of magnitude 7. ...
def zip(what, archive_zip='', risk_file=''): """ Zip into an archive one or two job.ini files with all related files """ if os.path.isdir(what): oqzip.zip_all(what) elif what.endswith('.xml') and '<logicTree' in open(what).read(512): # hack to see if the NRML file is of kind logicTre...
def reduce(fname, reduction_factor): """ Produce a submodel from `fname` by sampling the nodes randomly. Supports source models, site models and exposure models. As a special case, it is also able to reduce .csv files by sampling the lines. This is a debugging utility to reduce large computations to...
def get_mfd(self, slip, area, shear_modulus=30.0): ''' Calculates activity rate on the fault :param float slip: Slip rate in mm/yr :param area: Width of the fault (km) :param float shear_modulus: Shear modulus of the fault (GPa) :re...
def cumulative_value(self, mag_val, moment_rate, beta, moment_mag): ''' Calculates the cumulative rate of events with M > m0 using equation 11 of Youngs & Coppersmith (1985) :param float mag_val: Magnitude :param float moment_rate: Moment rate on fault (...
def get_mfd(self, slip, area, shear_modulus=30.0): ''' Calculates activity rate on the fault :param float slip: Slip rate in mm/yr :param area: Area of the fault (km) :param float shear_modulus: Shear modulus of the fault (GPa) :ret...
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, rup, dists, imt, stddev_types) st...
def _get_mean(self, sites, rup, dists, imt, stddev_types): """ See :meth:`superclass method <.base.GroundShakingIntensityModel.get_mean_and_stddevs>` for spec of input and result values. """ # Zhao et al. 2006 - Vs30 + Rrup mean_zh06, stds1 = super().get_mean_and_...
def _find_turning_points(mesh, tol=1.0): """ Identifies the turning points in a rectangular mesh based on the deviation in the azimuth between successive points on the upper edge. A turning point is flagged if the change in azimuth change is greater than the specified tolerance (in degrees) :pa...
def downsample_mesh(mesh, tol=1.0): """ Returns a mesh sampled at a lower resolution - if the difference in azimuth is larger than the specified tolerance a turn is assumed :returns: Downsampled mesh as instance of :class: openquake.hazardlib.geo.mesh.RectangularMesh """ idx = _...
def downsample_trace(mesh, tol=1.0): """ Downsamples the upper edge of a fault within a rectangular mesh, retaining node points only if changes in direction on the order of tol are found :returns: Downsampled edge as a numpy array of [long, lat, depth] """ idx = _find_turning_points(mes...
def get_ry0_distance(self, mesh): """ Compute the minimum distance between each point of a mesh and the great circle arcs perpendicular to the average strike direction of the fault trace and passing through the end-points of the trace. :param mesh: :class:`~openquake...
def get_rx_distance(self, mesh): """ Compute distance between each point of mesh and surface's great circle arc. Distance is measured perpendicular to the rupture strike, from the surface projection of the updip edge of the rupture, with the down dip direction being posi...
def get_top_edge_depth(self): """ Return minimum depth of surface's top edge. :returns: Float value, the vertical distance between the earth surface and the shallowest point in surface's top edge in km. """ top_edge = self.mesh[0:1] if top_edge.de...
def get_area(self): """ Compute area as the sum of the mesh cells area values. """ mesh = self.mesh _, _, _, area = mesh.get_cell_dimensions() return numpy.sum(area)
def get_bounding_box(self): """ Compute surface bounding box from surface mesh representation. That is extract longitudes and latitudes of mesh points and calls: :meth:`openquake.hazardlib.geo.utils.get_spherical_bounding_box` :return: A tuple of four items. These it...
def get_surface_boundaries(self): """ Returns the boundaries in the same format as a multiplanar surface, with two one-element lists of lons and lats """ mesh = self.mesh lons = numpy.concatenate((mesh.lons[0, :], mesh.lons[1:, -1], ...
def get_resampled_top_edge(self, angle_var=0.1): """ This methods computes a simplified representation of a fault top edge by removing the points that are not describing a change of direction, provided a certain tolerance angle. :param float angle_var: Number represe...
def get_hypo_location(self, mesh_spacing, hypo_loc=None): """ The method determines the location of the hypocentre within the rupture :param mesh: :class:`~openquake.hazardlib.geo.mesh.Mesh` of points :param mesh_spacing: The desired distance between two adjacent...
def get_azimuth(self, mesh): """ This method computes the azimuth of a set of points in a :class:`openquake.hazardlib.geo.mesh` instance. The reference used for the calculation of azimuth is the middle point and the strike of the rupture. The value of azimuth computed corresponds...
def export_avg_losses(ekey, dstore): """ :param ekey: export key, i.e. a pair (datastore key, fmt) :param dstore: datastore object """ dskey = ekey[0] oq = dstore['oqparam'] dt = oq.loss_dt() name, value, tags = _get_data(dstore, dskey, oq.hazard_stats().items()) writer = writers.Csv...
def export_agg_losses(ekey, dstore): """ :param ekey: export key, i.e. a pair (datastore key, fmt) :param dstore: datastore object """ dskey = ekey[0] oq = dstore['oqparam'] dt = oq.loss_dt() name, value, tags = _get_data(dstore, dskey, oq.hazard_stats().items()) writer = writers.Csv...
def export_avg_losses_ebrisk(ekey, dstore): """ :param ekey: export key, i.e. a pair (datastore key, fmt) :param dstore: datastore object """ name = ekey[0] oq = dstore['oqparam'] dt = oq.loss_dt() value = dstore[name].value # shape (A, L) writer = writers.CsvWriter(fmt=writers.FIVE...
def export_losses_by_asset(ekey, dstore): """ :param ekey: export key, i.e. a pair (datastore key, fmt) :param dstore: datastore object """ loss_dt = dstore['oqparam'].loss_dt(stat_dt) losses_by_asset = dstore[ekey[0]].value rlzs = dstore['csm_info'].get_rlzs_assoc().realizations assets ...
def export_losses_by_event(ekey, dstore): """ :param ekey: export key, i.e. a pair (datastore key, fmt) :param dstore: datastore object """ oq = dstore['oqparam'] writer = writers.CsvWriter(fmt=writers.FIVEDIGITS) dest = dstore.build_fname('losses_by_event', '', 'csv') if oq.calculation_...
def export_losses_by_asset_npz(ekey, dstore): """ :param ekey: export key, i.e. a pair (datastore key, fmt) :param dstore: datastore object """ fname = dstore.export_path('%s.%s' % ekey) savez(fname, **dict(extract(dstore, 'losses_by_asset'))) return [fname]
def export_maxloss_ruptures(ekey, dstore): """ :param ekey: export key, i.e. a pair (datastore key, fmt) :param dstore: datastore object """ oq = dstore['oqparam'] mesh = get_mesh(dstore['sitecol']) rlzs_by_gsim = dstore['csm_info'].get_rlzs_by_gsim_grp() num_ses = oq.ses_per_logic_tree_...
def export_agg_losses_ebr(ekey, dstore): """ :param ekey: export key, i.e. a pair (datastore key, fmt) :param dstore: datastore object """ if 'ruptures' not in dstore: logging.warning('There are no ruptures in the datastore') return [] name, ext = export.keyfunc(ekey) agg_los...
def export_dmg_by_event(ekey, dstore): """ :param ekey: export key, i.e. a pair (datastore key, fmt) :param dstore: datastore object """ damage_dt = build_damage_dt(dstore, mean_std=False) dt_list = [('event_id', numpy.uint64), ('rlzi', numpy.uint16)] + [ (f, damage_dt.fields[f][0]) for ...
def get_loss_maps(dstore, kind): """ :param dstore: a DataStore instance :param kind: 'rlzs' or 'stats' """ oq = dstore['oqparam'] name = 'loss_maps-%s' % kind if name in dstore: # event_based risk return _to_loss_maps(dstore[name].value, oq.loss_maps_dt()) name = 'loss_curves-%...
def get_paths(rlz): """ :param rlz: a logic tree realization (composite or simple) :returns: a dict {'source_model_tree_path': string, 'gsim_tree_path': string} """ dic = {} if hasattr(rlz, 'sm_lt_path'): # composite realization dic['source_model_tree_path'] = '_'.join(r...
def export_by_tag_csv(ekey, dstore): """ :param ekey: export key, i.e. a pair (datastore key, fmt) :param dstore: datastore object """ token, tag = ekey[0].split('/') data = extract(dstore, token + '/' + tag) fnames = [] writer = writers.CsvWriter(fmt=writers.FIVEDIGITS) for stat, ar...
def export_aggregate_by_csv(ekey, dstore): """ :param ekey: export key, i.e. a pair (datastore key, fmt) :param dstore: datastore object """ token, what = ekey[0].split('/', 1) aw = extract(dstore, 'aggregate/' + what) fnames = [] writer = writers.CsvWriter(fmt=writers.FIVEDIGITS) pa...
def export_asset_risk_csv(ekey, dstore): """ :param ekey: export key, i.e. a pair (datastore key, fmt) :param dstore: datastore object """ writer = writers.CsvWriter(fmt=writers.FIVEDIGITS) path = '%s.%s' % (sanitize(ekey[0]), ekey[1]) fname = dstore.export_path(path) md = extract(dstore...
def export_agg_risk_csv(ekey, dstore): """ :param ekey: export key, i.e. a pair (datastore key, fmt) :param dstore: datastore object """ writer = writers.CsvWriter(fmt=writers.FIVEDIGITS) path = '%s.%s' % (sanitize(ekey[0]), ekey[1]) fname = dstore.export_path(path) writer.save(dstore['a...
def viewlog(calc_id, host='localhost', port=8000): """ Extract the log of the given calculation ID from the WebUI """ base_url = 'http://%s:%s/v1/calc/' % (host, port) start = 0 psize = 10 # page size try: while True: url = base_url + '%d/log/%d:%d' % (calc_id, start, st...
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. """ # Check that the GSIM supports the standard deviations requested ...
def _get_distance_scaling(self, coe, rhypo): """ Returns the distance scaling term """ return coe["a3"] * np.log(rhypo) + coe["a4"] * rhypo
def _get_azimuth_correction(self, coe, azimuth): """ This is the azimuth correction defined in the functional form (see equation 3 at page 2256) """ term1 = abs(np.cos(np.radians(2.*azimuth))) term2 = abs(np.sin(np.radians(2.*azimuth)))*coe['a5'] return np.log(np....
def get_pickled_sizes(obj): """ Return the pickled sizes of an object and its direct attributes, ordered by decreasing size. Here is an example: >> total_size, partial_sizes = get_pickled_sizes(Monitor('')) >> total_size 345 >> partial_sizes [('_procs', 214), ('exc', 4), ('mem', 4), ('s...
def pickle_sequence(objects): """ Convert an iterable of objects into a list of pickled objects. If the iterable contains copies, the pickling will be done only once. If the iterable contains objects already pickled, they will not be pickled again. :param objects: a sequence of objects to pickl...
def check_mem_usage(soft_percent=None, hard_percent=None): """ Display a warning if we are running out of memory """ soft_percent = soft_percent or config.memory.soft_mem_limit hard_percent = hard_percent or config.memory.hard_mem_limit used_mem_percent = psutil.virtual_memory().percent if u...
def safely_call(func, args, task_no=0, mon=dummy_mon): """ Call the given function with the given arguments safely, i.e. by trapping the exceptions. Return a pair (result, exc_type) where exc_type is None if no exceptions occur, otherwise it is the exception class and the result is a string containi...
def save_task_info(self, res, mem_gb=0): """ :param self: an object with attributes .hdf5, .argnames, .sent :parent res: a :class:`Result` object :param mem_gb: memory consumption at the saving time (optional) """ mon = res.mon name = mon.operation[6:] # strip 'total ' if self.hdf5: ...
def init_workers(): """Waiting function, used to wake up the process pool""" setproctitle('oq-worker') # unregister raiseMasterKilled in oq-workers to avoid deadlock # since processes are terminated via pool.terminate() signal.signal(signal.SIGTERM, signal.SIG_DFL) # prctl is still useful (on Li...
def sequential_apply(task, args, concurrent_tasks=cpu_count * 3, weight=lambda item: 1, key=lambda item: 'Unspecified'): """ Apply sequentially task to args by splitting args[0] in blocks """ chunks = split_in_blocks(args[0], concurrent_tasks or 1, weight, key) task_args = [(ch,...
def get(self): """ Returns the underlying value or raise the underlying exception """ val = self.pik.unpickle() if self.tb_str: etype = val.__class__ msg = '\n%s%s: %s' % (self.tb_str, etype.__name__, val) if issubclass(etype, KeyError): ...
def new(cls, func, args, mon, count=0): """ :returns: a new Result instance """ try: with mon: val = func(*args) except StopIteration: res = Result(None, mon, msg='TASK_ENDED') except Exception: _etype, exc, tb = sys.exc...
def sum(cls, iresults): """ Sum the data transfer information of a set of results """ res = object.__new__(cls) res.received = [] res.sent = 0 for iresult in iresults: res.received.extend(iresult.received) res.sent += iresult.sent ...
def apply(cls, task, args, concurrent_tasks=cpu_count * 3, maxweight=None, weight=lambda item: 1, key=lambda item: 'Unspecified', distribute=None, progress=logging.info): r""" Apply a task to a tuple of the form (sequence, \*other_args) by first splittin...
def log_percent(self): """ Log the progress of the computation in percentage """ done = self.total - self.todo percent = int(float(done) / self.total * 100) if not hasattr(self, 'prev_percent'): # first time self.prev_percent = 0 self.progress('Se...
def submit(self, *args, func=None, monitor=None): """ Submit the given arguments to the underlying task """ monitor = monitor or self.monitor func = func or self.task_func if not hasattr(self, 'socket'): # first time self.__class__.running_tasks = self.tasks ...
def submit_all(self): """ :returns: an IterResult object """ for args in self.task_args: self.submit(*args) return self.get_results()
def get_results(self): """ :returns: an :class:`IterResult` instance """ return IterResult(self._loop(), self.name, self.argnames, self.sent, self.monitor.hdf5)
def reduce(self, agg=operator.add, acc=None): """ Submit all tasks and reduce the results """ return self.submit_all().reduce(agg, acc)
def _get_equivalent_distances_east(wid, lng, mag, repi, focal_depth=10., ab06=False): """ Computes equivalent values of Joyner-Boore and closest distance to the rupture given epoicentral distance. The procedure is described in Atkinson (2012) - Appendix A (page 32). ...
def get_equivalent_distance_inslab(mag, repi, hslab): """ :param float mag: Magnitude :param repi: A :class:`numpy.ndarray` instance containing repi values :param float hslab: Depth of the slab """ area = 10**(-3.225+0.89*mag) radius = (area / scipy.constants.pi)**0.5...
def get_shape(pmaps): """ :param pmaps: a set of homogenous ProbabilityMaps :returns: the common shape (N, L, I) """ for pmap in pmaps: if pmap: sid = next(iter(pmap)) break else: raise AllEmptyProbabilityMaps(pmaps) return (len(pmap),) + pmap[sid].arr...
def combine(pmaps): """ :param pmaps: a set of homogenous ProbabilityMaps :returns: the combined map """ shape = get_shape(pmaps) res = ProbabilityMap(shape[1], shape[2]) for pmap in pmaps: res |= pmap return res
def convert(self, imtls, idx=0): """ Convert a probability curve into a record of dtype `imtls.dt`. :param imtls: DictArray instance :param idx: extract the data corresponding to the given inner index """ curve = numpy.zeros(1, imtls.dt) for imt in imtls: ...
def build(cls, shape_y, shape_z, sids, initvalue=0., dtype=F64): """ :param shape_y: the total number of intensity measure levels :param shape_z: the number of inner levels :param sids: a set of site indices :param initvalue: the initial value of the probability (default 0) ...
def from_array(cls, array, sids): """ :param array: array of shape (N, L) or (N, L, I) :param sids: array of N site IDs """ n_sites = len(sids) n = len(array) if n_sites != n: raise ValueError('Passed %d site IDs, but the array has length %d' ...
def setdefault(self, sid, value, dtype=F64): """ Works like `dict.setdefault`: if the `sid` key is missing, it fills it with an array and returns the associate ProbabilityCurve :param sid: site ID :param value: value used to fill the returned ProbabilityCurve :param dtyp...
def array(self): """ The underlying array of shape (N, L, I) """ return numpy.array([self[sid].array for sid in sorted(self)])
def nbytes(self): """The size of the underlying array""" try: N, L, I = get_shape([self]) except AllEmptyProbabilityMaps: return 0 return BYTES_PER_FLOAT * N * L * I
def convert(self, imtls, nsites, idx=0): """ Convert a probability map into a composite array of length `nsites` and dtype `imtls.dt`. :param imtls: DictArray instance :param nsites: the total number of sites :param idx: index on the z...
def convert2(self, imtls, sids): """ Convert a probability map into a composite array of shape (N,) and dtype `imtls.dt`. :param imtls: DictArray instance :param sids: the IDs of the sites we are interested in :returns: an array of cur...
def filter(self, sids): """ Extracs a submap of self for the given sids. """ dic = self.__class__(self.shape_y, self.shape_z) for sid in sids: try: dic[sid] = self[sid] except KeyError: pass return dic
def extract(self, inner_idx): """ Extracts a component of the underlying ProbabilityCurves, specified by the index `inner_idx`. """ out = self.__class__(self.shape_y, 1) for sid in self: curve = self[sid] array = curve.array[:, inner_idx].reshape(-...
def get_diff_idxs(array, rtol, atol): """ Given an array with (C, N, L) values, being the first the reference value, compute the relative differences and discard the one below the tolerance. :returns: indices where there are sensible differences. """ C, N, L = array.shape diff_idxs = set() ...
def compare(what, imt, calc_ids, files, samplesites=100, rtol=.1, atol=1E-4): """ Compare the hazard curves or maps of two or more calculations """ sids, imtls, poes, arrays = getdata(what, calc_ids, samplesites) try: levels = imtls[imt] except KeyError: sys.exit( '%s...
def build_filename(filename, filetype='png', resolution=300): """ Uses the input properties to create the string of the filename :param str filename: Name of the file :param str filetype: Type of file :param int resolution: DPI resolution of the output figure """ fil...
def _save_image(fig, filename, filetype='png', resolution=300): """ If filename is specified, saves the image :param str filename: Name of the file :param str filetype: Type of file :param int resolution: DPI resolution of the output figure """ if filename: fi...
def _get_catalogue_bin_limits(catalogue, dmag): """ Returns the magnitude bins corresponing to the catalogue """ mag_bins = np.arange( float(np.floor(np.min(catalogue.data['magnitude']))) - dmag, float(np.ceil(np.max(catalogue.data['magnitude']))) + dmag, dmag) counter = np.h...