id int32 0 252k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
400 | gem/oq-engine | openquake/hmtk/faults/mfd/anderson_luco_arbitrary.py | AndersonLucoArbitrary.get_mmax | def get_mmax(self, mfd_conf, msr, rake, area):
'''
Gets the mmax for the fault - reading directly from the config file
or using the msr otherwise
:param dict mfd_config:
Configuration file (see setUp for paramters)
:param msr:
Instance of :class:`nhlib.s... | python | def get_mmax(self, mfd_conf, msr, rake, area):
'''
Gets the mmax for the fault - reading directly from the config file
or using the msr otherwise
:param dict mfd_config:
Configuration file (see setUp for paramters)
:param msr:
Instance of :class:`nhlib.s... | [
"def",
"get_mmax",
"(",
"self",
",",
"mfd_conf",
",",
"msr",
",",
"rake",
",",
"area",
")",
":",
"if",
"mfd_conf",
"[",
"'Maximum_Magnitude'",
"]",
":",
"self",
".",
"mmax",
"=",
"mfd_conf",
"[",
"'Maximum_Magnitude'",
"]",
"else",
":",
"self",
".",
"m... | Gets the mmax for the fault - reading directly from the config file
or using the msr otherwise
:param dict mfd_config:
Configuration file (see setUp for paramters)
:param msr:
Instance of :class:`nhlib.scalerel`
:param float rake:
Rake of the fault ... | [
"Gets",
"the",
"mmax",
"for",
"the",
"fault",
"-",
"reading",
"directly",
"from",
"the",
"config",
"file",
"or",
"using",
"the",
"msr",
"otherwise"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/mfd/anderson_luco_arbitrary.py#L290-L316 |
401 | gem/oq-engine | openquake/hazardlib/gsim/lin_2009.py | Lin2009._get_magnitude_term | def _get_magnitude_term(self, C, mag):
"""
Returns the magnitude scaling term.
"""
lny = C['C1'] + (C['C3'] * ((8.5 - mag) ** 2.))
if mag > 6.3:
return lny + (-C['H'] * C['C5']) * (mag - 6.3)
else:
return lny + C['C2'] * (mag - 6.3) | python | def _get_magnitude_term(self, C, mag):
"""
Returns the magnitude scaling term.
"""
lny = C['C1'] + (C['C3'] * ((8.5 - mag) ** 2.))
if mag > 6.3:
return lny + (-C['H'] * C['C5']) * (mag - 6.3)
else:
return lny + C['C2'] * (mag - 6.3) | [
"def",
"_get_magnitude_term",
"(",
"self",
",",
"C",
",",
"mag",
")",
":",
"lny",
"=",
"C",
"[",
"'C1'",
"]",
"+",
"(",
"C",
"[",
"'C3'",
"]",
"*",
"(",
"(",
"8.5",
"-",
"mag",
")",
"**",
"2.",
")",
")",
"if",
"mag",
">",
"6.3",
":",
"retur... | Returns the magnitude scaling term. | [
"Returns",
"the",
"magnitude",
"scaling",
"term",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/lin_2009.py#L83-L91 |
402 | gem/oq-engine | openquake/hazardlib/gsim/lin_2009.py | Lin2009._get_style_of_faulting_term | def _get_style_of_faulting_term(self, C, rake):
"""
Returns the style of faulting factor
"""
f_n, f_r = self._get_fault_type_dummy_variables(rake)
return C['C6'] * f_n + C['C7'] * f_r | python | def _get_style_of_faulting_term(self, C, rake):
"""
Returns the style of faulting factor
"""
f_n, f_r = self._get_fault_type_dummy_variables(rake)
return C['C6'] * f_n + C['C7'] * f_r | [
"def",
"_get_style_of_faulting_term",
"(",
"self",
",",
"C",
",",
"rake",
")",
":",
"f_n",
",",
"f_r",
"=",
"self",
".",
"_get_fault_type_dummy_variables",
"(",
"rake",
")",
"return",
"C",
"[",
"'C6'",
"]",
"*",
"f_n",
"+",
"C",
"[",
"'C7'",
"]",
"*",
... | Returns the style of faulting factor | [
"Returns",
"the",
"style",
"of",
"faulting",
"factor"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/lin_2009.py#L100-L105 |
403 | gem/oq-engine | openquake/hazardlib/gsim/lin_2009.py | Lin2009._get_stddevs | def _get_stddevs(self, C, stddev_types, nsites):
"""
Compute total standard deviation, see table 4.2, page 50.
"""
stddevs = []
for stddev_type in stddev_types:
assert stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
if stddev_type == const.StdDev.... | python | def _get_stddevs(self, C, stddev_types, nsites):
"""
Compute total standard deviation, see table 4.2, page 50.
"""
stddevs = []
for stddev_type in stddev_types:
assert stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
if stddev_type == const.StdDev.... | [
"def",
"_get_stddevs",
"(",
"self",
",",
"C",
",",
"stddev_types",
",",
"nsites",
")",
":",
"stddevs",
"=",
"[",
"]",
"for",
"stddev_type",
"in",
"stddev_types",
":",
"assert",
"stddev_type",
"in",
"self",
".",
"DEFINED_FOR_STANDARD_DEVIATION_TYPES",
"if",
"st... | Compute total standard deviation, see table 4.2, page 50. | [
"Compute",
"total",
"standard",
"deviation",
"see",
"table",
"4",
".",
"2",
"page",
"50",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/lin_2009.py#L128-L137 |
404 | gem/oq-engine | openquake/hazardlib/calc/disagg.py | lon_lat_bins | def lon_lat_bins(bb, coord_bin_width):
"""
Define bin edges for disaggregation histograms.
Given bins data as provided by :func:`collect_bin_data`, this function
finds edges of histograms, taking into account maximum and minimum values
of magnitude, distance and coordinates as well as requested siz... | python | def lon_lat_bins(bb, coord_bin_width):
"""
Define bin edges for disaggregation histograms.
Given bins data as provided by :func:`collect_bin_data`, this function
finds edges of histograms, taking into account maximum and minimum values
of magnitude, distance and coordinates as well as requested siz... | [
"def",
"lon_lat_bins",
"(",
"bb",
",",
"coord_bin_width",
")",
":",
"west",
",",
"south",
",",
"east",
",",
"north",
"=",
"bb",
"west",
"=",
"numpy",
".",
"floor",
"(",
"west",
"/",
"coord_bin_width",
")",
"*",
"coord_bin_width",
"east",
"=",
"numpy",
... | Define bin edges for disaggregation histograms.
Given bins data as provided by :func:`collect_bin_data`, this function
finds edges of histograms, taking into account maximum and minimum values
of magnitude, distance and coordinates as well as requested sizes/numbers
of bins. | [
"Define",
"bin",
"edges",
"for",
"disaggregation",
"histograms",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/calc/disagg.py#L92-L111 |
405 | gem/oq-engine | openquake/hazardlib/calc/disagg.py | _digitize_lons | def _digitize_lons(lons, lon_bins):
"""
Return indices of the bins to which each value in lons belongs.
Takes into account the case in which longitude values cross the
international date line.
:parameter lons:
An instance of `numpy.ndarray`.
:parameter lons_bins:
An instance of ... | python | def _digitize_lons(lons, lon_bins):
"""
Return indices of the bins to which each value in lons belongs.
Takes into account the case in which longitude values cross the
international date line.
:parameter lons:
An instance of `numpy.ndarray`.
:parameter lons_bins:
An instance of ... | [
"def",
"_digitize_lons",
"(",
"lons",
",",
"lon_bins",
")",
":",
"if",
"cross_idl",
"(",
"lon_bins",
"[",
"0",
"]",
",",
"lon_bins",
"[",
"-",
"1",
"]",
")",
":",
"idx",
"=",
"numpy",
".",
"zeros_like",
"(",
"lons",
",",
"dtype",
"=",
"numpy",
".",... | Return indices of the bins to which each value in lons belongs.
Takes into account the case in which longitude values cross the
international date line.
:parameter lons:
An instance of `numpy.ndarray`.
:parameter lons_bins:
An instance of `numpy.ndarray`. | [
"Return",
"indices",
"of",
"the",
"bins",
"to",
"which",
"each",
"value",
"in",
"lons",
"belongs",
".",
"Takes",
"into",
"account",
"the",
"case",
"in",
"which",
"longitude",
"values",
"cross",
"the",
"international",
"date",
"line",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/calc/disagg.py#L188-L210 |
406 | gem/oq-engine | openquake/hazardlib/calc/disagg.py | mag_pmf | def mag_pmf(matrix):
"""
Fold full disaggregation matrix to magnitude PMF.
:returns:
1d array, a histogram representing magnitude PMF.
"""
nmags, ndists, nlons, nlats, neps = matrix.shape
mag_pmf = numpy.zeros(nmags)
for i in range(nmags):
mag_pmf[i] = numpy.prod(
... | python | def mag_pmf(matrix):
"""
Fold full disaggregation matrix to magnitude PMF.
:returns:
1d array, a histogram representing magnitude PMF.
"""
nmags, ndists, nlons, nlats, neps = matrix.shape
mag_pmf = numpy.zeros(nmags)
for i in range(nmags):
mag_pmf[i] = numpy.prod(
... | [
"def",
"mag_pmf",
"(",
"matrix",
")",
":",
"nmags",
",",
"ndists",
",",
"nlons",
",",
"nlats",
",",
"neps",
"=",
"matrix",
".",
"shape",
"mag_pmf",
"=",
"numpy",
".",
"zeros",
"(",
"nmags",
")",
"for",
"i",
"in",
"range",
"(",
"nmags",
")",
":",
... | Fold full disaggregation matrix to magnitude PMF.
:returns:
1d array, a histogram representing magnitude PMF. | [
"Fold",
"full",
"disaggregation",
"matrix",
"to",
"magnitude",
"PMF",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/calc/disagg.py#L338-L354 |
407 | gem/oq-engine | openquake/hazardlib/calc/disagg.py | trt_pmf | def trt_pmf(matrices):
"""
Fold full disaggregation matrix to tectonic region type PMF.
:param matrices:
a matrix with T submatrices
:returns:
an array of T probabilities one per each tectonic region type
"""
ntrts, nmags, ndists, nlons, nlats, neps = matrices.shape
pmf = nu... | python | def trt_pmf(matrices):
"""
Fold full disaggregation matrix to tectonic region type PMF.
:param matrices:
a matrix with T submatrices
:returns:
an array of T probabilities one per each tectonic region type
"""
ntrts, nmags, ndists, nlons, nlats, neps = matrices.shape
pmf = nu... | [
"def",
"trt_pmf",
"(",
"matrices",
")",
":",
"ntrts",
",",
"nmags",
",",
"ndists",
",",
"nlons",
",",
"nlats",
",",
"neps",
"=",
"matrices",
".",
"shape",
"pmf",
"=",
"numpy",
".",
"zeros",
"(",
"ntrts",
")",
"for",
"t",
"in",
"range",
"(",
"ntrts"... | Fold full disaggregation matrix to tectonic region type PMF.
:param matrices:
a matrix with T submatrices
:returns:
an array of T probabilities one per each tectonic region type | [
"Fold",
"full",
"disaggregation",
"matrix",
"to",
"tectonic",
"region",
"type",
"PMF",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/calc/disagg.py#L376-L395 |
408 | gem/oq-engine | openquake/commands/db.py | db | def db(cmd, args=()):
"""
Run a database command
"""
if cmd not in commands:
okcmds = '\n'.join(
'%s %s' % (name, repr(' '.join(args)) if args else '')
for name, args in sorted(commands.items()))
print('Invalid command "%s": choose one from\n%s' % (cmd, okcmds))
... | python | def db(cmd, args=()):
"""
Run a database command
"""
if cmd not in commands:
okcmds = '\n'.join(
'%s %s' % (name, repr(' '.join(args)) if args else '')
for name, args in sorted(commands.items()))
print('Invalid command "%s": choose one from\n%s' % (cmd, okcmds))
... | [
"def",
"db",
"(",
"cmd",
",",
"args",
"=",
"(",
")",
")",
":",
"if",
"cmd",
"not",
"in",
"commands",
":",
"okcmds",
"=",
"'\\n'",
".",
"join",
"(",
"'%s %s'",
"%",
"(",
"name",
",",
"repr",
"(",
"' '",
".",
"join",
"(",
"args",
")",
")",
"if"... | Run a database command | [
"Run",
"a",
"database",
"command"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/db.py#L47-L65 |
409 | gem/oq-engine | openquake/hazardlib/stats.py | mean_curve | def mean_curve(values, weights=None):
"""
Compute the mean by using numpy.average on the first axis.
"""
if weights is None:
weights = [1. / len(values)] * len(values)
if not isinstance(values, numpy.ndarray):
values = numpy.array(values)
return numpy.average(values, axis=0, weig... | python | def mean_curve(values, weights=None):
"""
Compute the mean by using numpy.average on the first axis.
"""
if weights is None:
weights = [1. / len(values)] * len(values)
if not isinstance(values, numpy.ndarray):
values = numpy.array(values)
return numpy.average(values, axis=0, weig... | [
"def",
"mean_curve",
"(",
"values",
",",
"weights",
"=",
"None",
")",
":",
"if",
"weights",
"is",
"None",
":",
"weights",
"=",
"[",
"1.",
"/",
"len",
"(",
"values",
")",
"]",
"*",
"len",
"(",
"values",
")",
"if",
"not",
"isinstance",
"(",
"values",... | Compute the mean by using numpy.average on the first axis. | [
"Compute",
"the",
"mean",
"by",
"using",
"numpy",
".",
"average",
"on",
"the",
"first",
"axis",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/stats.py#L25-L33 |
410 | gem/oq-engine | openquake/hazardlib/stats.py | quantile_curve | def quantile_curve(quantile, curves, weights=None):
"""
Compute the weighted quantile aggregate of a set of curves.
:param quantile:
Quantile value to calculate. Should be in the range [0.0, 1.0].
:param curves:
Array of R PoEs (possibly arrays)
:param weights:
Array-like of... | python | def quantile_curve(quantile, curves, weights=None):
"""
Compute the weighted quantile aggregate of a set of curves.
:param quantile:
Quantile value to calculate. Should be in the range [0.0, 1.0].
:param curves:
Array of R PoEs (possibly arrays)
:param weights:
Array-like of... | [
"def",
"quantile_curve",
"(",
"quantile",
",",
"curves",
",",
"weights",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"curves",
",",
"numpy",
".",
"ndarray",
")",
":",
"curves",
"=",
"numpy",
".",
"array",
"(",
"curves",
")",
"R",
"=",
"len... | Compute the weighted quantile aggregate of a set of curves.
:param quantile:
Quantile value to calculate. Should be in the range [0.0, 1.0].
:param curves:
Array of R PoEs (possibly arrays)
:param weights:
Array-like of weights, 1 for each input curve, or None
:returns:
... | [
"Compute",
"the",
"weighted",
"quantile",
"aggregate",
"of",
"a",
"set",
"of",
"curves",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/stats.py#L44-L74 |
411 | gem/oq-engine | openquake/hazardlib/gsim/toro_2002.py | ToroEtAl2002._compute_mean | def _compute_mean(self, C, mag, rjb):
"""
Compute mean value according to equation 3, page 46.
"""
mean = (C['c1'] +
self._compute_term1(C, mag) +
self._compute_term2(C, mag, rjb))
return mean | python | def _compute_mean(self, C, mag, rjb):
"""
Compute mean value according to equation 3, page 46.
"""
mean = (C['c1'] +
self._compute_term1(C, mag) +
self._compute_term2(C, mag, rjb))
return mean | [
"def",
"_compute_mean",
"(",
"self",
",",
"C",
",",
"mag",
",",
"rjb",
")",
":",
"mean",
"=",
"(",
"C",
"[",
"'c1'",
"]",
"+",
"self",
".",
"_compute_term1",
"(",
"C",
",",
"mag",
")",
"+",
"self",
".",
"_compute_term2",
"(",
"C",
",",
"mag",
"... | Compute mean value according to equation 3, page 46. | [
"Compute",
"mean",
"value",
"according",
"to",
"equation",
"3",
"page",
"46",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/toro_2002.py#L121-L128 |
412 | gem/oq-engine | openquake/hazardlib/gsim/toro_2002.py | ToroEtAl2002._compute_stddevs | def _compute_stddevs(self, C, mag, rjb, imt, stddev_types):
"""
Compute total standard deviation, equations 5 and 6, page 48.
"""
# aleatory uncertainty
sigma_ale_m = np.interp(mag, [5.0, 5.5, 8.0],
[C['m50'], C['m55'], C['m80']])
sigma_ale... | python | def _compute_stddevs(self, C, mag, rjb, imt, stddev_types):
"""
Compute total standard deviation, equations 5 and 6, page 48.
"""
# aleatory uncertainty
sigma_ale_m = np.interp(mag, [5.0, 5.5, 8.0],
[C['m50'], C['m55'], C['m80']])
sigma_ale... | [
"def",
"_compute_stddevs",
"(",
"self",
",",
"C",
",",
"mag",
",",
"rjb",
",",
"imt",
",",
"stddev_types",
")",
":",
"# aleatory uncertainty",
"sigma_ale_m",
"=",
"np",
".",
"interp",
"(",
"mag",
",",
"[",
"5.0",
",",
"5.5",
",",
"8.0",
"]",
",",
"["... | Compute total standard deviation, equations 5 and 6, page 48. | [
"Compute",
"total",
"standard",
"deviation",
"equations",
"5",
"and",
"6",
"page",
"48",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/toro_2002.py#L130-L152 |
413 | gem/oq-engine | openquake/hazardlib/gsim/mgmpe/nrcan15_site_term.py | NRCan15SiteTerm.BA08_AB06 | def BA08_AB06(self, vs30, imt, pgar):
"""
Computes amplification factor similarly to what is done in the 2015
version of the Canada building code. An initial version of this code
was kindly provided by Michal Kolaj - Geological Survey of Canada
:param vs30:
Can be ei... | python | def BA08_AB06(self, vs30, imt, pgar):
"""
Computes amplification factor similarly to what is done in the 2015
version of the Canada building code. An initial version of this code
was kindly provided by Michal Kolaj - Geological Survey of Canada
:param vs30:
Can be ei... | [
"def",
"BA08_AB06",
"(",
"self",
",",
"vs30",
",",
"imt",
",",
"pgar",
")",
":",
"fa",
"=",
"np",
".",
"ones_like",
"(",
"vs30",
")",
"if",
"np",
".",
"isscalar",
"(",
"vs30",
")",
":",
"vs30",
"=",
"np",
".",
"array",
"(",
"[",
"vs30",
"]",
... | Computes amplification factor similarly to what is done in the 2015
version of the Canada building code. An initial version of this code
was kindly provided by Michal Kolaj - Geological Survey of Canada
:param vs30:
Can be either a scalar or a :class:`~numpy.ndarray` instance
... | [
"Computes",
"amplification",
"factor",
"similarly",
"to",
"what",
"is",
"done",
"in",
"the",
"2015",
"version",
"of",
"the",
"Canada",
"building",
"code",
".",
"An",
"initial",
"version",
"of",
"this",
"code",
"was",
"kindly",
"provided",
"by",
"Michal",
"Ko... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/mgmpe/nrcan15_site_term.py#L89-L149 |
414 | gem/oq-engine | openquake/calculators/scenario_damage.py | scenario_damage | def scenario_damage(riskinputs, riskmodel, param, monitor):
"""
Core function for a damage computation.
:param riskinputs:
:class:`openquake.risklib.riskinput.RiskInput` objects
:param riskmodel:
a :class:`openquake.risklib.riskinput.CompositeRiskModel` instance
:param monitor:
... | python | def scenario_damage(riskinputs, riskmodel, param, monitor):
"""
Core function for a damage computation.
:param riskinputs:
:class:`openquake.risklib.riskinput.RiskInput` objects
:param riskmodel:
a :class:`openquake.risklib.riskinput.CompositeRiskModel` instance
:param monitor:
... | [
"def",
"scenario_damage",
"(",
"riskinputs",
",",
"riskmodel",
",",
"param",
",",
"monitor",
")",
":",
"L",
"=",
"len",
"(",
"riskmodel",
".",
"loss_types",
")",
"D",
"=",
"len",
"(",
"riskmodel",
".",
"damage_states",
")",
"E",
"=",
"param",
"[",
"'nu... | Core function for a damage computation.
:param riskinputs:
:class:`openquake.risklib.riskinput.RiskInput` objects
:param riskmodel:
a :class:`openquake.risklib.riskinput.CompositeRiskModel` instance
:param monitor:
:class:`openquake.baselib.performance.Monitor` instance
:param p... | [
"Core",
"function",
"for",
"a",
"damage",
"computation",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/scenario_damage.py#L28-L71 |
415 | gem/oq-engine | openquake/calculators/views.py | form | def form(value):
"""
Format numbers in a nice way.
>>> form(0)
'0'
>>> form(0.0)
'0.0'
>>> form(0.0001)
'1.000E-04'
>>> form(1003.4)
'1,003'
>>> form(103.4)
'103'
>>> form(9.3)
'9.30000'
>>> form(-1.2)
'-1.2'
"""
if isinstance(value, FLOAT + INT):... | python | def form(value):
"""
Format numbers in a nice way.
>>> form(0)
'0'
>>> form(0.0)
'0.0'
>>> form(0.0001)
'1.000E-04'
>>> form(1003.4)
'1,003'
>>> form(103.4)
'103'
>>> form(9.3)
'9.30000'
>>> form(-1.2)
'-1.2'
"""
if isinstance(value, FLOAT + INT):... | [
"def",
"form",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"FLOAT",
"+",
"INT",
")",
":",
"if",
"value",
"<=",
"0",
":",
"return",
"str",
"(",
"value",
")",
"elif",
"value",
"<",
".001",
":",
"return",
"'%.3E'",
"%",
"value",
"... | Format numbers in a nice way.
>>> form(0)
'0'
>>> form(0.0)
'0.0'
>>> form(0.0001)
'1.000E-04'
>>> form(1003.4)
'1,003'
>>> form(103.4)
'103'
>>> form(9.3)
'9.30000'
>>> form(-1.2)
'-1.2' | [
"Format",
"numbers",
"in",
"a",
"nice",
"way",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L51-L91 |
416 | gem/oq-engine | openquake/calculators/views.py | sum_tbl | def sum_tbl(tbl, kfield, vfields):
"""
Aggregate a composite array and compute the totals on a given key.
>>> dt = numpy.dtype([('name', (bytes, 10)), ('value', int)])
>>> tbl = numpy.array([('a', 1), ('a', 2), ('b', 3)], dt)
>>> sum_tbl(tbl, 'name', ['value'])['value']
array([3, 3])
"""
... | python | def sum_tbl(tbl, kfield, vfields):
"""
Aggregate a composite array and compute the totals on a given key.
>>> dt = numpy.dtype([('name', (bytes, 10)), ('value', int)])
>>> tbl = numpy.array([('a', 1), ('a', 2), ('b', 3)], dt)
>>> sum_tbl(tbl, 'name', ['value'])['value']
array([3, 3])
"""
... | [
"def",
"sum_tbl",
"(",
"tbl",
",",
"kfield",
",",
"vfields",
")",
":",
"pairs",
"=",
"[",
"(",
"n",
",",
"tbl",
".",
"dtype",
"[",
"n",
"]",
")",
"for",
"n",
"in",
"[",
"kfield",
"]",
"+",
"vfields",
"]",
"dt",
"=",
"numpy",
".",
"dtype",
"("... | Aggregate a composite array and compute the totals on a given key.
>>> dt = numpy.dtype([('name', (bytes, 10)), ('value', int)])
>>> tbl = numpy.array([('a', 1), ('a', 2), ('b', 3)], dt)
>>> sum_tbl(tbl, 'name', ['value'])['value']
array([3, 3]) | [
"Aggregate",
"a",
"composite",
"array",
"and",
"compute",
"the",
"totals",
"on",
"a",
"given",
"key",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L145-L170 |
417 | gem/oq-engine | openquake/calculators/views.py | view_slow_sources | def view_slow_sources(token, dstore, maxrows=20):
"""
Returns the slowest sources
"""
info = dstore['source_info'].value
info.sort(order='calc_time')
return rst_table(info[::-1][:maxrows]) | python | def view_slow_sources(token, dstore, maxrows=20):
"""
Returns the slowest sources
"""
info = dstore['source_info'].value
info.sort(order='calc_time')
return rst_table(info[::-1][:maxrows]) | [
"def",
"view_slow_sources",
"(",
"token",
",",
"dstore",
",",
"maxrows",
"=",
"20",
")",
":",
"info",
"=",
"dstore",
"[",
"'source_info'",
"]",
".",
"value",
"info",
".",
"sort",
"(",
"order",
"=",
"'calc_time'",
")",
"return",
"rst_table",
"(",
"info",
... | Returns the slowest sources | [
"Returns",
"the",
"slowest",
"sources"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L183-L189 |
418 | gem/oq-engine | openquake/calculators/views.py | view_contents | def view_contents(token, dstore):
"""
Returns the size of the contents of the datastore and its total size
"""
try:
desc = dstore['oqparam'].description
except KeyError:
desc = ''
data = sorted((dstore.getsize(key), key) for key in dstore)
rows = [(key, humansize(nbytes)) for... | python | def view_contents(token, dstore):
"""
Returns the size of the contents of the datastore and its total size
"""
try:
desc = dstore['oqparam'].description
except KeyError:
desc = ''
data = sorted((dstore.getsize(key), key) for key in dstore)
rows = [(key, humansize(nbytes)) for... | [
"def",
"view_contents",
"(",
"token",
",",
"dstore",
")",
":",
"try",
":",
"desc",
"=",
"dstore",
"[",
"'oqparam'",
"]",
".",
"description",
"except",
"KeyError",
":",
"desc",
"=",
"''",
"data",
"=",
"sorted",
"(",
"(",
"dstore",
".",
"getsize",
"(",
... | Returns the size of the contents of the datastore and its total size | [
"Returns",
"the",
"size",
"of",
"the",
"contents",
"of",
"the",
"datastore",
"and",
"its",
"total",
"size"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L193-L205 |
419 | gem/oq-engine | openquake/calculators/views.py | view_job_info | def view_job_info(token, dstore):
"""
Determine the amount of data transferred from the controller node
to the workers and back in a classical calculation.
"""
data = [['task', 'sent', 'received']]
for task in dstore['task_info']:
dset = dstore['task_info/' + task]
if 'argnames' ... | python | def view_job_info(token, dstore):
"""
Determine the amount of data transferred from the controller node
to the workers and back in a classical calculation.
"""
data = [['task', 'sent', 'received']]
for task in dstore['task_info']:
dset = dstore['task_info/' + task]
if 'argnames' ... | [
"def",
"view_job_info",
"(",
"token",
",",
"dstore",
")",
":",
"data",
"=",
"[",
"[",
"'task'",
",",
"'sent'",
",",
"'received'",
"]",
"]",
"for",
"task",
"in",
"dstore",
"[",
"'task_info'",
"]",
":",
"dset",
"=",
"dstore",
"[",
"'task_info/'",
"+",
... | Determine the amount of data transferred from the controller node
to the workers and back in a classical calculation. | [
"Determine",
"the",
"amount",
"of",
"data",
"transferred",
"from",
"the",
"controller",
"node",
"to",
"the",
"workers",
"and",
"back",
"in",
"a",
"classical",
"calculation",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L309-L324 |
420 | gem/oq-engine | openquake/calculators/views.py | avglosses_data_transfer | def avglosses_data_transfer(token, dstore):
"""
Determine the amount of average losses transferred from the workers to the
controller node in a risk calculation.
"""
oq = dstore['oqparam']
N = len(dstore['assetcol'])
R = dstore['csm_info'].get_num_rlzs()
L = len(dstore.get_attr('risk_mod... | python | def avglosses_data_transfer(token, dstore):
"""
Determine the amount of average losses transferred from the workers to the
controller node in a risk calculation.
"""
oq = dstore['oqparam']
N = len(dstore['assetcol'])
R = dstore['csm_info'].get_num_rlzs()
L = len(dstore.get_attr('risk_mod... | [
"def",
"avglosses_data_transfer",
"(",
"token",
",",
"dstore",
")",
":",
"oq",
"=",
"dstore",
"[",
"'oqparam'",
"]",
"N",
"=",
"len",
"(",
"dstore",
"[",
"'assetcol'",
"]",
")",
"R",
"=",
"dstore",
"[",
"'csm_info'",
"]",
".",
"get_num_rlzs",
"(",
")",... | Determine the amount of average losses transferred from the workers to the
controller node in a risk calculation. | [
"Determine",
"the",
"amount",
"of",
"average",
"losses",
"transferred",
"from",
"the",
"workers",
"to",
"the",
"controller",
"node",
"in",
"a",
"risk",
"calculation",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L328-L341 |
421 | gem/oq-engine | openquake/calculators/views.py | ebr_data_transfer | def ebr_data_transfer(token, dstore):
"""
Display the data transferred in an event based risk calculation
"""
attrs = dstore['losses_by_event'].attrs
sent = humansize(attrs['sent'])
received = humansize(attrs['tot_received'])
return 'Event Based Risk: sent %s, received %s' % (sent, received) | python | def ebr_data_transfer(token, dstore):
"""
Display the data transferred in an event based risk calculation
"""
attrs = dstore['losses_by_event'].attrs
sent = humansize(attrs['sent'])
received = humansize(attrs['tot_received'])
return 'Event Based Risk: sent %s, received %s' % (sent, received) | [
"def",
"ebr_data_transfer",
"(",
"token",
",",
"dstore",
")",
":",
"attrs",
"=",
"dstore",
"[",
"'losses_by_event'",
"]",
".",
"attrs",
"sent",
"=",
"humansize",
"(",
"attrs",
"[",
"'sent'",
"]",
")",
"received",
"=",
"humansize",
"(",
"attrs",
"[",
"'to... | Display the data transferred in an event based risk calculation | [
"Display",
"the",
"data",
"transferred",
"in",
"an",
"event",
"based",
"risk",
"calculation"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L345-L352 |
422 | gem/oq-engine | openquake/calculators/views.py | view_totlosses | def view_totlosses(token, dstore):
"""
This is a debugging view. You can use it to check that the total
losses, i.e. the losses obtained by summing the average losses on
all assets are indeed equal to the aggregate losses. This is a
sanity check for the correctness of the implementation.
"""
... | python | def view_totlosses(token, dstore):
"""
This is a debugging view. You can use it to check that the total
losses, i.e. the losses obtained by summing the average losses on
all assets are indeed equal to the aggregate losses. This is a
sanity check for the correctness of the implementation.
"""
... | [
"def",
"view_totlosses",
"(",
"token",
",",
"dstore",
")",
":",
"oq",
"=",
"dstore",
"[",
"'oqparam'",
"]",
"tot_losses",
"=",
"dstore",
"[",
"'losses_by_asset'",
"]",
"[",
"'mean'",
"]",
".",
"sum",
"(",
"axis",
"=",
"0",
")",
"return",
"rst_table",
"... | This is a debugging view. You can use it to check that the total
losses, i.e. the losses obtained by summing the average losses on
all assets are indeed equal to the aggregate losses. This is a
sanity check for the correctness of the implementation. | [
"This",
"is",
"a",
"debugging",
"view",
".",
"You",
"can",
"use",
"it",
"to",
"check",
"that",
"the",
"total",
"losses",
"i",
".",
"e",
".",
"the",
"losses",
"obtained",
"by",
"summing",
"the",
"average",
"losses",
"on",
"all",
"assets",
"are",
"indeed... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L357-L366 |
423 | gem/oq-engine | openquake/calculators/views.py | view_portfolio_losses | def view_portfolio_losses(token, dstore):
"""
The losses for the full portfolio, for each realization and loss type,
extracted from the event loss table.
"""
oq = dstore['oqparam']
loss_dt = oq.loss_dt()
data = portfolio_loss(dstore).view(loss_dt)[:, 0]
rlzids = [str(r) for r in range(le... | python | def view_portfolio_losses(token, dstore):
"""
The losses for the full portfolio, for each realization and loss type,
extracted from the event loss table.
"""
oq = dstore['oqparam']
loss_dt = oq.loss_dt()
data = portfolio_loss(dstore).view(loss_dt)[:, 0]
rlzids = [str(r) for r in range(le... | [
"def",
"view_portfolio_losses",
"(",
"token",
",",
"dstore",
")",
":",
"oq",
"=",
"dstore",
"[",
"'oqparam'",
"]",
"loss_dt",
"=",
"oq",
".",
"loss_dt",
"(",
")",
"data",
"=",
"portfolio_loss",
"(",
"dstore",
")",
".",
"view",
"(",
"loss_dt",
")",
"[",... | The losses for the full portfolio, for each realization and loss type,
extracted from the event loss table. | [
"The",
"losses",
"for",
"the",
"full",
"portfolio",
"for",
"each",
"realization",
"and",
"loss",
"type",
"extracted",
"from",
"the",
"event",
"loss",
"table",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L382-L393 |
424 | gem/oq-engine | openquake/calculators/views.py | view_portfolio_loss | def view_portfolio_loss(token, dstore):
"""
The mean and stddev loss for the full portfolio for each loss type,
extracted from the event loss table, averaged over the realizations
"""
data = portfolio_loss(dstore) # shape (R, L)
loss_types = list(dstore['oqparam'].loss_dt().names)
header = ... | python | def view_portfolio_loss(token, dstore):
"""
The mean and stddev loss for the full portfolio for each loss type,
extracted from the event loss table, averaged over the realizations
"""
data = portfolio_loss(dstore) # shape (R, L)
loss_types = list(dstore['oqparam'].loss_dt().names)
header = ... | [
"def",
"view_portfolio_loss",
"(",
"token",
",",
"dstore",
")",
":",
"data",
"=",
"portfolio_loss",
"(",
"dstore",
")",
"# shape (R, L)",
"loss_types",
"=",
"list",
"(",
"dstore",
"[",
"'oqparam'",
"]",
".",
"loss_dt",
"(",
")",
".",
"names",
")",
"header"... | The mean and stddev loss for the full portfolio for each loss type,
extracted from the event loss table, averaged over the realizations | [
"The",
"mean",
"and",
"stddev",
"loss",
"for",
"the",
"full",
"portfolio",
"for",
"each",
"loss",
"type",
"extracted",
"from",
"the",
"event",
"loss",
"table",
"averaged",
"over",
"the",
"realizations"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L397-L407 |
425 | gem/oq-engine | openquake/calculators/views.py | view_exposure_info | def view_exposure_info(token, dstore):
"""
Display info about the exposure model
"""
assetcol = dstore['assetcol/array'][:]
taxonomies = sorted(set(dstore['assetcol'].taxonomies))
cc = dstore['assetcol/cost_calculator']
ra_flag = ['relative', 'absolute']
data = [('#assets', len(assetcol)... | python | def view_exposure_info(token, dstore):
"""
Display info about the exposure model
"""
assetcol = dstore['assetcol/array'][:]
taxonomies = sorted(set(dstore['assetcol'].taxonomies))
cc = dstore['assetcol/cost_calculator']
ra_flag = ['relative', 'absolute']
data = [('#assets', len(assetcol)... | [
"def",
"view_exposure_info",
"(",
"token",
",",
"dstore",
")",
":",
"assetcol",
"=",
"dstore",
"[",
"'assetcol/array'",
"]",
"[",
":",
"]",
"taxonomies",
"=",
"sorted",
"(",
"set",
"(",
"dstore",
"[",
"'assetcol'",
"]",
".",
"taxonomies",
")",
")",
"cc",... | Display info about the exposure model | [
"Display",
"info",
"about",
"the",
"exposure",
"model"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L431-L444 |
426 | gem/oq-engine | openquake/calculators/views.py | view_fullreport | def view_fullreport(token, dstore):
"""
Display an .rst report about the computation
"""
# avoid circular imports
from openquake.calculators.reportwriter import ReportWriter
return ReportWriter(dstore).make_report() | python | def view_fullreport(token, dstore):
"""
Display an .rst report about the computation
"""
# avoid circular imports
from openquake.calculators.reportwriter import ReportWriter
return ReportWriter(dstore).make_report() | [
"def",
"view_fullreport",
"(",
"token",
",",
"dstore",
")",
":",
"# avoid circular imports",
"from",
"openquake",
".",
"calculators",
".",
"reportwriter",
"import",
"ReportWriter",
"return",
"ReportWriter",
"(",
"dstore",
")",
".",
"make_report",
"(",
")"
] | Display an .rst report about the computation | [
"Display",
"an",
".",
"rst",
"report",
"about",
"the",
"computation"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L461-L467 |
427 | gem/oq-engine | openquake/calculators/views.py | performance_view | def performance_view(dstore):
"""
Returns the performance view as a numpy array.
"""
data = sorted(dstore['performance_data'], key=operator.itemgetter(0))
out = []
for operation, group in itertools.groupby(data, operator.itemgetter(0)):
counts = 0
time = 0
mem = 0
... | python | def performance_view(dstore):
"""
Returns the performance view as a numpy array.
"""
data = sorted(dstore['performance_data'], key=operator.itemgetter(0))
out = []
for operation, group in itertools.groupby(data, operator.itemgetter(0)):
counts = 0
time = 0
mem = 0
... | [
"def",
"performance_view",
"(",
"dstore",
")",
":",
"data",
"=",
"sorted",
"(",
"dstore",
"[",
"'performance_data'",
"]",
",",
"key",
"=",
"operator",
".",
"itemgetter",
"(",
"0",
")",
")",
"out",
"=",
"[",
"]",
"for",
"operation",
",",
"group",
"in",
... | Returns the performance view as a numpy array. | [
"Returns",
"the",
"performance",
"view",
"as",
"a",
"numpy",
"array",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L470-L486 |
428 | gem/oq-engine | openquake/calculators/views.py | stats | def stats(name, array, *extras):
"""
Returns statistics from an array of numbers.
:param name: a descriptive string
:returns: (name, mean, std, min, max, len)
"""
std = numpy.nan if len(array) == 1 else numpy.std(array, ddof=1)
return (name, numpy.mean(array), std,
numpy.min(arr... | python | def stats(name, array, *extras):
"""
Returns statistics from an array of numbers.
:param name: a descriptive string
:returns: (name, mean, std, min, max, len)
"""
std = numpy.nan if len(array) == 1 else numpy.std(array, ddof=1)
return (name, numpy.mean(array), std,
numpy.min(arr... | [
"def",
"stats",
"(",
"name",
",",
"array",
",",
"*",
"extras",
")",
":",
"std",
"=",
"numpy",
".",
"nan",
"if",
"len",
"(",
"array",
")",
"==",
"1",
"else",
"numpy",
".",
"std",
"(",
"array",
",",
"ddof",
"=",
"1",
")",
"return",
"(",
"name",
... | Returns statistics from an array of numbers.
:param name: a descriptive string
:returns: (name, mean, std, min, max, len) | [
"Returns",
"statistics",
"from",
"an",
"array",
"of",
"numbers",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L497-L506 |
429 | gem/oq-engine | openquake/calculators/views.py | view_num_units | def view_num_units(token, dstore):
"""
Display the number of units by taxonomy
"""
taxo = dstore['assetcol/tagcol/taxonomy'].value
counts = collections.Counter()
for asset in dstore['assetcol']:
counts[taxo[asset['taxonomy']]] += asset['number']
data = sorted(counts.items())
data... | python | def view_num_units(token, dstore):
"""
Display the number of units by taxonomy
"""
taxo = dstore['assetcol/tagcol/taxonomy'].value
counts = collections.Counter()
for asset in dstore['assetcol']:
counts[taxo[asset['taxonomy']]] += asset['number']
data = sorted(counts.items())
data... | [
"def",
"view_num_units",
"(",
"token",
",",
"dstore",
")",
":",
"taxo",
"=",
"dstore",
"[",
"'assetcol/tagcol/taxonomy'",
"]",
".",
"value",
"counts",
"=",
"collections",
".",
"Counter",
"(",
")",
"for",
"asset",
"in",
"dstore",
"[",
"'assetcol'",
"]",
":"... | Display the number of units by taxonomy | [
"Display",
"the",
"number",
"of",
"units",
"by",
"taxonomy"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L510-L520 |
430 | gem/oq-engine | openquake/calculators/views.py | view_assets_by_site | def view_assets_by_site(token, dstore):
"""
Display statistical information about the distribution of the assets
"""
taxonomies = dstore['assetcol/tagcol/taxonomy'].value
assets_by_site = dstore['assetcol'].assets_by_site()
data = ['taxonomy mean stddev min max num_sites num_assets'.split()]
... | python | def view_assets_by_site(token, dstore):
"""
Display statistical information about the distribution of the assets
"""
taxonomies = dstore['assetcol/tagcol/taxonomy'].value
assets_by_site = dstore['assetcol'].assets_by_site()
data = ['taxonomy mean stddev min max num_sites num_assets'.split()]
... | [
"def",
"view_assets_by_site",
"(",
"token",
",",
"dstore",
")",
":",
"taxonomies",
"=",
"dstore",
"[",
"'assetcol/tagcol/taxonomy'",
"]",
".",
"value",
"assets_by_site",
"=",
"dstore",
"[",
"'assetcol'",
"]",
".",
"assets_by_site",
"(",
")",
"data",
"=",
"[",
... | Display statistical information about the distribution of the assets | [
"Display",
"statistical",
"information",
"about",
"the",
"distribution",
"of",
"the",
"assets"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L524-L541 |
431 | gem/oq-engine | openquake/calculators/views.py | view_required_params_per_trt | def view_required_params_per_trt(token, dstore):
"""
Display the parameters needed by each tectonic region type
"""
csm_info = dstore['csm_info']
tbl = []
for grp_id, trt in sorted(csm_info.grp_by("trt").items()):
gsims = csm_info.gsim_lt.get_gsims(trt)
maker = ContextMaker(trt, ... | python | def view_required_params_per_trt(token, dstore):
"""
Display the parameters needed by each tectonic region type
"""
csm_info = dstore['csm_info']
tbl = []
for grp_id, trt in sorted(csm_info.grp_by("trt").items()):
gsims = csm_info.gsim_lt.get_gsims(trt)
maker = ContextMaker(trt, ... | [
"def",
"view_required_params_per_trt",
"(",
"token",
",",
"dstore",
")",
":",
"csm_info",
"=",
"dstore",
"[",
"'csm_info'",
"]",
"tbl",
"=",
"[",
"]",
"for",
"grp_id",
",",
"trt",
"in",
"sorted",
"(",
"csm_info",
".",
"grp_by",
"(",
"\"trt\"",
")",
".",
... | Display the parameters needed by each tectonic region type | [
"Display",
"the",
"parameters",
"needed",
"by",
"each",
"tectonic",
"region",
"type"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L545-L561 |
432 | gem/oq-engine | openquake/calculators/views.py | view_global_hcurves | def view_global_hcurves(token, dstore):
"""
Display the global hazard curves for the calculation. They are
used for debugging purposes when comparing the results of two
calculations. They are the mean over the sites of the mean hazard
curves.
"""
oq = dstore['oqparam']
nsites = len(dstor... | python | def view_global_hcurves(token, dstore):
"""
Display the global hazard curves for the calculation. They are
used for debugging purposes when comparing the results of two
calculations. They are the mean over the sites of the mean hazard
curves.
"""
oq = dstore['oqparam']
nsites = len(dstor... | [
"def",
"view_global_hcurves",
"(",
"token",
",",
"dstore",
")",
":",
"oq",
"=",
"dstore",
"[",
"'oqparam'",
"]",
"nsites",
"=",
"len",
"(",
"dstore",
"[",
"'sitecol'",
"]",
")",
"rlzs_assoc",
"=",
"dstore",
"[",
"'csm_info'",
"]",
".",
"get_rlzs_assoc",
... | Display the global hazard curves for the calculation. They are
used for debugging purposes when comparing the results of two
calculations. They are the mean over the sites of the mean hazard
curves. | [
"Display",
"the",
"global",
"hazard",
"curves",
"for",
"the",
"calculation",
".",
"They",
"are",
"used",
"for",
"debugging",
"purposes",
"when",
"comparing",
"the",
"results",
"of",
"two",
"calculations",
".",
"They",
"are",
"the",
"mean",
"over",
"the",
"si... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L671-L686 |
433 | gem/oq-engine | openquake/calculators/views.py | view_dupl_sources_time | def view_dupl_sources_time(token, dstore):
"""
Display the time spent computing duplicated sources
"""
info = dstore['source_info']
items = sorted(group_array(info.value, 'source_id').items())
tbl = []
tot_time = 0
for source_id, records in items:
if len(records) > 1: # dupl
... | python | def view_dupl_sources_time(token, dstore):
"""
Display the time spent computing duplicated sources
"""
info = dstore['source_info']
items = sorted(group_array(info.value, 'source_id').items())
tbl = []
tot_time = 0
for source_id, records in items:
if len(records) > 1: # dupl
... | [
"def",
"view_dupl_sources_time",
"(",
"token",
",",
"dstore",
")",
":",
"info",
"=",
"dstore",
"[",
"'source_info'",
"]",
"items",
"=",
"sorted",
"(",
"group_array",
"(",
"info",
".",
"value",
",",
"'source_id'",
")",
".",
"items",
"(",
")",
")",
"tbl",
... | Display the time spent computing duplicated sources | [
"Display",
"the",
"time",
"spent",
"computing",
"duplicated",
"sources"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L690-L710 |
434 | gem/oq-engine | openquake/calculators/views.py | view_global_poes | def view_global_poes(token, dstore):
"""
Display global probabilities averaged on all sites and all GMPEs
"""
tbl = []
imtls = dstore['oqparam'].imtls
header = ['grp_id'] + [str(poe) for poe in imtls.array]
for grp in sorted(dstore['poes']):
poes = dstore['poes/' + grp]
nsite... | python | def view_global_poes(token, dstore):
"""
Display global probabilities averaged on all sites and all GMPEs
"""
tbl = []
imtls = dstore['oqparam'].imtls
header = ['grp_id'] + [str(poe) for poe in imtls.array]
for grp in sorted(dstore['poes']):
poes = dstore['poes/' + grp]
nsite... | [
"def",
"view_global_poes",
"(",
"token",
",",
"dstore",
")",
":",
"tbl",
"=",
"[",
"]",
"imtls",
"=",
"dstore",
"[",
"'oqparam'",
"]",
".",
"imtls",
"header",
"=",
"[",
"'grp_id'",
"]",
"+",
"[",
"str",
"(",
"poe",
")",
"for",
"poe",
"in",
"imtls",... | Display global probabilities averaged on all sites and all GMPEs | [
"Display",
"global",
"probabilities",
"averaged",
"on",
"all",
"sites",
"and",
"all",
"GMPEs"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L714-L727 |
435 | gem/oq-engine | openquake/calculators/views.py | view_global_hmaps | def view_global_hmaps(token, dstore):
"""
Display the global hazard maps for the calculation. They are
used for debugging purposes when comparing the results of two
calculations. They are the mean over the sites of the mean hazard
maps.
"""
oq = dstore['oqparam']
dt = numpy.dtype([('%s-%... | python | def view_global_hmaps(token, dstore):
"""
Display the global hazard maps for the calculation. They are
used for debugging purposes when comparing the results of two
calculations. They are the mean over the sites of the mean hazard
maps.
"""
oq = dstore['oqparam']
dt = numpy.dtype([('%s-%... | [
"def",
"view_global_hmaps",
"(",
"token",
",",
"dstore",
")",
":",
"oq",
"=",
"dstore",
"[",
"'oqparam'",
"]",
"dt",
"=",
"numpy",
".",
"dtype",
"(",
"[",
"(",
"'%s-%s'",
"%",
"(",
"imt",
",",
"poe",
")",
",",
"F32",
")",
"for",
"imt",
"in",
"oq"... | Display the global hazard maps for the calculation. They are
used for debugging purposes when comparing the results of two
calculations. They are the mean over the sites of the mean hazard
maps. | [
"Display",
"the",
"global",
"hazard",
"maps",
"for",
"the",
"calculation",
".",
"They",
"are",
"used",
"for",
"debugging",
"purposes",
"when",
"comparing",
"the",
"results",
"of",
"two",
"calculations",
".",
"They",
"are",
"the",
"mean",
"over",
"the",
"site... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L731-L745 |
436 | gem/oq-engine | openquake/calculators/views.py | view_global_gmfs | def view_global_gmfs(token, dstore):
"""
Display GMFs averaged on everything for debugging purposes
"""
imtls = dstore['oqparam'].imtls
row = dstore['gmf_data/data']['gmv'].mean(axis=0)
return rst_table([row], header=imtls) | python | def view_global_gmfs(token, dstore):
"""
Display GMFs averaged on everything for debugging purposes
"""
imtls = dstore['oqparam'].imtls
row = dstore['gmf_data/data']['gmv'].mean(axis=0)
return rst_table([row], header=imtls) | [
"def",
"view_global_gmfs",
"(",
"token",
",",
"dstore",
")",
":",
"imtls",
"=",
"dstore",
"[",
"'oqparam'",
"]",
".",
"imtls",
"row",
"=",
"dstore",
"[",
"'gmf_data/data'",
"]",
"[",
"'gmv'",
"]",
".",
"mean",
"(",
"axis",
"=",
"0",
")",
"return",
"r... | Display GMFs averaged on everything for debugging purposes | [
"Display",
"GMFs",
"averaged",
"on",
"everything",
"for",
"debugging",
"purposes"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L749-L755 |
437 | gem/oq-engine | openquake/calculators/views.py | view_mean_disagg | def view_mean_disagg(token, dstore):
"""
Display mean quantities for the disaggregation. Useful for checking
differences between two calculations.
"""
tbl = []
for key, dset in sorted(dstore['disagg'].items()):
vals = [ds.value.mean() for k, ds in sorted(dset.items())]
tbl.append... | python | def view_mean_disagg(token, dstore):
"""
Display mean quantities for the disaggregation. Useful for checking
differences between two calculations.
"""
tbl = []
for key, dset in sorted(dstore['disagg'].items()):
vals = [ds.value.mean() for k, ds in sorted(dset.items())]
tbl.append... | [
"def",
"view_mean_disagg",
"(",
"token",
",",
"dstore",
")",
":",
"tbl",
"=",
"[",
"]",
"for",
"key",
",",
"dset",
"in",
"sorted",
"(",
"dstore",
"[",
"'disagg'",
"]",
".",
"items",
"(",
")",
")",
":",
"vals",
"=",
"[",
"ds",
".",
"value",
".",
... | Display mean quantities for the disaggregation. Useful for checking
differences between two calculations. | [
"Display",
"mean",
"quantities",
"for",
"the",
"disaggregation",
".",
"Useful",
"for",
"checking",
"differences",
"between",
"two",
"calculations",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L759-L769 |
438 | gem/oq-engine | openquake/calculators/views.py | view_elt | def view_elt(token, dstore):
"""
Display the event loss table averaged by event
"""
oq = dstore['oqparam']
R = len(dstore['csm_info'].rlzs)
dic = group_array(dstore['losses_by_event'].value, 'rlzi')
header = oq.loss_dt().names
tbl = []
for rlzi in range(R):
if rlzi in dic:
... | python | def view_elt(token, dstore):
"""
Display the event loss table averaged by event
"""
oq = dstore['oqparam']
R = len(dstore['csm_info'].rlzs)
dic = group_array(dstore['losses_by_event'].value, 'rlzi')
header = oq.loss_dt().names
tbl = []
for rlzi in range(R):
if rlzi in dic:
... | [
"def",
"view_elt",
"(",
"token",
",",
"dstore",
")",
":",
"oq",
"=",
"dstore",
"[",
"'oqparam'",
"]",
"R",
"=",
"len",
"(",
"dstore",
"[",
"'csm_info'",
"]",
".",
"rlzs",
")",
"dic",
"=",
"group_array",
"(",
"dstore",
"[",
"'losses_by_event'",
"]",
"... | Display the event loss table averaged by event | [
"Display",
"the",
"event",
"loss",
"table",
"averaged",
"by",
"event"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L773-L787 |
439 | gem/oq-engine | openquake/calculators/views.py | view_pmap | def view_pmap(token, dstore):
"""
Display the mean ProbabilityMap associated to a given source group name
"""
grp = token.split(':')[1] # called as pmap:grp
pmap = {}
rlzs_assoc = dstore['csm_info'].get_rlzs_assoc()
pgetter = getters.PmapGetter(dstore, rlzs_assoc)
pmap = pgetter.get_mea... | python | def view_pmap(token, dstore):
"""
Display the mean ProbabilityMap associated to a given source group name
"""
grp = token.split(':')[1] # called as pmap:grp
pmap = {}
rlzs_assoc = dstore['csm_info'].get_rlzs_assoc()
pgetter = getters.PmapGetter(dstore, rlzs_assoc)
pmap = pgetter.get_mea... | [
"def",
"view_pmap",
"(",
"token",
",",
"dstore",
")",
":",
"grp",
"=",
"token",
".",
"split",
"(",
"':'",
")",
"[",
"1",
"]",
"# called as pmap:grp",
"pmap",
"=",
"{",
"}",
"rlzs_assoc",
"=",
"dstore",
"[",
"'csm_info'",
"]",
".",
"get_rlzs_assoc",
"("... | Display the mean ProbabilityMap associated to a given source group name | [
"Display",
"the",
"mean",
"ProbabilityMap",
"associated",
"to",
"a",
"given",
"source",
"group",
"name"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L791-L800 |
440 | gem/oq-engine | openquake/calculators/views.py | view_act_ruptures_by_src | def view_act_ruptures_by_src(token, dstore):
"""
Display the actual number of ruptures by source in event based calculations
"""
data = dstore['ruptures'].value[['srcidx', 'serial']]
counts = sorted(countby(data, 'srcidx').items(),
key=operator.itemgetter(1), reverse=True)
sr... | python | def view_act_ruptures_by_src(token, dstore):
"""
Display the actual number of ruptures by source in event based calculations
"""
data = dstore['ruptures'].value[['srcidx', 'serial']]
counts = sorted(countby(data, 'srcidx').items(),
key=operator.itemgetter(1), reverse=True)
sr... | [
"def",
"view_act_ruptures_by_src",
"(",
"token",
",",
"dstore",
")",
":",
"data",
"=",
"dstore",
"[",
"'ruptures'",
"]",
".",
"value",
"[",
"[",
"'srcidx'",
",",
"'serial'",
"]",
"]",
"counts",
"=",
"sorted",
"(",
"countby",
"(",
"data",
",",
"'srcidx'",... | Display the actual number of ruptures by source in event based calculations | [
"Display",
"the",
"actual",
"number",
"of",
"ruptures",
"by",
"source",
"in",
"event",
"based",
"calculations"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L804-L816 |
441 | gem/oq-engine | openquake/calculators/views.py | view_dupl_sources | def view_dupl_sources(token, dstore):
"""
Show the sources with the same ID and the truly duplicated sources
"""
fields = ['source_id', 'code', 'gidx1', 'gidx2', 'num_ruptures']
dic = group_array(dstore['source_info'].value[fields], 'source_id')
sameid = []
dupl = []
for source_id, group... | python | def view_dupl_sources(token, dstore):
"""
Show the sources with the same ID and the truly duplicated sources
"""
fields = ['source_id', 'code', 'gidx1', 'gidx2', 'num_ruptures']
dic = group_array(dstore['source_info'].value[fields], 'source_id')
sameid = []
dupl = []
for source_id, group... | [
"def",
"view_dupl_sources",
"(",
"token",
",",
"dstore",
")",
":",
"fields",
"=",
"[",
"'source_id'",
",",
"'code'",
",",
"'gidx1'",
",",
"'gidx2'",
",",
"'num_ruptures'",
"]",
"dic",
"=",
"group_array",
"(",
"dstore",
"[",
"'source_info'",
"]",
".",
"valu... | Show the sources with the same ID and the truly duplicated sources | [
"Show",
"the",
"sources",
"with",
"the",
"same",
"ID",
"and",
"the",
"truly",
"duplicated",
"sources"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L838-L864 |
442 | gem/oq-engine | openquake/calculators/views.py | view_extreme_groups | def view_extreme_groups(token, dstore):
"""
Show the source groups contributing the most to the highest IML
"""
data = dstore['disagg_by_grp'].value
data.sort(order='extreme_poe')
return rst_table(data[::-1]) | python | def view_extreme_groups(token, dstore):
"""
Show the source groups contributing the most to the highest IML
"""
data = dstore['disagg_by_grp'].value
data.sort(order='extreme_poe')
return rst_table(data[::-1]) | [
"def",
"view_extreme_groups",
"(",
"token",
",",
"dstore",
")",
":",
"data",
"=",
"dstore",
"[",
"'disagg_by_grp'",
"]",
".",
"value",
"data",
".",
"sort",
"(",
"order",
"=",
"'extreme_poe'",
")",
"return",
"rst_table",
"(",
"data",
"[",
":",
":",
"-",
... | Show the source groups contributing the most to the highest IML | [
"Show",
"the",
"source",
"groups",
"contributing",
"the",
"most",
"to",
"the",
"highest",
"IML"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L868-L874 |
443 | gem/oq-engine | openquake/commonlib/oqzip.py | zip_all | def zip_all(directory):
"""
Zip source models and exposures recursively
"""
zips = []
for cwd, dirs, files in os.walk(directory):
if 'ssmLT.xml' in files:
zips.append(zip_source_model(os.path.join(cwd, 'ssmLT.xml')))
for f in files:
if f.endswith('.xml') and '... | python | def zip_all(directory):
"""
Zip source models and exposures recursively
"""
zips = []
for cwd, dirs, files in os.walk(directory):
if 'ssmLT.xml' in files:
zips.append(zip_source_model(os.path.join(cwd, 'ssmLT.xml')))
for f in files:
if f.endswith('.xml') and '... | [
"def",
"zip_all",
"(",
"directory",
")",
":",
"zips",
"=",
"[",
"]",
"for",
"cwd",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"directory",
")",
":",
"if",
"'ssmLT.xml'",
"in",
"files",
":",
"zips",
".",
"append",
"(",
"zip_source_model"... | Zip source models and exposures recursively | [
"Zip",
"source",
"models",
"and",
"exposures",
"recursively"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqzip.py#L27-L39 |
444 | gem/oq-engine | openquake/commonlib/oqzip.py | zip_source_model | def zip_source_model(ssmLT, archive_zip='', log=logging.info):
"""
Zip the source model files starting from the smmLT.xml file
"""
basedir = os.path.dirname(ssmLT)
if os.path.basename(ssmLT) != 'ssmLT.xml':
orig = ssmLT
ssmLT = os.path.join(basedir, 'ssmLT.xml')
with open(ssm... | python | def zip_source_model(ssmLT, archive_zip='', log=logging.info):
"""
Zip the source model files starting from the smmLT.xml file
"""
basedir = os.path.dirname(ssmLT)
if os.path.basename(ssmLT) != 'ssmLT.xml':
orig = ssmLT
ssmLT = os.path.join(basedir, 'ssmLT.xml')
with open(ssm... | [
"def",
"zip_source_model",
"(",
"ssmLT",
",",
"archive_zip",
"=",
"''",
",",
"log",
"=",
"logging",
".",
"info",
")",
":",
"basedir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"ssmLT",
")",
"if",
"os",
".",
"path",
".",
"basename",
"(",
"ssmLT",
... | Zip the source model files starting from the smmLT.xml file | [
"Zip",
"the",
"source",
"model",
"files",
"starting",
"from",
"the",
"smmLT",
".",
"xml",
"file"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqzip.py#L42-L64 |
445 | gem/oq-engine | openquake/commonlib/oqzip.py | zip_job | def zip_job(job_ini, archive_zip='', risk_ini='', oq=None, log=logging.info):
"""
Zip the given job.ini file into the given archive, together with all
related files.
"""
if not os.path.exists(job_ini):
sys.exit('%s does not exist' % job_ini)
archive_zip = archive_zip or 'job.zip'
if ... | python | def zip_job(job_ini, archive_zip='', risk_ini='', oq=None, log=logging.info):
"""
Zip the given job.ini file into the given archive, together with all
related files.
"""
if not os.path.exists(job_ini):
sys.exit('%s does not exist' % job_ini)
archive_zip = archive_zip or 'job.zip'
if ... | [
"def",
"zip_job",
"(",
"job_ini",
",",
"archive_zip",
"=",
"''",
",",
"risk_ini",
"=",
"''",
",",
"oq",
"=",
"None",
",",
"log",
"=",
"logging",
".",
"info",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"job_ini",
")",
":",
"sys"... | Zip the given job.ini file into the given archive, together with all
related files. | [
"Zip",
"the",
"given",
"job",
".",
"ini",
"file",
"into",
"the",
"given",
"archive",
"together",
"with",
"all",
"related",
"files",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqzip.py#L80-L103 |
446 | gem/oq-engine | openquake/calculators/reportwriter.py | build_report | def build_report(job_ini, output_dir=None):
"""
Write a `report.csv` file with information about the calculation
without running it
:param job_ini:
full pathname of the job.ini file
:param output_dir:
the directory where the report is written (default the input directory)
"""
... | python | def build_report(job_ini, output_dir=None):
"""
Write a `report.csv` file with information about the calculation
without running it
:param job_ini:
full pathname of the job.ini file
:param output_dir:
the directory where the report is written (default the input directory)
"""
... | [
"def",
"build_report",
"(",
"job_ini",
",",
"output_dir",
"=",
"None",
")",
":",
"calc_id",
"=",
"logs",
".",
"init",
"(",
")",
"oq",
"=",
"readinput",
".",
"get_oqparam",
"(",
"job_ini",
")",
"if",
"oq",
".",
"calculation_mode",
"==",
"'classical'",
":"... | Write a `report.csv` file with information about the calculation
without running it
:param job_ini:
full pathname of the job.ini file
:param output_dir:
the directory where the report is written (default the input directory) | [
"Write",
"a",
"report",
".",
"csv",
"file",
"with",
"information",
"about",
"the",
"calculation",
"without",
"running",
"it"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/reportwriter.py#L125-L159 |
447 | gem/oq-engine | openquake/calculators/reportwriter.py | ReportWriter.add | def add(self, name, obj=None):
"""Add the view named `name` to the report text"""
if obj:
text = '\n::\n\n' + indent(str(obj))
else:
text = views.view(name, self.dstore)
if text:
title = self.title[name]
line = '-' * len(title)
... | python | def add(self, name, obj=None):
"""Add the view named `name` to the report text"""
if obj:
text = '\n::\n\n' + indent(str(obj))
else:
text = views.view(name, self.dstore)
if text:
title = self.title[name]
line = '-' * len(title)
... | [
"def",
"add",
"(",
"self",
",",
"name",
",",
"obj",
"=",
"None",
")",
":",
"if",
"obj",
":",
"text",
"=",
"'\\n::\\n\\n'",
"+",
"indent",
"(",
"str",
"(",
"obj",
")",
")",
"else",
":",
"text",
"=",
"views",
".",
"view",
"(",
"name",
",",
"self"... | Add the view named `name` to the report text | [
"Add",
"the",
"view",
"named",
"name",
"to",
"the",
"report",
"text"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/reportwriter.py#L74-L83 |
448 | gem/oq-engine | openquake/calculators/reportwriter.py | ReportWriter.make_report | def make_report(self):
"""Build the report and return a restructed text string"""
oq, ds = self.oq, self.dstore
for name in ('params', 'inputs'):
self.add(name)
if 'csm_info' in ds:
self.add('csm_info')
if ds['csm_info'].source_models[0].name != 'scena... | python | def make_report(self):
"""Build the report and return a restructed text string"""
oq, ds = self.oq, self.dstore
for name in ('params', 'inputs'):
self.add(name)
if 'csm_info' in ds:
self.add('csm_info')
if ds['csm_info'].source_models[0].name != 'scena... | [
"def",
"make_report",
"(",
"self",
")",
":",
"oq",
",",
"ds",
"=",
"self",
".",
"oq",
",",
"self",
".",
"dstore",
"for",
"name",
"in",
"(",
"'params'",
",",
"'inputs'",
")",
":",
"self",
".",
"add",
"(",
"name",
")",
"if",
"'csm_info'",
"in",
"ds... | Build the report and return a restructed text string | [
"Build",
"the",
"report",
"and",
"return",
"a",
"restructed",
"text",
"string"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/reportwriter.py#L85-L117 |
449 | gem/oq-engine | openquake/calculators/reportwriter.py | ReportWriter.save | def save(self, fname):
"""Save the report"""
with open(fname, 'wb') as f:
f.write(encode(self.text)) | python | def save(self, fname):
"""Save the report"""
with open(fname, 'wb') as f:
f.write(encode(self.text)) | [
"def",
"save",
"(",
"self",
",",
"fname",
")",
":",
"with",
"open",
"(",
"fname",
",",
"'wb'",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"encode",
"(",
"self",
".",
"text",
")",
")"
] | Save the report | [
"Save",
"the",
"report"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/reportwriter.py#L119-L122 |
450 | gem/oq-engine | openquake/hazardlib/gsim/frankel_1996.py | FrankelEtAl1996MblgAB1987NSHMP2008._compute_mean | def _compute_mean(self, imt, mag, rhypo):
"""
Compute mean value from lookup table.
Lookup table defines log10(IMT) (in g) for combinations of Mw and
log10(rhypo) values. ``mag`` is therefore converted from Mblg to Mw
using Atkinson and Boore 1987 conversion equation. Mean value... | python | def _compute_mean(self, imt, mag, rhypo):
"""
Compute mean value from lookup table.
Lookup table defines log10(IMT) (in g) for combinations of Mw and
log10(rhypo) values. ``mag`` is therefore converted from Mblg to Mw
using Atkinson and Boore 1987 conversion equation. Mean value... | [
"def",
"_compute_mean",
"(",
"self",
",",
"imt",
",",
"mag",
",",
"rhypo",
")",
":",
"mag",
"=",
"np",
".",
"zeros_like",
"(",
"rhypo",
")",
"+",
"self",
".",
"_convert_magnitude",
"(",
"mag",
")",
"# to avoid run time warning in case rhypo is zero set minimum d... | Compute mean value from lookup table.
Lookup table defines log10(IMT) (in g) for combinations of Mw and
log10(rhypo) values. ``mag`` is therefore converted from Mblg to Mw
using Atkinson and Boore 1987 conversion equation. Mean value is
finally converted from base 10 to base e. | [
"Compute",
"mean",
"value",
"from",
"lookup",
"table",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/frankel_1996.py#L129-L152 |
451 | gem/oq-engine | openquake/hmtk/plotting/seismicity/occurrence/recurrence_plot.py | _get_recurrence_model | def _get_recurrence_model(input_model):
"""
Returns the annual and cumulative recurrence rates predicted by the
recurrence model
"""
if not isinstance(input_model, (TruncatedGRMFD,
EvenlyDiscretizedMFD,
YoungsCoppersmith1985MFD)... | python | def _get_recurrence_model(input_model):
"""
Returns the annual and cumulative recurrence rates predicted by the
recurrence model
"""
if not isinstance(input_model, (TruncatedGRMFD,
EvenlyDiscretizedMFD,
YoungsCoppersmith1985MFD)... | [
"def",
"_get_recurrence_model",
"(",
"input_model",
")",
":",
"if",
"not",
"isinstance",
"(",
"input_model",
",",
"(",
"TruncatedGRMFD",
",",
"EvenlyDiscretizedMFD",
",",
"YoungsCoppersmith1985MFD",
")",
")",
":",
"raise",
"ValueError",
"(",
"'Recurrence model not rec... | Returns the annual and cumulative recurrence rates predicted by the
recurrence model | [
"Returns",
"the",
"annual",
"and",
"cumulative",
"recurrence",
"rates",
"predicted",
"by",
"the",
"recurrence",
"model"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/occurrence/recurrence_plot.py#L62-L77 |
452 | gem/oq-engine | openquake/hmtk/plotting/seismicity/occurrence/recurrence_plot.py | _check_completeness_table | def _check_completeness_table(completeness, catalogue):
"""
Generates the completeness table according to different instances
"""
if isinstance(completeness, np.ndarray) and np.shape(completeness)[1] == 2:
return completeness
elif isinstance(completeness, float):
return np.array([[fl... | python | def _check_completeness_table(completeness, catalogue):
"""
Generates the completeness table according to different instances
"""
if isinstance(completeness, np.ndarray) and np.shape(completeness)[1] == 2:
return completeness
elif isinstance(completeness, float):
return np.array([[fl... | [
"def",
"_check_completeness_table",
"(",
"completeness",
",",
"catalogue",
")",
":",
"if",
"isinstance",
"(",
"completeness",
",",
"np",
".",
"ndarray",
")",
"and",
"np",
".",
"shape",
"(",
"completeness",
")",
"[",
"1",
"]",
"==",
"2",
":",
"return",
"c... | Generates the completeness table according to different instances | [
"Generates",
"the",
"completeness",
"table",
"according",
"to",
"different",
"instances"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/occurrence/recurrence_plot.py#L80-L93 |
453 | gem/oq-engine | openquake/hmtk/plotting/seismicity/occurrence/recurrence_plot.py | plot_recurrence_model | def plot_recurrence_model(
input_model, catalogue, completeness, dmag=0.1, filename=None,
figure_size=(8, 6), filetype='png', dpi=300, ax=None):
"""
Plot a calculated recurrence model over an observed catalogue, adjusted for
time-varying completeness
"""
annual_rates, cumulative_rate... | python | def plot_recurrence_model(
input_model, catalogue, completeness, dmag=0.1, filename=None,
figure_size=(8, 6), filetype='png', dpi=300, ax=None):
"""
Plot a calculated recurrence model over an observed catalogue, adjusted for
time-varying completeness
"""
annual_rates, cumulative_rate... | [
"def",
"plot_recurrence_model",
"(",
"input_model",
",",
"catalogue",
",",
"completeness",
",",
"dmag",
"=",
"0.1",
",",
"filename",
"=",
"None",
",",
"figure_size",
"=",
"(",
"8",
",",
"6",
")",
",",
"filetype",
"=",
"'png'",
",",
"dpi",
"=",
"300",
"... | Plot a calculated recurrence model over an observed catalogue, adjusted for
time-varying completeness | [
"Plot",
"a",
"calculated",
"recurrence",
"model",
"over",
"an",
"observed",
"catalogue",
"adjusted",
"for",
"time",
"-",
"varying",
"completeness"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/occurrence/recurrence_plot.py#L96-L132 |
454 | gem/oq-engine | openquake/hmtk/plotting/seismicity/occurrence/recurrence_plot.py | plot_trunc_gr_model | def plot_trunc_gr_model(
aval, bval, min_mag, max_mag, dmag,
catalogue=None, completeness=None, filename=None,
figure_size=(8, 6), filetype='png', dpi=300, ax=None):
"""
Plots a Gutenberg-Richter model
"""
input_model = TruncatedGRMFD(min_mag, max_mag, dmag, aval, bval)
if no... | python | def plot_trunc_gr_model(
aval, bval, min_mag, max_mag, dmag,
catalogue=None, completeness=None, filename=None,
figure_size=(8, 6), filetype='png', dpi=300, ax=None):
"""
Plots a Gutenberg-Richter model
"""
input_model = TruncatedGRMFD(min_mag, max_mag, dmag, aval, bval)
if no... | [
"def",
"plot_trunc_gr_model",
"(",
"aval",
",",
"bval",
",",
"min_mag",
",",
"max_mag",
",",
"dmag",
",",
"catalogue",
"=",
"None",
",",
"completeness",
"=",
"None",
",",
"filename",
"=",
"None",
",",
"figure_size",
"=",
"(",
"8",
",",
"6",
")",
",",
... | Plots a Gutenberg-Richter model | [
"Plots",
"a",
"Gutenberg",
"-",
"Richter",
"model"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/occurrence/recurrence_plot.py#L135-L163 |
455 | gem/oq-engine | openquake/hazardlib/nrml.py | read | def read(source, chatty=True, stop=None):
"""
Convert a NRML file into a validated Node object. Keeps
the entire tree in memory.
:param source:
a file name or file object open for reading
"""
vparser = ValidatingXmlParser(validators, stop)
nrml = vparser.parse_file(source)
if st... | python | def read(source, chatty=True, stop=None):
"""
Convert a NRML file into a validated Node object. Keeps
the entire tree in memory.
:param source:
a file name or file object open for reading
"""
vparser = ValidatingXmlParser(validators, stop)
nrml = vparser.parse_file(source)
if st... | [
"def",
"read",
"(",
"source",
",",
"chatty",
"=",
"True",
",",
"stop",
"=",
"None",
")",
":",
"vparser",
"=",
"ValidatingXmlParser",
"(",
"validators",
",",
"stop",
")",
"nrml",
"=",
"vparser",
".",
"parse_file",
"(",
"source",
")",
"if",
"striptag",
"... | Convert a NRML file into a validated Node object. Keeps
the entire tree in memory.
:param source:
a file name or file object open for reading | [
"Convert",
"a",
"NRML",
"file",
"into",
"a",
"validated",
"Node",
"object",
".",
"Keeps",
"the",
"entire",
"tree",
"in",
"memory",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/nrml.py#L329-L349 |
456 | gem/oq-engine | openquake/hazardlib/nrml.py | write | def write(nodes, output=sys.stdout, fmt='%.7E', gml=True, xmlns=None):
"""
Convert nodes into a NRML file. output must be a file
object open in write mode. If you want to perform a
consistency check, open it in read-write mode, then it will
be read after creation and validated.
:params nodes: a... | python | def write(nodes, output=sys.stdout, fmt='%.7E', gml=True, xmlns=None):
"""
Convert nodes into a NRML file. output must be a file
object open in write mode. If you want to perform a
consistency check, open it in read-write mode, then it will
be read after creation and validated.
:params nodes: a... | [
"def",
"write",
"(",
"nodes",
",",
"output",
"=",
"sys",
".",
"stdout",
",",
"fmt",
"=",
"'%.7E'",
",",
"gml",
"=",
"True",
",",
"xmlns",
"=",
"None",
")",
":",
"root",
"=",
"Node",
"(",
"'nrml'",
",",
"nodes",
"=",
"nodes",
")",
"namespaces",
"=... | Convert nodes into a NRML file. output must be a file
object open in write mode. If you want to perform a
consistency check, open it in read-write mode, then it will
be read after creation and validated.
:params nodes: an iterable over Node objects
:params output: a file-like object in write or rea... | [
"Convert",
"nodes",
"into",
"a",
"NRML",
"file",
".",
"output",
"must",
"be",
"a",
"file",
"object",
"open",
"in",
"write",
"mode",
".",
"If",
"you",
"want",
"to",
"perform",
"a",
"consistency",
"check",
"open",
"it",
"in",
"read",
"-",
"write",
"mode"... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/nrml.py#L352-L373 |
457 | gem/oq-engine | openquake/hazardlib/nrml.py | to_string | def to_string(node):
"""
Convert a node into a string in NRML format
"""
with io.BytesIO() as f:
write([node], f)
return f.getvalue().decode('utf-8') | python | def to_string(node):
"""
Convert a node into a string in NRML format
"""
with io.BytesIO() as f:
write([node], f)
return f.getvalue().decode('utf-8') | [
"def",
"to_string",
"(",
"node",
")",
":",
"with",
"io",
".",
"BytesIO",
"(",
")",
"as",
"f",
":",
"write",
"(",
"[",
"node",
"]",
",",
"f",
")",
"return",
"f",
".",
"getvalue",
"(",
")",
".",
"decode",
"(",
"'utf-8'",
")"
] | Convert a node into a string in NRML format | [
"Convert",
"a",
"node",
"into",
"a",
"string",
"in",
"NRML",
"format"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/nrml.py#L376-L382 |
458 | gem/oq-engine | openquake/hazardlib/gsim/campbell_bozorgnia_2014.py | CampbellBozorgnia2014.get_mean_values | def get_mean_values(self, C, sites, rup, dists, a1100):
"""
Returns the mean values for a specific IMT
"""
if isinstance(a1100, np.ndarray):
# Site model defined
temp_vs30 = sites.vs30
temp_z2pt5 = sites.z2pt5
else:
# Default site a... | python | def get_mean_values(self, C, sites, rup, dists, a1100):
"""
Returns the mean values for a specific IMT
"""
if isinstance(a1100, np.ndarray):
# Site model defined
temp_vs30 = sites.vs30
temp_z2pt5 = sites.z2pt5
else:
# Default site a... | [
"def",
"get_mean_values",
"(",
"self",
",",
"C",
",",
"sites",
",",
"rup",
",",
"dists",
",",
"a1100",
")",
":",
"if",
"isinstance",
"(",
"a1100",
",",
"np",
".",
"ndarray",
")",
":",
"# Site model defined",
"temp_vs30",
"=",
"sites",
".",
"vs30",
"tem... | Returns the mean values for a specific IMT | [
"Returns",
"the",
"mean",
"values",
"for",
"a",
"specific",
"IMT"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L122-L144 |
459 | gem/oq-engine | openquake/hazardlib/gsim/campbell_bozorgnia_2014.py | CampbellBozorgnia2014._get_magnitude_term | def _get_magnitude_term(self, C, mag):
"""
Returns the magnitude scaling term defined in equation 2
"""
f_mag = C["c0"] + C["c1"] * mag
if (mag > 4.5) and (mag <= 5.5):
return f_mag + (C["c2"] * (mag - 4.5))
elif (mag > 5.5) and (mag <= 6.5):
retur... | python | def _get_magnitude_term(self, C, mag):
"""
Returns the magnitude scaling term defined in equation 2
"""
f_mag = C["c0"] + C["c1"] * mag
if (mag > 4.5) and (mag <= 5.5):
return f_mag + (C["c2"] * (mag - 4.5))
elif (mag > 5.5) and (mag <= 6.5):
retur... | [
"def",
"_get_magnitude_term",
"(",
"self",
",",
"C",
",",
"mag",
")",
":",
"f_mag",
"=",
"C",
"[",
"\"c0\"",
"]",
"+",
"C",
"[",
"\"c1\"",
"]",
"*",
"mag",
"if",
"(",
"mag",
">",
"4.5",
")",
"and",
"(",
"mag",
"<=",
"5.5",
")",
":",
"return",
... | Returns the magnitude scaling term defined in equation 2 | [
"Returns",
"the",
"magnitude",
"scaling",
"term",
"defined",
"in",
"equation",
"2"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L146-L159 |
460 | gem/oq-engine | openquake/hazardlib/gsim/campbell_bozorgnia_2014.py | CampbellBozorgnia2014._get_geometric_attenuation_term | def _get_geometric_attenuation_term(self, C, mag, rrup):
"""
Returns the geometric attenuation term defined in equation 3
"""
return (C["c5"] + C["c6"] * mag) * np.log(np.sqrt((rrup ** 2.) +
(C["c7"] ** 2.))) | python | def _get_geometric_attenuation_term(self, C, mag, rrup):
"""
Returns the geometric attenuation term defined in equation 3
"""
return (C["c5"] + C["c6"] * mag) * np.log(np.sqrt((rrup ** 2.) +
(C["c7"] ** 2.))) | [
"def",
"_get_geometric_attenuation_term",
"(",
"self",
",",
"C",
",",
"mag",
",",
"rrup",
")",
":",
"return",
"(",
"C",
"[",
"\"c5\"",
"]",
"+",
"C",
"[",
"\"c6\"",
"]",
"*",
"mag",
")",
"*",
"np",
".",
"log",
"(",
"np",
".",
"sqrt",
"(",
"(",
... | Returns the geometric attenuation term defined in equation 3 | [
"Returns",
"the",
"geometric",
"attenuation",
"term",
"defined",
"in",
"equation",
"3"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L161-L166 |
461 | gem/oq-engine | openquake/hazardlib/gsim/campbell_bozorgnia_2014.py | CampbellBozorgnia2014._get_style_of_faulting_term | def _get_style_of_faulting_term(self, C, rup):
"""
Returns the style-of-faulting scaling term defined in equations 4 to 6
"""
if (rup.rake > 30.0) and (rup.rake < 150.):
frv = 1.0
fnm = 0.0
elif (rup.rake > -150.0) and (rup.rake < -30.0):
fnm =... | python | def _get_style_of_faulting_term(self, C, rup):
"""
Returns the style-of-faulting scaling term defined in equations 4 to 6
"""
if (rup.rake > 30.0) and (rup.rake < 150.):
frv = 1.0
fnm = 0.0
elif (rup.rake > -150.0) and (rup.rake < -30.0):
fnm =... | [
"def",
"_get_style_of_faulting_term",
"(",
"self",
",",
"C",
",",
"rup",
")",
":",
"if",
"(",
"rup",
".",
"rake",
">",
"30.0",
")",
"and",
"(",
"rup",
".",
"rake",
"<",
"150.",
")",
":",
"frv",
"=",
"1.0",
"fnm",
"=",
"0.0",
"elif",
"(",
"rup",
... | Returns the style-of-faulting scaling term defined in equations 4 to 6 | [
"Returns",
"the",
"style",
"-",
"of",
"-",
"faulting",
"scaling",
"term",
"defined",
"in",
"equations",
"4",
"to",
"6"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L168-L189 |
462 | gem/oq-engine | openquake/hazardlib/gsim/campbell_bozorgnia_2014.py | CampbellBozorgnia2014._get_hanging_wall_term | def _get_hanging_wall_term(self, C, rup, dists):
"""
Returns the hanging wall scaling term defined in equations 7 to 16
"""
return (C["c10"] *
self._get_hanging_wall_coeffs_rx(C, rup, dists.rx) *
self._get_hanging_wall_coeffs_rrup(dists) *
... | python | def _get_hanging_wall_term(self, C, rup, dists):
"""
Returns the hanging wall scaling term defined in equations 7 to 16
"""
return (C["c10"] *
self._get_hanging_wall_coeffs_rx(C, rup, dists.rx) *
self._get_hanging_wall_coeffs_rrup(dists) *
... | [
"def",
"_get_hanging_wall_term",
"(",
"self",
",",
"C",
",",
"rup",
",",
"dists",
")",
":",
"return",
"(",
"C",
"[",
"\"c10\"",
"]",
"*",
"self",
".",
"_get_hanging_wall_coeffs_rx",
"(",
"C",
",",
"rup",
",",
"dists",
".",
"rx",
")",
"*",
"self",
"."... | Returns the hanging wall scaling term defined in equations 7 to 16 | [
"Returns",
"the",
"hanging",
"wall",
"scaling",
"term",
"defined",
"in",
"equations",
"7",
"to",
"16"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L191-L200 |
463 | gem/oq-engine | openquake/hazardlib/gsim/campbell_bozorgnia_2014.py | CampbellBozorgnia2014._get_hanging_wall_coeffs_rx | def _get_hanging_wall_coeffs_rx(self, C, rup, r_x):
"""
Returns the hanging wall r-x caling term defined in equation 7 to 12
"""
# Define coefficients R1 and R2
r_1 = rup.width * cos(radians(rup.dip))
r_2 = 62.0 * rup.mag - 350.0
fhngrx = np.zeros(len(r_x))
... | python | def _get_hanging_wall_coeffs_rx(self, C, rup, r_x):
"""
Returns the hanging wall r-x caling term defined in equation 7 to 12
"""
# Define coefficients R1 and R2
r_1 = rup.width * cos(radians(rup.dip))
r_2 = 62.0 * rup.mag - 350.0
fhngrx = np.zeros(len(r_x))
... | [
"def",
"_get_hanging_wall_coeffs_rx",
"(",
"self",
",",
"C",
",",
"rup",
",",
"r_x",
")",
":",
"# Define coefficients R1 and R2",
"r_1",
"=",
"rup",
".",
"width",
"*",
"cos",
"(",
"radians",
"(",
"rup",
".",
"dip",
")",
")",
"r_2",
"=",
"62.0",
"*",
"r... | Returns the hanging wall r-x caling term defined in equation 7 to 12 | [
"Returns",
"the",
"hanging",
"wall",
"r",
"-",
"x",
"caling",
"term",
"defined",
"in",
"equation",
"7",
"to",
"12"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L202-L218 |
464 | gem/oq-engine | openquake/hazardlib/gsim/campbell_bozorgnia_2014.py | CampbellBozorgnia2014._get_f1rx | def _get_f1rx(self, C, r_x, r_1):
"""
Defines the f1 scaling coefficient defined in equation 9
"""
rxr1 = r_x / r_1
return C["h1"] + (C["h2"] * rxr1) + (C["h3"] * (rxr1 ** 2.)) | python | def _get_f1rx(self, C, r_x, r_1):
"""
Defines the f1 scaling coefficient defined in equation 9
"""
rxr1 = r_x / r_1
return C["h1"] + (C["h2"] * rxr1) + (C["h3"] * (rxr1 ** 2.)) | [
"def",
"_get_f1rx",
"(",
"self",
",",
"C",
",",
"r_x",
",",
"r_1",
")",
":",
"rxr1",
"=",
"r_x",
"/",
"r_1",
"return",
"C",
"[",
"\"h1\"",
"]",
"+",
"(",
"C",
"[",
"\"h2\"",
"]",
"*",
"rxr1",
")",
"+",
"(",
"C",
"[",
"\"h3\"",
"]",
"*",
"("... | Defines the f1 scaling coefficient defined in equation 9 | [
"Defines",
"the",
"f1",
"scaling",
"coefficient",
"defined",
"in",
"equation",
"9"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L220-L225 |
465 | gem/oq-engine | openquake/hazardlib/gsim/campbell_bozorgnia_2014.py | CampbellBozorgnia2014._get_f2rx | def _get_f2rx(self, C, r_x, r_1, r_2):
"""
Defines the f2 scaling coefficient defined in equation 10
"""
drx = (r_x - r_1) / (r_2 - r_1)
return self.CONSTS["h4"] + (C["h5"] * drx) + (C["h6"] * (drx ** 2.)) | python | def _get_f2rx(self, C, r_x, r_1, r_2):
"""
Defines the f2 scaling coefficient defined in equation 10
"""
drx = (r_x - r_1) / (r_2 - r_1)
return self.CONSTS["h4"] + (C["h5"] * drx) + (C["h6"] * (drx ** 2.)) | [
"def",
"_get_f2rx",
"(",
"self",
",",
"C",
",",
"r_x",
",",
"r_1",
",",
"r_2",
")",
":",
"drx",
"=",
"(",
"r_x",
"-",
"r_1",
")",
"/",
"(",
"r_2",
"-",
"r_1",
")",
"return",
"self",
".",
"CONSTS",
"[",
"\"h4\"",
"]",
"+",
"(",
"C",
"[",
"\"... | Defines the f2 scaling coefficient defined in equation 10 | [
"Defines",
"the",
"f2",
"scaling",
"coefficient",
"defined",
"in",
"equation",
"10"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L227-L232 |
466 | gem/oq-engine | openquake/hazardlib/gsim/campbell_bozorgnia_2014.py | CampbellBozorgnia2014._get_hanging_wall_coeffs_rrup | def _get_hanging_wall_coeffs_rrup(self, dists):
"""
Returns the hanging wall rrup term defined in equation 13
"""
fhngrrup = np.ones(len(dists.rrup))
idx = dists.rrup > 0.0
fhngrrup[idx] = (dists.rrup[idx] - dists.rjb[idx]) / dists.rrup[idx]
return fhngrrup | python | def _get_hanging_wall_coeffs_rrup(self, dists):
"""
Returns the hanging wall rrup term defined in equation 13
"""
fhngrrup = np.ones(len(dists.rrup))
idx = dists.rrup > 0.0
fhngrrup[idx] = (dists.rrup[idx] - dists.rjb[idx]) / dists.rrup[idx]
return fhngrrup | [
"def",
"_get_hanging_wall_coeffs_rrup",
"(",
"self",
",",
"dists",
")",
":",
"fhngrrup",
"=",
"np",
".",
"ones",
"(",
"len",
"(",
"dists",
".",
"rrup",
")",
")",
"idx",
"=",
"dists",
".",
"rrup",
">",
"0.0",
"fhngrrup",
"[",
"idx",
"]",
"=",
"(",
"... | Returns the hanging wall rrup term defined in equation 13 | [
"Returns",
"the",
"hanging",
"wall",
"rrup",
"term",
"defined",
"in",
"equation",
"13"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L234-L241 |
467 | gem/oq-engine | openquake/hazardlib/gsim/campbell_bozorgnia_2014.py | CampbellBozorgnia2014._get_hanging_wall_coeffs_mag | def _get_hanging_wall_coeffs_mag(self, C, mag):
"""
Returns the hanging wall magnitude term defined in equation 14
"""
if mag < 5.5:
return 0.0
elif mag > 6.5:
return 1.0 + C["a2"] * (mag - 6.5)
else:
return (mag - 5.5) * (1.0 + C["a2"]... | python | def _get_hanging_wall_coeffs_mag(self, C, mag):
"""
Returns the hanging wall magnitude term defined in equation 14
"""
if mag < 5.5:
return 0.0
elif mag > 6.5:
return 1.0 + C["a2"] * (mag - 6.5)
else:
return (mag - 5.5) * (1.0 + C["a2"]... | [
"def",
"_get_hanging_wall_coeffs_mag",
"(",
"self",
",",
"C",
",",
"mag",
")",
":",
"if",
"mag",
"<",
"5.5",
":",
"return",
"0.0",
"elif",
"mag",
">",
"6.5",
":",
"return",
"1.0",
"+",
"C",
"[",
"\"a2\"",
"]",
"*",
"(",
"mag",
"-",
"6.5",
")",
"e... | Returns the hanging wall magnitude term defined in equation 14 | [
"Returns",
"the",
"hanging",
"wall",
"magnitude",
"term",
"defined",
"in",
"equation",
"14"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L243-L252 |
468 | gem/oq-engine | openquake/hazardlib/gsim/campbell_bozorgnia_2014.py | CampbellBozorgnia2014._get_hypocentral_depth_term | def _get_hypocentral_depth_term(self, C, rup):
"""
Returns the hypocentral depth scaling term defined in equations 21 - 23
"""
if rup.hypo_depth <= 7.0:
fhyp_h = 0.0
elif rup.hypo_depth > 20.0:
fhyp_h = 13.0
else:
fhyp_h = rup.hypo_dept... | python | def _get_hypocentral_depth_term(self, C, rup):
"""
Returns the hypocentral depth scaling term defined in equations 21 - 23
"""
if rup.hypo_depth <= 7.0:
fhyp_h = 0.0
elif rup.hypo_depth > 20.0:
fhyp_h = 13.0
else:
fhyp_h = rup.hypo_dept... | [
"def",
"_get_hypocentral_depth_term",
"(",
"self",
",",
"C",
",",
"rup",
")",
":",
"if",
"rup",
".",
"hypo_depth",
"<=",
"7.0",
":",
"fhyp_h",
"=",
"0.0",
"elif",
"rup",
".",
"hypo_depth",
">",
"20.0",
":",
"fhyp_h",
"=",
"13.0",
"else",
":",
"fhyp_h",... | Returns the hypocentral depth scaling term defined in equations 21 - 23 | [
"Returns",
"the",
"hypocentral",
"depth",
"scaling",
"term",
"defined",
"in",
"equations",
"21",
"-",
"23"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L269-L286 |
469 | gem/oq-engine | openquake/hazardlib/gsim/campbell_bozorgnia_2014.py | CampbellBozorgnia2014._get_fault_dip_term | def _get_fault_dip_term(self, C, rup):
"""
Returns the fault dip term, defined in equation 24
"""
if rup.mag < 4.5:
return C["c19"] * rup.dip
elif rup.mag > 5.5:
return 0.0
else:
return C["c19"] * (5.5 - rup.mag) * rup.dip | python | def _get_fault_dip_term(self, C, rup):
"""
Returns the fault dip term, defined in equation 24
"""
if rup.mag < 4.5:
return C["c19"] * rup.dip
elif rup.mag > 5.5:
return 0.0
else:
return C["c19"] * (5.5 - rup.mag) * rup.dip | [
"def",
"_get_fault_dip_term",
"(",
"self",
",",
"C",
",",
"rup",
")",
":",
"if",
"rup",
".",
"mag",
"<",
"4.5",
":",
"return",
"C",
"[",
"\"c19\"",
"]",
"*",
"rup",
".",
"dip",
"elif",
"rup",
".",
"mag",
">",
"5.5",
":",
"return",
"0.0",
"else",
... | Returns the fault dip term, defined in equation 24 | [
"Returns",
"the",
"fault",
"dip",
"term",
"defined",
"in",
"equation",
"24"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L288-L297 |
470 | gem/oq-engine | openquake/hazardlib/gsim/campbell_bozorgnia_2014.py | CampbellBozorgnia2014._get_anelastic_attenuation_term | def _get_anelastic_attenuation_term(self, C, rrup):
"""
Returns the anelastic attenuation term defined in equation 25
"""
f_atn = np.zeros(len(rrup))
idx = rrup >= 80.0
f_atn[idx] = (C["c20"] + C["Dc20"]) * (rrup[idx] - 80.0)
return f_atn | python | def _get_anelastic_attenuation_term(self, C, rrup):
"""
Returns the anelastic attenuation term defined in equation 25
"""
f_atn = np.zeros(len(rrup))
idx = rrup >= 80.0
f_atn[idx] = (C["c20"] + C["Dc20"]) * (rrup[idx] - 80.0)
return f_atn | [
"def",
"_get_anelastic_attenuation_term",
"(",
"self",
",",
"C",
",",
"rrup",
")",
":",
"f_atn",
"=",
"np",
".",
"zeros",
"(",
"len",
"(",
"rrup",
")",
")",
"idx",
"=",
"rrup",
">=",
"80.0",
"f_atn",
"[",
"idx",
"]",
"=",
"(",
"C",
"[",
"\"c20\"",
... | Returns the anelastic attenuation term defined in equation 25 | [
"Returns",
"the",
"anelastic",
"attenuation",
"term",
"defined",
"in",
"equation",
"25"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L299-L306 |
471 | gem/oq-engine | openquake/hazardlib/gsim/campbell_bozorgnia_2014.py | CampbellBozorgnia2014._get_basin_response_term | def _get_basin_response_term(self, C, z2pt5):
"""
Returns the basin response term defined in equation 20
"""
f_sed = np.zeros(len(z2pt5))
idx = z2pt5 < 1.0
f_sed[idx] = (C["c14"] + C["c15"] * float(self.CONSTS["SJ"])) *\
(z2pt5[idx] - 1.0)
idx = z2pt5 ... | python | def _get_basin_response_term(self, C, z2pt5):
"""
Returns the basin response term defined in equation 20
"""
f_sed = np.zeros(len(z2pt5))
idx = z2pt5 < 1.0
f_sed[idx] = (C["c14"] + C["c15"] * float(self.CONSTS["SJ"])) *\
(z2pt5[idx] - 1.0)
idx = z2pt5 ... | [
"def",
"_get_basin_response_term",
"(",
"self",
",",
"C",
",",
"z2pt5",
")",
":",
"f_sed",
"=",
"np",
".",
"zeros",
"(",
"len",
"(",
"z2pt5",
")",
")",
"idx",
"=",
"z2pt5",
"<",
"1.0",
"f_sed",
"[",
"idx",
"]",
"=",
"(",
"C",
"[",
"\"c14\"",
"]",... | Returns the basin response term defined in equation 20 | [
"Returns",
"the",
"basin",
"response",
"term",
"defined",
"in",
"equation",
"20"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L321-L332 |
472 | gem/oq-engine | openquake/hazardlib/gsim/campbell_bozorgnia_2014.py | CampbellBozorgnia2014._get_shallow_site_response_term | def _get_shallow_site_response_term(self, C, vs30, pga_rock):
"""
Returns the shallow site response term defined in equations 17, 18 and
19
"""
vs_mod = vs30 / C["k1"]
# Get linear global site response term
f_site_g = C["c11"] * np.log(vs_mod)
idx = vs30 >... | python | def _get_shallow_site_response_term(self, C, vs30, pga_rock):
"""
Returns the shallow site response term defined in equations 17, 18 and
19
"""
vs_mod = vs30 / C["k1"]
# Get linear global site response term
f_site_g = C["c11"] * np.log(vs_mod)
idx = vs30 >... | [
"def",
"_get_shallow_site_response_term",
"(",
"self",
",",
"C",
",",
"vs30",
",",
"pga_rock",
")",
":",
"vs_mod",
"=",
"vs30",
"/",
"C",
"[",
"\"k1\"",
"]",
"# Get linear global site response term",
"f_site_g",
"=",
"C",
"[",
"\"c11\"",
"]",
"*",
"np",
".",... | Returns the shallow site response term defined in equations 17, 18 and
19 | [
"Returns",
"the",
"shallow",
"site",
"response",
"term",
"defined",
"in",
"equations",
"17",
"18",
"and",
"19"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L334-L369 |
473 | gem/oq-engine | openquake/hazardlib/gsim/campbell_bozorgnia_2014.py | CampbellBozorgnia2014._get_stddevs | def _get_stddevs(self, C, C_PGA, rup, sites, pga1100, stddev_types):
"""
Returns the inter- and intra-event and total standard deviations
"""
# Get stddevs for PGA on basement rock
tau_lnpga_b, phi_lnpga_b = self._get_stddevs_pga(C_PGA, rup)
num_sites = len(sites.vs30)
... | python | def _get_stddevs(self, C, C_PGA, rup, sites, pga1100, stddev_types):
"""
Returns the inter- and intra-event and total standard deviations
"""
# Get stddevs for PGA on basement rock
tau_lnpga_b, phi_lnpga_b = self._get_stddevs_pga(C_PGA, rup)
num_sites = len(sites.vs30)
... | [
"def",
"_get_stddevs",
"(",
"self",
",",
"C",
",",
"C_PGA",
",",
"rup",
",",
"sites",
",",
"pga1100",
",",
"stddev_types",
")",
":",
"# Get stddevs for PGA on basement rock",
"tau_lnpga_b",
",",
"phi_lnpga_b",
"=",
"self",
".",
"_get_stddevs_pga",
"(",
"C_PGA",
... | Returns the inter- and intra-event and total standard deviations | [
"Returns",
"the",
"inter",
"-",
"and",
"intra",
"-",
"event",
"and",
"total",
"standard",
"deviations"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L371-L407 |
474 | gem/oq-engine | openquake/hazardlib/gsim/campbell_bozorgnia_2014.py | CampbellBozorgnia2014._get_stddevs_pga | def _get_stddevs_pga(self, C, rup):
"""
Returns the inter- and intra-event coefficients for PGA
"""
tau_lnpga_b = self._get_taulny(C, rup.mag)
phi_lnpga_b = np.sqrt(self._get_philny(C, rup.mag) ** 2. -
self.CONSTS["philnAF"] ** 2.)
return tau... | python | def _get_stddevs_pga(self, C, rup):
"""
Returns the inter- and intra-event coefficients for PGA
"""
tau_lnpga_b = self._get_taulny(C, rup.mag)
phi_lnpga_b = np.sqrt(self._get_philny(C, rup.mag) ** 2. -
self.CONSTS["philnAF"] ** 2.)
return tau... | [
"def",
"_get_stddevs_pga",
"(",
"self",
",",
"C",
",",
"rup",
")",
":",
"tau_lnpga_b",
"=",
"self",
".",
"_get_taulny",
"(",
"C",
",",
"rup",
".",
"mag",
")",
"phi_lnpga_b",
"=",
"np",
".",
"sqrt",
"(",
"self",
".",
"_get_philny",
"(",
"C",
",",
"r... | Returns the inter- and intra-event coefficients for PGA | [
"Returns",
"the",
"inter",
"-",
"and",
"intra",
"-",
"event",
"coefficients",
"for",
"PGA"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L409-L416 |
475 | gem/oq-engine | openquake/hazardlib/gsim/campbell_bozorgnia_2014.py | CampbellBozorgnia2014._get_alpha | def _get_alpha(self, C, vs30, pga_rock):
"""
Returns the alpha, the linearised functional relationship between the
site amplification and the PGA on rock. Equation 31.
"""
alpha = np.zeros(len(pga_rock))
idx = vs30 < C["k1"]
if np.any(idx):
af1 = pga_r... | python | def _get_alpha(self, C, vs30, pga_rock):
"""
Returns the alpha, the linearised functional relationship between the
site amplification and the PGA on rock. Equation 31.
"""
alpha = np.zeros(len(pga_rock))
idx = vs30 < C["k1"]
if np.any(idx):
af1 = pga_r... | [
"def",
"_get_alpha",
"(",
"self",
",",
"C",
",",
"vs30",
",",
"pga_rock",
")",
":",
"alpha",
"=",
"np",
".",
"zeros",
"(",
"len",
"(",
"pga_rock",
")",
")",
"idx",
"=",
"vs30",
"<",
"C",
"[",
"\"k1\"",
"]",
"if",
"np",
".",
"any",
"(",
"idx",
... | Returns the alpha, the linearised functional relationship between the
site amplification and the PGA on rock. Equation 31. | [
"Returns",
"the",
"alpha",
"the",
"linearised",
"functional",
"relationship",
"between",
"the",
"site",
"amplification",
"and",
"the",
"PGA",
"on",
"rock",
".",
"Equation",
"31",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L442-L454 |
476 | gem/oq-engine | openquake/hmtk/seismicity/utils.py | decimal_time | def decimal_time(year, month, day, hour, minute, second):
"""
Returns the full time as a decimal value
:param year:
Year of events (integer numpy.ndarray)
:param month:
Month of events (integer numpy.ndarray)
:param day:
Days of event (integer numpy.ndarray)
:param hour:... | python | def decimal_time(year, month, day, hour, minute, second):
"""
Returns the full time as a decimal value
:param year:
Year of events (integer numpy.ndarray)
:param month:
Month of events (integer numpy.ndarray)
:param day:
Days of event (integer numpy.ndarray)
:param hour:... | [
"def",
"decimal_time",
"(",
"year",
",",
"month",
",",
"day",
",",
"hour",
",",
"minute",
",",
"second",
")",
":",
"tmo",
"=",
"np",
".",
"ones_like",
"(",
"year",
",",
"dtype",
"=",
"int",
")",
"tda",
"=",
"np",
".",
"ones_like",
"(",
"year",
",... | Returns the full time as a decimal value
:param year:
Year of events (integer numpy.ndarray)
:param month:
Month of events (integer numpy.ndarray)
:param day:
Days of event (integer numpy.ndarray)
:param hour:
Hour of event (integer numpy.ndarray)
:param minute:
... | [
"Returns",
"the",
"full",
"time",
"as",
"a",
"decimal",
"value"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/utils.py#L137-L197 |
477 | gem/oq-engine | openquake/hmtk/seismicity/utils.py | haversine | def haversine(lon1, lat1, lon2, lat2, radians=False, earth_rad=6371.227):
"""
Allows to calculate geographical distance
using the haversine formula.
:param lon1: longitude of the first set of locations
:type lon1: numpy.ndarray
:param lat1: latitude of the frist set of locations
:type lat1:... | python | def haversine(lon1, lat1, lon2, lat2, radians=False, earth_rad=6371.227):
"""
Allows to calculate geographical distance
using the haversine formula.
:param lon1: longitude of the first set of locations
:type lon1: numpy.ndarray
:param lat1: latitude of the frist set of locations
:type lat1:... | [
"def",
"haversine",
"(",
"lon1",
",",
"lat1",
",",
"lon2",
",",
"lat2",
",",
"radians",
"=",
"False",
",",
"earth_rad",
"=",
"6371.227",
")",
":",
"if",
"not",
"radians",
":",
"cfact",
"=",
"np",
".",
"pi",
"/",
"180.",
"lon1",
"=",
"cfact",
"*",
... | Allows to calculate geographical distance
using the haversine formula.
:param lon1: longitude of the first set of locations
:type lon1: numpy.ndarray
:param lat1: latitude of the frist set of locations
:type lat1: numpy.ndarray
:param lon2: longitude of the second set of locations
:type lon... | [
"Allows",
"to",
"calculate",
"geographical",
"distance",
"using",
"the",
"haversine",
"formula",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/utils.py#L200-L252 |
478 | gem/oq-engine | openquake/hmtk/seismicity/utils.py | greg2julian | def greg2julian(year, month, day, hour, minute, second):
"""
Function to convert a date from Gregorian to Julian format
:param year:
Year of events (integer numpy.ndarray)
:param month:
Month of events (integer numpy.ndarray)
:param day:
Days of event (integer numpy.ndarray)... | python | def greg2julian(year, month, day, hour, minute, second):
"""
Function to convert a date from Gregorian to Julian format
:param year:
Year of events (integer numpy.ndarray)
:param month:
Month of events (integer numpy.ndarray)
:param day:
Days of event (integer numpy.ndarray)... | [
"def",
"greg2julian",
"(",
"year",
",",
"month",
",",
"day",
",",
"hour",
",",
"minute",
",",
"second",
")",
":",
"year",
"=",
"year",
".",
"astype",
"(",
"float",
")",
"month",
"=",
"month",
".",
"astype",
"(",
"float",
")",
"day",
"=",
"day",
"... | Function to convert a date from Gregorian to Julian format
:param year:
Year of events (integer numpy.ndarray)
:param month:
Month of events (integer numpy.ndarray)
:param day:
Days of event (integer numpy.ndarray)
:param hour:
Hour of event (integer numpy.ndarray)
:... | [
"Function",
"to",
"convert",
"a",
"date",
"from",
"Gregorian",
"to",
"Julian",
"format"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/utils.py#L255-L289 |
479 | gem/oq-engine | openquake/hmtk/seismicity/utils.py | sample_truncated_gaussian_vector | def sample_truncated_gaussian_vector(data, uncertainties, bounds=None):
'''
Samples a Gaussian distribution subject to boundaries on the data
:param numpy.ndarray data:
Vector of N data values
:param numpy.ndarray uncertainties:
Vector of N data uncertainties
:param int number_boots... | python | def sample_truncated_gaussian_vector(data, uncertainties, bounds=None):
'''
Samples a Gaussian distribution subject to boundaries on the data
:param numpy.ndarray data:
Vector of N data values
:param numpy.ndarray uncertainties:
Vector of N data uncertainties
:param int number_boots... | [
"def",
"sample_truncated_gaussian_vector",
"(",
"data",
",",
"uncertainties",
",",
"bounds",
"=",
"None",
")",
":",
"nvals",
"=",
"len",
"(",
"data",
")",
"if",
"bounds",
":",
"# if bounds[0] or (fabs(bounds[0]) < PRECISION):",
"if",
"bounds",
"[",
"0",
"]",
"is... | Samples a Gaussian distribution subject to boundaries on the data
:param numpy.ndarray data:
Vector of N data values
:param numpy.ndarray uncertainties:
Vector of N data uncertainties
:param int number_bootstraps:
Number of bootstrap samples
:param tuple bounds:
(Lower, ... | [
"Samples",
"a",
"Gaussian",
"distribution",
"subject",
"to",
"boundaries",
"on",
"the",
"data"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/utils.py#L333-L363 |
480 | gem/oq-engine | openquake/hmtk/seismicity/utils.py | hmtk_histogram_2D | def hmtk_histogram_2D(xvalues, yvalues, bins, x_offset=1.0E-10,
y_offset=1.0E-10):
"""
See the explanation for the 1D case - now applied to 2D.
:param numpy.ndarray xvalues:
Values of x-data
:param numpy.ndarray yvalues:
Values of y-data
:param tuple bins:
... | python | def hmtk_histogram_2D(xvalues, yvalues, bins, x_offset=1.0E-10,
y_offset=1.0E-10):
"""
See the explanation for the 1D case - now applied to 2D.
:param numpy.ndarray xvalues:
Values of x-data
:param numpy.ndarray yvalues:
Values of y-data
:param tuple bins:
... | [
"def",
"hmtk_histogram_2D",
"(",
"xvalues",
",",
"yvalues",
",",
"bins",
",",
"x_offset",
"=",
"1.0E-10",
",",
"y_offset",
"=",
"1.0E-10",
")",
":",
"xbins",
",",
"ybins",
"=",
"(",
"bins",
"[",
"0",
"]",
"-",
"x_offset",
",",
"bins",
"[",
"1",
"]",
... | See the explanation for the 1D case - now applied to 2D.
:param numpy.ndarray xvalues:
Values of x-data
:param numpy.ndarray yvalues:
Values of y-data
:param tuple bins:
Tuple containing bin intervals for x-data and y-data (as numpy arrays)
:param float x_offset:
Small a... | [
"See",
"the",
"explanation",
"for",
"the",
"1D",
"case",
"-",
"now",
"applied",
"to",
"2D",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/utils.py#L404-L432 |
481 | gem/oq-engine | openquake/hmtk/seismicity/utils.py | bootstrap_histogram_1D | def bootstrap_histogram_1D(
values, intervals, uncertainties=None,
normalisation=False, number_bootstraps=None, boundaries=None):
'''
Bootstrap samples a set of vectors
:param numpy.ndarray values:
The data values
:param numpy.ndarray intervals:
The bin edges
:param ... | python | def bootstrap_histogram_1D(
values, intervals, uncertainties=None,
normalisation=False, number_bootstraps=None, boundaries=None):
'''
Bootstrap samples a set of vectors
:param numpy.ndarray values:
The data values
:param numpy.ndarray intervals:
The bin edges
:param ... | [
"def",
"bootstrap_histogram_1D",
"(",
"values",
",",
"intervals",
",",
"uncertainties",
"=",
"None",
",",
"normalisation",
"=",
"False",
",",
"number_bootstraps",
"=",
"None",
",",
"boundaries",
"=",
"None",
")",
":",
"if",
"not",
"number_bootstraps",
"or",
"n... | Bootstrap samples a set of vectors
:param numpy.ndarray values:
The data values
:param numpy.ndarray intervals:
The bin edges
:param numpy.ndarray uncertainties:
The standard deviations of each observation
:param bool normalisation:
If True then returns the histogram as ... | [
"Bootstrap",
"samples",
"a",
"set",
"of",
"vectors"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/utils.py#L435-L483 |
482 | gem/oq-engine | openquake/hmtk/seismicity/utils.py | bootstrap_histogram_2D | def bootstrap_histogram_2D(
xvalues, yvalues, xbins, ybins,
boundaries=[None, None], xsigma=None, ysigma=None,
normalisation=False, number_bootstraps=None):
'''
Calculates a 2D histogram of data, allowing for normalisation and
bootstrap sampling
:param numpy.ndarray xvalues:
... | python | def bootstrap_histogram_2D(
xvalues, yvalues, xbins, ybins,
boundaries=[None, None], xsigma=None, ysigma=None,
normalisation=False, number_bootstraps=None):
'''
Calculates a 2D histogram of data, allowing for normalisation and
bootstrap sampling
:param numpy.ndarray xvalues:
... | [
"def",
"bootstrap_histogram_2D",
"(",
"xvalues",
",",
"yvalues",
",",
"xbins",
",",
"ybins",
",",
"boundaries",
"=",
"[",
"None",
",",
"None",
"]",
",",
"xsigma",
"=",
"None",
",",
"ysigma",
"=",
"None",
",",
"normalisation",
"=",
"False",
",",
"number_b... | Calculates a 2D histogram of data, allowing for normalisation and
bootstrap sampling
:param numpy.ndarray xvalues:
Data values of the first variable
:param numpy.ndarray yvalues:
Data values of the second variable
:param numpy.ndarray xbins:
Bin edges for the first variable
... | [
"Calculates",
"a",
"2D",
"histogram",
"of",
"data",
"allowing",
"for",
"normalisation",
"and",
"bootstrap",
"sampling"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/utils.py#L486-L558 |
483 | gem/oq-engine | openquake/hmtk/seismicity/utils.py | area_of_polygon | def area_of_polygon(polygon):
"""
Returns the area of an OpenQuake polygon in square kilometres
"""
lon0 = np.mean(polygon.lons)
lat0 = np.mean(polygon.lats)
# Transform to lamber equal area projection
x, y = lonlat_to_laea(polygon.lons, polygon.lats, lon0, lat0)
# Build shapely polygons... | python | def area_of_polygon(polygon):
"""
Returns the area of an OpenQuake polygon in square kilometres
"""
lon0 = np.mean(polygon.lons)
lat0 = np.mean(polygon.lats)
# Transform to lamber equal area projection
x, y = lonlat_to_laea(polygon.lons, polygon.lats, lon0, lat0)
# Build shapely polygons... | [
"def",
"area_of_polygon",
"(",
"polygon",
")",
":",
"lon0",
"=",
"np",
".",
"mean",
"(",
"polygon",
".",
"lons",
")",
"lat0",
"=",
"np",
".",
"mean",
"(",
"polygon",
".",
"lats",
")",
"# Transform to lamber equal area projection",
"x",
",",
"y",
"=",
"lo... | Returns the area of an OpenQuake polygon in square kilometres | [
"Returns",
"the",
"area",
"of",
"an",
"OpenQuake",
"polygon",
"in",
"square",
"kilometres"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/utils.py#L628-L638 |
484 | gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.lti | def lti(self):
"""
Dictionary extended_loss_type -> extended_loss_type index
"""
return {lt: i for i, (lt, dt) in enumerate(self.loss_dt_list())} | python | def lti(self):
"""
Dictionary extended_loss_type -> extended_loss_type index
"""
return {lt: i for i, (lt, dt) in enumerate(self.loss_dt_list())} | [
"def",
"lti",
"(",
"self",
")",
":",
"return",
"{",
"lt",
":",
"i",
"for",
"i",
",",
"(",
"lt",
",",
"dt",
")",
"in",
"enumerate",
"(",
"self",
".",
"loss_dt_list",
"(",
")",
")",
"}"
] | Dictionary extended_loss_type -> extended_loss_type index | [
"Dictionary",
"extended_loss_type",
"-",
">",
"extended_loss_type",
"index"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L468-L472 |
485 | gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.loss_maps_dt | def loss_maps_dt(self, dtype=F32):
"""
Return a composite data type for loss maps
"""
ltypes = self.loss_dt(dtype).names
lst = [('poe-%s' % poe, dtype) for poe in self.conditional_loss_poes]
return numpy.dtype([(lt, lst) for lt in ltypes]) | python | def loss_maps_dt(self, dtype=F32):
"""
Return a composite data type for loss maps
"""
ltypes = self.loss_dt(dtype).names
lst = [('poe-%s' % poe, dtype) for poe in self.conditional_loss_poes]
return numpy.dtype([(lt, lst) for lt in ltypes]) | [
"def",
"loss_maps_dt",
"(",
"self",
",",
"dtype",
"=",
"F32",
")",
":",
"ltypes",
"=",
"self",
".",
"loss_dt",
"(",
"dtype",
")",
".",
"names",
"lst",
"=",
"[",
"(",
"'poe-%s'",
"%",
"poe",
",",
"dtype",
")",
"for",
"poe",
"in",
"self",
".",
"con... | Return a composite data type for loss maps | [
"Return",
"a",
"composite",
"data",
"type",
"for",
"loss",
"maps"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L488-L494 |
486 | gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.gmf_data_dt | def gmf_data_dt(self):
"""
Return a composite data type for the GMFs
"""
return numpy.dtype(
[('rlzi', U16), ('sid', U32),
('eid', U64), ('gmv', (F32, (len(self.imtls),)))]) | python | def gmf_data_dt(self):
"""
Return a composite data type for the GMFs
"""
return numpy.dtype(
[('rlzi', U16), ('sid', U32),
('eid', U64), ('gmv', (F32, (len(self.imtls),)))]) | [
"def",
"gmf_data_dt",
"(",
"self",
")",
":",
"return",
"numpy",
".",
"dtype",
"(",
"[",
"(",
"'rlzi'",
",",
"U16",
")",
",",
"(",
"'sid'",
",",
"U32",
")",
",",
"(",
"'eid'",
",",
"U64",
")",
",",
"(",
"'gmv'",
",",
"(",
"F32",
",",
"(",
"len... | Return a composite data type for the GMFs | [
"Return",
"a",
"composite",
"data",
"type",
"for",
"the",
"GMFs"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L496-L502 |
487 | gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.no_imls | def no_imls(self):
"""
Return True if there are no intensity measure levels
"""
return all(numpy.isnan(ls).any() for ls in self.imtls.values()) | python | def no_imls(self):
"""
Return True if there are no intensity measure levels
"""
return all(numpy.isnan(ls).any() for ls in self.imtls.values()) | [
"def",
"no_imls",
"(",
"self",
")",
":",
"return",
"all",
"(",
"numpy",
".",
"isnan",
"(",
"ls",
")",
".",
"any",
"(",
")",
"for",
"ls",
"in",
"self",
".",
"imtls",
".",
"values",
"(",
")",
")"
] | Return True if there are no intensity measure levels | [
"Return",
"True",
"if",
"there",
"are",
"no",
"intensity",
"measure",
"levels"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L504-L508 |
488 | gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.get_kinds | def get_kinds(self, kind, R):
"""
Yield 'rlz-000', 'rlz-001', ...', 'mean', 'quantile-0.1', ...
"""
stats = self.hazard_stats()
if kind == 'stats':
yield from stats
return
elif kind == 'rlzs':
for r in range(R):
yield 'r... | python | def get_kinds(self, kind, R):
"""
Yield 'rlz-000', 'rlz-001', ...', 'mean', 'quantile-0.1', ...
"""
stats = self.hazard_stats()
if kind == 'stats':
yield from stats
return
elif kind == 'rlzs':
for r in range(R):
yield 'r... | [
"def",
"get_kinds",
"(",
"self",
",",
"kind",
",",
"R",
")",
":",
"stats",
"=",
"self",
".",
"hazard_stats",
"(",
")",
"if",
"kind",
"==",
"'stats'",
":",
"yield",
"from",
"stats",
"return",
"elif",
"kind",
"==",
"'rlzs'",
":",
"for",
"r",
"in",
"r... | Yield 'rlz-000', 'rlz-001', ...', 'mean', 'quantile-0.1', ... | [
"Yield",
"rlz",
"-",
"000",
"rlz",
"-",
"001",
"...",
"mean",
"quantile",
"-",
"0",
".",
"1",
"..."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L523-L542 |
489 | gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.hazard_stats | def hazard_stats(self):
"""
Return a list of item with the statistical functions defined for the
hazard calculation
"""
names = [] # name of statistical functions
funcs = [] # statistical functions of kind func(values, weights)
if self.mean_hazard_curves:
... | python | def hazard_stats(self):
"""
Return a list of item with the statistical functions defined for the
hazard calculation
"""
names = [] # name of statistical functions
funcs = [] # statistical functions of kind func(values, weights)
if self.mean_hazard_curves:
... | [
"def",
"hazard_stats",
"(",
"self",
")",
":",
"names",
"=",
"[",
"]",
"# name of statistical functions",
"funcs",
"=",
"[",
"]",
"# statistical functions of kind func(values, weights)",
"if",
"self",
".",
"mean_hazard_curves",
":",
"names",
".",
"append",
"(",
"'mea... | Return a list of item with the statistical functions defined for the
hazard calculation | [
"Return",
"a",
"list",
"of",
"item",
"with",
"the",
"statistical",
"functions",
"defined",
"for",
"the",
"hazard",
"calculation"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L544-L563 |
490 | gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.is_valid_geometry | def is_valid_geometry(self):
"""
It is possible to infer the geometry only if exactly
one of sites, sites_csv, hazard_curves_csv, gmfs_csv,
region is set. You did set more than one, or nothing.
"""
has_sites = (self.sites is not None or 'sites' in self.inputs
... | python | def is_valid_geometry(self):
"""
It is possible to infer the geometry only if exactly
one of sites, sites_csv, hazard_curves_csv, gmfs_csv,
region is set. You did set more than one, or nothing.
"""
has_sites = (self.sites is not None or 'sites' in self.inputs
... | [
"def",
"is_valid_geometry",
"(",
"self",
")",
":",
"has_sites",
"=",
"(",
"self",
".",
"sites",
"is",
"not",
"None",
"or",
"'sites'",
"in",
"self",
".",
"inputs",
"or",
"'site_model'",
"in",
"self",
".",
"inputs",
")",
"if",
"not",
"has_sites",
"and",
... | It is possible to infer the geometry only if exactly
one of sites, sites_csv, hazard_curves_csv, gmfs_csv,
region is set. You did set more than one, or nothing. | [
"It",
"is",
"possible",
"to",
"infer",
"the",
"geometry",
"only",
"if",
"exactly",
"one",
"of",
"sites",
"sites_csv",
"hazard_curves_csv",
"gmfs_csv",
"region",
"is",
"set",
".",
"You",
"did",
"set",
"more",
"than",
"one",
"or",
"nothing",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L595-L622 |
491 | gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.is_valid_intensity_measure_types | def is_valid_intensity_measure_types(self):
"""
If the IMTs and levels are extracted from the risk models,
they must not be set directly. Moreover, if
`intensity_measure_types_and_levels` is set directly,
`intensity_measure_types` must not be set.
"""
if self.grou... | python | def is_valid_intensity_measure_types(self):
"""
If the IMTs and levels are extracted from the risk models,
they must not be set directly. Moreover, if
`intensity_measure_types_and_levels` is set directly,
`intensity_measure_types` must not be set.
"""
if self.grou... | [
"def",
"is_valid_intensity_measure_types",
"(",
"self",
")",
":",
"if",
"self",
".",
"ground_motion_correlation_model",
":",
"for",
"imt",
"in",
"self",
".",
"imtls",
":",
"if",
"not",
"(",
"imt",
".",
"startswith",
"(",
"'SA'",
")",
"or",
"imt",
"==",
"'P... | If the IMTs and levels are extracted from the risk models,
they must not be set directly. Moreover, if
`intensity_measure_types_and_levels` is set directly,
`intensity_measure_types` must not be set. | [
"If",
"the",
"IMTs",
"and",
"levels",
"are",
"extracted",
"from",
"the",
"risk",
"models",
"they",
"must",
"not",
"be",
"set",
"directly",
".",
"Moreover",
"if",
"intensity_measure_types_and_levels",
"is",
"set",
"directly",
"intensity_measure_types",
"must",
"not... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L660-L679 |
492 | gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.is_valid_intensity_measure_levels | def is_valid_intensity_measure_levels(self):
"""
In order to compute hazard curves, `intensity_measure_types_and_levels`
must be set or extracted from the risk models.
"""
invalid = self.no_imls() and not self.risk_files and (
self.hazard_curves_from_gmfs or self.calc... | python | def is_valid_intensity_measure_levels(self):
"""
In order to compute hazard curves, `intensity_measure_types_and_levels`
must be set or extracted from the risk models.
"""
invalid = self.no_imls() and not self.risk_files and (
self.hazard_curves_from_gmfs or self.calc... | [
"def",
"is_valid_intensity_measure_levels",
"(",
"self",
")",
":",
"invalid",
"=",
"self",
".",
"no_imls",
"(",
")",
"and",
"not",
"self",
".",
"risk_files",
"and",
"(",
"self",
".",
"hazard_curves_from_gmfs",
"or",
"self",
".",
"calculation_mode",
"in",
"(",
... | In order to compute hazard curves, `intensity_measure_types_and_levels`
must be set or extracted from the risk models. | [
"In",
"order",
"to",
"compute",
"hazard",
"curves",
"intensity_measure_types_and_levels",
"must",
"be",
"set",
"or",
"extracted",
"from",
"the",
"risk",
"models",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L681-L689 |
493 | gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.is_valid_sites | def is_valid_sites(self):
"""
The sites are overdetermined
"""
if 'site_model' in self.inputs and 'sites' in self.inputs:
return False
elif 'site_model' in self.inputs and self.sites:
return False
elif 'sites' in self.inputs and self.sites:
... | python | def is_valid_sites(self):
"""
The sites are overdetermined
"""
if 'site_model' in self.inputs and 'sites' in self.inputs:
return False
elif 'site_model' in self.inputs and self.sites:
return False
elif 'sites' in self.inputs and self.sites:
... | [
"def",
"is_valid_sites",
"(",
"self",
")",
":",
"if",
"'site_model'",
"in",
"self",
".",
"inputs",
"and",
"'sites'",
"in",
"self",
".",
"inputs",
":",
"return",
"False",
"elif",
"'site_model'",
"in",
"self",
".",
"inputs",
"and",
"self",
".",
"sites",
":... | The sites are overdetermined | [
"The",
"sites",
"are",
"overdetermined"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L733-L746 |
494 | gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.is_valid_complex_fault_mesh_spacing | def is_valid_complex_fault_mesh_spacing(self):
"""
The `complex_fault_mesh_spacing` parameter can be None only if
`rupture_mesh_spacing` is set. In that case it is identified with it.
"""
rms = getattr(self, 'rupture_mesh_spacing', None)
if rms and not getattr(self, 'comp... | python | def is_valid_complex_fault_mesh_spacing(self):
"""
The `complex_fault_mesh_spacing` parameter can be None only if
`rupture_mesh_spacing` is set. In that case it is identified with it.
"""
rms = getattr(self, 'rupture_mesh_spacing', None)
if rms and not getattr(self, 'comp... | [
"def",
"is_valid_complex_fault_mesh_spacing",
"(",
"self",
")",
":",
"rms",
"=",
"getattr",
"(",
"self",
",",
"'rupture_mesh_spacing'",
",",
"None",
")",
"if",
"rms",
"and",
"not",
"getattr",
"(",
"self",
",",
"'complex_fault_mesh_spacing'",
",",
"None",
")",
... | The `complex_fault_mesh_spacing` parameter can be None only if
`rupture_mesh_spacing` is set. In that case it is identified with it. | [
"The",
"complex_fault_mesh_spacing",
"parameter",
"can",
"be",
"None",
"only",
"if",
"rupture_mesh_spacing",
"is",
"set",
".",
"In",
"that",
"case",
"it",
"is",
"identified",
"with",
"it",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L748-L756 |
495 | gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.is_valid_optimize_same_id_sources | def is_valid_optimize_same_id_sources(self):
"""
The `optimize_same_id_sources` can be true only in the classical
calculators.
"""
if (self.optimize_same_id_sources and
'classical' in self.calculation_mode or
'disagg' in self.calculation_mode):
... | python | def is_valid_optimize_same_id_sources(self):
"""
The `optimize_same_id_sources` can be true only in the classical
calculators.
"""
if (self.optimize_same_id_sources and
'classical' in self.calculation_mode or
'disagg' in self.calculation_mode):
... | [
"def",
"is_valid_optimize_same_id_sources",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"optimize_same_id_sources",
"and",
"'classical'",
"in",
"self",
".",
"calculation_mode",
"or",
"'disagg'",
"in",
"self",
".",
"calculation_mode",
")",
":",
"return",
"True",... | The `optimize_same_id_sources` can be true only in the classical
calculators. | [
"The",
"optimize_same_id_sources",
"can",
"be",
"true",
"only",
"in",
"the",
"classical",
"calculators",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L758-L770 |
496 | gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.check_missing | def check_missing(self, param, action):
"""
Make sure the given parameter is missing in the job.ini file
"""
assert action in ('debug', 'info', 'warn', 'error'), action
if self.inputs.get(param):
msg = '%s_file in %s is ignored in %s' % (
param, self.i... | python | def check_missing(self, param, action):
"""
Make sure the given parameter is missing in the job.ini file
"""
assert action in ('debug', 'info', 'warn', 'error'), action
if self.inputs.get(param):
msg = '%s_file in %s is ignored in %s' % (
param, self.i... | [
"def",
"check_missing",
"(",
"self",
",",
"param",
",",
"action",
")",
":",
"assert",
"action",
"in",
"(",
"'debug'",
",",
"'info'",
",",
"'warn'",
",",
"'error'",
")",
",",
"action",
"if",
"self",
".",
"inputs",
".",
"get",
"(",
"param",
")",
":",
... | Make sure the given parameter is missing in the job.ini file | [
"Make",
"sure",
"the",
"given",
"parameter",
"is",
"missing",
"in",
"the",
"job",
".",
"ini",
"file"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L795-L806 |
497 | gem/oq-engine | openquake/hazardlib/sourceconverter.py | get_set_num_ruptures | def get_set_num_ruptures(src):
"""
Extract the number of ruptures and set it
"""
if not src.num_ruptures:
t0 = time.time()
src.num_ruptures = src.count_ruptures()
dt = time.time() - t0
clsname = src.__class__.__name__
if dt > 10:
if 'Area' in clsname:
... | python | def get_set_num_ruptures(src):
"""
Extract the number of ruptures and set it
"""
if not src.num_ruptures:
t0 = time.time()
src.num_ruptures = src.count_ruptures()
dt = time.time() - t0
clsname = src.__class__.__name__
if dt > 10:
if 'Area' in clsname:
... | [
"def",
"get_set_num_ruptures",
"(",
"src",
")",
":",
"if",
"not",
"src",
".",
"num_ruptures",
":",
"t0",
"=",
"time",
".",
"time",
"(",
")",
"src",
".",
"num_ruptures",
"=",
"src",
".",
"count_ruptures",
"(",
")",
"dt",
"=",
"time",
".",
"time",
"(",... | Extract the number of ruptures and set it | [
"Extract",
"the",
"number",
"of",
"ruptures",
"and",
"set",
"it"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L238-L263 |
498 | gem/oq-engine | openquake/hazardlib/sourceconverter.py | mfds2multimfd | def mfds2multimfd(mfds):
"""
Convert a list of MFD nodes into a single MultiMFD node
"""
_, kind = mfds[0].tag.split('}')
node = Node('multiMFD', dict(kind=kind, size=len(mfds)))
lengths = None
for field in mfd.multi_mfd.ASSOC[kind][1:]:
alias = mfd.multi_mfd.ALIAS.get(field, field)
... | python | def mfds2multimfd(mfds):
"""
Convert a list of MFD nodes into a single MultiMFD node
"""
_, kind = mfds[0].tag.split('}')
node = Node('multiMFD', dict(kind=kind, size=len(mfds)))
lengths = None
for field in mfd.multi_mfd.ASSOC[kind][1:]:
alias = mfd.multi_mfd.ALIAS.get(field, field)
... | [
"def",
"mfds2multimfd",
"(",
"mfds",
")",
":",
"_",
",",
"kind",
"=",
"mfds",
"[",
"0",
"]",
".",
"tag",
".",
"split",
"(",
"'}'",
")",
"node",
"=",
"Node",
"(",
"'multiMFD'",
",",
"dict",
"(",
"kind",
"=",
"kind",
",",
"size",
"=",
"len",
"(",... | Convert a list of MFD nodes into a single MultiMFD node | [
"Convert",
"a",
"list",
"of",
"MFD",
"nodes",
"into",
"a",
"single",
"MultiMFD",
"node"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L918-L943 |
499 | gem/oq-engine | openquake/hazardlib/sourceconverter.py | SourceGroup.update | def update(self, src):
"""
Update the attributes sources, min_mag, max_mag
according to the given source.
:param src:
an instance of :class:
`openquake.hazardlib.source.base.BaseSeismicSource`
"""
assert src.tectonic_region_type == self.trt, (
... | python | def update(self, src):
"""
Update the attributes sources, min_mag, max_mag
according to the given source.
:param src:
an instance of :class:
`openquake.hazardlib.source.base.BaseSeismicSource`
"""
assert src.tectonic_region_type == self.trt, (
... | [
"def",
"update",
"(",
"self",
",",
"src",
")",
":",
"assert",
"src",
".",
"tectonic_region_type",
"==",
"self",
".",
"trt",
",",
"(",
"src",
".",
"tectonic_region_type",
",",
"self",
".",
"trt",
")",
"if",
"not",
"src",
".",
"min_mag",
":",
"# if not s... | Update the attributes sources, min_mag, max_mag
according to the given source.
:param src:
an instance of :class:
`openquake.hazardlib.source.base.BaseSeismicSource` | [
"Update",
"the",
"attributes",
"sources",
"min_mag",
"max_mag",
"according",
"to",
"the",
"given",
"source",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L159-L187 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.