repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
gem/oq-engine
openquake/hazardlib/source/rupture_collection.py
split
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,...
python
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", "split", "(", "src", ",", "chunksize", "=", "MINWEIGHT", ")", ":", "for", "i", ",", "block", "in", "enumerate", "(", "block_splitter", "(", "src", ".", "iter_ruptures", "(", ")", ",", "chunksize", ",", "key", "=", "operator", ".", "attrgetter", ...
Split a complex fault source in chunks
[ "Split", "a", "complex", "fault", "source", "in", "chunks" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/source/rupture_collection.py#L61-L72
train
gem/oq-engine
openquake/hazardlib/source/rupture_collection.py
RuptureCollectionSource.get_bounding_box
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)
python
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", "get_bounding_box", "(", "self", ",", "maxdist", ")", ":", "locations", "=", "[", "rup", ".", "hypocenter", "for", "rup", "in", "self", ".", "ruptures", "]", "return", "get_bounding_box", "(", "locations", ",", "maxdist", ")" ]
Bounding box containing all the hypocenters, enlarged by the maximum distance
[ "Bounding", "box", "containing", "all", "the", "hypocenters", "enlarged", "by", "the", "maximum", "distance" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/source/rupture_collection.py#L52-L58
train
gem/oq-engine
openquake/commands/show_attrs.py
show_attrs
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: ...
python
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", "show_attrs", "(", "key", ",", "calc_id", "=", "-", "1", ")", ":", "ds", "=", "util", ".", "read", "(", "calc_id", ")", "try", ":", "attrs", "=", "h5py", ".", "File", ".", "__getitem__", "(", "ds", ".", "hdf5", ",", "key", ")", ".", "att...
Show the attributes of a HDF5 dataset in the datastore.
[ "Show", "the", "attributes", "of", "a", "HDF5", "dataset", "in", "the", "datastore", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/show_attrs.py#L24-L39
train
gem/oq-engine
utils/compare_mean_curves.py
compare_mean_curves
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...
python
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", "compare_mean_curves", "(", "calc_ref", ",", "calc", ",", "nsigma", "=", "3", ")", ":", "dstore_ref", "=", "datastore", ".", "read", "(", "calc_ref", ")", "dstore", "=", "datastore", ".", "read", "(", "calc", ")", "imtls", "=", "dstore_ref", "[", ...
Compare the hazard curves coming from two different calculations.
[ "Compare", "the", "hazard", "curves", "coming", "from", "two", "different", "calculations", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/utils/compare_mean_curves.py#L27-L69
train
gem/oq-engine
openquake/hazardlib/gsim/chiou_youngs_2014.py
ChiouYoungs2014PEER._get_stddevs
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 ...
python
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", "_get_stddevs", "(", "self", ",", "sites", ",", "rup", ",", "C", ",", "stddev_types", ",", "ln_y_ref", ",", "exp1", ",", "exp2", ")", ":", "ret", "=", "[", "]", "for", "stddev_type", "in", "stddev_types", ":", "assert", "stddev_type", "in", "sel...
Returns the standard deviation, which is fixed at 0.65 for every site
[ "Returns", "the", "standard", "deviation", "which", "is", "fixed", "at", "0", ".", "65", "for", "every", "site" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/chiou_youngs_2014.py#L313-L323
train
gem/oq-engine
openquake/risklib/scientific.py
build_imls
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...
python
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", "build_imls", "(", "ff", ",", "continuous_fragility_discretization", ",", "steps_per_interval", "=", "0", ")", ":", "if", "ff", ".", "format", "==", "'discrete'", ":", "imls", "=", "ff", ".", "imls", "if", "ff", ".", "nodamage", "and", "ff", ".", ...
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 with a complex logic depending on the noDamageLimit and the parameter steps per interval. :p...
[ "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", "fun...
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/scientific.py#L665-L690
train
gem/oq-engine
openquake/risklib/scientific.py
insured_loss_curve
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...
python
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", "insured_loss_curve", "(", "curve", ",", "deductible", ",", "insured_limit", ")", ":", "losses", ",", "poes", "=", "curve", "[", ":", ",", "curve", "[", "0", "]", "<=", "insured_limit", "]", "limit_poe", "=", "interpolate", ".", "interp1d", "(", "...
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 fraction form >>> losses = numpy.array([3, 20, 101]) >>> poes ...
[ "Compute", "an", "insured", "loss", "ratio", "curve", "given", "a", "loss", "ratio", "curve" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/scientific.py#L1097-L1116
train
gem/oq-engine
openquake/risklib/scientific.py
bcr
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...
python
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", "bcr", "(", "eal_original", ",", "eal_retrofitted", ",", "interest_rate", ",", "asset_life_expectancy", ",", "asset_value", ",", "retrofitting_cost", ")", ":", "return", "(", "(", "eal_original", "-", "eal_retrofitted", ")", "*", "asset_value", "*", "(", ...
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 -- Expected annual loss for retrofitted asset * r -- Interest rate * t -- Life expectancy of the asset * C -- Retrofitting...
[ "Compute", "the", "Benefit", "-", "Cost", "Ratio", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/scientific.py#L1124-L1142
train
gem/oq-engine
openquake/risklib/scientific.py
pairwise_mean
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)])
python
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_mean", "(", "values", ")", ":", "\"Averages between a value and the next value in a sequence\"", "return", "numpy", ".", "array", "(", "[", "numpy", ".", "mean", "(", "pair", ")", "for", "pair", "in", "pairwise", "(", "values", ")", "]", ")" ]
Averages between a value and the next value in a sequence
[ "Averages", "between", "a", "value", "and", "the", "next", "value", "in", "a", "sequence" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/scientific.py#L1147-L1149
train
gem/oq-engine
openquake/risklib/scientific.py
pairwise_diff
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)])
python
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", "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", ")", "]", ")" ]
Differences between a value and the next value in a sequence
[ "Differences", "between", "a", "value", "and", "the", "next", "value", "in", "a", "sequence" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/scientific.py#L1152-L1154
train
gem/oq-engine
openquake/risklib/scientific.py
mean_std
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...
python
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", "mean_std", "(", "fractions", ")", ":", "n", "=", "fractions", ".", "shape", "[", "0", "]", "if", "n", "==", "1", ":", "return", "fractions", "[", "0", "]", ",", "numpy", ".", "ones_like", "(", "fractions", "[", "0", "]", ")", "*", "numpy"...
Given an N x M matrix, returns mean and std computed on the rows, i.e. two M-dimensional vectors.
[ "Given", "an", "N", "x", "M", "matrix", "returns", "mean", "and", "std", "computed", "on", "the", "rows", "i", ".", "e", ".", "two", "M", "-", "dimensional", "vectors", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/scientific.py#L1157-L1165
train
gem/oq-engine
openquake/risklib/scientific.py
broadcast
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...
python
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", "broadcast", "(", "func", ",", "composite_array", ",", "*", "args", ")", ":", "dic", "=", "{", "}", "dtypes", "=", "[", "]", "for", "name", "in", "composite_array", ".", "dtype", ".", "names", ":", "dic", "[", "name", "]", "=", "func", "(", ...
Broadcast an array function over a composite array
[ "Broadcast", "an", "array", "function", "over", "a", "composite", "array" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/scientific.py#L1184-L1196
train
gem/oq-engine
openquake/risklib/scientific.py
average_loss
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...
python
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", "average_loss", "(", "lc", ")", ":", "losses", ",", "poes", "=", "(", "lc", "[", "'loss'", "]", ",", "lc", "[", "'poe'", "]", ")", "if", "lc", ".", "dtype", ".", "names", "else", "lc", "return", "-", "pairwise_diff", "(", "losses", ")", "@...
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 trapeizodal rule with the width given by...
[ "Given", "a", "loss", "curve", "array", "with", "poe", "and", "loss", "fields", "computes", "the", "average", "loss", "on", "a", "period", "of", "time", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/scientific.py#L1200-L1211
train
gem/oq-engine
openquake/risklib/scientific.py
normalize_curves_eb
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...
python
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", "normalize_curves_eb", "(", "curves", ")", ":", "non_zero_curves", "=", "[", "(", "losses", ",", "poes", ")", "for", "losses", ",", "poes", "in", "curves", "if", "losses", "[", "-", "1", "]", ">", "0", "]", "if", "not", "non_zero_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
[ "A", "more", "sophisticated", "version", "of", "normalize_curves", "used", "in", "the", "event", "based", "calculator", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/scientific.py#L1214-L1238
train
gem/oq-engine
openquake/risklib/scientific.py
VulnerabilityFunction.sample
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...
python
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", "sample", "(", "self", ",", "means", ",", "covs", ",", "idxs", ",", "epsilons", "=", "None", ")", ":", "if", "epsilons", "is", "None", ":", "return", "means", "self", ".", "set_distribution", "(", "epsilons", ")", "res", "=", "self", ".", "dis...
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 idxs: array of E booleans with E >= E' :param epsilons:...
[ "Sample", "the", "epsilons", "and", "apply", "the", "corrections", "to", "the", "means", ".", "This", "method", "is", "called", "only", "if", "there", "are", "nonzero", "covs", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/scientific.py#L161-L181
train
gem/oq-engine
openquake/risklib/scientific.py
VulnerabilityFunction.mean_loss_ratios_with_steps
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...
python
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", "mean_loss_ratios_with_steps", "(", "self", ",", "steps", ")", ":", "loss_ratios", "=", "self", ".", "mean_loss_ratios", "if", "min", "(", "loss_ratios", ")", ">", "0.0", ":", "loss_ratios", "=", "numpy", ".", "concatenate", "(", "[", "[", "0.0", "]...
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 example, if we have [0.5, 0.7]:: steps = 1 produces [0.0,...
[ "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" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/scientific.py#L216-L240
train
gem/oq-engine
openquake/risklib/scientific.py
VulnerabilityFunctionWithPMF.sample
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' ...
python
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", "sample", "(", "self", ",", "probs", ",", "_covs", ",", "idxs", ",", "epsilons", ")", ":", "self", ".", "set_distribution", "(", "epsilons", ")", "return", "self", ".", "distribution", ".", "sample", "(", "self", ".", "loss_ratios", ",", "probs", ...
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' :param epsilons: array of E floats :return...
[ "Sample", "the", ".", "loss_ratios", "with", "the", "given", "probabilities", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/scientific.py#L406-L422
train
gem/oq-engine
openquake/risklib/scientific.py
FragilityModel.build
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...
python
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", "build", "(", "self", ",", "continuous_fragility_discretization", ",", "steps_per_interval", ")", ":", "newfm", "=", "copy", ".", "copy", "(", "self", ")", "for", "key", ",", "ffl", "in", "self", ".", "items", "(", ")", ":", "newfm", "[", "key", ...
Return a new FragilityModel instance, in which the values have been replaced with FragilityFunctionList instances. :param continuous_fragility_discretization: configuration parameter :param steps_per_interval: configuration parameter
[ "Return", "a", "new", "FragilityModel", "instance", "in", "which", "the", "values", "have", "been", "replaced", "with", "FragilityFunctionList", "instances", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/scientific.py#L719-L734
train
gem/oq-engine
openquake/calculators/event_based.py
compute_gmfs
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)
python
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", "compute_gmfs", "(", "rupgetter", ",", "srcfilter", ",", "param", ",", "monitor", ")", ":", "getter", "=", "GmfGetter", "(", "rupgetter", ",", "srcfilter", ",", "param", "[", "'oqparam'", "]", ")", "with", "monitor", "(", "'getting ruptures'", ")", ...
Compute GMFs and optionally hazard curves
[ "Compute", "GMFs", "and", "optionally", "hazard", "curves" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/event_based.py#L82-L89
train
gem/oq-engine
openquake/hmtk/sources/complex_fault_source.py
mtkComplexFaultSource._get_minmax_edges
def _get_minmax_edges(self, edge): ''' Updates the upper and lower depths based on the input edges ''' if isinstance(edge, Line): # For instance of line class need to loop over values depth_vals = np.array([node.depth for node in edge.points]) else: ...
python
def _get_minmax_edges(self, edge): ''' Updates the upper and lower depths based on the input edges ''' if isinstance(edge, Line): # For instance of line class need to loop over values depth_vals = np.array([node.depth for node in edge.points]) else: ...
[ "def", "_get_minmax_edges", "(", "self", ",", "edge", ")", ":", "if", "isinstance", "(", "edge", ",", "Line", ")", ":", "depth_vals", "=", "np", ".", "array", "(", "[", "node", ".", "depth", "for", "node", "in", "edge", ".", "points", "]", ")", "el...
Updates the upper and lower depths based on the input edges
[ "Updates", "the", "upper", "and", "lower", "depths", "based", "on", "the", "input", "edges" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/sources/complex_fault_source.py#L153-L175
train
gem/oq-engine
openquake/hazardlib/gsim/kotha_2016.py
KothaEtAl2016._get_magnitude_term
def _get_magnitude_term(self, C, mag): """ Returns the magnitude scaling term - equation 3 """ if mag >= self.CONSTS["Mh"]: return C["e1"] + C["b3"] * (mag - self.CONSTS["Mh"]) else: return C["e1"] + (C["b1"] * (mag - self.CONSTS["Mh"])) +\ ...
python
def _get_magnitude_term(self, C, mag): """ Returns the magnitude scaling term - equation 3 """ if mag >= self.CONSTS["Mh"]: return C["e1"] + C["b3"] * (mag - self.CONSTS["Mh"]) else: return C["e1"] + (C["b1"] * (mag - self.CONSTS["Mh"])) +\ ...
[ "def", "_get_magnitude_term", "(", "self", ",", "C", ",", "mag", ")", ":", "if", "mag", ">=", "self", ".", "CONSTS", "[", "\"Mh\"", "]", ":", "return", "C", "[", "\"e1\"", "]", "+", "C", "[", "\"b3\"", "]", "*", "(", "mag", "-", "self", ".", "C...
Returns the magnitude scaling term - equation 3
[ "Returns", "the", "magnitude", "scaling", "term", "-", "equation", "3" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/kotha_2016.py#L101-L109
train
gem/oq-engine
openquake/hazardlib/gsim/kotha_2016.py
KothaEtAl2016._get_distance_term
def _get_distance_term(self, C, rjb, mag): """ Returns the general distance scaling term - equation 2 """ c_3 = self._get_anelastic_coeff(C) rval = np.sqrt(rjb ** 2. + C["h"] ** 2.) return (C["c1"] + C["c2"] * (mag - self.CONSTS["Mref"])) *\ np.log(rval / self...
python
def _get_distance_term(self, C, rjb, mag): """ Returns the general distance scaling term - equation 2 """ c_3 = self._get_anelastic_coeff(C) rval = np.sqrt(rjb ** 2. + C["h"] ** 2.) return (C["c1"] + C["c2"] * (mag - self.CONSTS["Mref"])) *\ np.log(rval / self...
[ "def", "_get_distance_term", "(", "self", ",", "C", ",", "rjb", ",", "mag", ")", ":", "c_3", "=", "self", ".", "_get_anelastic_coeff", "(", "C", ")", "rval", "=", "np", ".", "sqrt", "(", "rjb", "**", "2.", "+", "C", "[", "\"h\"", "]", "**", "2.",...
Returns the general distance scaling term - equation 2
[ "Returns", "the", "general", "distance", "scaling", "term", "-", "equation", "2" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/kotha_2016.py#L111-L119
train
gem/oq-engine
openquake/hazardlib/gsim/kotha_2016.py
KothaEtAl2016._get_site_term
def _get_site_term(self, C, vs30): """ Returns only a linear site amplification term """ dg1, dg2 = self._get_regional_site_term(C) return (C["g1"] + dg1) + (C["g2"] + dg2) * np.log(vs30)
python
def _get_site_term(self, C, vs30): """ Returns only a linear site amplification term """ dg1, dg2 = self._get_regional_site_term(C) return (C["g1"] + dg1) + (C["g2"] + dg2) * np.log(vs30)
[ "def", "_get_site_term", "(", "self", ",", "C", ",", "vs30", ")", ":", "dg1", ",", "dg2", "=", "self", ".", "_get_regional_site_term", "(", "C", ")", "return", "(", "C", "[", "\"g1\"", "]", "+", "dg1", ")", "+", "(", "C", "[", "\"g2\"", "]", "+",...
Returns only a linear site amplification term
[ "Returns", "only", "a", "linear", "site", "amplification", "term" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/kotha_2016.py#L128-L133
train
gem/oq-engine
openquake/hazardlib/gsim/tusa_langer_2016.py
TusaLanger2016RepiBA08SE._get_stddevs
def _get_stddevs(self, C, stddev_types, num_sites): """ Return standard deviations as defined in tables below """ assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES for stddev_type in stddev_types) stddevs = [np.zeros(num_sites) + C['SigmaTot'] for _ ...
python
def _get_stddevs(self, C, stddev_types, num_sites): """ Return standard deviations as defined in tables below """ assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES for stddev_type in stddev_types) stddevs = [np.zeros(num_sites) + C['SigmaTot'] for _ ...
[ "def", "_get_stddevs", "(", "self", ",", "C", ",", "stddev_types", ",", "num_sites", ")", ":", "assert", "all", "(", "stddev_type", "in", "self", ".", "DEFINED_FOR_STANDARD_DEVIATION_TYPES", "for", "stddev_type", "in", "stddev_types", ")", "stddevs", "=", "[", ...
Return standard deviations as defined in tables below
[ "Return", "standard", "deviations", "as", "defined", "in", "tables", "below" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/tusa_langer_2016.py#L112-L119
train
gem/oq-engine
openquake/hazardlib/gsim/dowrickrhoades_2005.py
DowrickRhoades2005Asc._compute_mean
def _compute_mean(self, C, mag, rrup, hypo_depth, delta_R, delta_S, delta_V, delta_I, vs30): """ Compute MMI Intensity Value as per Equation in Table 5 and Table 7 pag 198. """ # mean is calculated for all the 4 classes using the same equation. # Fo...
python
def _compute_mean(self, C, mag, rrup, hypo_depth, delta_R, delta_S, delta_V, delta_I, vs30): """ Compute MMI Intensity Value as per Equation in Table 5 and Table 7 pag 198. """ # mean is calculated for all the 4 classes using the same equation. # Fo...
[ "def", "_compute_mean", "(", "self", ",", "C", ",", "mag", ",", "rrup", ",", "hypo_depth", ",", "delta_R", ",", "delta_S", ",", "delta_V", ",", "delta_I", ",", "vs30", ")", ":", "mean", "=", "(", "C", "[", "'A1'", "]", "+", "(", "C", "[", "'A2'",...
Compute MMI Intensity Value as per Equation in Table 5 and Table 7 pag 198.
[ "Compute", "MMI", "Intensity", "Value", "as", "per", "Equation", "in", "Table", "5", "and", "Table", "7", "pag", "198", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/dowrickrhoades_2005.py#L98-L120
train
gem/oq-engine
openquake/hazardlib/gsim/dowrickrhoades_2005.py
DowrickRhoades2005Asc._get_stddevs
def _get_stddevs(self, C, stddev_types, num_sites): """ Return total standard deviation as described in paragraph 5.2 pag 200. """ # interevent stddev sigma_inter = C['tau'] + np.zeros(num_sites) # intraevent std sigma_intra = C['sigma'] + np.zeros(num_sites) ...
python
def _get_stddevs(self, C, stddev_types, num_sites): """ Return total standard deviation as described in paragraph 5.2 pag 200. """ # interevent stddev sigma_inter = C['tau'] + np.zeros(num_sites) # intraevent std sigma_intra = C['sigma'] + np.zeros(num_sites) ...
[ "def", "_get_stddevs", "(", "self", ",", "C", ",", "stddev_types", ",", "num_sites", ")", ":", "sigma_inter", "=", "C", "[", "'tau'", "]", "+", "np", ".", "zeros", "(", "num_sites", ")", "sigma_intra", "=", "C", "[", "'sigma'", "]", "+", "np", ".", ...
Return total standard deviation as described in paragraph 5.2 pag 200.
[ "Return", "total", "standard", "deviation", "as", "described", "in", "paragraph", "5", ".", "2", "pag", "200", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/dowrickrhoades_2005.py#L122-L143
train
gem/oq-engine
openquake/commands/plot_assets.py
plot_assets
def plot_assets(calc_id=-1, site_model=False): """ Plot the sites and the assets """ # NB: matplotlib is imported inside since it is a costly import import matplotlib.pyplot as p from openquake.hmtk.plotting.patch import PolygonPatch dstore = util.read(calc_id) try: region = dsto...
python
def plot_assets(calc_id=-1, site_model=False): """ Plot the sites and the assets """ # NB: matplotlib is imported inside since it is a costly import import matplotlib.pyplot as p from openquake.hmtk.plotting.patch import PolygonPatch dstore = util.read(calc_id) try: region = dsto...
[ "def", "plot_assets", "(", "calc_id", "=", "-", "1", ",", "site_model", "=", "False", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "p", "from", "openquake", ".", "hmtk", ".", "plotting", ".", "patch", "import", "PolygonPatch", "dstore", "=", "u...
Plot the sites and the assets
[ "Plot", "the", "sites", "and", "the", "assets" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/plot_assets.py#L26-L62
train
gem/oq-engine
openquake/hmtk/seismicity/smoothing/smoothed_seismicity.py
_get_adjustment
def _get_adjustment(mag, year, mmin, completeness_year, t_f, mag_inc=0.1): ''' If the magnitude is greater than the minimum in the completeness table and the year is greater than the corresponding completeness year then return the Weichert factor :param float mag: Magnitude of an earthquake...
python
def _get_adjustment(mag, year, mmin, completeness_year, t_f, mag_inc=0.1): ''' If the magnitude is greater than the minimum in the completeness table and the year is greater than the corresponding completeness year then return the Weichert factor :param float mag: Magnitude of an earthquake...
[ "def", "_get_adjustment", "(", "mag", ",", "year", ",", "mmin", ",", "completeness_year", ",", "t_f", ",", "mag_inc", "=", "0.1", ")", ":", "if", "len", "(", "completeness_year", ")", "==", "1", ":", "if", "(", "mag", ">=", "mmin", ")", "and", "(", ...
If the magnitude is greater than the minimum in the completeness table and the year is greater than the corresponding completeness year then return the Weichert factor :param float mag: Magnitude of an earthquake :param float year: Year of earthquake :param np.ndarray completeness...
[ "If", "the", "magnitude", "is", "greater", "than", "the", "minimum", "in", "the", "completeness", "table", "and", "the", "year", "is", "greater", "than", "the", "corresponding", "completeness", "year", "then", "return", "the", "Weichert", "factor" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/smoothing/smoothed_seismicity.py#L129-L167
train
gem/oq-engine
openquake/hmtk/seismicity/smoothing/smoothed_seismicity.py
get_catalogue_bounding_polygon
def get_catalogue_bounding_polygon(catalogue): ''' Returns a polygon containing the bounding box of the catalogue ''' upper_lon = np.max(catalogue.data['longitude']) upper_lat = np.max(catalogue.data['latitude']) lower_lon = np.min(catalogue.data['longitude']) lower_lat = np.min(catalogue.da...
python
def get_catalogue_bounding_polygon(catalogue): ''' Returns a polygon containing the bounding box of the catalogue ''' upper_lon = np.max(catalogue.data['longitude']) upper_lat = np.max(catalogue.data['latitude']) lower_lon = np.min(catalogue.data['longitude']) lower_lat = np.min(catalogue.da...
[ "def", "get_catalogue_bounding_polygon", "(", "catalogue", ")", ":", "upper_lon", "=", "np", ".", "max", "(", "catalogue", ".", "data", "[", "'longitude'", "]", ")", "upper_lat", "=", "np", ".", "max", "(", "catalogue", ".", "data", "[", "'latitude'", "]",...
Returns a polygon containing the bounding box of the catalogue
[ "Returns", "a", "polygon", "containing", "the", "bounding", "box", "of", "the", "catalogue" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/smoothing/smoothed_seismicity.py#L170-L180
train
gem/oq-engine
openquake/hmtk/seismicity/smoothing/smoothed_seismicity.py
Grid.make_from_catalogue
def make_from_catalogue(cls, catalogue, spacing, dilate): ''' Defines the grid on the basis of the catalogue ''' new = cls() cat_bbox = get_catalogue_bounding_polygon(catalogue) if dilate > 0: cat_bbox = cat_bbox.dilate(dilate) # Define Grid spacing ...
python
def make_from_catalogue(cls, catalogue, spacing, dilate): ''' Defines the grid on the basis of the catalogue ''' new = cls() cat_bbox = get_catalogue_bounding_polygon(catalogue) if dilate > 0: cat_bbox = cat_bbox.dilate(dilate) # Define Grid spacing ...
[ "def", "make_from_catalogue", "(", "cls", ",", "catalogue", ",", "spacing", ",", "dilate", ")", ":", "new", "=", "cls", "(", ")", "cat_bbox", "=", "get_catalogue_bounding_polygon", "(", "catalogue", ")", "if", "dilate", ">", "0", ":", "cat_bbox", "=", "cat...
Defines the grid on the basis of the catalogue
[ "Defines", "the", "grid", "on", "the", "basis", "of", "the", "catalogue" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/smoothing/smoothed_seismicity.py#L81-L105
train
gem/oq-engine
openquake/hmtk/seismicity/smoothing/smoothed_seismicity.py
SmoothedSeismicity.write_to_csv
def write_to_csv(self, filename): ''' Exports to simple csv :param str filename: Path to file for export ''' fid = open(filename, 'wt') # Create header list header_info = ['Longitude', 'Latitude', 'Depth', 'Observed Count', 'Smo...
python
def write_to_csv(self, filename): ''' Exports to simple csv :param str filename: Path to file for export ''' fid = open(filename, 'wt') # Create header list header_info = ['Longitude', 'Latitude', 'Depth', 'Observed Count', 'Smo...
[ "def", "write_to_csv", "(", "self", ",", "filename", ")", ":", "fid", "=", "open", "(", "filename", ",", "'wt'", ")", "header_info", "=", "[", "'Longitude'", ",", "'Latitude'", ",", "'Depth'", ",", "'Observed Count'", ",", "'Smoothed Rate'", ",", "'b-value'"...
Exports to simple csv :param str filename: Path to file for export
[ "Exports", "to", "simple", "csv" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/smoothing/smoothed_seismicity.py#L491-L518
train
gem/oq-engine
openquake/commonlib/hazard_writers.py
_validate_hazard_metadata
def _validate_hazard_metadata(md): """ Validate metadata `dict` of attributes, which are more or less the same for hazard curves, hazard maps, and disaggregation histograms. :param dict md: `dict` which can contain the following keys: * statistics * gsimlt_path * smlt_p...
python
def _validate_hazard_metadata(md): """ Validate metadata `dict` of attributes, which are more or less the same for hazard curves, hazard maps, and disaggregation histograms. :param dict md: `dict` which can contain the following keys: * statistics * gsimlt_path * smlt_p...
[ "def", "_validate_hazard_metadata", "(", "md", ")", ":", "if", "(", "md", ".", "get", "(", "'statistics'", ")", "is", "not", "None", "and", "(", "md", ".", "get", "(", "'smlt_path'", ")", "is", "not", "None", "or", "md", ".", "get", "(", "'gsimlt_pat...
Validate metadata `dict` of attributes, which are more or less the same for hazard curves, hazard maps, and disaggregation histograms. :param dict md: `dict` which can contain the following keys: * statistics * gsimlt_path * smlt_path * imt * sa_period *...
[ "Validate", "metadata", "dict", "of", "attributes", "which", "are", "more", "or", "less", "the", "same", "for", "hazard", "curves", "hazard", "maps", "and", "disaggregation", "histograms", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/hazard_writers.py#L54-L103
train
gem/oq-engine
openquake/commonlib/hazard_writers.py
_set_metadata
def _set_metadata(element, metadata, attr_map, transform=str): """ Set metadata attributes on a given ``element``. :param element: :class:`xml.etree.ElementTree.Element` instance :param metadata: Dictionary of metadata items containing attribute data for ``element``. :param attr_map...
python
def _set_metadata(element, metadata, attr_map, transform=str): """ Set metadata attributes on a given ``element``. :param element: :class:`xml.etree.ElementTree.Element` instance :param metadata: Dictionary of metadata items containing attribute data for ``element``. :param attr_map...
[ "def", "_set_metadata", "(", "element", ",", "metadata", ",", "attr_map", ",", "transform", "=", "str", ")", ":", "for", "kw", ",", "attr", "in", "attr_map", ".", "items", "(", ")", ":", "value", "=", "metadata", ".", "get", "(", "kw", ")", "if", "...
Set metadata attributes on a given ``element``. :param element: :class:`xml.etree.ElementTree.Element` instance :param metadata: Dictionary of metadata items containing attribute data for ``element``. :param attr_map: Dictionary mapping of metadata key->attribute name. :param tr...
[ "Set", "metadata", "attributes", "on", "a", "given", "element", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/hazard_writers.py#L106-L123
train
gem/oq-engine
openquake/commonlib/hazard_writers.py
HazardCurveXMLWriter.serialize
def serialize(self, data): """ Write a sequence of hazard curves to the specified file. :param data: Iterable of hazard curve data. Each datum must be an object with the following attributes: * poes: A list of probability of exceedence values (floats). ...
python
def serialize(self, data): """ Write a sequence of hazard curves to the specified file. :param data: Iterable of hazard curve data. Each datum must be an object with the following attributes: * poes: A list of probability of exceedence values (floats). ...
[ "def", "serialize", "(", "self", ",", "data", ")", ":", "with", "open", "(", "self", ".", "dest", ",", "'wb'", ")", "as", "fh", ":", "root", "=", "et", ".", "Element", "(", "'nrml'", ")", "self", ".", "add_hazard_curves", "(", "root", ",", "self", ...
Write a sequence of hazard curves to the specified file. :param data: Iterable of hazard curve data. Each datum must be an object with the following attributes: * poes: A list of probability of exceedence values (floats). * location: An object representing the l...
[ "Write", "a", "sequence", "of", "hazard", "curves", "to", "the", "specified", "file", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/hazard_writers.py#L177-L192
train
gem/oq-engine
openquake/commonlib/hazard_writers.py
HazardCurveXMLWriter.add_hazard_curves
def add_hazard_curves(self, root, metadata, data): """ Add hazard curves stored into `data` as child of the `root` element with `metadata`. See the documentation of the method `serialize` and the constructor for a description of `data` and `metadata`, respectively. """ ...
python
def add_hazard_curves(self, root, metadata, data): """ Add hazard curves stored into `data` as child of the `root` element with `metadata`. See the documentation of the method `serialize` and the constructor for a description of `data` and `metadata`, respectively. """ ...
[ "def", "add_hazard_curves", "(", "self", ",", "root", ",", "metadata", ",", "data", ")", ":", "hazard_curves", "=", "et", ".", "SubElement", "(", "root", ",", "'hazardCurves'", ")", "_set_metadata", "(", "hazard_curves", ",", "metadata", ",", "_ATTR_MAP", ")...
Add hazard curves stored into `data` as child of the `root` element with `metadata`. See the documentation of the method `serialize` and the constructor for a description of `data` and `metadata`, respectively.
[ "Add", "hazard", "curves", "stored", "into", "data", "as", "child", "of", "the", "root", "element", "with", "metadata", ".", "See", "the", "documentation", "of", "the", "method", "serialize", "and", "the", "constructor", "for", "a", "description", "of", "dat...
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/hazard_writers.py#L194-L215
train
gem/oq-engine
openquake/commonlib/hazard_writers.py
EventBasedGMFXMLWriter.serialize
def serialize(self, data, fmt='%10.7E'): """ Serialize a collection of ground motion fields to XML. :param data: An iterable of "GMF set" objects. Each "GMF set" object should: * have an `investigation_time` attribute * have an `stochastic_event_...
python
def serialize(self, data, fmt='%10.7E'): """ Serialize a collection of ground motion fields to XML. :param data: An iterable of "GMF set" objects. Each "GMF set" object should: * have an `investigation_time` attribute * have an `stochastic_event_...
[ "def", "serialize", "(", "self", ",", "data", ",", "fmt", "=", "'%10.7E'", ")", ":", "gmf_set_nodes", "=", "[", "]", "for", "gmf_set", "in", "data", ":", "gmf_set_node", "=", "Node", "(", "'gmfSet'", ")", "if", "gmf_set", ".", "investigation_time", ":", ...
Serialize a collection of ground motion fields to XML. :param data: An iterable of "GMF set" objects. Each "GMF set" object should: * have an `investigation_time` attribute * have an `stochastic_event_set_id` attribute * be iterable, yielding a seque...
[ "Serialize", "a", "collection", "of", "ground", "motion", "fields", "to", "XML", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/hazard_writers.py#L259-L303
train
gem/oq-engine
openquake/commonlib/hazard_writers.py
SESXMLWriter.serialize
def serialize(self, data, investigation_time): """ Serialize a collection of stochastic event sets to XML. :param data: A dictionary src_group_id -> list of :class:`openquake.commonlib.calc.Rupture` objects. Each Rupture should have the following attributes: ...
python
def serialize(self, data, investigation_time): """ Serialize a collection of stochastic event sets to XML. :param data: A dictionary src_group_id -> list of :class:`openquake.commonlib.calc.Rupture` objects. Each Rupture should have the following attributes: ...
[ "def", "serialize", "(", "self", ",", "data", ",", "investigation_time", ")", ":", "with", "open", "(", "self", ".", "dest", ",", "'wb'", ")", "as", "fh", ":", "root", "=", "et", ".", "Element", "(", "'nrml'", ")", "ses_container", "=", "et", ".", ...
Serialize a collection of stochastic event sets to XML. :param data: A dictionary src_group_id -> list of :class:`openquake.commonlib.calc.Rupture` objects. Each Rupture should have the following attributes: * `rupid` * `events_by_ses` * ...
[ "Serialize", "a", "collection", "of", "stochastic", "event", "sets", "to", "XML", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/hazard_writers.py#L440-L507
train
gem/oq-engine
openquake/commonlib/hazard_writers.py
HazardMapXMLWriter.serialize
def serialize(self, data): """ Serialize hazard map data to XML. See :meth:`HazardMapWriter.serialize` for details about the expected input. """ with open(self.dest, 'wb') as fh: root = et.Element('nrml') hazard_map = et.SubElement(root, 'hazardMa...
python
def serialize(self, data): """ Serialize hazard map data to XML. See :meth:`HazardMapWriter.serialize` for details about the expected input. """ with open(self.dest, 'wb') as fh: root = et.Element('nrml') hazard_map = et.SubElement(root, 'hazardMa...
[ "def", "serialize", "(", "self", ",", "data", ")", ":", "with", "open", "(", "self", ".", "dest", ",", "'wb'", ")", "as", "fh", ":", "root", "=", "et", ".", "Element", "(", "'nrml'", ")", "hazard_map", "=", "et", ".", "SubElement", "(", "root", "...
Serialize hazard map data to XML. See :meth:`HazardMapWriter.serialize` for details about the expected input.
[ "Serialize", "hazard", "map", "data", "to", "XML", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/hazard_writers.py#L560-L578
train
gem/oq-engine
openquake/commonlib/hazard_writers.py
UHSXMLWriter.serialize
def serialize(self, data): """ Write a sequence of uniform hazard spectra to the specified file. :param data: Iterable of UHS data. Each datum must be an object with the following attributes: * imls: A sequence of Intensity Measure Levels * locat...
python
def serialize(self, data): """ Write a sequence of uniform hazard spectra to the specified file. :param data: Iterable of UHS data. Each datum must be an object with the following attributes: * imls: A sequence of Intensity Measure Levels * locat...
[ "def", "serialize", "(", "self", ",", "data", ")", ":", "gml_ns", "=", "nrml", ".", "SERIALIZE_NS_MAP", "[", "'gml'", "]", "with", "open", "(", "self", ".", "dest", ",", "'wb'", ")", "as", "fh", ":", "root", "=", "et", ".", "Element", "(", "'nrml'"...
Write a sequence of uniform hazard spectra to the specified file. :param data: Iterable of UHS data. Each datum must be an object with the following attributes: * imls: A sequence of Intensity Measure Levels * location: An object representing the location of the...
[ "Write", "a", "sequence", "of", "uniform", "hazard", "spectra", "to", "the", "specified", "file", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/hazard_writers.py#L728-L761
train
gem/oq-engine
openquake/hmtk/seismicity/max_magnitude/kijko_sellevol_bayes.py
check_config
def check_config(config, data): '''Check config file inputs :param dict config: Configuration settings for the function ''' essential_keys = ['input_mmin', 'b-value', 'sigma-b'] for key in essential_keys: if not key in config.keys(): raise ValueError('For KijkoSellevol...
python
def check_config(config, data): '''Check config file inputs :param dict config: Configuration settings for the function ''' essential_keys = ['input_mmin', 'b-value', 'sigma-b'] for key in essential_keys: if not key in config.keys(): raise ValueError('For KijkoSellevol...
[ "def", "check_config", "(", "config", ",", "data", ")", ":", "essential_keys", "=", "[", "'input_mmin'", ",", "'b-value'", ",", "'sigma-b'", "]", "for", "key", "in", "essential_keys", ":", "if", "not", "key", "in", "config", ".", "keys", "(", ")", ":", ...
Check config file inputs :param dict config: Configuration settings for the function
[ "Check", "config", "file", "inputs" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/max_magnitude/kijko_sellevol_bayes.py#L60-L84
train
gem/oq-engine
openquake/hazardlib/gsim/toro_1997.py
ToroEtAl1997MblgNSHMP2008._compute_mean
def _compute_mean(self, C, mag, rjb): """ Compute ground motion mean value. """ # line 1686 in hazgridXnga2.f ffc = self._compute_finite_fault_correction(mag) d = np.sqrt(rjb ** 2 + (C['c7'] ** 2) * (ffc ** 2)) # lines 1663, 1694-1696 in hazgridXnga2.f me...
python
def _compute_mean(self, C, mag, rjb): """ Compute ground motion mean value. """ # line 1686 in hazgridXnga2.f ffc = self._compute_finite_fault_correction(mag) d = np.sqrt(rjb ** 2 + (C['c7'] ** 2) * (ffc ** 2)) # lines 1663, 1694-1696 in hazgridXnga2.f me...
[ "def", "_compute_mean", "(", "self", ",", "C", ",", "mag", ",", "rjb", ")", ":", "ffc", "=", "self", ".", "_compute_finite_fault_correction", "(", "mag", ")", "d", "=", "np", ".", "sqrt", "(", "rjb", "**", "2", "+", "(", "C", "[", "'c7'", "]", "*...
Compute ground motion mean value.
[ "Compute", "ground", "motion", "mean", "value", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/toro_1997.py#L110-L129
train
gem/oq-engine
openquake/hazardlib/gsim/toro_1997.py
ToroEtAl1997MblgNSHMP2008._compute_finite_fault_correction
def _compute_finite_fault_correction(self, mag): """ Compute finite fault correction term as geometric mean of correction terms obtained from Mw values calculated with Johnston 1996 and Atkinson and Boore 1987 conversion equations. Implement equations as in lines 1653 - 1658 in ...
python
def _compute_finite_fault_correction(self, mag): """ Compute finite fault correction term as geometric mean of correction terms obtained from Mw values calculated with Johnston 1996 and Atkinson and Boore 1987 conversion equations. Implement equations as in lines 1653 - 1658 in ...
[ "def", "_compute_finite_fault_correction", "(", "self", ",", "mag", ")", ":", "mw_j96", "=", "mblg_to_mw_johnston_96", "(", "mag", ")", "mw_ab87", "=", "mblg_to_mw_atkinson_boore_87", "(", "mag", ")", "t1", "=", "np", ".", "exp", "(", "-", "1.25", "+", "0.22...
Compute finite fault correction term as geometric mean of correction terms obtained from Mw values calculated with Johnston 1996 and Atkinson and Boore 1987 conversion equations. Implement equations as in lines 1653 - 1658 in hazgridXnga2.f
[ "Compute", "finite", "fault", "correction", "term", "as", "geometric", "mean", "of", "correction", "terms", "obtained", "from", "Mw", "values", "calculated", "with", "Johnston", "1996", "and", "Atkinson", "and", "Boore", "1987", "conversion", "equations", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/toro_1997.py#L131-L145
train
gem/oq-engine
openquake/commands/upgrade_nrml.py
get_vulnerability_functions_04
def get_vulnerability_functions_04(fname): """ Parse the vulnerability model in NRML 0.4 format. :param fname: path of the vulnerability file :returns: a dictionary imt, taxonomy -> vulnerability function + vset """ categories = dict(assetCategory=set(), lossCategory=set(), ...
python
def get_vulnerability_functions_04(fname): """ Parse the vulnerability model in NRML 0.4 format. :param fname: path of the vulnerability file :returns: a dictionary imt, taxonomy -> vulnerability function + vset """ categories = dict(assetCategory=set(), lossCategory=set(), ...
[ "def", "get_vulnerability_functions_04", "(", "fname", ")", ":", "categories", "=", "dict", "(", "assetCategory", "=", "set", "(", ")", ",", "lossCategory", "=", "set", "(", ")", ",", "vulnerabilitySetID", "=", "set", "(", ")", ")", "imts", "=", "set", "...
Parse the vulnerability model in NRML 0.4 format. :param fname: path of the vulnerability file :returns: a dictionary imt, taxonomy -> vulnerability function + vset
[ "Parse", "the", "vulnerability", "model", "in", "NRML", "0", ".", "4", "format", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/upgrade_nrml.py#L32-L80
train
gem/oq-engine
openquake/commands/upgrade_nrml.py
upgrade_file
def upgrade_file(path, multipoint): """Upgrade to the latest NRML version""" node0 = nrml.read(path, chatty=False)[0] shutil.copy(path, path + '.bak') # make a backup of the original file tag = striptag(node0.tag) gml = True if tag == 'vulnerabilityModel': vf_dict, cat_dict = get_vulner...
python
def upgrade_file(path, multipoint): """Upgrade to the latest NRML version""" node0 = nrml.read(path, chatty=False)[0] shutil.copy(path, path + '.bak') # make a backup of the original file tag = striptag(node0.tag) gml = True if tag == 'vulnerabilityModel': vf_dict, cat_dict = get_vulner...
[ "def", "upgrade_file", "(", "path", ",", "multipoint", ")", ":", "node0", "=", "nrml", ".", "read", "(", "path", ",", "chatty", "=", "False", ")", "[", "0", "]", "shutil", ".", "copy", "(", "path", ",", "path", "+", "'.bak'", ")", "tag", "=", "st...
Upgrade to the latest NRML version
[ "Upgrade", "to", "the", "latest", "NRML", "version" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/upgrade_nrml.py#L83-L110
train
gem/oq-engine
openquake/hazardlib/gsim/faccioli_2010.py
FaccioliEtAl2010._compute_term_3
def _compute_term_3(self, C, rrup, mag): """ This computes the third term in equation 2, page 2. """ return (C['a3'] * np.log10(rrup + C['a4'] * np.power(10, C['a5'] * mag)))
python
def _compute_term_3(self, C, rrup, mag): """ This computes the third term in equation 2, page 2. """ return (C['a3'] * np.log10(rrup + C['a4'] * np.power(10, C['a5'] * mag)))
[ "def", "_compute_term_3", "(", "self", ",", "C", ",", "rrup", ",", "mag", ")", ":", "return", "(", "C", "[", "'a3'", "]", "*", "np", ".", "log10", "(", "rrup", "+", "C", "[", "'a4'", "]", "*", "np", ".", "power", "(", "10", ",", "C", "[", "...
This computes the third term in equation 2, page 2.
[ "This", "computes", "the", "third", "term", "in", "equation", "2", "page", "2", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/faccioli_2010.py#L85-L90
train
gem/oq-engine
openquake/hmtk/sources/source_conversion_utils.py
mag_scale_rel_to_hazardlib
def mag_scale_rel_to_hazardlib(mag_scale_rel, use_default=False): """ Returns the magnitude scaling relation in a format readable by openquake.hazardlib """ if isinstance(mag_scale_rel, BaseMSR): return mag_scale_rel elif isinstance(mag_scale_rel, str): if not mag_scale_rel in SC...
python
def mag_scale_rel_to_hazardlib(mag_scale_rel, use_default=False): """ Returns the magnitude scaling relation in a format readable by openquake.hazardlib """ if isinstance(mag_scale_rel, BaseMSR): return mag_scale_rel elif isinstance(mag_scale_rel, str): if not mag_scale_rel in SC...
[ "def", "mag_scale_rel_to_hazardlib", "(", "mag_scale_rel", ",", "use_default", "=", "False", ")", ":", "if", "isinstance", "(", "mag_scale_rel", ",", "BaseMSR", ")", ":", "return", "mag_scale_rel", "elif", "isinstance", "(", "mag_scale_rel", ",", "str", ")", ":"...
Returns the magnitude scaling relation in a format readable by openquake.hazardlib
[ "Returns", "the", "magnitude", "scaling", "relation", "in", "a", "format", "readable", "by", "openquake", ".", "hazardlib" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/sources/source_conversion_utils.py#L79-L97
train
gem/oq-engine
openquake/hmtk/sources/source_conversion_utils.py
npd_to_pmf
def npd_to_pmf(nodal_plane_dist, use_default=False): """ Returns the nodal plane distribution as an instance of the PMF class """ if isinstance(nodal_plane_dist, PMF): # Aready in PMF format - return return nodal_plane_dist else: if use_default: return PMF([(1.0, ...
python
def npd_to_pmf(nodal_plane_dist, use_default=False): """ Returns the nodal plane distribution as an instance of the PMF class """ if isinstance(nodal_plane_dist, PMF): # Aready in PMF format - return return nodal_plane_dist else: if use_default: return PMF([(1.0, ...
[ "def", "npd_to_pmf", "(", "nodal_plane_dist", ",", "use_default", "=", "False", ")", ":", "if", "isinstance", "(", "nodal_plane_dist", ",", "PMF", ")", ":", "return", "nodal_plane_dist", "else", ":", "if", "use_default", ":", "return", "PMF", "(", "[", "(", ...
Returns the nodal plane distribution as an instance of the PMF class
[ "Returns", "the", "nodal", "plane", "distribution", "as", "an", "instance", "of", "the", "PMF", "class" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/sources/source_conversion_utils.py#L100-L111
train
gem/oq-engine
openquake/commands/engine.py
run_job
def run_job(job_ini, log_level='info', log_file=None, exports='', username=getpass.getuser(), **kw): """ Run a job using the specified config file and other options. :param str job_ini: Path to calculation config (INI-style) files. :param str log_level: 'debug', 'info', 'war...
python
def run_job(job_ini, log_level='info', log_file=None, exports='', username=getpass.getuser(), **kw): """ Run a job using the specified config file and other options. :param str job_ini: Path to calculation config (INI-style) files. :param str log_level: 'debug', 'info', 'war...
[ "def", "run_job", "(", "job_ini", ",", "log_level", "=", "'info'", ",", "log_file", "=", "None", ",", "exports", "=", "''", ",", "username", "=", "getpass", ".", "getuser", "(", ")", ",", "**", "kw", ")", ":", "job_id", "=", "logs", ".", "init", "(...
Run a job using the specified config file and other options. :param str job_ini: Path to calculation config (INI-style) files. :param str log_level: 'debug', 'info', 'warn', 'error', or 'critical' :param str log_file: Path to log file. :param exports: A comma-separated s...
[ "Run", "a", "job", "using", "the", "specified", "config", "file", "and", "other", "options", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/engine.py#L45-L71
train
gem/oq-engine
openquake/commands/engine.py
run_tile
def run_tile(job_ini, sites_slice): """ Used in tiling calculations """ return run_job(job_ini, sites_slice=(sites_slice.start, sites_slice.stop))
python
def run_tile(job_ini, sites_slice): """ Used in tiling calculations """ return run_job(job_ini, sites_slice=(sites_slice.start, sites_slice.stop))
[ "def", "run_tile", "(", "job_ini", ",", "sites_slice", ")", ":", "return", "run_job", "(", "job_ini", ",", "sites_slice", "=", "(", "sites_slice", ".", "start", ",", "sites_slice", ".", "stop", ")", ")" ]
Used in tiling calculations
[ "Used", "in", "tiling", "calculations" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/engine.py#L74-L78
train
gem/oq-engine
openquake/commands/engine.py
del_calculation
def del_calculation(job_id, confirmed=False): """ Delete a calculation and all associated outputs. """ if logs.dbcmd('get_job', job_id) is None: print('There is no job %d' % job_id) return if confirmed or confirm( 'Are you sure you want to (abort and) delete this calcula...
python
def del_calculation(job_id, confirmed=False): """ Delete a calculation and all associated outputs. """ if logs.dbcmd('get_job', job_id) is None: print('There is no job %d' % job_id) return if confirmed or confirm( 'Are you sure you want to (abort and) delete this calcula...
[ "def", "del_calculation", "(", "job_id", ",", "confirmed", "=", "False", ")", ":", "if", "logs", ".", "dbcmd", "(", "'get_job'", ",", "job_id", ")", "is", "None", ":", "print", "(", "'There is no job %d'", "%", "job_id", ")", "return", "if", "confirmed", ...
Delete a calculation and all associated outputs.
[ "Delete", "a", "calculation", "and", "all", "associated", "outputs", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/engine.py#L81-L101
train
gem/oq-engine
openquake/commands/engine.py
smart_run
def smart_run(job_ini, oqparam, log_level, log_file, exports, reuse_hazard): """ Run calculations by storing their hazard checksum and reusing previous calculations if requested. """ haz_checksum = readinput.get_checksum32(oqparam, hazard=True) # retrieve an old calculation with the right checks...
python
def smart_run(job_ini, oqparam, log_level, log_file, exports, reuse_hazard): """ Run calculations by storing their hazard checksum and reusing previous calculations if requested. """ haz_checksum = readinput.get_checksum32(oqparam, hazard=True) # retrieve an old calculation with the right checks...
[ "def", "smart_run", "(", "job_ini", ",", "oqparam", ",", "log_level", ",", "log_file", ",", "exports", ",", "reuse_hazard", ")", ":", "haz_checksum", "=", "readinput", ".", "get_checksum32", "(", "oqparam", ",", "hazard", "=", "True", ")", "job", "=", "log...
Run calculations by storing their hazard checksum and reusing previous calculations if requested.
[ "Run", "calculations", "by", "storing", "their", "hazard", "checksum", "and", "reusing", "previous", "calculations", "if", "requested", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/engine.py#L104-L137
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2008.py
CampbellBozorgnia2008._get_stddevs
def _get_stddevs(self, C, sites, pga1100, sigma_pga, stddev_types): """ Returns the standard deviations as described in the "ALEATORY UNCERTAINTY MODEL" section of the paper. Equations 13 to 19, pages 147 to 151 """ std_intra = self._compute_intra_event_std(C, ...
python
def _get_stddevs(self, C, sites, pga1100, sigma_pga, stddev_types): """ Returns the standard deviations as described in the "ALEATORY UNCERTAINTY MODEL" section of the paper. Equations 13 to 19, pages 147 to 151 """ std_intra = self._compute_intra_event_std(C, ...
[ "def", "_get_stddevs", "(", "self", ",", "C", ",", "sites", ",", "pga1100", ",", "sigma_pga", ",", "stddev_types", ")", ":", "std_intra", "=", "self", ".", "_compute_intra_event_std", "(", "C", ",", "sites", ".", "vs30", ",", "pga1100", ",", "sigma_pga", ...
Returns the standard deviations as described in the "ALEATORY UNCERTAINTY MODEL" section of the paper. Equations 13 to 19, pages 147 to 151
[ "Returns", "the", "standard", "deviations", "as", "described", "in", "the", "ALEATORY", "UNCERTAINTY", "MODEL", "section", "of", "the", "paper", ".", "Equations", "13", "to", "19", "pages", "147", "to", "151" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2008.py#L300-L321
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2008.py
CampbellBozorgnia2008._compute_intra_event_std
def _compute_intra_event_std(self, C, vs30, pga1100, sigma_pga): """ Returns the intra-event standard deviation at the site, as defined in equation 15, page 147 """ # Get intra-event standard deviation at the base of the site profile sig_lnyb = np.sqrt(C['s_lny'] ** 2. - ...
python
def _compute_intra_event_std(self, C, vs30, pga1100, sigma_pga): """ Returns the intra-event standard deviation at the site, as defined in equation 15, page 147 """ # Get intra-event standard deviation at the base of the site profile sig_lnyb = np.sqrt(C['s_lny'] ** 2. - ...
[ "def", "_compute_intra_event_std", "(", "self", ",", "C", ",", "vs30", ",", "pga1100", ",", "sigma_pga", ")", ":", "sig_lnyb", "=", "np", ".", "sqrt", "(", "C", "[", "'s_lny'", "]", "**", "2.", "-", "C", "[", "'s_lnAF'", "]", "**", "2.", ")", "sig_...
Returns the intra-event standard deviation at the site, as defined in equation 15, page 147
[ "Returns", "the", "intra", "-", "event", "standard", "deviation", "at", "the", "site", "as", "defined", "in", "equation", "15", "page", "147" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2008.py#L323-L338
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2008.py
CampbellBozorgnia2008._compute_intra_event_alpha
def _compute_intra_event_alpha(self, C, vs30, pga1100): """ Returns the linearised functional relationship between fsite and pga1100, determined from the partial derivative defined on equation 17 on page 148 """ alpha = np.zeros_like(vs30, dtype=float) idx = vs30 ...
python
def _compute_intra_event_alpha(self, C, vs30, pga1100): """ Returns the linearised functional relationship between fsite and pga1100, determined from the partial derivative defined on equation 17 on page 148 """ alpha = np.zeros_like(vs30, dtype=float) idx = vs30 ...
[ "def", "_compute_intra_event_alpha", "(", "self", ",", "C", ",", "vs30", ",", "pga1100", ")", ":", "alpha", "=", "np", ".", "zeros_like", "(", "vs30", ",", "dtype", "=", "float", ")", "idx", "=", "vs30", "<", "C", "[", "'k1'", "]", "if", "np", ".",...
Returns the linearised functional relationship between fsite and pga1100, determined from the partial derivative defined on equation 17 on page 148
[ "Returns", "the", "linearised", "functional", "relationship", "between", "fsite", "and", "pga1100", "determined", "from", "the", "partial", "derivative", "defined", "on", "equation", "17", "on", "page", "148" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2008.py#L340-L354
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2008.py
CampbellBozorgnia2008Arbitrary._get_total_sigma
def _get_total_sigma(self, C, std_intra, std_inter): """ Returns the total sigma term for the arbitrary horizontal component of ground motion defined by equation 18, page 150 """ return np.sqrt(std_intra ** 2. + std_inter ** 2. + C['c_lny'] ** 2.)
python
def _get_total_sigma(self, C, std_intra, std_inter): """ Returns the total sigma term for the arbitrary horizontal component of ground motion defined by equation 18, page 150 """ return np.sqrt(std_intra ** 2. + std_inter ** 2. + C['c_lny'] ** 2.)
[ "def", "_get_total_sigma", "(", "self", ",", "C", ",", "std_intra", ",", "std_inter", ")", ":", "return", "np", ".", "sqrt", "(", "std_intra", "**", "2.", "+", "std_inter", "**", "2.", "+", "C", "[", "'c_lny'", "]", "**", "2.", ")" ]
Returns the total sigma term for the arbitrary horizontal component of ground motion defined by equation 18, page 150
[ "Returns", "the", "total", "sigma", "term", "for", "the", "arbitrary", "horizontal", "component", "of", "ground", "motion", "defined", "by", "equation", "18", "page", "150" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2008.py#L407-L412
train
gem/oq-engine
openquake/calculators/ucerf_event_based.py
generate_event_set
def generate_event_set(ucerf, background_sids, src_filter, ses_idx, seed): """ Generates the event set corresponding to a particular branch """ serial = seed + ses_idx * TWO16 # get rates from file with h5py.File(ucerf.source_file, 'r') as hdf5: occurrences = ucerf.tom.sample_number_of_o...
python
def generate_event_set(ucerf, background_sids, src_filter, ses_idx, seed): """ Generates the event set corresponding to a particular branch """ serial = seed + ses_idx * TWO16 # get rates from file with h5py.File(ucerf.source_file, 'r') as hdf5: occurrences = ucerf.tom.sample_number_of_o...
[ "def", "generate_event_set", "(", "ucerf", ",", "background_sids", ",", "src_filter", ",", "ses_idx", ",", "seed", ")", ":", "serial", "=", "seed", "+", "ses_idx", "*", "TWO16", "with", "h5py", ".", "File", "(", "ucerf", ".", "source_file", ",", "'r'", "...
Generates the event set corresponding to a particular branch
[ "Generates", "the", "event", "set", "corresponding", "to", "a", "particular", "branch" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/ucerf_event_based.py#L41-L76
train
gem/oq-engine
openquake/calculators/ucerf_event_based.py
sample_background_model
def sample_background_model( hdf5, branch_key, tom, seed, filter_idx, min_mag, npd, hdd, upper_seismogenic_depth, lower_seismogenic_depth, msr=WC1994(), aspect=1.5, trt=DEFAULT_TRT): """ Generates a rupture set from a sample of the background model :param branch_key: Key to ...
python
def sample_background_model( hdf5, branch_key, tom, seed, filter_idx, min_mag, npd, hdd, upper_seismogenic_depth, lower_seismogenic_depth, msr=WC1994(), aspect=1.5, trt=DEFAULT_TRT): """ Generates a rupture set from a sample of the background model :param branch_key: Key to ...
[ "def", "sample_background_model", "(", "hdf5", ",", "branch_key", ",", "tom", ",", "seed", ",", "filter_idx", ",", "min_mag", ",", "npd", ",", "hdd", ",", "upper_seismogenic_depth", ",", "lower_seismogenic_depth", ",", "msr", "=", "WC1994", "(", ")", ",", "a...
Generates a rupture set from a sample of the background model :param branch_key: Key to indicate the branch for selecting the background model :param tom: Temporal occurrence model as instance of :class: openquake.hazardlib.tom.TOM :param seed: Random seed to use in the call...
[ "Generates", "a", "rupture", "set", "from", "a", "sample", "of", "the", "background", "model" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/ucerf_event_based.py#L79-L136
train
gem/oq-engine
openquake/hazardlib/scalerel/wc1994.py
WC1994.get_median_area
def get_median_area(self, mag, rake): """ The values are a function of both magnitude and rake. Setting the rake to ``None`` causes their "All" rupture-types to be applied. """ assert rake is None or -180 <= rake <= 180 if rake is None: # their "All" ...
python
def get_median_area(self, mag, rake): """ The values are a function of both magnitude and rake. Setting the rake to ``None`` causes their "All" rupture-types to be applied. """ assert rake is None or -180 <= rake <= 180 if rake is None: # their "All" ...
[ "def", "get_median_area", "(", "self", ",", "mag", ",", "rake", ")", ":", "assert", "rake", "is", "None", "or", "-", "180", "<=", "rake", "<=", "180", "if", "rake", "is", "None", ":", "return", "10.0", "**", "(", "-", "3.49", "+", "0.91", "*", "m...
The values are a function of both magnitude and rake. Setting the rake to ``None`` causes their "All" rupture-types to be applied.
[ "The", "values", "are", "a", "function", "of", "both", "magnitude", "and", "rake", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/scalerel/wc1994.py#L33-L52
train
gem/oq-engine
openquake/hazardlib/scalerel/wc1994.py
WC1994.get_std_dev_area
def get_std_dev_area(self, mag, rake): """ Standard deviation for WC1994. Magnitude is ignored. """ assert rake is None or -180 <= rake <= 180 if rake is None: # their "All" case return 0.24 elif (-45 <= rake <= 45) or (rake >= 135) or (rake <= -13...
python
def get_std_dev_area(self, mag, rake): """ Standard deviation for WC1994. Magnitude is ignored. """ assert rake is None or -180 <= rake <= 180 if rake is None: # their "All" case return 0.24 elif (-45 <= rake <= 45) or (rake >= 135) or (rake <= -13...
[ "def", "get_std_dev_area", "(", "self", ",", "mag", ",", "rake", ")", ":", "assert", "rake", "is", "None", "or", "-", "180", "<=", "rake", "<=", "180", "if", "rake", "is", "None", ":", "return", "0.24", "elif", "(", "-", "45", "<=", "rake", "<=", ...
Standard deviation for WC1994. Magnitude is ignored.
[ "Standard", "deviation", "for", "WC1994", ".", "Magnitude", "is", "ignored", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/scalerel/wc1994.py#L54-L70
train
gem/oq-engine
openquake/hazardlib/scalerel/wc1994.py
WC1994.get_std_dev_mag
def get_std_dev_mag(self, rake): """ Standard deviation on the magnitude for the WC1994 area relation. """ assert rake is None or -180 <= rake <= 180 if rake is None: # their "All" case return 0.24 elif (-45 <= rake <= 45) or (rake >= 135) or (rake...
python
def get_std_dev_mag(self, rake): """ Standard deviation on the magnitude for the WC1994 area relation. """ assert rake is None or -180 <= rake <= 180 if rake is None: # their "All" case return 0.24 elif (-45 <= rake <= 45) or (rake >= 135) or (rake...
[ "def", "get_std_dev_mag", "(", "self", ",", "rake", ")", ":", "assert", "rake", "is", "None", "or", "-", "180", "<=", "rake", "<=", "180", "if", "rake", "is", "None", ":", "return", "0.24", "elif", "(", "-", "45", "<=", "rake", "<=", "45", ")", "...
Standard deviation on the magnitude for the WC1994 area relation.
[ "Standard", "deviation", "on", "the", "magnitude", "for", "the", "WC1994", "area", "relation", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/scalerel/wc1994.py#L72-L88
train
gem/oq-engine
openquake/hazardlib/gsim/mgmpe/generic_gmpe_avgsa.py
GenericGmpeAvgSA.set_parameters
def set_parameters(self): """ Combines the parameters of the GMPE provided at the construction level with the ones assigned to the average GMPE. """ for key in dir(self): if key.startswith('REQUIRES_'): setattr(self, key, getattr(self.gmpe, key)) ...
python
def set_parameters(self): """ Combines the parameters of the GMPE provided at the construction level with the ones assigned to the average GMPE. """ for key in dir(self): if key.startswith('REQUIRES_'): setattr(self, key, getattr(self.gmpe, key)) ...
[ "def", "set_parameters", "(", "self", ")", ":", "for", "key", "in", "dir", "(", "self", ")", ":", "if", "key", ".", "startswith", "(", "'REQUIRES_'", ")", ":", "setattr", "(", "self", ",", "key", ",", "getattr", "(", "self", ".", "gmpe", ",", "key"...
Combines the parameters of the GMPE provided at the construction level with the ones assigned to the average GMPE.
[ "Combines", "the", "parameters", "of", "the", "GMPE", "provided", "at", "the", "construction", "level", "with", "the", "ones", "assigned", "to", "the", "average", "GMPE", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/mgmpe/generic_gmpe_avgsa.py#L87-L97
train
gem/oq-engine
openquake/hazardlib/geo/mesh.py
Mesh.from_points_list
def from_points_list(cls, points): """ Create a mesh object from a collection of points. :param point: List of :class:`~openquake.hazardlib.geo.point.Point` objects. :returns: An instance of :class:`Mesh` with one-dimensional arrays of coordinates fro...
python
def from_points_list(cls, points): """ Create a mesh object from a collection of points. :param point: List of :class:`~openquake.hazardlib.geo.point.Point` objects. :returns: An instance of :class:`Mesh` with one-dimensional arrays of coordinates fro...
[ "def", "from_points_list", "(", "cls", ",", "points", ")", ":", "lons", "=", "numpy", ".", "zeros", "(", "len", "(", "points", ")", ",", "dtype", "=", "float", ")", "lats", "=", "lons", ".", "copy", "(", ")", "depths", "=", "lons", ".", "copy", "...
Create a mesh object from a collection of points. :param point: List of :class:`~openquake.hazardlib.geo.point.Point` objects. :returns: An instance of :class:`Mesh` with one-dimensional arrays of coordinates from ``points``.
[ "Create", "a", "mesh", "object", "from", "a", "collection", "of", "points", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/mesh.py#L134-L154
train
gem/oq-engine
openquake/hazardlib/geo/mesh.py
Mesh.get_min_distance
def get_min_distance(self, mesh): """ Compute and return the minimum distance from the mesh to each point in another mesh. :returns: numpy array of distances in km of shape (self.size, mesh.size) Method doesn't make any assumptions on arrangement of the points ...
python
def get_min_distance(self, mesh): """ Compute and return the minimum distance from the mesh to each point in another mesh. :returns: numpy array of distances in km of shape (self.size, mesh.size) Method doesn't make any assumptions on arrangement of the points ...
[ "def", "get_min_distance", "(", "self", ",", "mesh", ")", ":", "return", "cdist", "(", "self", ".", "xyz", ",", "mesh", ".", "xyz", ")", ".", "min", "(", "axis", "=", "0", ")" ]
Compute and return the minimum distance from the mesh to each point in another mesh. :returns: numpy array of distances in km of shape (self.size, mesh.size) Method doesn't make any assumptions on arrangement of the points in either mesh and instead calculates the distance ...
[ "Compute", "and", "return", "the", "minimum", "distance", "from", "the", "mesh", "to", "each", "point", "in", "another", "mesh", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/mesh.py#L236-L249
train
gem/oq-engine
openquake/hazardlib/geo/mesh.py
Mesh.get_closest_points
def get_closest_points(self, mesh): """ Find closest point of this mesh for each point in the other mesh :returns: :class:`Mesh` object of the same shape as `mesh` with closest points from this one at respective indices. """ min_idx = cdist(self.xyz, mesh...
python
def get_closest_points(self, mesh): """ Find closest point of this mesh for each point in the other mesh :returns: :class:`Mesh` object of the same shape as `mesh` with closest points from this one at respective indices. """ min_idx = cdist(self.xyz, mesh...
[ "def", "get_closest_points", "(", "self", ",", "mesh", ")", ":", "min_idx", "=", "cdist", "(", "self", ".", "xyz", ",", "mesh", ".", "xyz", ")", ".", "argmin", "(", "axis", "=", "0", ")", "if", "hasattr", "(", "mesh", ",", "'shape'", ")", ":", "m...
Find closest point of this mesh for each point in the other mesh :returns: :class:`Mesh` object of the same shape as `mesh` with closest points from this one at respective indices.
[ "Find", "closest", "point", "of", "this", "mesh", "for", "each", "point", "in", "the", "other", "mesh" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/mesh.py#L251-L265
train
gem/oq-engine
openquake/hazardlib/geo/mesh.py
Mesh.get_distance_matrix
def get_distance_matrix(self): """ Compute and return distances between each pairs of points in the mesh. This method requires that the coordinate arrays are one-dimensional. NB: the depth of the points is ignored .. warning:: Because of its quadratic space and time...
python
def get_distance_matrix(self): """ Compute and return distances between each pairs of points in the mesh. This method requires that the coordinate arrays are one-dimensional. NB: the depth of the points is ignored .. warning:: Because of its quadratic space and time...
[ "def", "get_distance_matrix", "(", "self", ")", ":", "assert", "self", ".", "lons", ".", "ndim", "==", "1", "distances", "=", "geodetic", ".", "geodetic_distance", "(", "self", ".", "lons", ".", "reshape", "(", "self", ".", "lons", ".", "shape", "+", "...
Compute and return distances between each pairs of points in the mesh. This method requires that the coordinate arrays are one-dimensional. NB: the depth of the points is ignored .. warning:: Because of its quadratic space and time complexity this method is safe to use ...
[ "Compute", "and", "return", "distances", "between", "each", "pairs", "of", "points", "in", "the", "mesh", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/mesh.py#L267-L295
train
gem/oq-engine
openquake/hazardlib/geo/mesh.py
Mesh._get_proj_convex_hull
def _get_proj_convex_hull(self): """ Create a projection centered in the center of this mesh and define a convex polygon in that projection, enveloping all the points of the mesh. :returns: Tuple of two items: projection function and shapely 2d polygon. N...
python
def _get_proj_convex_hull(self): """ Create a projection centered in the center of this mesh and define a convex polygon in that projection, enveloping all the points of the mesh. :returns: Tuple of two items: projection function and shapely 2d polygon. N...
[ "def", "_get_proj_convex_hull", "(", "self", ")", ":", "proj", "=", "geo_utils", ".", "OrthographicProjection", "(", "*", "geo_utils", ".", "get_spherical_bounding_box", "(", "self", ".", "lons", ",", "self", ".", "lats", ")", ")", "coords", "=", "numpy", "....
Create a projection centered in the center of this mesh and define a convex polygon in that projection, enveloping all the points of the mesh. :returns: Tuple of two items: projection function and shapely 2d polygon. Note that the result geometry can be line or point dep...
[ "Create", "a", "projection", "centered", "in", "the", "center", "of", "this", "mesh", "and", "define", "a", "convex", "polygon", "in", "that", "projection", "enveloping", "all", "the", "points", "of", "the", "mesh", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/mesh.py#L297-L317
train
gem/oq-engine
openquake/hazardlib/geo/mesh.py
Mesh.get_joyner_boore_distance
def get_joyner_boore_distance(self, mesh): """ Compute and return Joyner-Boore distance to each point of ``mesh``. Point's depth is ignored. See :meth:`openquake.hazardlib.geo.surface.base.BaseSurface.get_joyner_boore_distance` for definition of this distance. :...
python
def get_joyner_boore_distance(self, mesh): """ Compute and return Joyner-Boore distance to each point of ``mesh``. Point's depth is ignored. See :meth:`openquake.hazardlib.geo.surface.base.BaseSurface.get_joyner_boore_distance` for definition of this distance. :...
[ "def", "get_joyner_boore_distance", "(", "self", ",", "mesh", ")", ":", "distances", "=", "geodetic", ".", "min_geodetic_distance", "(", "(", "self", ".", "lons", ",", "self", ".", "lats", ")", ",", "(", "mesh", ".", "lons", ",", "mesh", ".", "lats", "...
Compute and return Joyner-Boore distance to each point of ``mesh``. Point's depth is ignored. See :meth:`openquake.hazardlib.geo.surface.base.BaseSurface.get_joyner_boore_distance` for definition of this distance. :returns: numpy array of distances in km of the same...
[ "Compute", "and", "return", "Joyner", "-", "Boore", "distance", "to", "each", "point", "of", "mesh", ".", "Point", "s", "depth", "is", "ignored", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/mesh.py#L319-L393
train
gem/oq-engine
openquake/hazardlib/geo/mesh.py
Mesh.get_convex_hull
def get_convex_hull(self): """ Get a convex polygon object that contains projections of all the points of the mesh. :returns: Instance of :class:`openquake.hazardlib.geo.polygon.Polygon` that is a convex hull around all the points in this mesh. If the ...
python
def get_convex_hull(self): """ Get a convex polygon object that contains projections of all the points of the mesh. :returns: Instance of :class:`openquake.hazardlib.geo.polygon.Polygon` that is a convex hull around all the points in this mesh. If the ...
[ "def", "get_convex_hull", "(", "self", ")", ":", "proj", ",", "polygon2d", "=", "self", ".", "_get_proj_convex_hull", "(", ")", "if", "isinstance", "(", "polygon2d", ",", "(", "shapely", ".", "geometry", ".", "LineString", ",", "shapely", ".", "geometry", ...
Get a convex polygon object that contains projections of all the points of the mesh. :returns: Instance of :class:`openquake.hazardlib.geo.polygon.Polygon` that is a convex hull around all the points in this mesh. If the original mesh had only one point, the resultin...
[ "Get", "a", "convex", "polygon", "object", "that", "contains", "projections", "of", "all", "the", "points", "of", "the", "mesh", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/mesh.py#L457-L480
train
gem/oq-engine
openquake/hazardlib/geo/mesh.py
RectangularMesh.from_points_list
def from_points_list(cls, points): """ Create a rectangular mesh object from a list of lists of points. Lists in a list are supposed to have the same length. :param point: List of lists of :class:`~openquake.hazardlib.geo.point.Point` objects. """ ...
python
def from_points_list(cls, points): """ Create a rectangular mesh object from a list of lists of points. Lists in a list are supposed to have the same length. :param point: List of lists of :class:`~openquake.hazardlib.geo.point.Point` objects. """ ...
[ "def", "from_points_list", "(", "cls", ",", "points", ")", ":", "assert", "points", "is", "not", "None", "and", "len", "(", "points", ")", ">", "0", "and", "len", "(", "points", "[", "0", "]", ")", ">", "0", ",", "'list of at least one non-empty list of ...
Create a rectangular mesh object from a list of lists of points. Lists in a list are supposed to have the same length. :param point: List of lists of :class:`~openquake.hazardlib.geo.point.Point` objects.
[ "Create", "a", "rectangular", "mesh", "object", "from", "a", "list", "of", "lists", "of", "points", ".", "Lists", "in", "a", "list", "are", "supposed", "to", "have", "the", "same", "length", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/mesh.py#L497-L521
train
gem/oq-engine
openquake/hazardlib/geo/mesh.py
RectangularMesh.get_middle_point
def get_middle_point(self): """ Return the middle point of the mesh. :returns: An instance of :class:`~openquake.hazardlib.geo.point.Point`. The middle point is taken from the middle row and a middle column of the mesh if there are odd number of both. Otherwise the ...
python
def get_middle_point(self): """ Return the middle point of the mesh. :returns: An instance of :class:`~openquake.hazardlib.geo.point.Point`. The middle point is taken from the middle row and a middle column of the mesh if there are odd number of both. Otherwise the ...
[ "def", "get_middle_point", "(", "self", ")", ":", "num_rows", ",", "num_cols", "=", "self", ".", "lons", ".", "shape", "mid_row", "=", "num_rows", "//", "2", "depth", "=", "0", "if", "num_rows", "&", "1", "==", "1", ":", "mid_col", "=", "num_cols", "...
Return the middle point of the mesh. :returns: An instance of :class:`~openquake.hazardlib.geo.point.Point`. The middle point is taken from the middle row and a middle column of the mesh if there are odd number of both. Otherwise the geometric mean point of two or four midd...
[ "Return", "the", "middle", "point", "of", "the", "mesh", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/mesh.py#L523-L566
train
gem/oq-engine
openquake/hazardlib/geo/mesh.py
RectangularMesh.get_cell_dimensions
def get_cell_dimensions(self): """ Calculate centroid, width, length and area of each mesh cell. :returns: Tuple of four elements, each being 2d numpy array. Each array has both dimensions less by one the dimensions of the mesh, since they represent cells, no...
python
def get_cell_dimensions(self): """ Calculate centroid, width, length and area of each mesh cell. :returns: Tuple of four elements, each being 2d numpy array. Each array has both dimensions less by one the dimensions of the mesh, since they represent cells, no...
[ "def", "get_cell_dimensions", "(", "self", ")", ":", "points", ",", "along_azimuth", ",", "updip", ",", "diag", "=", "self", ".", "triangulate", "(", ")", "top", "=", "along_azimuth", "[", ":", "-", "1", "]", "left", "=", "updip", "[", ":", ",", ":",...
Calculate centroid, width, length and area of each mesh cell. :returns: Tuple of four elements, each being 2d numpy array. Each array has both dimensions less by one the dimensions of the mesh, since they represent cells, not vertices. Arrays contain the followin...
[ "Calculate", "centroid", "width", "length", "and", "area", "of", "each", "mesh", "cell", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/mesh.py#L704-L746
train
gem/oq-engine
openquake/hazardlib/geo/mesh.py
RectangularMesh.triangulate
def triangulate(self): """ Convert mesh points to vectors in Cartesian space. :returns: Tuple of four elements, each being 2d numpy array of 3d vectors (the same structure and shape as the mesh itself). Those arrays are: #. points vectors, ...
python
def triangulate(self): """ Convert mesh points to vectors in Cartesian space. :returns: Tuple of four elements, each being 2d numpy array of 3d vectors (the same structure and shape as the mesh itself). Those arrays are: #. points vectors, ...
[ "def", "triangulate", "(", "self", ")", ":", "points", "=", "geo_utils", ".", "spherical_to_cartesian", "(", "self", ".", "lons", ",", "self", ".", "lats", ",", "self", ".", "depths", ")", "along_azimuth", "=", "points", "[", ":", ",", "1", ":", "]", ...
Convert mesh points to vectors in Cartesian space. :returns: Tuple of four elements, each being 2d numpy array of 3d vectors (the same structure and shape as the mesh itself). Those arrays are: #. points vectors, #. vectors directed from each point (...
[ "Convert", "mesh", "points", "to", "vectors", "in", "Cartesian", "space", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/mesh.py#L748-L778
train
gem/oq-engine
openquake/hmtk/seismicity/smoothing/kernels/isotropic_gaussian.py
IsotropicGaussian.smooth_data
def smooth_data(self, data, config, is_3d=False): ''' Applies the smoothing kernel to the data :param np.ndarray data: Raw earthquake count in the form [Longitude, Latitude, Depth, Count] :param dict config: Configuration parameters must contain: ...
python
def smooth_data(self, data, config, is_3d=False): ''' Applies the smoothing kernel to the data :param np.ndarray data: Raw earthquake count in the form [Longitude, Latitude, Depth, Count] :param dict config: Configuration parameters must contain: ...
[ "def", "smooth_data", "(", "self", ",", "data", ",", "config", ",", "is_3d", "=", "False", ")", ":", "max_dist", "=", "config", "[", "'Length_Limit'", "]", "*", "config", "[", "'BandWidth'", "]", "smoothed_value", "=", "np", ".", "zeros", "(", "len", "...
Applies the smoothing kernel to the data :param np.ndarray data: Raw earthquake count in the form [Longitude, Latitude, Depth, Count] :param dict config: Configuration parameters must contain: * BandWidth: The bandwidth of the kernel (in km) (float) ...
[ "Applies", "the", "smoothing", "kernel", "to", "the", "data" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/smoothing/kernels/isotropic_gaussian.py#L69-L99
train
gem/oq-engine
openquake/commands/purge.py
purge_one
def purge_one(calc_id, user): """ Remove one calculation ID from the database and remove its datastore """ filename = os.path.join(datadir, 'calc_%s.hdf5' % calc_id) err = dbcmd('del_calc', calc_id, user) if err: print(err) elif os.path.exists(filename): # not removed yet os...
python
def purge_one(calc_id, user): """ Remove one calculation ID from the database and remove its datastore """ filename = os.path.join(datadir, 'calc_%s.hdf5' % calc_id) err = dbcmd('del_calc', calc_id, user) if err: print(err) elif os.path.exists(filename): # not removed yet os...
[ "def", "purge_one", "(", "calc_id", ",", "user", ")", ":", "filename", "=", "os", ".", "path", ".", "join", "(", "datadir", ",", "'calc_%s.hdf5'", "%", "calc_id", ")", "err", "=", "dbcmd", "(", "'del_calc'", ",", "calc_id", ",", "user", ")", "if", "e...
Remove one calculation ID from the database and remove its datastore
[ "Remove", "one", "calculation", "ID", "from", "the", "database", "and", "remove", "its", "datastore" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/purge.py#L28-L38
train
gem/oq-engine
openquake/commands/purge.py
purge_all
def purge_all(user=None, fast=False): """ Remove all calculations of the given user """ user = user or getpass.getuser() if os.path.exists(datadir): if fast: shutil.rmtree(datadir) print('Removed %s' % datadir) else: for fname in os.listdir(datadir...
python
def purge_all(user=None, fast=False): """ Remove all calculations of the given user """ user = user or getpass.getuser() if os.path.exists(datadir): if fast: shutil.rmtree(datadir) print('Removed %s' % datadir) else: for fname in os.listdir(datadir...
[ "def", "purge_all", "(", "user", "=", "None", ",", "fast", "=", "False", ")", ":", "user", "=", "user", "or", "getpass", ".", "getuser", "(", ")", "if", "os", ".", "path", ".", "exists", "(", "datadir", ")", ":", "if", "fast", ":", "shutil", ".",...
Remove all calculations of the given user
[ "Remove", "all", "calculations", "of", "the", "given", "user" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/purge.py#L42-L56
train
gem/oq-engine
openquake/commands/purge.py
purge
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...
python
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", "purge", "(", "calc_id", ")", ":", "if", "calc_id", "<", "0", ":", "try", ":", "calc_id", "=", "datastore", ".", "get_calc_ids", "(", "datadir", ")", "[", "calc_id", "]", "except", "IndexError", ":", "print", "(", "'Calculation %d not found'", "%", ...
Remove the given calculation. If you want to remove all calculations, use oq reset.
[ "Remove", "the", "given", "calculation", ".", "If", "you", "want", "to", "remove", "all", "calculations", "use", "oq", "reset", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/purge.py#L60-L71
train
gem/oq-engine
openquake/hmtk/plotting/patch.py
PolygonPatch
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...
python
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", "PolygonPatch", "(", "polygon", ",", "**", "kwargs", ")", ":", "def", "coding", "(", "ob", ")", ":", "n", "=", "len", "(", "getattr", "(", "ob", ",", "'coords'", ",", "None", ")", "or", "ob", ")", "vals", "=", "ones", "(", "n", ",", "dty...
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.PathPatch. Example (using Shapely Point and a...
[ "Constructs", "a", "matplotlib", "patch", "from", "a", "geometric", "object" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/patch.py#L43-L93
train
gem/oq-engine
openquake/hazardlib/gsim/kotha_2019.py
KothaEtAl2019.retreive_sigma_mu_data
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, ...
python
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", "retreive_sigma_mu_data", "(", "self", ")", ":", "fle", "=", "h5py", ".", "File", "(", "os", ".", "path", ".", "join", "(", "BASE_PATH", ",", "\"KothaEtAl2019_SigmaMu_Fixed.hdf5\"", ")", ",", "\"r\"", ")", "self", ".", "mags", "=", "fle", "[", "\"...
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
[ "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"...
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/kotha_2019.py#L129-L143
train
gem/oq-engine
openquake/hazardlib/gsim/kotha_2019.py
KothaEtAl2019.get_magnitude_scaling
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
python
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_magnitude_scaling", "(", "self", ",", "C", ",", "mag", ")", ":", "d_m", "=", "mag", "-", "self", ".", "CONSTANTS", "[", "\"Mh\"", "]", "if", "mag", "<", "self", ".", "CONSTANTS", "[", "\"Mh\"", "]", ":", "return", "C", "[", "\"e1\"", "]...
Returns the magnitude scaling term
[ "Returns", "the", "magnitude", "scaling", "term" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/kotha_2019.py#L174-L182
train
gem/oq-engine
openquake/hazardlib/gsim/kotha_2019.py
KothaEtAl2019.get_distance_term
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[...
python
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_term", "(", "self", ",", "C", ",", "rup", ",", "rjb", ",", "imt", ")", ":", "h", "=", "self", ".", "_get_h", "(", "C", ",", "rup", ".", "hypo_depth", ")", "rval", "=", "np", ".", "sqrt", "(", "rjb", "**", "2.", "+", "h", ...
Returns the distance attenuation factor
[ "Returns", "the", "distance", "attenuation", "factor" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/kotha_2019.py#L184-L195
train
gem/oq-engine
openquake/hazardlib/gsim/kotha_2019.py
KothaEtAl2019.get_distance_coefficients
def get_distance_coefficients(self, C, imt): """ Returns the c3 term """ c3 = self.c3[imt]["c3"] if self.c3 else C["c3"] return c3
python
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_distance_coefficients", "(", "self", ",", "C", ",", "imt", ")", ":", "c3", "=", "self", ".", "c3", "[", "imt", "]", "[", "\"c3\"", "]", "if", "self", ".", "c3", "else", "C", "[", "\"c3\"", "]", "return", "c3" ]
Returns the c3 term
[ "Returns", "the", "c3", "term" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/kotha_2019.py#L208-L213
train
gem/oq-engine
openquake/hazardlib/gsim/kotha_2019.py
KothaEtAl2019.get_sigma_mu_adjustment
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[...
python
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_sigma_mu_adjustment", "(", "self", ",", "C", ",", "imt", ",", "rup", ",", "dists", ")", ":", "if", "imt", ".", "name", "in", "\"PGA PGV\"", ":", "sigma_mu", "=", "getattr", "(", "self", ",", "imt", ".", "name", ".", "lower", "(", ")", "...
Returns the sigma mu adjustment factor
[ "Returns", "the", "sigma", "mu", "adjustment", "factor" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/kotha_2019.py#L221-L258
train
gem/oq-engine
openquake/hazardlib/gsim/kotha_2019.py
KothaEtAl2019SERA.get_site_amplification
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"] *...
python
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_site_amplification", "(", "self", ",", "C", ",", "sites", ")", ":", "ampl", "=", "np", ".", "zeros", "(", "sites", ".", "vs30", ".", "shape", ")", "ampl", "[", "sites", ".", "vs30measured", "]", "=", "(", "C", "[", "\"d0_obs\"", "]", "+...
Returns the linear site amplification term depending on whether the Vs30 is observed of inferred
[ "Returns", "the", "linear", "site", "amplification", "term", "depending", "on", "whether", "the", "Vs30", "is", "observed", "of", "inferred" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/kotha_2019.py#L332-L344
train
gem/oq-engine
openquake/hazardlib/gsim/kotha_2019.py
KothaEtAl2019SERA.get_stddevs
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=...
python
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", "get_stddevs", "(", "self", ",", "C", ",", "stddev_shape", ",", "stddev_types", ",", "sites", ")", ":", "stddevs", "=", "[", "]", "tau", "=", "C", "[", "\"tau_event\"", "]", "sigma_s", "=", "np", ".", "zeros", "(", "sites", ".", "vs30measured", ...
Returns the standard deviations, with different site standard deviation for inferred vs. observed vs30 sites.
[ "Returns", "the", "standard", "deviations", "with", "different", "site", "standard", "deviation", "for", "inferred", "vs", ".", "observed", "vs30", "sites", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/kotha_2019.py#L346-L366
train
gem/oq-engine
openquake/hazardlib/geo/geodetic.py
geodetic_distance
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 ...
python
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", "geodetic_distance", "(", "lons1", ",", "lats1", ",", "lons2", ",", "lats2", ",", "diameter", "=", "2", "*", "EARTH_RADIUS", ")", ":", "lons1", ",", "lats1", ",", "lons2", ",", "lats2", "=", "_prepare_coords", "(", "lons1", ",", "lats1", ",", "l...
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 together". Implements http://williams.best.vwh.net/avform.htm#Dist :returns:...
[ "Calculate", "the", "geodetic", "distance", "between", "two", "points", "or", "two", "collections", "of", "points", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/geodetic.py#L34-L54
train
gem/oq-engine
openquake/hazardlib/geo/geodetic.py
azimuth
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...
python
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", "azimuth", "(", "lons1", ",", "lats1", ",", "lons2", ",", "lats2", ")", ":", "lons1", ",", "lats1", ",", "lons2", ",", "lats2", "=", "_prepare_coords", "(", "lons1", ",", "lats1", ",", "lons2", ",", "lats2", ")", "cos_lat2", "=", "numpy", ".",...
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 angle between direction to north from first point and ...
[ "Calculate", "the", "azimuth", "between", "two", "points", "or", "two", "collections", "of", "points", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/geodetic.py#L57-L77
train
gem/oq-engine
openquake/hazardlib/geo/geodetic.py
min_distance_to_segment
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 ...
python
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", "min_distance_to_segment", "(", "seglons", ",", "seglats", ",", "lons", ",", "lats", ")", ":", "assert", "len", "(", "seglons", ")", "==", "len", "(", "seglats", ")", "==", "2", "seg_azim", "=", "azimuth", "(", "seglons", "[", "0", "]", ",", "...
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 seglats: A list or an array of floats specifying the latitude v...
[ "This", "function", "computes", "the", "shortest", "distance", "to", "a", "segment", "in", "a", "2D", "reference", "system", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/geodetic.py#L99-L174
train
gem/oq-engine
openquake/hazardlib/geo/geodetic.py
min_geodetic_distance
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...
python
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", "min_geodetic_distance", "(", "a", ",", "b", ")", ":", "if", "isinstance", "(", "a", ",", "tuple", ")", ":", "a", "=", "spherical_to_cartesian", "(", "a", "[", "0", "]", ".", "flatten", "(", ")", ",", "a", "[", "1", "]", ".", "flatten", "(...
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 coordinates
[ "Compute", "the", "minimum", "distance", "between", "first", "mesh", "and", "each", "point", "of", "the", "second", "mesh", "when", "both", "are", "defined", "on", "the", "earth", "surface", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/geodetic.py#L224-L236
train
gem/oq-engine
openquake/hazardlib/geo/geodetic.py
intervals_between
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...
python
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", "intervals_between", "(", "lon1", ",", "lat1", ",", "depth1", ",", "lon2", ",", "lat2", ",", "depth2", ",", "length", ")", ":", "assert", "length", ">", "0", "hdist", "=", "geodetic_distance", "(", "lon1", ",", "lat1", ",", "lon2", ",", "lat2", ...
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 first point in the resulting list has these coordinates. :param float lon2...
[ "Find", "a", "list", "of", "points", "between", "two", "given", "ones", "that", "lie", "on", "the", "same", "great", "circle", "arc", "and", "are", "equally", "spaced", "by", "length", "km", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/geodetic.py#L259-L302
train
gem/oq-engine
openquake/hazardlib/geo/geodetic.py
npoints_between
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...
python
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_between", "(", "lon1", ",", "lat1", ",", "depth1", ",", "lon2", ",", "lat2", ",", "depth2", ",", "npoints", ")", ":", "hdist", "=", "geodetic_distance", "(", "lon1", ",", "lat1", ",", "lon2", ",", "lat2", ")", "vdist", "=", "depth2", ...
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 point in a resulting list has these coordinates. :param float lon2, l...
[ "Find", "a", "list", "of", "specified", "number", "of", "points", "between", "two", "given", "ones", "that", "are", "equally", "spaced", "along", "the", "great", "circle", "arc", "connecting", "given", "points", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/geodetic.py#L305-L336
train
gem/oq-engine
openquake/hazardlib/geo/geodetic.py
npoints_towards
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...
python
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", "npoints_towards", "(", "lon", ",", "lat", ",", "depth", ",", "azimuth", ",", "hdist", ",", "vdist", ",", "npoints", ")", ":", "assert", "npoints", ">", "1", "rlon", ",", "rlat", "=", "numpy", ".", "radians", "(", "lon", ")", ",", "numpy", "...
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 point in a resulting list has these coordinates. :param azimuth: ...
[ "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", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/geodetic.py#L339-L393
train
gem/oq-engine
openquake/hazardlib/geo/geodetic.py
_prepare_coords
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...
python
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", "_prepare_coords", "(", "lons1", ",", "lats1", ",", "lons2", ",", "lats2", ")", ":", "lons1", "=", "numpy", ".", "radians", "(", "lons1", ")", "lats1", "=", "numpy", ".", "radians", "(", "lats1", ")", "assert", "lons1", ".", "shape", "==", "la...
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.
[ "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", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/geodetic.py#L528-L540
train
gem/oq-engine
openquake/hmtk/sources/simple_fault_source.py
mtkSimpleFaultSource.select_catalogue
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: ...
python
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", "select_catalogue", "(", "self", ",", "selector", ",", "distance", ",", "distance_metric", "=", "'joyner-boore'", ",", "upper_eq_depth", "=", "None", ",", "lower_eq_depth", "=", "None", ")", ":", "if", "selector", ".", "catalogue", ".", "get_number_events...
Selects earthquakes within a distance of the fault :param selector: Populated instance of :class: `openquake.hmtk.seismicity.selector.CatalogueSelector` :param distance: Distance from point (km) for selection :param str distance_metric Choice of...
[ "Selects", "earthquakes", "within", "a", "distance", "of", "the", "fault" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/sources/simple_fault_source.py#L191-L237
train
gem/oq-engine
openquake/hmtk/plotting/faults/geology_mfd_plot.py
plot_recurrence_models
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...
python
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", "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", ")"...
Plots a set of recurrence models :param list configs: List of configuration dictionaries
[ "Plots", "a", "set", "of", "recurrence", "models" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/faults/geology_mfd_plot.py#L69-L105
train
gem/oq-engine
openquake/hazardlib/sourcewriter.py
build_area_source_geometry
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...
python
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_area_source_geometry", "(", "area_source", ")", ":", "geom", "=", "[", "]", "for", "lon_lat", "in", "zip", "(", "area_source", ".", "polygon", ".", "lons", ",", "area_source", ".", "polygon", ".", "lats", ")", ":", "geom", ".", "extend", "(...
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`
[ "Returns", "the", "area", "source", "geometry", "as", "a", "Node" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourcewriter.py#L35-L58
train
gem/oq-engine
openquake/hazardlib/sourcewriter.py
build_point_source_geometry
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` """ ...
python
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_point_source_geometry", "(", "point_source", ")", ":", "xy", "=", "point_source", ".", "location", ".", "x", ",", "point_source", ".", "location", ".", "y", "pos_node", "=", "Node", "(", "\"gml:pos\"", ",", "text", "=", "xy", ")", "point_node",...
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`
[ "Returns", "the", "poing", "source", "geometry", "as", "a", "Node" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourcewriter.py#L61-L80
train
gem/oq-engine
openquake/hazardlib/sourcewriter.py
build_linestring_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...
python
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_linestring_node", "(", "line", ",", "with_depth", "=", "False", ")", ":", "geom", "=", "[", "]", "for", "p", "in", "line", ".", "points", ":", "if", "with_depth", ":", "geom", ".", "extend", "(", "(", "p", ".", "x", ",", "p", ".", "...
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.baselib.node.Node`
[ "Parses", "a", "line", "to", "a", "Node", "class" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourcewriter.py#L83-L101
train
gem/oq-engine
openquake/hazardlib/sourcewriter.py
build_simple_fault_geometry
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....
python
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_simple_fault_geometry", "(", "fault_source", ")", ":", "linestring_node", "=", "build_linestring_node", "(", "fault_source", ".", "fault_trace", ",", "with_depth", "=", "False", ")", "dip_node", "=", "Node", "(", "\"dip\"", ",", "text", "=", "fault_s...
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.baselib.node.Node`
[ "Returns", "the", "simple", "fault", "source", "geometry", "as", "a", "Node" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourcewriter.py#L104-L123
train
gem/oq-engine
openquake/hazardlib/sourcewriter.py
build_complex_fault_geometry
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...
python
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_complex_fault_geometry", "(", "fault_source", ")", ":", "num_edges", "=", "len", "(", "fault_source", ".", "edges", ")", "edge_nodes", "=", "[", "]", "for", "iloc", ",", "edge", "in", "enumerate", "(", "fault_source", ".", "edges", ")", ":", ...
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:`openquake.baselib.node.Node`
[ "Returns", "the", "complex", "fault", "source", "geometry", "as", "a", "Node" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourcewriter.py#L126-L152
train
gem/oq-engine
openquake/hazardlib/sourcewriter.py
build_evenly_discretised_mfd
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...
python
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_evenly_discretised_mfd", "(", "mfd", ")", ":", "occur_rates", "=", "Node", "(", "\"occurRates\"", ",", "text", "=", "mfd", ".", "occurrence_rates", ")", "return", "Node", "(", "\"incrementalMFD\"", ",", "{", "\"binWidth\"", ":", "mfd", ".", "bin_...
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`
[ "Returns", "the", "evenly", "discretized", "MFD", "as", "a", "Node" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourcewriter.py#L156-L169
train