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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
0 | gem/oq-engine | openquake/calculators/export/hazard.py | export_hmaps_csv | def export_hmaps_csv(key, dest, sitemesh, array, comment):
"""
Export the hazard maps of the given realization into CSV.
:param key: output_type and export_type
:param dest: name of the exported file
:param sitemesh: site collection
:param array: a composite array of dtype hmap_dt
:param co... | python | def export_hmaps_csv(key, dest, sitemesh, array, comment):
"""
Export the hazard maps of the given realization into CSV.
:param key: output_type and export_type
:param dest: name of the exported file
:param sitemesh: site collection
:param array: a composite array of dtype hmap_dt
:param co... | [
"def",
"export_hmaps_csv",
"(",
"key",
",",
"dest",
",",
"sitemesh",
",",
"array",
",",
"comment",
")",
":",
"curves",
"=",
"util",
".",
"compose_arrays",
"(",
"sitemesh",
",",
"array",
")",
"writers",
".",
"write_csv",
"(",
"dest",
",",
"curves",
",",
... | Export the hazard maps of the given realization into CSV.
:param key: output_type and export_type
:param dest: name of the exported file
:param sitemesh: site collection
:param array: a composite array of dtype hmap_dt
:param comment: comment to use as header of the exported CSV file | [
"Export",
"the",
"hazard",
"maps",
"of",
"the",
"given",
"realization",
"into",
"CSV",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/export/hazard.py#L223-L235 |
1 | gem/oq-engine | openquake/calculators/export/hazard.py | export_hcurves_by_imt_csv | def export_hcurves_by_imt_csv(
key, kind, rlzs_assoc, fname, sitecol, array, oq, checksum):
"""
Export the curves of the given realization into CSV.
:param key: output_type and export_type
:param kind: a string with the kind of output (realization or statistics)
:param rlzs_assoc: a :class:... | python | def export_hcurves_by_imt_csv(
key, kind, rlzs_assoc, fname, sitecol, array, oq, checksum):
"""
Export the curves of the given realization into CSV.
:param key: output_type and export_type
:param kind: a string with the kind of output (realization or statistics)
:param rlzs_assoc: a :class:... | [
"def",
"export_hcurves_by_imt_csv",
"(",
"key",
",",
"kind",
",",
"rlzs_assoc",
",",
"fname",
",",
"sitecol",
",",
"array",
",",
"oq",
",",
"checksum",
")",
":",
"nsites",
"=",
"len",
"(",
"sitecol",
")",
"fnames",
"=",
"[",
"]",
"for",
"imt",
",",
"... | Export the curves of the given realization into CSV.
:param key: output_type and export_type
:param kind: a string with the kind of output (realization or statistics)
:param rlzs_assoc: a :class:`openquake.commonlib.source.RlzsAssoc` instance
:param fname: name of the exported file
:param sitecol: ... | [
"Export",
"the",
"curves",
"of",
"the",
"given",
"realization",
"into",
"CSV",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/export/hazard.py#L248-L277 |
2 | gem/oq-engine | openquake/calculators/export/hazard.py | export_hcurves_csv | def export_hcurves_csv(ekey, dstore):
"""
Exports the hazard curves into several .csv files
:param ekey: export key, i.e. a pair (datastore key, fmt)
:param dstore: datastore object
"""
oq = dstore['oqparam']
info = get_info(dstore)
rlzs_assoc = dstore['csm_info'].get_rlzs_assoc()
R... | python | def export_hcurves_csv(ekey, dstore):
"""
Exports the hazard curves into several .csv files
:param ekey: export key, i.e. a pair (datastore key, fmt)
:param dstore: datastore object
"""
oq = dstore['oqparam']
info = get_info(dstore)
rlzs_assoc = dstore['csm_info'].get_rlzs_assoc()
R... | [
"def",
"export_hcurves_csv",
"(",
"ekey",
",",
"dstore",
")",
":",
"oq",
"=",
"dstore",
"[",
"'oqparam'",
"]",
"info",
"=",
"get_info",
"(",
"dstore",
")",
"rlzs_assoc",
"=",
"dstore",
"[",
"'csm_info'",
"]",
".",
"get_rlzs_assoc",
"(",
")",
"R",
"=",
... | Exports the hazard curves into several .csv files
:param ekey: export key, i.e. a pair (datastore key, fmt)
:param dstore: datastore object | [
"Exports",
"the",
"hazard",
"curves",
"into",
"several",
".",
"csv",
"files"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/export/hazard.py#L333-L373 |
3 | gem/oq-engine | openquake/calculators/export/hazard.py | save_disagg_to_csv | def save_disagg_to_csv(metadata, matrices):
"""
Save disaggregation matrices to multiple .csv files.
"""
skip_keys = ('Mag', 'Dist', 'Lon', 'Lat', 'Eps', 'TRT')
base_header = ','.join(
'%s=%s' % (key, value) for key, value in metadata.items()
if value is not None and key not in skip_... | python | def save_disagg_to_csv(metadata, matrices):
"""
Save disaggregation matrices to multiple .csv files.
"""
skip_keys = ('Mag', 'Dist', 'Lon', 'Lat', 'Eps', 'TRT')
base_header = ','.join(
'%s=%s' % (key, value) for key, value in metadata.items()
if value is not None and key not in skip_... | [
"def",
"save_disagg_to_csv",
"(",
"metadata",
",",
"matrices",
")",
":",
"skip_keys",
"=",
"(",
"'Mag'",
",",
"'Dist'",
",",
"'Lon'",
",",
"'Lat'",
",",
"'Eps'",
",",
"'TRT'",
")",
"base_header",
"=",
"','",
".",
"join",
"(",
"'%s=%s'",
"%",
"(",
"key"... | Save disaggregation matrices to multiple .csv files. | [
"Save",
"disaggregation",
"matrices",
"to",
"multiple",
".",
"csv",
"files",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/export/hazard.py#L743-L776 |
4 | gem/oq-engine | openquake/hazardlib/gsim/bradley_2013b.py | Bradley2013bChchCBD._interp_function | def _interp_function(self, y_ip1, y_i, t_ip1, t_i, imt_per):
"""
Generic interpolation function used in equation 19 of 2013 report.
"""
return y_i + (y_ip1 - y_i) / (t_ip1 - t_i) * (imt_per - t_i) | python | def _interp_function(self, y_ip1, y_i, t_ip1, t_i, imt_per):
"""
Generic interpolation function used in equation 19 of 2013 report.
"""
return y_i + (y_ip1 - y_i) / (t_ip1 - t_i) * (imt_per - t_i) | [
"def",
"_interp_function",
"(",
"self",
",",
"y_ip1",
",",
"y_i",
",",
"t_ip1",
",",
"t_i",
",",
"imt_per",
")",
":",
"return",
"y_i",
"+",
"(",
"y_ip1",
"-",
"y_i",
")",
"/",
"(",
"t_ip1",
"-",
"t_i",
")",
"*",
"(",
"imt_per",
"-",
"t_i",
")"
] | Generic interpolation function used in equation 19 of 2013 report. | [
"Generic",
"interpolation",
"function",
"used",
"in",
"equation",
"19",
"of",
"2013",
"report",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/bradley_2013b.py#L154-L158 |
5 | gem/oq-engine | openquake/hazardlib/gsim/bradley_2013b.py | Bradley2013bChchCBD._get_SRF_tau | def _get_SRF_tau(self, imt_per):
"""
Table 6 and equation 19 of 2013 report.
"""
if imt_per < 1:
srf = 0.87
elif 1 <= imt_per < 5:
srf = self._interp_function(0.58, 0.87, 5, 1, imt_per)
elif 5 <= imt_per <= 10:
srf = 0.58
else:
... | python | def _get_SRF_tau(self, imt_per):
"""
Table 6 and equation 19 of 2013 report.
"""
if imt_per < 1:
srf = 0.87
elif 1 <= imt_per < 5:
srf = self._interp_function(0.58, 0.87, 5, 1, imt_per)
elif 5 <= imt_per <= 10:
srf = 0.58
else:
... | [
"def",
"_get_SRF_tau",
"(",
"self",
",",
"imt_per",
")",
":",
"if",
"imt_per",
"<",
"1",
":",
"srf",
"=",
"0.87",
"elif",
"1",
"<=",
"imt_per",
"<",
"5",
":",
"srf",
"=",
"self",
".",
"_interp_function",
"(",
"0.58",
",",
"0.87",
",",
"5",
",",
"... | Table 6 and equation 19 of 2013 report. | [
"Table",
"6",
"and",
"equation",
"19",
"of",
"2013",
"report",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/bradley_2013b.py#L160-L173 |
6 | gem/oq-engine | openquake/hazardlib/gsim/bradley_2013b.py | Bradley2013bChchCBD._get_SRF_phi | def _get_SRF_phi(self, imt_per):
"""
Table 7 and equation 19 of 2013 report. NB change in notation,
2013 report calls this term 'sigma' but it is referred to here
as phi.
"""
if imt_per < 0.6:
srf = 0.8
elif 0.6 <= imt_per < 1:
srf = self._... | python | def _get_SRF_phi(self, imt_per):
"""
Table 7 and equation 19 of 2013 report. NB change in notation,
2013 report calls this term 'sigma' but it is referred to here
as phi.
"""
if imt_per < 0.6:
srf = 0.8
elif 0.6 <= imt_per < 1:
srf = self._... | [
"def",
"_get_SRF_phi",
"(",
"self",
",",
"imt_per",
")",
":",
"if",
"imt_per",
"<",
"0.6",
":",
"srf",
"=",
"0.8",
"elif",
"0.6",
"<=",
"imt_per",
"<",
"1",
":",
"srf",
"=",
"self",
".",
"_interp_function",
"(",
"0.7",
",",
"0.8",
",",
"1",
",",
... | Table 7 and equation 19 of 2013 report. NB change in notation,
2013 report calls this term 'sigma' but it is referred to here
as phi. | [
"Table",
"7",
"and",
"equation",
"19",
"of",
"2013",
"report",
".",
"NB",
"change",
"in",
"notation",
"2013",
"report",
"calls",
"this",
"term",
"sigma",
"but",
"it",
"is",
"referred",
"to",
"here",
"as",
"phi",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/bradley_2013b.py#L175-L190 |
7 | gem/oq-engine | openquake/hazardlib/gsim/bradley_2013b.py | Bradley2013bChchCBD._get_SRF_sigma | def _get_SRF_sigma(self, imt_per):
"""
Table 8 and equation 19 of 2013 report. NB change in notation,
2013 report calls this term 'sigma_t' but it is referred to
here as sigma. Note that Table 8 is identical to Table 7 in
the 2013 report.
"""
if imt_per < 0.6:
... | python | def _get_SRF_sigma(self, imt_per):
"""
Table 8 and equation 19 of 2013 report. NB change in notation,
2013 report calls this term 'sigma_t' but it is referred to
here as sigma. Note that Table 8 is identical to Table 7 in
the 2013 report.
"""
if imt_per < 0.6:
... | [
"def",
"_get_SRF_sigma",
"(",
"self",
",",
"imt_per",
")",
":",
"if",
"imt_per",
"<",
"0.6",
":",
"srf",
"=",
"0.8",
"elif",
"0.6",
"<=",
"imt_per",
"<",
"1",
":",
"srf",
"=",
"self",
".",
"_interp_function",
"(",
"0.7",
",",
"0.8",
",",
"1",
",",
... | Table 8 and equation 19 of 2013 report. NB change in notation,
2013 report calls this term 'sigma_t' but it is referred to
here as sigma. Note that Table 8 is identical to Table 7 in
the 2013 report. | [
"Table",
"8",
"and",
"equation",
"19",
"of",
"2013",
"report",
".",
"NB",
"change",
"in",
"notation",
"2013",
"report",
"calls",
"this",
"term",
"sigma_t",
"but",
"it",
"is",
"referred",
"to",
"here",
"as",
"sigma",
".",
"Note",
"that",
"Table",
"8",
"... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/bradley_2013b.py#L192-L208 |
8 | gem/oq-engine | openquake/hazardlib/gsim/bradley_2013b.py | Bradley2013bChchCBD._get_dL2L | def _get_dL2L(self, imt_per):
"""
Table 3 and equation 19 of 2013 report.
"""
if imt_per < 0.18:
dL2L = -0.06
elif 0.18 <= imt_per < 0.35:
dL2L = self._interp_function(0.12, -0.06, 0.35, 0.18, imt_per)
elif 0.35 <= imt_per <= 10:
dL2L =... | python | def _get_dL2L(self, imt_per):
"""
Table 3 and equation 19 of 2013 report.
"""
if imt_per < 0.18:
dL2L = -0.06
elif 0.18 <= imt_per < 0.35:
dL2L = self._interp_function(0.12, -0.06, 0.35, 0.18, imt_per)
elif 0.35 <= imt_per <= 10:
dL2L =... | [
"def",
"_get_dL2L",
"(",
"self",
",",
"imt_per",
")",
":",
"if",
"imt_per",
"<",
"0.18",
":",
"dL2L",
"=",
"-",
"0.06",
"elif",
"0.18",
"<=",
"imt_per",
"<",
"0.35",
":",
"dL2L",
"=",
"self",
".",
"_interp_function",
"(",
"0.12",
",",
"-",
"0.06",
... | Table 3 and equation 19 of 2013 report. | [
"Table",
"3",
"and",
"equation",
"19",
"of",
"2013",
"report",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/bradley_2013b.py#L210-L223 |
9 | gem/oq-engine | openquake/hazardlib/gsim/bradley_2013b.py | Bradley2013bChchCBD._get_dS2S | def _get_dS2S(self, imt_per):
"""
Table 4 of 2013 report
"""
if imt_per == 0:
dS2S = 0.05
elif 0 < imt_per < 0.15:
dS2S = self._interp_function(-0.15, 0.05, 0.15, 0, imt_per)
elif 0.15 <= imt_per < 0.45:
dS2S = self._interp_function(0.4... | python | def _get_dS2S(self, imt_per):
"""
Table 4 of 2013 report
"""
if imt_per == 0:
dS2S = 0.05
elif 0 < imt_per < 0.15:
dS2S = self._interp_function(-0.15, 0.05, 0.15, 0, imt_per)
elif 0.15 <= imt_per < 0.45:
dS2S = self._interp_function(0.4... | [
"def",
"_get_dS2S",
"(",
"self",
",",
"imt_per",
")",
":",
"if",
"imt_per",
"==",
"0",
":",
"dS2S",
"=",
"0.05",
"elif",
"0",
"<",
"imt_per",
"<",
"0.15",
":",
"dS2S",
"=",
"self",
".",
"_interp_function",
"(",
"-",
"0.15",
",",
"0.05",
",",
"0.15"... | Table 4 of 2013 report | [
"Table",
"4",
"of",
"2013",
"report"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/bradley_2013b.py#L225-L244 |
10 | gem/oq-engine | openquake/hazardlib/calc/filters.py | context | def context(src):
"""
Used to add the source_id to the error message. To be used as
with context(src):
operation_with(src)
Typically the operation is filtering a source, that can fail for
tricky geometries.
"""
try:
yield
except Exception:
etype, err, tb = sys.e... | python | def context(src):
"""
Used to add the source_id to the error message. To be used as
with context(src):
operation_with(src)
Typically the operation is filtering a source, that can fail for
tricky geometries.
"""
try:
yield
except Exception:
etype, err, tb = sys.e... | [
"def",
"context",
"(",
"src",
")",
":",
"try",
":",
"yield",
"except",
"Exception",
":",
"etype",
",",
"err",
",",
"tb",
"=",
"sys",
".",
"exc_info",
"(",
")",
"msg",
"=",
"'An error occurred with source id=%s. Error: %s'",
"msg",
"%=",
"(",
"src",
".",
... | Used to add the source_id to the error message. To be used as
with context(src):
operation_with(src)
Typically the operation is filtering a source, that can fail for
tricky geometries. | [
"Used",
"to",
"add",
"the",
"source_id",
"to",
"the",
"error",
"message",
".",
"To",
"be",
"used",
"as"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/calc/filters.py#L39-L55 |
11 | gem/oq-engine | openquake/hazardlib/calc/filters.py | IntegrationDistance.get_bounding_box | def get_bounding_box(self, lon, lat, trt=None, mag=None):
"""
Build a bounding box around the given lon, lat by computing the
maximum_distance at the given tectonic region type and magnitude.
:param lon: longitude
:param lat: latitude
:param trt: tectonic region type, po... | python | def get_bounding_box(self, lon, lat, trt=None, mag=None):
"""
Build a bounding box around the given lon, lat by computing the
maximum_distance at the given tectonic region type and magnitude.
:param lon: longitude
:param lat: latitude
:param trt: tectonic region type, po... | [
"def",
"get_bounding_box",
"(",
"self",
",",
"lon",
",",
"lat",
",",
"trt",
"=",
"None",
",",
"mag",
"=",
"None",
")",
":",
"if",
"trt",
"is",
"None",
":",
"# take the greatest integration distance",
"maxdist",
"=",
"max",
"(",
"self",
"(",
"trt",
",",
... | Build a bounding box around the given lon, lat by computing the
maximum_distance at the given tectonic region type and magnitude.
:param lon: longitude
:param lat: latitude
:param trt: tectonic region type, possibly None
:param mag: magnitude, possibly None
:returns: min... | [
"Build",
"a",
"bounding",
"box",
"around",
"the",
"given",
"lon",
"lat",
"by",
"computing",
"the",
"maximum_distance",
"at",
"the",
"given",
"tectonic",
"region",
"type",
"and",
"magnitude",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/calc/filters.py#L138-L155 |
12 | gem/oq-engine | openquake/hazardlib/calc/filters.py | IntegrationDistance.get_affected_box | def get_affected_box(self, src):
"""
Get the enlarged bounding box of a source.
:param src: a source object
:returns: a bounding box (min_lon, min_lat, max_lon, max_lat)
"""
mag = src.get_min_max_mag()[1]
maxdist = self(src.tectonic_region_type, mag)
bbox... | python | def get_affected_box(self, src):
"""
Get the enlarged bounding box of a source.
:param src: a source object
:returns: a bounding box (min_lon, min_lat, max_lon, max_lat)
"""
mag = src.get_min_max_mag()[1]
maxdist = self(src.tectonic_region_type, mag)
bbox... | [
"def",
"get_affected_box",
"(",
"self",
",",
"src",
")",
":",
"mag",
"=",
"src",
".",
"get_min_max_mag",
"(",
")",
"[",
"1",
"]",
"maxdist",
"=",
"self",
"(",
"src",
".",
"tectonic_region_type",
",",
"mag",
")",
"bbox",
"=",
"get_bounding_box",
"(",
"s... | Get the enlarged bounding box of a source.
:param src: a source object
:returns: a bounding box (min_lon, min_lat, max_lon, max_lat) | [
"Get",
"the",
"enlarged",
"bounding",
"box",
"of",
"a",
"source",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/calc/filters.py#L157-L167 |
13 | gem/oq-engine | openquake/hazardlib/calc/filters.py | SourceFilter.sitecol | def sitecol(self):
"""
Read the site collection from .filename and cache it
"""
if 'sitecol' in vars(self):
return self.__dict__['sitecol']
if self.filename is None or not os.path.exists(self.filename):
# case of nofilter/None sitecol
return
... | python | def sitecol(self):
"""
Read the site collection from .filename and cache it
"""
if 'sitecol' in vars(self):
return self.__dict__['sitecol']
if self.filename is None or not os.path.exists(self.filename):
# case of nofilter/None sitecol
return
... | [
"def",
"sitecol",
"(",
"self",
")",
":",
"if",
"'sitecol'",
"in",
"vars",
"(",
"self",
")",
":",
"return",
"self",
".",
"__dict__",
"[",
"'sitecol'",
"]",
"if",
"self",
".",
"filename",
"is",
"None",
"or",
"not",
"os",
".",
"path",
".",
"exists",
"... | Read the site collection from .filename and cache it | [
"Read",
"the",
"site",
"collection",
"from",
".",
"filename",
"and",
"cache",
"it"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/calc/filters.py#L276-L287 |
14 | gem/oq-engine | openquake/hazardlib/geo/surface/simple_fault.py | SimpleFaultSurface.hypocentre_patch_index | def hypocentre_patch_index(cls, hypocentre, rupture_top_edge,
upper_seismogenic_depth,
lower_seismogenic_depth, dip):
"""
This methods finds the index of the fault patch including
the hypocentre.
:param hypocentre:
... | python | def hypocentre_patch_index(cls, hypocentre, rupture_top_edge,
upper_seismogenic_depth,
lower_seismogenic_depth, dip):
"""
This methods finds the index of the fault patch including
the hypocentre.
:param hypocentre:
... | [
"def",
"hypocentre_patch_index",
"(",
"cls",
",",
"hypocentre",
",",
"rupture_top_edge",
",",
"upper_seismogenic_depth",
",",
"lower_seismogenic_depth",
",",
"dip",
")",
":",
"totaln_patch",
"=",
"len",
"(",
"rupture_top_edge",
")",
"indexlist",
"=",
"[",
"]",
"di... | This methods finds the index of the fault patch including
the hypocentre.
:param hypocentre:
:class:`~openquake.hazardlib.geo.point.Point` object
representing the location of hypocentre.
:param rupture_top_edge:
A instances of :class:`openquake.hazardlib.geo.... | [
"This",
"methods",
"finds",
"the",
"index",
"of",
"the",
"fault",
"patch",
"including",
"the",
"hypocentre",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/simple_fault.py#L256-L298 |
15 | gem/oq-engine | openquake/hazardlib/geo/surface/simple_fault.py | SimpleFaultSurface.get_surface_vertexes | def get_surface_vertexes(cls, fault_trace,
upper_seismogenic_depth,
lower_seismogenic_depth, dip):
"""
Get surface main vertexes.
Parameters are the same as for :meth:`from_fault_data`, excluding
mesh spacing.
:returns:
... | python | def get_surface_vertexes(cls, fault_trace,
upper_seismogenic_depth,
lower_seismogenic_depth, dip):
"""
Get surface main vertexes.
Parameters are the same as for :meth:`from_fault_data`, excluding
mesh spacing.
:returns:
... | [
"def",
"get_surface_vertexes",
"(",
"cls",
",",
"fault_trace",
",",
"upper_seismogenic_depth",
",",
"lower_seismogenic_depth",
",",
"dip",
")",
":",
"# Similar to :meth:`from_fault_data`, we just don't resample edges",
"dip_tan",
"=",
"math",
".",
"tan",
"(",
"math",
".",... | Get surface main vertexes.
Parameters are the same as for :meth:`from_fault_data`, excluding
mesh spacing.
:returns:
Instance of :class:`~openquake.hazardlib.geo.polygon.Polygon`
describing the surface projection of the simple fault with
specified parameters... | [
"Get",
"surface",
"main",
"vertexes",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/simple_fault.py#L301-L336 |
16 | gem/oq-engine | openquake/hazardlib/geo/surface/simple_fault.py | SimpleFaultSurface.surface_projection_from_fault_data | def surface_projection_from_fault_data(cls, fault_trace,
upper_seismogenic_depth,
lower_seismogenic_depth, dip):
"""
Get a surface projection of the simple fault surface.
Parameters are the same as for :meth:`... | python | def surface_projection_from_fault_data(cls, fault_trace,
upper_seismogenic_depth,
lower_seismogenic_depth, dip):
"""
Get a surface projection of the simple fault surface.
Parameters are the same as for :meth:`... | [
"def",
"surface_projection_from_fault_data",
"(",
"cls",
",",
"fault_trace",
",",
"upper_seismogenic_depth",
",",
"lower_seismogenic_depth",
",",
"dip",
")",
":",
"lons",
",",
"lats",
"=",
"cls",
".",
"get_surface_vertexes",
"(",
"fault_trace",
",",
"upper_seismogenic... | Get a surface projection of the simple fault surface.
Parameters are the same as for :meth:`from_fault_data`, excluding
mesh spacing.
:returns:
Instance of :class:`~openquake.hazardlib.geo.polygon.Polygon`
describing the surface projection of the simple fault with
... | [
"Get",
"a",
"surface",
"projection",
"of",
"the",
"simple",
"fault",
"surface",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/simple_fault.py#L339-L356 |
17 | gem/oq-engine | openquake/hazardlib/gsim/zhao_2006.py | ZhaoEtAl2006Asc._compute_distance_term | def _compute_distance_term(self, C, mag, rrup):
"""
Compute second and third terms in equation 1, p. 901.
"""
term1 = C['b'] * rrup
term2 = - np.log(rrup + C['c'] * np.exp(C['d'] * mag))
return term1 + term2 | python | def _compute_distance_term(self, C, mag, rrup):
"""
Compute second and third terms in equation 1, p. 901.
"""
term1 = C['b'] * rrup
term2 = - np.log(rrup + C['c'] * np.exp(C['d'] * mag))
return term1 + term2 | [
"def",
"_compute_distance_term",
"(",
"self",
",",
"C",
",",
"mag",
",",
"rrup",
")",
":",
"term1",
"=",
"C",
"[",
"'b'",
"]",
"*",
"rrup",
"term2",
"=",
"-",
"np",
".",
"log",
"(",
"rrup",
"+",
"C",
"[",
"'c'",
"]",
"*",
"np",
".",
"exp",
"(... | Compute second and third terms in equation 1, p. 901. | [
"Compute",
"second",
"and",
"third",
"terms",
"in",
"equation",
"1",
"p",
".",
"901",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2006.py#L133-L140 |
18 | gem/oq-engine | openquake/hazardlib/gsim/zhao_2006.py | ZhaoEtAl2006Asc._compute_focal_depth_term | def _compute_focal_depth_term(self, C, hypo_depth):
"""
Compute fourth term in equation 1, p. 901.
"""
# p. 901. "(i.e, depth is capped at 125 km)".
focal_depth = hypo_depth
if focal_depth > 125.0:
focal_depth = 125.0
# p. 902. "We used the value of 1... | python | def _compute_focal_depth_term(self, C, hypo_depth):
"""
Compute fourth term in equation 1, p. 901.
"""
# p. 901. "(i.e, depth is capped at 125 km)".
focal_depth = hypo_depth
if focal_depth > 125.0:
focal_depth = 125.0
# p. 902. "We used the value of 1... | [
"def",
"_compute_focal_depth_term",
"(",
"self",
",",
"C",
",",
"hypo_depth",
")",
":",
"# p. 901. \"(i.e, depth is capped at 125 km)\".",
"focal_depth",
"=",
"hypo_depth",
"if",
"focal_depth",
">",
"125.0",
":",
"focal_depth",
"=",
"125.0",
"# p. 902. \"We used the value... | Compute fourth term in equation 1, p. 901. | [
"Compute",
"fourth",
"term",
"in",
"equation",
"1",
"p",
".",
"901",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2006.py#L142-L157 |
19 | gem/oq-engine | openquake/hazardlib/gsim/zhao_2006.py | ZhaoEtAl2006Asc._compute_site_class_term | def _compute_site_class_term(self, C, vs30):
"""
Compute nine-th term in equation 1, p. 901.
"""
# map vs30 value to site class, see table 2, p. 901.
site_term = np.zeros(len(vs30))
# hard rock
site_term[vs30 > 1100.0] = C['CH']
# rock
site_term[... | python | def _compute_site_class_term(self, C, vs30):
"""
Compute nine-th term in equation 1, p. 901.
"""
# map vs30 value to site class, see table 2, p. 901.
site_term = np.zeros(len(vs30))
# hard rock
site_term[vs30 > 1100.0] = C['CH']
# rock
site_term[... | [
"def",
"_compute_site_class_term",
"(",
"self",
",",
"C",
",",
"vs30",
")",
":",
"# map vs30 value to site class, see table 2, p. 901.",
"site_term",
"=",
"np",
".",
"zeros",
"(",
"len",
"(",
"vs30",
")",
")",
"# hard rock",
"site_term",
"[",
"vs30",
">",
"1100.... | Compute nine-th term in equation 1, p. 901. | [
"Compute",
"nine",
"-",
"th",
"term",
"in",
"equation",
"1",
"p",
".",
"901",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2006.py#L168-L190 |
20 | gem/oq-engine | openquake/hazardlib/gsim/zhao_2006.py | ZhaoEtAl2006Asc._compute_magnitude_squared_term | def _compute_magnitude_squared_term(self, P, M, Q, W, mag):
"""
Compute magnitude squared term, equation 5, p. 909.
"""
return P * (mag - M) + Q * (mag - M) ** 2 + W | python | def _compute_magnitude_squared_term(self, P, M, Q, W, mag):
"""
Compute magnitude squared term, equation 5, p. 909.
"""
return P * (mag - M) + Q * (mag - M) ** 2 + W | [
"def",
"_compute_magnitude_squared_term",
"(",
"self",
",",
"P",
",",
"M",
",",
"Q",
",",
"W",
",",
"mag",
")",
":",
"return",
"P",
"*",
"(",
"mag",
"-",
"M",
")",
"+",
"Q",
"*",
"(",
"mag",
"-",
"M",
")",
"**",
"2",
"+",
"W"
] | Compute magnitude squared term, equation 5, p. 909. | [
"Compute",
"magnitude",
"squared",
"term",
"equation",
"5",
"p",
".",
"909",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2006.py#L192-L196 |
21 | gem/oq-engine | openquake/hazardlib/gsim/zhao_2006.py | ZhaoEtAl2006SSlab._compute_slab_correction_term | def _compute_slab_correction_term(self, C, rrup):
"""
Compute path modification term for slab events, that is
the 8-th term in equation 1, p. 901.
"""
slab_term = C['SSL'] * np.log(rrup)
return slab_term | python | def _compute_slab_correction_term(self, C, rrup):
"""
Compute path modification term for slab events, that is
the 8-th term in equation 1, p. 901.
"""
slab_term = C['SSL'] * np.log(rrup)
return slab_term | [
"def",
"_compute_slab_correction_term",
"(",
"self",
",",
"C",
",",
"rrup",
")",
":",
"slab_term",
"=",
"C",
"[",
"'SSL'",
"]",
"*",
"np",
".",
"log",
"(",
"rrup",
")",
"return",
"slab_term"
] | Compute path modification term for slab events, that is
the 8-th term in equation 1, p. 901. | [
"Compute",
"path",
"modification",
"term",
"for",
"slab",
"events",
"that",
"is",
"the",
"8",
"-",
"th",
"term",
"in",
"equation",
"1",
"p",
".",
"901",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2006.py#L369-L376 |
22 | gem/oq-engine | openquake/hazardlib/gsim/zhao_2006.py | ZhaoEtAl2006AscSGS.get_mean_and_stddevs | def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
"""
Using a minimum distance of 5km for the calculation.
"""
dists_mod = copy.deepcopy(dists)
dists_mod.rrup[dists.rrup <= 5.] = 5.
return super().get_mean_and_stddevs(
sites, rup, dists_m... | python | def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
"""
Using a minimum distance of 5km for the calculation.
"""
dists_mod = copy.deepcopy(dists)
dists_mod.rrup[dists.rrup <= 5.] = 5.
return super().get_mean_and_stddevs(
sites, rup, dists_m... | [
"def",
"get_mean_and_stddevs",
"(",
"self",
",",
"sites",
",",
"rup",
",",
"dists",
",",
"imt",
",",
"stddev_types",
")",
":",
"dists_mod",
"=",
"copy",
".",
"deepcopy",
"(",
"dists",
")",
"dists_mod",
".",
"rrup",
"[",
"dists",
".",
"rrup",
"<=",
"5."... | Using a minimum distance of 5km for the calculation. | [
"Using",
"a",
"minimum",
"distance",
"of",
"5km",
"for",
"the",
"calculation",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2006.py#L654-L663 |
23 | gem/oq-engine | openquake/engine/utils/__init__.py | confirm | def confirm(prompt):
"""
Ask for confirmation, given a ``prompt`` and return a boolean value.
"""
while True:
try:
answer = input(prompt)
except KeyboardInterrupt:
# the user presses ctrl+c, just say 'no'
return False
answer = answer.strip().lo... | python | def confirm(prompt):
"""
Ask for confirmation, given a ``prompt`` and return a boolean value.
"""
while True:
try:
answer = input(prompt)
except KeyboardInterrupt:
# the user presses ctrl+c, just say 'no'
return False
answer = answer.strip().lo... | [
"def",
"confirm",
"(",
"prompt",
")",
":",
"while",
"True",
":",
"try",
":",
"answer",
"=",
"input",
"(",
"prompt",
")",
"except",
"KeyboardInterrupt",
":",
"# the user presses ctrl+c, just say 'no'",
"return",
"False",
"answer",
"=",
"answer",
".",
"strip",
"... | Ask for confirmation, given a ``prompt`` and return a boolean value. | [
"Ask",
"for",
"confirmation",
"given",
"a",
"prompt",
"and",
"return",
"a",
"boolean",
"value",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/engine/utils/__init__.py#L20-L34 |
24 | gem/oq-engine | openquake/risklib/asset.py | Exposure._csv_header | def _csv_header(self):
"""
Extract the expected CSV header from the exposure metadata
"""
fields = ['id', 'number', 'taxonomy', 'lon', 'lat']
for name in self.cost_types['name']:
fields.append(name)
if 'per_area' in self.cost_types['type']:
fields.... | python | def _csv_header(self):
"""
Extract the expected CSV header from the exposure metadata
"""
fields = ['id', 'number', 'taxonomy', 'lon', 'lat']
for name in self.cost_types['name']:
fields.append(name)
if 'per_area' in self.cost_types['type']:
fields.... | [
"def",
"_csv_header",
"(",
"self",
")",
":",
"fields",
"=",
"[",
"'id'",
",",
"'number'",
",",
"'taxonomy'",
",",
"'lon'",
",",
"'lat'",
"]",
"for",
"name",
"in",
"self",
".",
"cost_types",
"[",
"'name'",
"]",
":",
"fields",
".",
"append",
"(",
"name... | Extract the expected CSV header from the exposure metadata | [
"Extract",
"the",
"expected",
"CSV",
"header",
"from",
"the",
"exposure",
"metadata"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/asset.py#L885-L897 |
25 | gem/oq-engine | openquake/risklib/riskmodels.py | build_vf_node | def build_vf_node(vf):
"""
Convert a VulnerabilityFunction object into a Node suitable
for XML conversion.
"""
nodes = [Node('imls', {'imt': vf.imt}, vf.imls),
Node('meanLRs', {}, vf.mean_loss_ratios),
Node('covLRs', {}, vf.covs)]
return Node(
'vulnerabilityFunc... | python | def build_vf_node(vf):
"""
Convert a VulnerabilityFunction object into a Node suitable
for XML conversion.
"""
nodes = [Node('imls', {'imt': vf.imt}, vf.imls),
Node('meanLRs', {}, vf.mean_loss_ratios),
Node('covLRs', {}, vf.covs)]
return Node(
'vulnerabilityFunc... | [
"def",
"build_vf_node",
"(",
"vf",
")",
":",
"nodes",
"=",
"[",
"Node",
"(",
"'imls'",
",",
"{",
"'imt'",
":",
"vf",
".",
"imt",
"}",
",",
"vf",
".",
"imls",
")",
",",
"Node",
"(",
"'meanLRs'",
",",
"{",
"}",
",",
"vf",
".",
"mean_loss_ratios",
... | Convert a VulnerabilityFunction object into a Node suitable
for XML conversion. | [
"Convert",
"a",
"VulnerabilityFunction",
"object",
"into",
"a",
"Node",
"suitable",
"for",
"XML",
"conversion",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/riskmodels.py#L69-L79 |
26 | gem/oq-engine | openquake/risklib/riskmodels.py | get_riskmodel | def get_riskmodel(taxonomy, oqparam, **extra):
"""
Return an instance of the correct riskmodel class, depending on the
attribute `calculation_mode` of the object `oqparam`.
:param taxonomy:
a taxonomy string
:param oqparam:
an object containing the parameters needed by the riskmodel... | python | def get_riskmodel(taxonomy, oqparam, **extra):
"""
Return an instance of the correct riskmodel class, depending on the
attribute `calculation_mode` of the object `oqparam`.
:param taxonomy:
a taxonomy string
:param oqparam:
an object containing the parameters needed by the riskmodel... | [
"def",
"get_riskmodel",
"(",
"taxonomy",
",",
"oqparam",
",",
"*",
"*",
"extra",
")",
":",
"riskmodel_class",
"=",
"registry",
"[",
"oqparam",
".",
"calculation_mode",
"]",
"# arguments needed to instantiate the riskmodel class",
"argnames",
"=",
"inspect",
".",
"ge... | Return an instance of the correct riskmodel class, depending on the
attribute `calculation_mode` of the object `oqparam`.
:param taxonomy:
a taxonomy string
:param oqparam:
an object containing the parameters needed by the riskmodel class
:param extra:
extra parameters to pass t... | [
"Return",
"an",
"instance",
"of",
"the",
"correct",
"riskmodel",
"class",
"depending",
"on",
"the",
"attribute",
"calculation_mode",
"of",
"the",
"object",
"oqparam",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/riskmodels.py#L548-L580 |
27 | gem/oq-engine | openquake/hmtk/plotting/beachball.py | Beachball | def Beachball(fm, linewidth=2, facecolor='b', bgcolor='w', edgecolor='k',
alpha=1.0, xy=(0, 0), width=200, size=100, nofill=False,
zorder=100, outfile=None, format=None, fig=None):
"""
Draws a beach ball diagram of an earthquake focal mechanism.
S1, D1, and R1, the strike, dip a... | python | def Beachball(fm, linewidth=2, facecolor='b', bgcolor='w', edgecolor='k',
alpha=1.0, xy=(0, 0), width=200, size=100, nofill=False,
zorder=100, outfile=None, format=None, fig=None):
"""
Draws a beach ball diagram of an earthquake focal mechanism.
S1, D1, and R1, the strike, dip a... | [
"def",
"Beachball",
"(",
"fm",
",",
"linewidth",
"=",
"2",
",",
"facecolor",
"=",
"'b'",
",",
"bgcolor",
"=",
"'w'",
",",
"edgecolor",
"=",
"'k'",
",",
"alpha",
"=",
"1.0",
",",
"xy",
"=",
"(",
"0",
",",
"0",
")",
",",
"width",
"=",
"200",
",",... | Draws a beach ball diagram of an earthquake focal mechanism.
S1, D1, and R1, the strike, dip and rake of one of the focal planes, can
be vectors of multiple focal mechanisms.
:param fm: Focal mechanism that is either number of mechanisms (NM) by 3
(strike, dip, and rake) or NM x 6 (M11, M22, M33, ... | [
"Draws",
"a",
"beach",
"ball",
"diagram",
"of",
"an",
"earthquake",
"focal",
"mechanism",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/beachball.py#L147-L230 |
28 | gem/oq-engine | openquake/hmtk/plotting/beachball.py | StrikeDip | def StrikeDip(n, e, u):
"""
Finds strike and dip of plane given normal vector having components n, e,
and u.
Adapted from MATLAB script
`bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_
written by Andy Michael and Oliver Boyd.
"""
r2d = 180 / np.pi
if u < 0:... | python | def StrikeDip(n, e, u):
"""
Finds strike and dip of plane given normal vector having components n, e,
and u.
Adapted from MATLAB script
`bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_
written by Andy Michael and Oliver Boyd.
"""
r2d = 180 / np.pi
if u < 0:... | [
"def",
"StrikeDip",
"(",
"n",
",",
"e",
",",
"u",
")",
":",
"r2d",
"=",
"180",
"/",
"np",
".",
"pi",
"if",
"u",
"<",
"0",
":",
"n",
"=",
"-",
"n",
"e",
"=",
"-",
"e",
"u",
"=",
"-",
"u",
"strike",
"=",
"np",
".",
"arctan2",
"(",
"e",
... | Finds strike and dip of plane given normal vector having components n, e,
and u.
Adapted from MATLAB script
`bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_
written by Andy Michael and Oliver Boyd. | [
"Finds",
"strike",
"and",
"dip",
"of",
"plane",
"given",
"normal",
"vector",
"having",
"components",
"n",
"e",
"and",
"u",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/beachball.py#L669-L692 |
29 | gem/oq-engine | openquake/hmtk/plotting/beachball.py | AuxPlane | def AuxPlane(s1, d1, r1):
"""
Get Strike and dip of second plane.
Adapted from MATLAB script
`bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_
written by Andy Michael and Oliver Boyd.
"""
r2d = 180 / np.pi
z = (s1 + 90) / r2d
z2 = d1 / r2d
z3 = r1 / r2d... | python | def AuxPlane(s1, d1, r1):
"""
Get Strike and dip of second plane.
Adapted from MATLAB script
`bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_
written by Andy Michael and Oliver Boyd.
"""
r2d = 180 / np.pi
z = (s1 + 90) / r2d
z2 = d1 / r2d
z3 = r1 / r2d... | [
"def",
"AuxPlane",
"(",
"s1",
",",
"d1",
",",
"r1",
")",
":",
"r2d",
"=",
"180",
"/",
"np",
".",
"pi",
"z",
"=",
"(",
"s1",
"+",
"90",
")",
"/",
"r2d",
"z2",
"=",
"d1",
"/",
"r2d",
"z3",
"=",
"r1",
"/",
"r2d",
"# slick vector in plane 1",
"sl... | Get Strike and dip of second plane.
Adapted from MATLAB script
`bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_
written by Andy Michael and Oliver Boyd. | [
"Get",
"Strike",
"and",
"dip",
"of",
"second",
"plane",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/beachball.py#L695-L729 |
30 | gem/oq-engine | openquake/hmtk/plotting/beachball.py | MT2Plane | def MT2Plane(mt):
"""
Calculates a nodal plane of a given moment tensor.
:param mt: :class:`~MomentTensor`
:return: :class:`~NodalPlane`
Adapted from MATLAB script
`bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_
written by Andy Michael and Oliver Boyd.
"""
... | python | def MT2Plane(mt):
"""
Calculates a nodal plane of a given moment tensor.
:param mt: :class:`~MomentTensor`
:return: :class:`~NodalPlane`
Adapted from MATLAB script
`bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_
written by Andy Michael and Oliver Boyd.
"""
... | [
"def",
"MT2Plane",
"(",
"mt",
")",
":",
"(",
"d",
",",
"v",
")",
"=",
"np",
".",
"linalg",
".",
"eig",
"(",
"mt",
".",
"mt",
")",
"D",
"=",
"np",
".",
"array",
"(",
"[",
"d",
"[",
"1",
"]",
",",
"d",
"[",
"0",
"]",
",",
"d",
"[",
"2",... | Calculates a nodal plane of a given moment tensor.
:param mt: :class:`~MomentTensor`
:return: :class:`~NodalPlane`
Adapted from MATLAB script
`bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_
written by Andy Michael and Oliver Boyd. | [
"Calculates",
"a",
"nodal",
"plane",
"of",
"a",
"given",
"moment",
"tensor",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/beachball.py#L732-L766 |
31 | gem/oq-engine | openquake/hmtk/plotting/beachball.py | TDL | def TDL(AN, BN):
"""
Helper function for MT2Plane.
Adapted from MATLAB script
`bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_
written by Andy Michael and Oliver Boyd.
"""
XN = AN[0]
YN = AN[1]
ZN = AN[2]
XE = BN[0]
YE = BN[1]
ZE = BN[2]
AAA... | python | def TDL(AN, BN):
"""
Helper function for MT2Plane.
Adapted from MATLAB script
`bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_
written by Andy Michael and Oliver Boyd.
"""
XN = AN[0]
YN = AN[1]
ZN = AN[2]
XE = BN[0]
YE = BN[1]
ZE = BN[2]
AAA... | [
"def",
"TDL",
"(",
"AN",
",",
"BN",
")",
":",
"XN",
"=",
"AN",
"[",
"0",
"]",
"YN",
"=",
"AN",
"[",
"1",
"]",
"ZN",
"=",
"AN",
"[",
"2",
"]",
"XE",
"=",
"BN",
"[",
"0",
"]",
"YE",
"=",
"BN",
"[",
"1",
"]",
"ZE",
"=",
"BN",
"[",
"2",... | Helper function for MT2Plane.
Adapted from MATLAB script
`bb.m <http://www.ceri.memphis.edu/people/olboyd/Software/Software.html>`_
written by Andy Michael and Oliver Boyd. | [
"Helper",
"function",
"for",
"MT2Plane",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/beachball.py#L769-L849 |
32 | gem/oq-engine | openquake/hmtk/plotting/beachball.py | MT2Axes | def MT2Axes(mt):
"""
Calculates the principal axes of a given moment tensor.
:param mt: :class:`~MomentTensor`
:return: tuple of :class:`~PrincipalAxis` T, N and P
Adapted from ps_tensor / utilmeca.c /
`Generic Mapping Tools (GMT) <http://gmt.soest.hawaii.edu>`_.
"""
(D, V) = np.linalg... | python | def MT2Axes(mt):
"""
Calculates the principal axes of a given moment tensor.
:param mt: :class:`~MomentTensor`
:return: tuple of :class:`~PrincipalAxis` T, N and P
Adapted from ps_tensor / utilmeca.c /
`Generic Mapping Tools (GMT) <http://gmt.soest.hawaii.edu>`_.
"""
(D, V) = np.linalg... | [
"def",
"MT2Axes",
"(",
"mt",
")",
":",
"(",
"D",
",",
"V",
")",
"=",
"np",
".",
"linalg",
".",
"eigh",
"(",
"mt",
".",
"mt",
")",
"pl",
"=",
"np",
".",
"arcsin",
"(",
"-",
"V",
"[",
"0",
"]",
")",
"az",
"=",
"np",
".",
"arctan2",
"(",
"... | Calculates the principal axes of a given moment tensor.
:param mt: :class:`~MomentTensor`
:return: tuple of :class:`~PrincipalAxis` T, N and P
Adapted from ps_tensor / utilmeca.c /
`Generic Mapping Tools (GMT) <http://gmt.soest.hawaii.edu>`_. | [
"Calculates",
"the",
"principal",
"axes",
"of",
"a",
"given",
"moment",
"tensor",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/beachball.py#L852-L879 |
33 | gem/oq-engine | openquake/hmtk/strain/strain_utils.py | tapered_gutenberg_richter_cdf | def tapered_gutenberg_richter_cdf(moment, moment_threshold, beta,
corner_moment):
'''
Tapered Gutenberg Richter Cumulative Density Function
:param float or numpy.ndarray moment:
Moment for calculation of rate
:param float or numpy.ndarray moment_threshold:
... | python | def tapered_gutenberg_richter_cdf(moment, moment_threshold, beta,
corner_moment):
'''
Tapered Gutenberg Richter Cumulative Density Function
:param float or numpy.ndarray moment:
Moment for calculation of rate
:param float or numpy.ndarray moment_threshold:
... | [
"def",
"tapered_gutenberg_richter_cdf",
"(",
"moment",
",",
"moment_threshold",
",",
"beta",
",",
"corner_moment",
")",
":",
"cdf",
"=",
"np",
".",
"exp",
"(",
"(",
"moment_threshold",
"-",
"moment",
")",
"/",
"corner_moment",
")",
"return",
"(",
"(",
"momen... | Tapered Gutenberg Richter Cumulative Density Function
:param float or numpy.ndarray moment:
Moment for calculation of rate
:param float or numpy.ndarray moment_threshold:
Threshold Moment of the distribution (moment rate essentially!)
:param float beta:
Beta value (b * ln(10.)) of... | [
"Tapered",
"Gutenberg",
"Richter",
"Cumulative",
"Density",
"Function"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/strain/strain_utils.py#L111-L134 |
34 | gem/oq-engine | openquake/hmtk/strain/strain_utils.py | tapered_gutenberg_richter_pdf | def tapered_gutenberg_richter_pdf(moment, moment_threshold, beta,
corner_moment):
'''
Tapered Gutenberg-Richter Probability Density Function
:param float or numpy.ndarray moment:
Moment for calculation of rate
:param float or numpy.ndarray moment_threshold:
... | python | def tapered_gutenberg_richter_pdf(moment, moment_threshold, beta,
corner_moment):
'''
Tapered Gutenberg-Richter Probability Density Function
:param float or numpy.ndarray moment:
Moment for calculation of rate
:param float or numpy.ndarray moment_threshold:
... | [
"def",
"tapered_gutenberg_richter_pdf",
"(",
"moment",
",",
"moment_threshold",
",",
"beta",
",",
"corner_moment",
")",
":",
"return",
"(",
"(",
"beta",
"/",
"moment",
"+",
"1.",
"/",
"corner_moment",
")",
"*",
"tapered_gutenberg_richter_cdf",
"(",
"moment",
","... | Tapered Gutenberg-Richter Probability Density Function
:param float or numpy.ndarray moment:
Moment for calculation of rate
:param float or numpy.ndarray moment_threshold:
Threshold Moment of the distribution (moment rate essentially!)
:param float beta:
Beta value (b * ln(10.)) o... | [
"Tapered",
"Gutenberg",
"-",
"Richter",
"Probability",
"Density",
"Function"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/strain/strain_utils.py#L137-L159 |
35 | gem/oq-engine | openquake/engine/export/core.py | makedirs | def makedirs(path):
"""
Make all of the directories in the ``path`` using `os.makedirs`.
"""
if os.path.exists(path):
if not os.path.isdir(path):
# If it's not a directory, we can't do anything.
# This is a problem
raise RuntimeError('%s already exists and is ... | python | def makedirs(path):
"""
Make all of the directories in the ``path`` using `os.makedirs`.
"""
if os.path.exists(path):
if not os.path.isdir(path):
# If it's not a directory, we can't do anything.
# This is a problem
raise RuntimeError('%s already exists and is ... | [
"def",
"makedirs",
"(",
"path",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":",
"# If it's not a directory, we can't do anything.",
"# This is a problem",
"raise",
... | Make all of the directories in the ``path`` using `os.makedirs`. | [
"Make",
"all",
"of",
"the",
"directories",
"in",
"the",
"path",
"using",
"os",
".",
"makedirs",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/engine/export/core.py#L80-L91 |
36 | gem/oq-engine | openquake/hmtk/seismicity/max_magnitude/base.py | _get_observed_mmax | def _get_observed_mmax(catalogue, config):
'''Check see if observed mmax values are input, if not then take
from the catalogue'''
if config['input_mmax']:
obsmax = config['input_mmax']
if config['input_mmax_uncertainty']:
return config['input_mmax'], config['input_mmax_uncertaint... | python | def _get_observed_mmax(catalogue, config):
'''Check see if observed mmax values are input, if not then take
from the catalogue'''
if config['input_mmax']:
obsmax = config['input_mmax']
if config['input_mmax_uncertainty']:
return config['input_mmax'], config['input_mmax_uncertaint... | [
"def",
"_get_observed_mmax",
"(",
"catalogue",
",",
"config",
")",
":",
"if",
"config",
"[",
"'input_mmax'",
"]",
":",
"obsmax",
"=",
"config",
"[",
"'input_mmax'",
"]",
"if",
"config",
"[",
"'input_mmax_uncertainty'",
"]",
":",
"return",
"config",
"[",
"'in... | Check see if observed mmax values are input, if not then take
from the catalogue | [
"Check",
"see",
"if",
"observed",
"mmax",
"values",
"are",
"input",
"if",
"not",
"then",
"take",
"from",
"the",
"catalogue"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/max_magnitude/base.py#L57-L83 |
37 | gem/oq-engine | openquake/hmtk/seismicity/max_magnitude/base.py | _get_magnitude_vector_properties | def _get_magnitude_vector_properties(catalogue, config):
'''If an input minimum magnitude is given then consider catalogue
only above the minimum magnitude - returns corresponding properties'''
mmin = config.get('input_mmin', np.min(catalogue['magnitude']))
neq = np.float(np.sum(catalogue['magnitude'] ... | python | def _get_magnitude_vector_properties(catalogue, config):
'''If an input minimum magnitude is given then consider catalogue
only above the minimum magnitude - returns corresponding properties'''
mmin = config.get('input_mmin', np.min(catalogue['magnitude']))
neq = np.float(np.sum(catalogue['magnitude'] ... | [
"def",
"_get_magnitude_vector_properties",
"(",
"catalogue",
",",
"config",
")",
":",
"mmin",
"=",
"config",
".",
"get",
"(",
"'input_mmin'",
",",
"np",
".",
"min",
"(",
"catalogue",
"[",
"'magnitude'",
"]",
")",
")",
"neq",
"=",
"np",
".",
"float",
"(",... | If an input minimum magnitude is given then consider catalogue
only above the minimum magnitude - returns corresponding properties | [
"If",
"an",
"input",
"minimum",
"magnitude",
"is",
"given",
"then",
"consider",
"catalogue",
"only",
"above",
"the",
"minimum",
"magnitude",
"-",
"returns",
"corresponding",
"properties"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/max_magnitude/base.py#L104-L110 |
38 | gem/oq-engine | openquake/hazardlib/geo/surface/complex_fault.py | ComplexFaultSurface.get_dip | def get_dip(self):
"""
Return the fault dip as the average dip over the mesh.
The average dip is defined as the weighted mean inclination
of all the mesh cells. See
:meth:`openquake.hazardlib.geo.mesh.RectangularMesh.get_mean_inclination_and_azimuth`
:returns:
... | python | def get_dip(self):
"""
Return the fault dip as the average dip over the mesh.
The average dip is defined as the weighted mean inclination
of all the mesh cells. See
:meth:`openquake.hazardlib.geo.mesh.RectangularMesh.get_mean_inclination_and_azimuth`
:returns:
... | [
"def",
"get_dip",
"(",
"self",
")",
":",
"# uses the same approach as in simple fault surface",
"if",
"self",
".",
"dip",
"is",
"None",
":",
"mesh",
"=",
"self",
".",
"mesh",
"self",
".",
"dip",
",",
"self",
".",
"strike",
"=",
"mesh",
".",
"get_mean_inclina... | Return the fault dip as the average dip over the mesh.
The average dip is defined as the weighted mean inclination
of all the mesh cells. See
:meth:`openquake.hazardlib.geo.mesh.RectangularMesh.get_mean_inclination_and_azimuth`
:returns:
The average dip, in decimal degrees. | [
"Return",
"the",
"fault",
"dip",
"as",
"the",
"average",
"dip",
"over",
"the",
"mesh",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/complex_fault.py#L96-L111 |
39 | gem/oq-engine | openquake/hazardlib/geo/surface/complex_fault.py | ComplexFaultSurface.check_surface_validity | def check_surface_validity(cls, edges):
"""
Check validity of the surface.
Project edge points to vertical plane anchored to surface upper left
edge and with strike equal to top edge strike. Check that resulting
polygon is valid.
This method doesn't have to be called by... | python | def check_surface_validity(cls, edges):
"""
Check validity of the surface.
Project edge points to vertical plane anchored to surface upper left
edge and with strike equal to top edge strike. Check that resulting
polygon is valid.
This method doesn't have to be called by... | [
"def",
"check_surface_validity",
"(",
"cls",
",",
"edges",
")",
":",
"# extract coordinates of surface boundary (as defined from edges)",
"full_boundary",
"=",
"[",
"]",
"left_boundary",
"=",
"[",
"]",
"right_boundary",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",... | Check validity of the surface.
Project edge points to vertical plane anchored to surface upper left
edge and with strike equal to top edge strike. Check that resulting
polygon is valid.
This method doesn't have to be called by hands before creating the
surface object, because i... | [
"Check",
"validity",
"of",
"the",
"surface",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/complex_fault.py#L182-L230 |
40 | gem/oq-engine | openquake/hazardlib/geo/surface/complex_fault.py | ComplexFaultSurface.surface_projection_from_fault_data | def surface_projection_from_fault_data(cls, edges):
"""
Get a surface projection of the complex fault surface.
:param edges:
A list of horizontal edges of the surface as instances
of :class:`openquake.hazardlib.geo.line.Line`.
:returns:
Instance of :c... | python | def surface_projection_from_fault_data(cls, edges):
"""
Get a surface projection of the complex fault surface.
:param edges:
A list of horizontal edges of the surface as instances
of :class:`openquake.hazardlib.geo.line.Line`.
:returns:
Instance of :c... | [
"def",
"surface_projection_from_fault_data",
"(",
"cls",
",",
"edges",
")",
":",
"# collect lons and lats of all the vertices of all the edges",
"lons",
"=",
"[",
"]",
"lats",
"=",
"[",
"]",
"for",
"edge",
"in",
"edges",
":",
"for",
"point",
"in",
"edge",
":",
"... | Get a surface projection of the complex fault surface.
:param edges:
A list of horizontal edges of the surface as instances
of :class:`openquake.hazardlib.geo.line.Line`.
:returns:
Instance of :class:`~openquake.hazardlib.geo.polygon.Polygon`
describing t... | [
"Get",
"a",
"surface",
"projection",
"of",
"the",
"complex",
"fault",
"surface",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/complex_fault.py#L302-L323 |
41 | gem/oq-engine | openquake/calculators/base.py | check_time_event | def check_time_event(oqparam, occupancy_periods):
"""
Check the `time_event` parameter in the datastore, by comparing
with the periods found in the exposure.
"""
time_event = oqparam.time_event
if time_event and time_event not in occupancy_periods:
raise ValueError(
'time_eve... | python | def check_time_event(oqparam, occupancy_periods):
"""
Check the `time_event` parameter in the datastore, by comparing
with the periods found in the exposure.
"""
time_event = oqparam.time_event
if time_event and time_event not in occupancy_periods:
raise ValueError(
'time_eve... | [
"def",
"check_time_event",
"(",
"oqparam",
",",
"occupancy_periods",
")",
":",
"time_event",
"=",
"oqparam",
".",
"time_event",
"if",
"time_event",
"and",
"time_event",
"not",
"in",
"occupancy_periods",
":",
"raise",
"ValueError",
"(",
"'time_event is %s in %s, but th... | Check the `time_event` parameter in the datastore, by comparing
with the periods found in the exposure. | [
"Check",
"the",
"time_event",
"parameter",
"in",
"the",
"datastore",
"by",
"comparing",
"with",
"the",
"periods",
"found",
"in",
"the",
"exposure",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L321-L331 |
42 | gem/oq-engine | openquake/calculators/base.py | get_idxs | def get_idxs(data, eid2idx):
"""
Convert from event IDs to event indices.
:param data: an array with a field eid
:param eid2idx: a dictionary eid -> idx
:returns: the array of event indices
"""
uniq, inv = numpy.unique(data['eid'], return_inverse=True)
idxs = numpy.array([eid2idx[eid] f... | python | def get_idxs(data, eid2idx):
"""
Convert from event IDs to event indices.
:param data: an array with a field eid
:param eid2idx: a dictionary eid -> idx
:returns: the array of event indices
"""
uniq, inv = numpy.unique(data['eid'], return_inverse=True)
idxs = numpy.array([eid2idx[eid] f... | [
"def",
"get_idxs",
"(",
"data",
",",
"eid2idx",
")",
":",
"uniq",
",",
"inv",
"=",
"numpy",
".",
"unique",
"(",
"data",
"[",
"'eid'",
"]",
",",
"return_inverse",
"=",
"True",
")",
"idxs",
"=",
"numpy",
".",
"array",
"(",
"[",
"eid2idx",
"[",
"eid",... | Convert from event IDs to event indices.
:param data: an array with a field eid
:param eid2idx: a dictionary eid -> idx
:returns: the array of event indices | [
"Convert",
"from",
"event",
"IDs",
"to",
"event",
"indices",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L959-L969 |
43 | gem/oq-engine | openquake/calculators/base.py | import_gmfs | def import_gmfs(dstore, fname, sids):
"""
Import in the datastore a ground motion field CSV file.
:param dstore: the datastore
:param fname: the CSV file
:param sids: the site IDs (complete)
:returns: event_ids, num_rlzs
"""
array = writers.read_composite_array(fname).array
# has he... | python | def import_gmfs(dstore, fname, sids):
"""
Import in the datastore a ground motion field CSV file.
:param dstore: the datastore
:param fname: the CSV file
:param sids: the site IDs (complete)
:returns: event_ids, num_rlzs
"""
array = writers.read_composite_array(fname).array
# has he... | [
"def",
"import_gmfs",
"(",
"dstore",
",",
"fname",
",",
"sids",
")",
":",
"array",
"=",
"writers",
".",
"read_composite_array",
"(",
"fname",
")",
".",
"array",
"# has header rlzi, sid, eid, gmv_PGA, ...",
"imts",
"=",
"[",
"name",
"[",
"4",
":",
"]",
"for",... | Import in the datastore a ground motion field CSV file.
:param dstore: the datastore
:param fname: the CSV file
:param sids: the site IDs (complete)
:returns: event_ids, num_rlzs | [
"Import",
"in",
"the",
"datastore",
"a",
"ground",
"motion",
"field",
"CSV",
"file",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L972-L1013 |
44 | gem/oq-engine | openquake/calculators/base.py | BaseCalculator.save_params | def save_params(self, **kw):
"""
Update the current calculation parameters and save engine_version
"""
if ('hazard_calculation_id' in kw and
kw['hazard_calculation_id'] is None):
del kw['hazard_calculation_id']
vars(self.oqparam).update(**kw)
s... | python | def save_params(self, **kw):
"""
Update the current calculation parameters and save engine_version
"""
if ('hazard_calculation_id' in kw and
kw['hazard_calculation_id'] is None):
del kw['hazard_calculation_id']
vars(self.oqparam).update(**kw)
s... | [
"def",
"save_params",
"(",
"self",
",",
"*",
"*",
"kw",
")",
":",
"if",
"(",
"'hazard_calculation_id'",
"in",
"kw",
"and",
"kw",
"[",
"'hazard_calculation_id'",
"]",
"is",
"None",
")",
":",
"del",
"kw",
"[",
"'hazard_calculation_id'",
"]",
"vars",
"(",
"... | Update the current calculation parameters and save engine_version | [
"Update",
"the",
"current",
"calculation",
"parameters",
"and",
"save",
"engine_version"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L142-L156 |
45 | gem/oq-engine | openquake/calculators/base.py | BaseCalculator.run | def run(self, pre_execute=True, concurrent_tasks=None, close=True, **kw):
"""
Run the calculation and return the exported outputs.
"""
with self._monitor:
self._monitor.username = kw.get('username', '')
self._monitor.hdf5 = self.datastore.hdf5
if concu... | python | def run(self, pre_execute=True, concurrent_tasks=None, close=True, **kw):
"""
Run the calculation and return the exported outputs.
"""
with self._monitor:
self._monitor.username = kw.get('username', '')
self._monitor.hdf5 = self.datastore.hdf5
if concu... | [
"def",
"run",
"(",
"self",
",",
"pre_execute",
"=",
"True",
",",
"concurrent_tasks",
"=",
"None",
",",
"close",
"=",
"True",
",",
"*",
"*",
"kw",
")",
":",
"with",
"self",
".",
"_monitor",
":",
"self",
".",
"_monitor",
".",
"username",
"=",
"kw",
"... | Run the calculation and return the exported outputs. | [
"Run",
"the",
"calculation",
"and",
"return",
"the",
"exported",
"outputs",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L175-L231 |
46 | gem/oq-engine | openquake/calculators/base.py | BaseCalculator.export | def export(self, exports=None):
"""
Export all the outputs in the datastore in the given export formats.
Individual outputs are not exported if there are multiple realizations.
"""
self.exported = getattr(self.precalc, 'exported', {})
if isinstance(exports, tuple):
... | python | def export(self, exports=None):
"""
Export all the outputs in the datastore in the given export formats.
Individual outputs are not exported if there are multiple realizations.
"""
self.exported = getattr(self.precalc, 'exported', {})
if isinstance(exports, tuple):
... | [
"def",
"export",
"(",
"self",
",",
"exports",
"=",
"None",
")",
":",
"self",
".",
"exported",
"=",
"getattr",
"(",
"self",
".",
"precalc",
",",
"'exported'",
",",
"{",
"}",
")",
"if",
"isinstance",
"(",
"exports",
",",
"tuple",
")",
":",
"fmts",
"=... | Export all the outputs in the datastore in the given export formats.
Individual outputs are not exported if there are multiple realizations. | [
"Export",
"all",
"the",
"outputs",
"in",
"the",
"datastore",
"in",
"the",
"given",
"export",
"formats",
".",
"Individual",
"outputs",
"are",
"not",
"exported",
"if",
"there",
"are",
"multiple",
"realizations",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L260-L289 |
47 | gem/oq-engine | openquake/calculators/base.py | BaseCalculator.before_export | def before_export(self):
"""
Set the attributes nbytes
"""
# sanity check that eff_ruptures have been set, i.e. are not -1
try:
csm_info = self.datastore['csm_info']
except KeyError:
csm_info = self.datastore['csm_info'] = self.csm.info
for... | python | def before_export(self):
"""
Set the attributes nbytes
"""
# sanity check that eff_ruptures have been set, i.e. are not -1
try:
csm_info = self.datastore['csm_info']
except KeyError:
csm_info = self.datastore['csm_info'] = self.csm.info
for... | [
"def",
"before_export",
"(",
"self",
")",
":",
"# sanity check that eff_ruptures have been set, i.e. are not -1",
"try",
":",
"csm_info",
"=",
"self",
".",
"datastore",
"[",
"'csm_info'",
"]",
"except",
"KeyError",
":",
"csm_info",
"=",
"self",
".",
"datastore",
"["... | Set the attributes nbytes | [
"Set",
"the",
"attributes",
"nbytes"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L303-L318 |
48 | gem/oq-engine | openquake/calculators/base.py | HazardCalculator.read_inputs | def read_inputs(self):
"""
Read risk data and sources if any
"""
oq = self.oqparam
self._read_risk_data()
self.check_overflow() # check if self.sitecol is too large
if ('source_model_logic_tree' in oq.inputs and
oq.hazard_calculation_id is None):
... | python | def read_inputs(self):
"""
Read risk data and sources if any
"""
oq = self.oqparam
self._read_risk_data()
self.check_overflow() # check if self.sitecol is too large
if ('source_model_logic_tree' in oq.inputs and
oq.hazard_calculation_id is None):
... | [
"def",
"read_inputs",
"(",
"self",
")",
":",
"oq",
"=",
"self",
".",
"oqparam",
"self",
".",
"_read_risk_data",
"(",
")",
"self",
".",
"check_overflow",
"(",
")",
"# check if self.sitecol is too large",
"if",
"(",
"'source_model_logic_tree'",
"in",
"oq",
".",
... | Read risk data and sources if any | [
"Read",
"risk",
"data",
"and",
"sources",
"if",
"any"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L406-L417 |
49 | gem/oq-engine | openquake/calculators/base.py | HazardCalculator.pre_execute | def pre_execute(self):
"""
Check if there is a previous calculation ID.
If yes, read the inputs by retrieving the previous calculation;
if not, read the inputs directly.
"""
oq = self.oqparam
if 'gmfs' in oq.inputs or 'multi_peril' in oq.inputs:
# read... | python | def pre_execute(self):
"""
Check if there is a previous calculation ID.
If yes, read the inputs by retrieving the previous calculation;
if not, read the inputs directly.
"""
oq = self.oqparam
if 'gmfs' in oq.inputs or 'multi_peril' in oq.inputs:
# read... | [
"def",
"pre_execute",
"(",
"self",
")",
":",
"oq",
"=",
"self",
".",
"oqparam",
"if",
"'gmfs'",
"in",
"oq",
".",
"inputs",
"or",
"'multi_peril'",
"in",
"oq",
".",
"inputs",
":",
"# read hazard from files",
"assert",
"not",
"oq",
".",
"hazard_calculation_id",... | Check if there is a previous calculation ID.
If yes, read the inputs by retrieving the previous calculation;
if not, read the inputs directly. | [
"Check",
"if",
"there",
"is",
"a",
"previous",
"calculation",
"ID",
".",
"If",
"yes",
"read",
"the",
"inputs",
"by",
"retrieving",
"the",
"previous",
"calculation",
";",
"if",
"not",
"read",
"the",
"inputs",
"directly",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L422-L496 |
50 | gem/oq-engine | openquake/calculators/base.py | HazardCalculator.init | def init(self):
"""
To be overridden to initialize the datasets needed by the calculation
"""
oq = self.oqparam
if not oq.risk_imtls:
if self.datastore.parent:
oq.risk_imtls = (
self.datastore.parent['oqparam'].risk_imtls)
i... | python | def init(self):
"""
To be overridden to initialize the datasets needed by the calculation
"""
oq = self.oqparam
if not oq.risk_imtls:
if self.datastore.parent:
oq.risk_imtls = (
self.datastore.parent['oqparam'].risk_imtls)
i... | [
"def",
"init",
"(",
"self",
")",
":",
"oq",
"=",
"self",
".",
"oqparam",
"if",
"not",
"oq",
".",
"risk_imtls",
":",
"if",
"self",
".",
"datastore",
".",
"parent",
":",
"oq",
".",
"risk_imtls",
"=",
"(",
"self",
".",
"datastore",
".",
"parent",
"[",... | To be overridden to initialize the datasets needed by the calculation | [
"To",
"be",
"overridden",
"to",
"initialize",
"the",
"datasets",
"needed",
"by",
"the",
"calculation"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L498-L522 |
51 | gem/oq-engine | openquake/calculators/base.py | HazardCalculator.read_exposure | def read_exposure(self, haz_sitecol=None): # after load_risk_model
"""
Read the exposure, the riskmodel and update the attributes
.sitecol, .assetcol
"""
with self.monitor('reading exposure', autoflush=True):
self.sitecol, self.assetcol, discarded = (
... | python | def read_exposure(self, haz_sitecol=None): # after load_risk_model
"""
Read the exposure, the riskmodel and update the attributes
.sitecol, .assetcol
"""
with self.monitor('reading exposure', autoflush=True):
self.sitecol, self.assetcol, discarded = (
... | [
"def",
"read_exposure",
"(",
"self",
",",
"haz_sitecol",
"=",
"None",
")",
":",
"# after load_risk_model",
"with",
"self",
".",
"monitor",
"(",
"'reading exposure'",
",",
"autoflush",
"=",
"True",
")",
":",
"self",
".",
"sitecol",
",",
"self",
".",
"assetcol... | Read the exposure, the riskmodel and update the attributes
.sitecol, .assetcol | [
"Read",
"the",
"exposure",
"the",
"riskmodel",
"and",
"update",
"the",
"attributes",
".",
"sitecol",
".",
"assetcol"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L534-L566 |
52 | gem/oq-engine | openquake/calculators/base.py | HazardCalculator.save_riskmodel | def save_riskmodel(self):
"""
Save the risk models in the datastore
"""
self.datastore['risk_model'] = rm = self.riskmodel
self.datastore['taxonomy_mapping'] = self.riskmodel.tmap
attrs = self.datastore.getitem('risk_model').attrs
attrs['min_iml'] = hdf5.array_of_... | python | def save_riskmodel(self):
"""
Save the risk models in the datastore
"""
self.datastore['risk_model'] = rm = self.riskmodel
self.datastore['taxonomy_mapping'] = self.riskmodel.tmap
attrs = self.datastore.getitem('risk_model').attrs
attrs['min_iml'] = hdf5.array_of_... | [
"def",
"save_riskmodel",
"(",
"self",
")",
":",
"self",
".",
"datastore",
"[",
"'risk_model'",
"]",
"=",
"rm",
"=",
"self",
".",
"riskmodel",
"self",
".",
"datastore",
"[",
"'taxonomy_mapping'",
"]",
"=",
"self",
".",
"riskmodel",
".",
"tmap",
"attrs",
"... | Save the risk models in the datastore | [
"Save",
"the",
"risk",
"models",
"in",
"the",
"datastore"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L588-L596 |
53 | gem/oq-engine | openquake/calculators/base.py | HazardCalculator.store_rlz_info | def store_rlz_info(self, eff_ruptures=None):
"""
Save info about the composite source model inside the csm_info dataset
"""
if hasattr(self, 'csm'): # no scenario
self.csm.info.update_eff_ruptures(eff_ruptures)
self.rlzs_assoc = self.csm.info.get_rlzs_assoc(
... | python | def store_rlz_info(self, eff_ruptures=None):
"""
Save info about the composite source model inside the csm_info dataset
"""
if hasattr(self, 'csm'): # no scenario
self.csm.info.update_eff_ruptures(eff_ruptures)
self.rlzs_assoc = self.csm.info.get_rlzs_assoc(
... | [
"def",
"store_rlz_info",
"(",
"self",
",",
"eff_ruptures",
"=",
"None",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'csm'",
")",
":",
"# no scenario",
"self",
".",
"csm",
".",
"info",
".",
"update_eff_ruptures",
"(",
"eff_ruptures",
")",
"self",
".",
"... | Save info about the composite source model inside the csm_info dataset | [
"Save",
"info",
"about",
"the",
"composite",
"source",
"model",
"inside",
"the",
"csm_info",
"dataset"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L701-L730 |
54 | gem/oq-engine | openquake/calculators/base.py | RiskCalculator.read_shakemap | def read_shakemap(self, haz_sitecol, assetcol):
"""
Enabled only if there is a shakemap_id parameter in the job.ini.
Download, unzip, parse USGS shakemap files and build a corresponding
set of GMFs which are then filtered with the hazard site collection
and stored in the datastor... | python | def read_shakemap(self, haz_sitecol, assetcol):
"""
Enabled only if there is a shakemap_id parameter in the job.ini.
Download, unzip, parse USGS shakemap files and build a corresponding
set of GMFs which are then filtered with the hazard site collection
and stored in the datastor... | [
"def",
"read_shakemap",
"(",
"self",
",",
"haz_sitecol",
",",
"assetcol",
")",
":",
"oq",
"=",
"self",
".",
"oqparam",
"E",
"=",
"oq",
".",
"number_of_ground_motion_fields",
"oq",
".",
"risk_imtls",
"=",
"oq",
".",
"imtls",
"or",
"self",
".",
"datastore",
... | Enabled only if there is a shakemap_id parameter in the job.ini.
Download, unzip, parse USGS shakemap files and build a corresponding
set of GMFs which are then filtered with the hazard site collection
and stored in the datastore. | [
"Enabled",
"only",
"if",
"there",
"is",
"a",
"shakemap_id",
"parameter",
"in",
"the",
"job",
".",
"ini",
".",
"Download",
"unzip",
"parse",
"USGS",
"shakemap",
"files",
"and",
"build",
"a",
"corresponding",
"set",
"of",
"GMFs",
"which",
"are",
"then",
"fil... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L766-L800 |
55 | gem/oq-engine | openquake/baselib/zeromq.py | bind | def bind(end_point, socket_type):
"""
Bind to a zmq URL; raise a proper error if the URL is invalid; return
a zmq socket.
"""
sock = context.socket(socket_type)
try:
sock.bind(end_point)
except zmq.error.ZMQError as exc:
sock.close()
raise exc.__class__('%s: %s' % (ex... | python | def bind(end_point, socket_type):
"""
Bind to a zmq URL; raise a proper error if the URL is invalid; return
a zmq socket.
"""
sock = context.socket(socket_type)
try:
sock.bind(end_point)
except zmq.error.ZMQError as exc:
sock.close()
raise exc.__class__('%s: %s' % (ex... | [
"def",
"bind",
"(",
"end_point",
",",
"socket_type",
")",
":",
"sock",
"=",
"context",
".",
"socket",
"(",
"socket_type",
")",
"try",
":",
"sock",
".",
"bind",
"(",
"end_point",
")",
"except",
"zmq",
".",
"error",
".",
"ZMQError",
"as",
"exc",
":",
"... | Bind to a zmq URL; raise a proper error if the URL is invalid; return
a zmq socket. | [
"Bind",
"to",
"a",
"zmq",
"URL",
";",
"raise",
"a",
"proper",
"error",
"if",
"the",
"URL",
"is",
"invalid",
";",
"return",
"a",
"zmq",
"socket",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/zeromq.py#L30-L41 |
56 | gem/oq-engine | openquake/baselib/zeromq.py | Socket.send | def send(self, obj):
"""
Send an object to the remote server; block and return the reply
if the socket type is REQ.
:param obj:
the Python object to send
"""
self.zsocket.send_pyobj(obj)
self.num_sent += 1
if self.socket_type == zmq.REQ:
... | python | def send(self, obj):
"""
Send an object to the remote server; block and return the reply
if the socket type is REQ.
:param obj:
the Python object to send
"""
self.zsocket.send_pyobj(obj)
self.num_sent += 1
if self.socket_type == zmq.REQ:
... | [
"def",
"send",
"(",
"self",
",",
"obj",
")",
":",
"self",
".",
"zsocket",
".",
"send_pyobj",
"(",
"obj",
")",
"self",
".",
"num_sent",
"+=",
"1",
"if",
"self",
".",
"socket_type",
"==",
"zmq",
".",
"REQ",
":",
"return",
"self",
".",
"zsocket",
".",... | Send an object to the remote server; block and return the reply
if the socket type is REQ.
:param obj:
the Python object to send | [
"Send",
"an",
"object",
"to",
"the",
"remote",
"server",
";",
"block",
"and",
"return",
"the",
"reply",
"if",
"the",
"socket",
"type",
"is",
"REQ",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/zeromq.py#L139-L150 |
57 | gem/oq-engine | openquake/hazardlib/geo/utils.py | angular_distance | def angular_distance(km, lat, lat2=None):
"""
Return the angular distance of two points at the given latitude.
>>> '%.3f' % angular_distance(100, lat=40)
'1.174'
>>> '%.3f' % angular_distance(100, lat=80)
'5.179'
"""
if lat2 is not None:
# use the largest latitude to compute the... | python | def angular_distance(km, lat, lat2=None):
"""
Return the angular distance of two points at the given latitude.
>>> '%.3f' % angular_distance(100, lat=40)
'1.174'
>>> '%.3f' % angular_distance(100, lat=80)
'5.179'
"""
if lat2 is not None:
# use the largest latitude to compute the... | [
"def",
"angular_distance",
"(",
"km",
",",
"lat",
",",
"lat2",
"=",
"None",
")",
":",
"if",
"lat2",
"is",
"not",
"None",
":",
"# use the largest latitude to compute the angular distance",
"lat",
"=",
"max",
"(",
"abs",
"(",
"lat",
")",
",",
"abs",
"(",
"la... | Return the angular distance of two points at the given latitude.
>>> '%.3f' % angular_distance(100, lat=40)
'1.174'
>>> '%.3f' % angular_distance(100, lat=80)
'5.179' | [
"Return",
"the",
"angular",
"distance",
"of",
"two",
"points",
"at",
"the",
"given",
"latitude",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L45-L57 |
58 | gem/oq-engine | openquake/hazardlib/geo/utils.py | assoc | def assoc(objects, sitecol, assoc_dist, mode, asset_refs=()):
"""
Associate geographic objects to a site collection.
:param objects:
something with .lons, .lats or ['lon'] ['lat'], or a list of lists
of objects with a .location attribute (i.e. assets_by_site)
:param assoc_dist:
... | python | def assoc(objects, sitecol, assoc_dist, mode, asset_refs=()):
"""
Associate geographic objects to a site collection.
:param objects:
something with .lons, .lats or ['lon'] ['lat'], or a list of lists
of objects with a .location attribute (i.e. assets_by_site)
:param assoc_dist:
... | [
"def",
"assoc",
"(",
"objects",
",",
"sitecol",
",",
"assoc_dist",
",",
"mode",
",",
"asset_refs",
"=",
"(",
")",
")",
":",
"if",
"isinstance",
"(",
"objects",
",",
"numpy",
".",
"ndarray",
")",
"or",
"hasattr",
"(",
"objects",
",",
"'lons'",
")",
":... | Associate geographic objects to a site collection.
:param objects:
something with .lons, .lats or ['lon'] ['lat'], or a list of lists
of objects with a .location attribute (i.e. assets_by_site)
:param assoc_dist:
the maximum distance for association
:param mode:
if 'strict' ... | [
"Associate",
"geographic",
"objects",
"to",
"a",
"site",
"collection",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L177-L196 |
59 | gem/oq-engine | openquake/hazardlib/geo/utils.py | line_intersects_itself | def line_intersects_itself(lons, lats, closed_shape=False):
"""
Return ``True`` if line of points intersects itself.
Line with the last point repeating the first one considered
intersecting itself.
The line is defined by lists (or numpy arrays) of points'
longitudes and latitudes (depth is not ... | python | def line_intersects_itself(lons, lats, closed_shape=False):
"""
Return ``True`` if line of points intersects itself.
Line with the last point repeating the first one considered
intersecting itself.
The line is defined by lists (or numpy arrays) of points'
longitudes and latitudes (depth is not ... | [
"def",
"line_intersects_itself",
"(",
"lons",
",",
"lats",
",",
"closed_shape",
"=",
"False",
")",
":",
"assert",
"len",
"(",
"lons",
")",
"==",
"len",
"(",
"lats",
")",
"if",
"len",
"(",
"lons",
")",
"<=",
"3",
":",
"# line can not intersect itself unless... | Return ``True`` if line of points intersects itself.
Line with the last point repeating the first one considered
intersecting itself.
The line is defined by lists (or numpy arrays) of points'
longitudes and latitudes (depth is not taken into account).
:param closed_shape:
If ``True`` the l... | [
"Return",
"True",
"if",
"line",
"of",
"points",
"intersects",
"itself",
".",
"Line",
"with",
"the",
"last",
"point",
"repeating",
"the",
"first",
"one",
"considered",
"intersecting",
"itself",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L214-L250 |
60 | gem/oq-engine | openquake/hazardlib/geo/utils.py | get_bounding_box | def get_bounding_box(obj, maxdist):
"""
Return the dilated bounding box of a geometric object.
:param obj:
an object with method .get_bounding_box, or with an attribute .polygon
or a list of locations
:param maxdist: maximum distance in km
"""
if hasattr(obj, 'get_bounding_box')... | python | def get_bounding_box(obj, maxdist):
"""
Return the dilated bounding box of a geometric object.
:param obj:
an object with method .get_bounding_box, or with an attribute .polygon
or a list of locations
:param maxdist: maximum distance in km
"""
if hasattr(obj, 'get_bounding_box')... | [
"def",
"get_bounding_box",
"(",
"obj",
",",
"maxdist",
")",
":",
"if",
"hasattr",
"(",
"obj",
",",
"'get_bounding_box'",
")",
":",
"return",
"obj",
".",
"get_bounding_box",
"(",
"maxdist",
")",
"elif",
"hasattr",
"(",
"obj",
",",
"'polygon'",
")",
":",
"... | Return the dilated bounding box of a geometric object.
:param obj:
an object with method .get_bounding_box, or with an attribute .polygon
or a list of locations
:param maxdist: maximum distance in km | [
"Return",
"the",
"dilated",
"bounding",
"box",
"of",
"a",
"geometric",
"object",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L267-L292 |
61 | gem/oq-engine | openquake/hazardlib/geo/utils.py | get_spherical_bounding_box | def get_spherical_bounding_box(lons, lats):
"""
Given a collection of points find and return the bounding box,
as a pair of longitudes and a pair of latitudes.
Parameters define longitudes and latitudes of a point collection
respectively in a form of lists or numpy arrays.
:return:
A t... | python | def get_spherical_bounding_box(lons, lats):
"""
Given a collection of points find and return the bounding box,
as a pair of longitudes and a pair of latitudes.
Parameters define longitudes and latitudes of a point collection
respectively in a form of lists or numpy arrays.
:return:
A t... | [
"def",
"get_spherical_bounding_box",
"(",
"lons",
",",
"lats",
")",
":",
"north",
",",
"south",
"=",
"numpy",
".",
"max",
"(",
"lats",
")",
",",
"numpy",
".",
"min",
"(",
"lats",
")",
"west",
",",
"east",
"=",
"numpy",
".",
"min",
"(",
"lons",
")",... | Given a collection of points find and return the bounding box,
as a pair of longitudes and a pair of latitudes.
Parameters define longitudes and latitudes of a point collection
respectively in a form of lists or numpy arrays.
:return:
A tuple of four items. These items represent western, easte... | [
"Given",
"a",
"collection",
"of",
"points",
"find",
"and",
"return",
"the",
"bounding",
"box",
"as",
"a",
"pair",
"of",
"longitudes",
"and",
"a",
"pair",
"of",
"latitudes",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L295-L329 |
62 | gem/oq-engine | openquake/hazardlib/geo/utils.py | get_middle_point | def get_middle_point(lon1, lat1, lon2, lat2):
"""
Given two points return the point exactly in the middle lying on the same
great circle arc.
Parameters are point coordinates in degrees.
:returns:
Tuple of longitude and latitude of the point in the middle.
"""
if lon1 == lon2 and l... | python | def get_middle_point(lon1, lat1, lon2, lat2):
"""
Given two points return the point exactly in the middle lying on the same
great circle arc.
Parameters are point coordinates in degrees.
:returns:
Tuple of longitude and latitude of the point in the middle.
"""
if lon1 == lon2 and l... | [
"def",
"get_middle_point",
"(",
"lon1",
",",
"lat1",
",",
"lon2",
",",
"lat2",
")",
":",
"if",
"lon1",
"==",
"lon2",
"and",
"lat1",
"==",
"lat2",
":",
"return",
"lon1",
",",
"lat1",
"dist",
"=",
"geodetic",
".",
"geodetic_distance",
"(",
"lon1",
",",
... | Given two points return the point exactly in the middle lying on the same
great circle arc.
Parameters are point coordinates in degrees.
:returns:
Tuple of longitude and latitude of the point in the middle. | [
"Given",
"two",
"points",
"return",
"the",
"point",
"exactly",
"in",
"the",
"middle",
"lying",
"on",
"the",
"same",
"great",
"circle",
"arc",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L428-L442 |
63 | gem/oq-engine | openquake/hazardlib/geo/utils.py | cartesian_to_spherical | def cartesian_to_spherical(vectors):
"""
Return the spherical coordinates for coordinates in Cartesian space.
This function does an opposite to :func:`spherical_to_cartesian`.
:param vectors:
Array of 3d vectors in Cartesian space of shape (..., 3)
:returns:
Tuple of three arrays o... | python | def cartesian_to_spherical(vectors):
"""
Return the spherical coordinates for coordinates in Cartesian space.
This function does an opposite to :func:`spherical_to_cartesian`.
:param vectors:
Array of 3d vectors in Cartesian space of shape (..., 3)
:returns:
Tuple of three arrays o... | [
"def",
"cartesian_to_spherical",
"(",
"vectors",
")",
":",
"rr",
"=",
"numpy",
".",
"sqrt",
"(",
"numpy",
".",
"sum",
"(",
"vectors",
"*",
"vectors",
",",
"axis",
"=",
"-",
"1",
")",
")",
"xx",
",",
"yy",
",",
"zz",
"=",
"vectors",
".",
"T",
"lat... | Return the spherical coordinates for coordinates in Cartesian space.
This function does an opposite to :func:`spherical_to_cartesian`.
:param vectors:
Array of 3d vectors in Cartesian space of shape (..., 3)
:returns:
Tuple of three arrays of the same shape as ``vectors`` representing
... | [
"Return",
"the",
"spherical",
"coordinates",
"for",
"coordinates",
"in",
"Cartesian",
"space",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L445-L463 |
64 | gem/oq-engine | openquake/hazardlib/geo/utils.py | triangle_area | def triangle_area(e1, e2, e3):
"""
Get the area of triangle formed by three vectors.
Parameters are three three-dimensional numpy arrays representing
vectors of triangle's edges in Cartesian space.
:returns:
Float number, the area of the triangle in squared units of coordinates,
or... | python | def triangle_area(e1, e2, e3):
"""
Get the area of triangle formed by three vectors.
Parameters are three three-dimensional numpy arrays representing
vectors of triangle's edges in Cartesian space.
:returns:
Float number, the area of the triangle in squared units of coordinates,
or... | [
"def",
"triangle_area",
"(",
"e1",
",",
"e2",
",",
"e3",
")",
":",
"# calculating edges length",
"e1_length",
"=",
"numpy",
".",
"sqrt",
"(",
"numpy",
".",
"sum",
"(",
"e1",
"*",
"e1",
",",
"axis",
"=",
"-",
"1",
")",
")",
"e2_length",
"=",
"numpy",
... | Get the area of triangle formed by three vectors.
Parameters are three three-dimensional numpy arrays representing
vectors of triangle's edges in Cartesian space.
:returns:
Float number, the area of the triangle in squared units of coordinates,
or numpy array of shape of edges with one dim... | [
"Get",
"the",
"area",
"of",
"triangle",
"formed",
"by",
"three",
"vectors",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L466-L486 |
65 | gem/oq-engine | openquake/hazardlib/geo/utils.py | normalized | def normalized(vector):
"""
Get unit vector for a given one.
:param vector:
Numpy vector as coordinates in Cartesian space, or an array of such.
:returns:
Numpy array of the same shape and structure where all vectors are
normalized. That is, each coordinate component is divided ... | python | def normalized(vector):
"""
Get unit vector for a given one.
:param vector:
Numpy vector as coordinates in Cartesian space, or an array of such.
:returns:
Numpy array of the same shape and structure where all vectors are
normalized. That is, each coordinate component is divided ... | [
"def",
"normalized",
"(",
"vector",
")",
":",
"length",
"=",
"numpy",
".",
"sum",
"(",
"vector",
"*",
"vector",
",",
"axis",
"=",
"-",
"1",
")",
"length",
"=",
"numpy",
".",
"sqrt",
"(",
"length",
".",
"reshape",
"(",
"length",
".",
"shape",
"+",
... | Get unit vector for a given one.
:param vector:
Numpy vector as coordinates in Cartesian space, or an array of such.
:returns:
Numpy array of the same shape and structure where all vectors are
normalized. That is, each coordinate component is divided by its
vector's length. | [
"Get",
"unit",
"vector",
"for",
"a",
"given",
"one",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L489-L502 |
66 | gem/oq-engine | openquake/hazardlib/geo/utils.py | point_to_polygon_distance | def point_to_polygon_distance(polygon, pxx, pyy):
"""
Calculate the distance to polygon for each point of the collection
on the 2d Cartesian plane.
:param polygon:
Shapely "Polygon" geometry object.
:param pxx:
List or numpy array of abscissae values of points to calculate
t... | python | def point_to_polygon_distance(polygon, pxx, pyy):
"""
Calculate the distance to polygon for each point of the collection
on the 2d Cartesian plane.
:param polygon:
Shapely "Polygon" geometry object.
:param pxx:
List or numpy array of abscissae values of points to calculate
t... | [
"def",
"point_to_polygon_distance",
"(",
"polygon",
",",
"pxx",
",",
"pyy",
")",
":",
"pxx",
"=",
"numpy",
".",
"array",
"(",
"pxx",
")",
"pyy",
"=",
"numpy",
".",
"array",
"(",
"pyy",
")",
"assert",
"pxx",
".",
"shape",
"==",
"pyy",
".",
"shape",
... | Calculate the distance to polygon for each point of the collection
on the 2d Cartesian plane.
:param polygon:
Shapely "Polygon" geometry object.
:param pxx:
List or numpy array of abscissae values of points to calculate
the distance from.
:param pyy:
Same structure as ``... | [
"Calculate",
"the",
"distance",
"to",
"polygon",
"for",
"each",
"point",
"of",
"the",
"collection",
"on",
"the",
"2d",
"Cartesian",
"plane",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L505-L531 |
67 | gem/oq-engine | openquake/hazardlib/geo/utils.py | cross_idl | def cross_idl(lon1, lon2, *lons):
"""
Return True if two longitude values define line crossing international date
line.
>>> cross_idl(-45, 45)
False
>>> cross_idl(-180, -179)
False
>>> cross_idl(180, 179)
False
>>> cross_idl(45, -45)
False
>>> cross_idl(0, 0)
False
... | python | def cross_idl(lon1, lon2, *lons):
"""
Return True if two longitude values define line crossing international date
line.
>>> cross_idl(-45, 45)
False
>>> cross_idl(-180, -179)
False
>>> cross_idl(180, 179)
False
>>> cross_idl(45, -45)
False
>>> cross_idl(0, 0)
False
... | [
"def",
"cross_idl",
"(",
"lon1",
",",
"lon2",
",",
"*",
"lons",
")",
":",
"lons",
"=",
"(",
"lon1",
",",
"lon2",
")",
"+",
"lons",
"l1",
",",
"l2",
"=",
"min",
"(",
"lons",
")",
",",
"max",
"(",
"lons",
")",
"# a line crosses the international date l... | Return True if two longitude values define line crossing international date
line.
>>> cross_idl(-45, 45)
False
>>> cross_idl(-180, -179)
False
>>> cross_idl(180, 179)
False
>>> cross_idl(45, -45)
False
>>> cross_idl(0, 0)
False
>>> cross_idl(-170, 170)
True
>>> c... | [
"Return",
"True",
"if",
"two",
"longitude",
"values",
"define",
"line",
"crossing",
"international",
"date",
"line",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L548-L574 |
68 | gem/oq-engine | openquake/hazardlib/geo/utils.py | normalize_lons | def normalize_lons(l1, l2):
"""
An international date line safe way of returning a range of longitudes.
>>> normalize_lons(20, 30) # no IDL within the range
[(20, 30)]
>>> normalize_lons(-17, +17) # no IDL within the range
[(-17, 17)]
>>> normalize_lons(-178, +179)
[(-180, -178), (179... | python | def normalize_lons(l1, l2):
"""
An international date line safe way of returning a range of longitudes.
>>> normalize_lons(20, 30) # no IDL within the range
[(20, 30)]
>>> normalize_lons(-17, +17) # no IDL within the range
[(-17, 17)]
>>> normalize_lons(-178, +179)
[(-180, -178), (179... | [
"def",
"normalize_lons",
"(",
"l1",
",",
"l2",
")",
":",
"if",
"l1",
">",
"l2",
":",
"# exchange lons",
"l1",
",",
"l2",
"=",
"l2",
",",
"l1",
"delta",
"=",
"l2",
"-",
"l1",
"if",
"l1",
"<",
"0",
"and",
"l2",
">",
"0",
"and",
"delta",
">",
"1... | An international date line safe way of returning a range of longitudes.
>>> normalize_lons(20, 30) # no IDL within the range
[(20, 30)]
>>> normalize_lons(-17, +17) # no IDL within the range
[(-17, 17)]
>>> normalize_lons(-178, +179)
[(-180, -178), (179, 180)]
>>> normalize_lons(178, -179... | [
"An",
"international",
"date",
"line",
"safe",
"way",
"of",
"returning",
"a",
"range",
"of",
"longitudes",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L577-L603 |
69 | gem/oq-engine | openquake/hazardlib/geo/utils.py | _GeographicObjects.get_closest | def get_closest(self, lon, lat, depth=0):
"""
Get the closest object to the given longitude and latitude
and its distance.
:param lon: longitude in degrees
:param lat: latitude in degrees
:param depth: depth in km (default 0)
:returns: (object, distance)
... | python | def get_closest(self, lon, lat, depth=0):
"""
Get the closest object to the given longitude and latitude
and its distance.
:param lon: longitude in degrees
:param lat: latitude in degrees
:param depth: depth in km (default 0)
:returns: (object, distance)
... | [
"def",
"get_closest",
"(",
"self",
",",
"lon",
",",
"lat",
",",
"depth",
"=",
"0",
")",
":",
"xyz",
"=",
"spherical_to_cartesian",
"(",
"lon",
",",
"lat",
",",
"depth",
")",
"min_dist",
",",
"idx",
"=",
"self",
".",
"kdtree",
".",
"query",
"(",
"xy... | Get the closest object to the given longitude and latitude
and its distance.
:param lon: longitude in degrees
:param lat: latitude in degrees
:param depth: depth in km (default 0)
:returns: (object, distance) | [
"Get",
"the",
"closest",
"object",
"to",
"the",
"given",
"longitude",
"and",
"latitude",
"and",
"its",
"distance",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L85-L97 |
70 | gem/oq-engine | openquake/hazardlib/geo/utils.py | _GeographicObjects.assoc2 | def assoc2(self, assets_by_site, assoc_dist, mode, asset_refs):
"""
Associated a list of assets by site to the site collection used
to instantiate GeographicObjects.
:param assets_by_sites: a list of lists of assets
:param assoc_dist: the maximum distance for association
... | python | def assoc2(self, assets_by_site, assoc_dist, mode, asset_refs):
"""
Associated a list of assets by site to the site collection used
to instantiate GeographicObjects.
:param assets_by_sites: a list of lists of assets
:param assoc_dist: the maximum distance for association
... | [
"def",
"assoc2",
"(",
"self",
",",
"assets_by_site",
",",
"assoc_dist",
",",
"mode",
",",
"asset_refs",
")",
":",
"assert",
"mode",
"in",
"'strict filter'",
",",
"mode",
"self",
".",
"objects",
".",
"filtered",
"# self.objects must be a SiteCollection",
"asset_dt"... | Associated a list of assets by site to the site collection used
to instantiate GeographicObjects.
:param assets_by_sites: a list of lists of assets
:param assoc_dist: the maximum distance for association
:param mode: 'strict', 'warn' or 'filter'
:param asset_ref: ID of the asset... | [
"Associated",
"a",
"list",
"of",
"assets",
"by",
"site",
"to",
"the",
"site",
"collection",
"used",
"to",
"instantiate",
"GeographicObjects",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L134-L174 |
71 | gem/oq-engine | openquake/risklib/read_nrml.py | ffconvert | def ffconvert(fname, limit_states, ff, min_iml=1E-10):
"""
Convert a fragility function into a numpy array plus a bunch
of attributes.
:param fname: path to the fragility model file
:param limit_states: expected limit states
:param ff: fragility function node
:returns: a pair (array, dictio... | python | def ffconvert(fname, limit_states, ff, min_iml=1E-10):
"""
Convert a fragility function into a numpy array plus a bunch
of attributes.
:param fname: path to the fragility model file
:param limit_states: expected limit states
:param ff: fragility function node
:returns: a pair (array, dictio... | [
"def",
"ffconvert",
"(",
"fname",
",",
"limit_states",
",",
"ff",
",",
"min_iml",
"=",
"1E-10",
")",
":",
"with",
"context",
"(",
"fname",
",",
"ff",
")",
":",
"ffs",
"=",
"ff",
"[",
"1",
":",
"]",
"imls",
"=",
"ff",
".",
"imls",
"nodamage",
"=",... | Convert a fragility function into a numpy array plus a bunch
of attributes.
:param fname: path to the fragility model file
:param limit_states: expected limit states
:param ff: fragility function node
:returns: a pair (array, dictionary) | [
"Convert",
"a",
"fragility",
"function",
"into",
"a",
"numpy",
"array",
"plus",
"a",
"bunch",
"of",
"attributes",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/read_nrml.py#L152-L217 |
72 | gem/oq-engine | openquake/risklib/read_nrml.py | taxonomy | def taxonomy(value):
"""
Any ASCII character goes into a taxonomy, except spaces.
"""
try:
value.encode('ascii')
except UnicodeEncodeError:
raise ValueError('tag %r is not ASCII' % value)
if re.search(r'\s', value):
raise ValueError('The taxonomy %r contains whitespace ch... | python | def taxonomy(value):
"""
Any ASCII character goes into a taxonomy, except spaces.
"""
try:
value.encode('ascii')
except UnicodeEncodeError:
raise ValueError('tag %r is not ASCII' % value)
if re.search(r'\s', value):
raise ValueError('The taxonomy %r contains whitespace ch... | [
"def",
"taxonomy",
"(",
"value",
")",
":",
"try",
":",
"value",
".",
"encode",
"(",
"'ascii'",
")",
"except",
"UnicodeEncodeError",
":",
"raise",
"ValueError",
"(",
"'tag %r is not ASCII'",
"%",
"value",
")",
"if",
"re",
".",
"search",
"(",
"r'\\s'",
",",
... | Any ASCII character goes into a taxonomy, except spaces. | [
"Any",
"ASCII",
"character",
"goes",
"into",
"a",
"taxonomy",
"except",
"spaces",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/read_nrml.py#L371-L381 |
73 | gem/oq-engine | openquake/risklib/read_nrml.py | update_validators | def update_validators():
"""
Call this to updade the global nrml.validators
"""
validators.update({
'fragilityFunction.id': valid.utf8, # taxonomy
'vulnerabilityFunction.id': valid.utf8, # taxonomy
'consequenceFunction.id': valid.utf8, # taxonomy
'asset.id': valid.asse... | python | def update_validators():
"""
Call this to updade the global nrml.validators
"""
validators.update({
'fragilityFunction.id': valid.utf8, # taxonomy
'vulnerabilityFunction.id': valid.utf8, # taxonomy
'consequenceFunction.id': valid.utf8, # taxonomy
'asset.id': valid.asse... | [
"def",
"update_validators",
"(",
")",
":",
"validators",
".",
"update",
"(",
"{",
"'fragilityFunction.id'",
":",
"valid",
".",
"utf8",
",",
"# taxonomy",
"'vulnerabilityFunction.id'",
":",
"valid",
".",
"utf8",
",",
"# taxonomy",
"'consequenceFunction.id'",
":",
"... | Call this to updade the global nrml.validators | [
"Call",
"this",
"to",
"updade",
"the",
"global",
"nrml",
".",
"validators"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/read_nrml.py#L384-L437 |
74 | gem/oq-engine | openquake/calculators/extract.py | barray | def barray(iterlines):
"""
Array of bytes
"""
lst = [line.encode('utf-8') for line in iterlines]
arr = numpy.array(lst)
return arr | python | def barray(iterlines):
"""
Array of bytes
"""
lst = [line.encode('utf-8') for line in iterlines]
arr = numpy.array(lst)
return arr | [
"def",
"barray",
"(",
"iterlines",
")",
":",
"lst",
"=",
"[",
"line",
".",
"encode",
"(",
"'utf-8'",
")",
"for",
"line",
"in",
"iterlines",
"]",
"arr",
"=",
"numpy",
".",
"array",
"(",
"lst",
")",
"return",
"arr"
] | Array of bytes | [
"Array",
"of",
"bytes"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/extract.py#L130-L136 |
75 | gem/oq-engine | openquake/calculators/extract.py | losses_by_tag | def losses_by_tag(dstore, tag):
"""
Statistical average losses by tag. For instance call
$ oq extract losses_by_tag/occupancy
"""
dt = [(tag, vstr)] + dstore['oqparam'].loss_dt_list()
aids = dstore['assetcol/array'][tag]
dset, stats = _get(dstore, 'avg_losses')
arr = dset.value
tagv... | python | def losses_by_tag(dstore, tag):
"""
Statistical average losses by tag. For instance call
$ oq extract losses_by_tag/occupancy
"""
dt = [(tag, vstr)] + dstore['oqparam'].loss_dt_list()
aids = dstore['assetcol/array'][tag]
dset, stats = _get(dstore, 'avg_losses')
arr = dset.value
tagv... | [
"def",
"losses_by_tag",
"(",
"dstore",
",",
"tag",
")",
":",
"dt",
"=",
"[",
"(",
"tag",
",",
"vstr",
")",
"]",
"+",
"dstore",
"[",
"'oqparam'",
"]",
".",
"loss_dt_list",
"(",
")",
"aids",
"=",
"dstore",
"[",
"'assetcol/array'",
"]",
"[",
"tag",
"]... | Statistical average losses by tag. For instance call
$ oq extract losses_by_tag/occupancy | [
"Statistical",
"average",
"losses",
"by",
"tag",
".",
"For",
"instance",
"call"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/extract.py#L808-L827 |
76 | gem/oq-engine | openquake/calculators/extract.py | WebExtractor.dump | def dump(self, fname):
"""
Dump the remote datastore on a local path.
"""
url = '%s/v1/calc/%d/datastore' % (self.server, self.calc_id)
resp = self.sess.get(url, stream=True)
down = 0
with open(fname, 'wb') as f:
logging.info('Saving %s', fname)
... | python | def dump(self, fname):
"""
Dump the remote datastore on a local path.
"""
url = '%s/v1/calc/%d/datastore' % (self.server, self.calc_id)
resp = self.sess.get(url, stream=True)
down = 0
with open(fname, 'wb') as f:
logging.info('Saving %s', fname)
... | [
"def",
"dump",
"(",
"self",
",",
"fname",
")",
":",
"url",
"=",
"'%s/v1/calc/%d/datastore'",
"%",
"(",
"self",
".",
"server",
",",
"self",
".",
"calc_id",
")",
"resp",
"=",
"self",
".",
"sess",
".",
"get",
"(",
"url",
",",
"stream",
"=",
"True",
")... | Dump the remote datastore on a local path. | [
"Dump",
"the",
"remote",
"datastore",
"on",
"a",
"local",
"path",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/extract.py#L988-L1001 |
77 | gem/oq-engine | openquake/hazardlib/gsim/utils_swiss_gmpe.py | _compute_small_mag_correction_term | def _compute_small_mag_correction_term(C, mag, rhypo):
"""
small magnitude correction applied to the median values
"""
if mag >= 3.00 and mag < 5.5:
min_term = np.minimum(rhypo, C['Rm'])
max_term = np.maximum(min_term, 10)
term_ln = np.log(max_term / 20)
term_ratio = ((5.... | python | def _compute_small_mag_correction_term(C, mag, rhypo):
"""
small magnitude correction applied to the median values
"""
if mag >= 3.00 and mag < 5.5:
min_term = np.minimum(rhypo, C['Rm'])
max_term = np.maximum(min_term, 10)
term_ln = np.log(max_term / 20)
term_ratio = ((5.... | [
"def",
"_compute_small_mag_correction_term",
"(",
"C",
",",
"mag",
",",
"rhypo",
")",
":",
"if",
"mag",
">=",
"3.00",
"and",
"mag",
"<",
"5.5",
":",
"min_term",
"=",
"np",
".",
"minimum",
"(",
"rhypo",
",",
"C",
"[",
"'Rm'",
"]",
")",
"max_term",
"="... | small magnitude correction applied to the median values | [
"small",
"magnitude",
"correction",
"applied",
"to",
"the",
"median",
"values"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/utils_swiss_gmpe.py#L40-L52 |
78 | gem/oq-engine | openquake/hazardlib/gsim/utils_swiss_gmpe.py | _apply_adjustments | def _apply_adjustments(COEFFS, C_ADJ, tau_ss, mean, stddevs, sites, rup, dists,
imt, stddev_types, log_phi_ss, NL=None, tau_value=None):
"""
This method applies adjustments to the mean and standard deviation.
The small-magnitude adjustments are applied to mean, whereas the
embeded... | python | def _apply_adjustments(COEFFS, C_ADJ, tau_ss, mean, stddevs, sites, rup, dists,
imt, stddev_types, log_phi_ss, NL=None, tau_value=None):
"""
This method applies adjustments to the mean and standard deviation.
The small-magnitude adjustments are applied to mean, whereas the
embeded... | [
"def",
"_apply_adjustments",
"(",
"COEFFS",
",",
"C_ADJ",
",",
"tau_ss",
",",
"mean",
",",
"stddevs",
",",
"sites",
",",
"rup",
",",
"dists",
",",
"imt",
",",
"stddev_types",
",",
"log_phi_ss",
",",
"NL",
"=",
"None",
",",
"tau_value",
"=",
"None",
")"... | This method applies adjustments to the mean and standard deviation.
The small-magnitude adjustments are applied to mean, whereas the
embeded single station sigma logic tree is applied to the
total standard deviation. | [
"This",
"method",
"applies",
"adjustments",
"to",
"the",
"mean",
"and",
"standard",
"deviation",
".",
"The",
"small",
"-",
"magnitude",
"adjustments",
"are",
"applied",
"to",
"mean",
"whereas",
"the",
"embeded",
"single",
"station",
"sigma",
"logic",
"tree",
"... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/utils_swiss_gmpe.py#L102-L125 |
79 | gem/oq-engine | openquake/commonlib/source.py | CompositionInfo.get_info | def get_info(self, sm_id):
"""
Extract a CompositionInfo instance containing the single
model of index `sm_id`.
"""
sm = self.source_models[sm_id]
num_samples = sm.samples if self.num_samples else 0
return self.__class__(
self.gsim_lt, self.seed, num_s... | python | def get_info(self, sm_id):
"""
Extract a CompositionInfo instance containing the single
model of index `sm_id`.
"""
sm = self.source_models[sm_id]
num_samples = sm.samples if self.num_samples else 0
return self.__class__(
self.gsim_lt, self.seed, num_s... | [
"def",
"get_info",
"(",
"self",
",",
"sm_id",
")",
":",
"sm",
"=",
"self",
".",
"source_models",
"[",
"sm_id",
"]",
"num_samples",
"=",
"sm",
".",
"samples",
"if",
"self",
".",
"num_samples",
"else",
"0",
"return",
"self",
".",
"__class__",
"(",
"self"... | Extract a CompositionInfo instance containing the single
model of index `sm_id`. | [
"Extract",
"a",
"CompositionInfo",
"instance",
"containing",
"the",
"single",
"model",
"of",
"index",
"sm_id",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/source.py#L142-L150 |
80 | gem/oq-engine | openquake/commonlib/source.py | CompositionInfo.get_source_model | def get_source_model(self, src_group_id):
"""
Return the source model for the given src_group_id
"""
for smodel in self.source_models:
for src_group in smodel.src_groups:
if src_group.id == src_group_id:
return smodel | python | def get_source_model(self, src_group_id):
"""
Return the source model for the given src_group_id
"""
for smodel in self.source_models:
for src_group in smodel.src_groups:
if src_group.id == src_group_id:
return smodel | [
"def",
"get_source_model",
"(",
"self",
",",
"src_group_id",
")",
":",
"for",
"smodel",
"in",
"self",
".",
"source_models",
":",
"for",
"src_group",
"in",
"smodel",
".",
"src_groups",
":",
"if",
"src_group",
".",
"id",
"==",
"src_group_id",
":",
"return",
... | Return the source model for the given src_group_id | [
"Return",
"the",
"source",
"model",
"for",
"the",
"given",
"src_group_id"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/source.py#L275-L282 |
81 | gem/oq-engine | openquake/commonlib/source.py | CompositeSourceModel.get_model | def get_model(self, sm_id):
"""
Extract a CompositeSourceModel instance containing the single
model of index `sm_id`.
"""
sm = self.source_models[sm_id]
if self.source_model_lt.num_samples:
self.source_model_lt.num_samples = sm.samples
new = self.__cla... | python | def get_model(self, sm_id):
"""
Extract a CompositeSourceModel instance containing the single
model of index `sm_id`.
"""
sm = self.source_models[sm_id]
if self.source_model_lt.num_samples:
self.source_model_lt.num_samples = sm.samples
new = self.__cla... | [
"def",
"get_model",
"(",
"self",
",",
"sm_id",
")",
":",
"sm",
"=",
"self",
".",
"source_models",
"[",
"sm_id",
"]",
"if",
"self",
".",
"source_model_lt",
".",
"num_samples",
":",
"self",
".",
"source_model_lt",
".",
"num_samples",
"=",
"sm",
".",
"sampl... | Extract a CompositeSourceModel instance containing the single
model of index `sm_id`. | [
"Extract",
"a",
"CompositeSourceModel",
"instance",
"containing",
"the",
"single",
"model",
"of",
"index",
"sm_id",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/source.py#L381-L392 |
82 | gem/oq-engine | openquake/commonlib/source.py | CompositeSourceModel.new | def new(self, sources_by_grp):
"""
Generate a new CompositeSourceModel from the given dictionary.
:param sources_by_group: a dictionary grp_id -> sources
:returns: a new CompositeSourceModel instance
"""
source_models = []
for sm in self.source_models:
... | python | def new(self, sources_by_grp):
"""
Generate a new CompositeSourceModel from the given dictionary.
:param sources_by_group: a dictionary grp_id -> sources
:returns: a new CompositeSourceModel instance
"""
source_models = []
for sm in self.source_models:
... | [
"def",
"new",
"(",
"self",
",",
"sources_by_grp",
")",
":",
"source_models",
"=",
"[",
"]",
"for",
"sm",
"in",
"self",
".",
"source_models",
":",
"src_groups",
"=",
"[",
"]",
"for",
"src_group",
"in",
"sm",
".",
"src_groups",
":",
"sg",
"=",
"copy",
... | Generate a new CompositeSourceModel from the given dictionary.
:param sources_by_group: a dictionary grp_id -> sources
:returns: a new CompositeSourceModel instance | [
"Generate",
"a",
"new",
"CompositeSourceModel",
"from",
"the",
"given",
"dictionary",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/source.py#L394-L417 |
83 | gem/oq-engine | openquake/commonlib/source.py | CompositeSourceModel.check_dupl_sources | def check_dupl_sources(self): # used in print_csm_info
"""
Extracts duplicated sources, i.e. sources with the same source_id in
different source groups. Raise an exception if there are sources with
the same ID which are not duplicated.
:returns: a list of list of sources, order... | python | def check_dupl_sources(self): # used in print_csm_info
"""
Extracts duplicated sources, i.e. sources with the same source_id in
different source groups. Raise an exception if there are sources with
the same ID which are not duplicated.
:returns: a list of list of sources, order... | [
"def",
"check_dupl_sources",
"(",
"self",
")",
":",
"# used in print_csm_info",
"dd",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"for",
"src_group",
"in",
"self",
".",
"src_groups",
":",
"for",
"src",
"in",
"src_group",
":",
"try",
":",
"srcid... | Extracts duplicated sources, i.e. sources with the same source_id in
different source groups. Raise an exception if there are sources with
the same ID which are not duplicated.
:returns: a list of list of sources, ordered by source_id | [
"Extracts",
"duplicated",
"sources",
"i",
".",
"e",
".",
"sources",
"with",
"the",
"same",
"source_id",
"in",
"different",
"source",
"groups",
".",
"Raise",
"an",
"exception",
"if",
"there",
"are",
"sources",
"with",
"the",
"same",
"ID",
"which",
"are",
"n... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/source.py#L443-L464 |
84 | gem/oq-engine | openquake/commonlib/source.py | CompositeSourceModel.get_sources | def get_sources(self, kind='all'):
"""
Extract the sources contained in the source models by optionally
filtering and splitting them, depending on the passed parameter.
"""
assert kind in ('all', 'indep', 'mutex'), kind
sources = []
for sm in self.source_models:
... | python | def get_sources(self, kind='all'):
"""
Extract the sources contained in the source models by optionally
filtering and splitting them, depending on the passed parameter.
"""
assert kind in ('all', 'indep', 'mutex'), kind
sources = []
for sm in self.source_models:
... | [
"def",
"get_sources",
"(",
"self",
",",
"kind",
"=",
"'all'",
")",
":",
"assert",
"kind",
"in",
"(",
"'all'",
",",
"'indep'",
",",
"'mutex'",
")",
",",
"kind",
"sources",
"=",
"[",
"]",
"for",
"sm",
"in",
"self",
".",
"source_models",
":",
"for",
"... | Extract the sources contained in the source models by optionally
filtering and splitting them, depending on the passed parameter. | [
"Extract",
"the",
"sources",
"contained",
"in",
"the",
"source",
"models",
"by",
"optionally",
"filtering",
"and",
"splitting",
"them",
"depending",
"on",
"the",
"passed",
"parameter",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/source.py#L466-L480 |
85 | gem/oq-engine | openquake/commonlib/source.py | CompositeSourceModel.init_serials | def init_serials(self, ses_seed):
"""
Generate unique seeds for each rupture with numpy.arange.
This should be called only in event based calculators
"""
sources = self.get_sources()
serial = ses_seed
for src in sources:
nr = src.num_ruptures
... | python | def init_serials(self, ses_seed):
"""
Generate unique seeds for each rupture with numpy.arange.
This should be called only in event based calculators
"""
sources = self.get_sources()
serial = ses_seed
for src in sources:
nr = src.num_ruptures
... | [
"def",
"init_serials",
"(",
"self",
",",
"ses_seed",
")",
":",
"sources",
"=",
"self",
".",
"get_sources",
"(",
")",
"serial",
"=",
"ses_seed",
"for",
"src",
"in",
"sources",
":",
"nr",
"=",
"src",
".",
"num_ruptures",
"src",
".",
"serial",
"=",
"seria... | Generate unique seeds for each rupture with numpy.arange.
This should be called only in event based calculators | [
"Generate",
"unique",
"seeds",
"for",
"each",
"rupture",
"with",
"numpy",
".",
"arange",
".",
"This",
"should",
"be",
"called",
"only",
"in",
"event",
"based",
"calculators"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/source.py#L525-L535 |
86 | gem/oq-engine | openquake/commonlib/source.py | CompositeSourceModel.get_maxweight | def get_maxweight(self, weight, concurrent_tasks, minweight=MINWEIGHT):
"""
Return an appropriate maxweight for use in the block_splitter
"""
totweight = self.get_weight(weight)
ct = concurrent_tasks or 1
mw = math.ceil(totweight / ct)
return max(mw, minweight) | python | def get_maxweight(self, weight, concurrent_tasks, minweight=MINWEIGHT):
"""
Return an appropriate maxweight for use in the block_splitter
"""
totweight = self.get_weight(weight)
ct = concurrent_tasks or 1
mw = math.ceil(totweight / ct)
return max(mw, minweight) | [
"def",
"get_maxweight",
"(",
"self",
",",
"weight",
",",
"concurrent_tasks",
",",
"minweight",
"=",
"MINWEIGHT",
")",
":",
"totweight",
"=",
"self",
".",
"get_weight",
"(",
"weight",
")",
"ct",
"=",
"concurrent_tasks",
"or",
"1",
"mw",
"=",
"math",
".",
... | Return an appropriate maxweight for use in the block_splitter | [
"Return",
"an",
"appropriate",
"maxweight",
"for",
"use",
"in",
"the",
"block_splitter"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/source.py#L537-L544 |
87 | gem/oq-engine | openquake/hmtk/parsers/faults/fault_yaml_parser.py | weight_list_to_tuple | def weight_list_to_tuple(data, attr_name):
'''
Converts a list of values and corresponding weights to a tuple of values
'''
if len(data['Value']) != len(data['Weight']):
raise ValueError('Number of weights do not correspond to number of '
'attributes in %s' % attr_name)... | python | def weight_list_to_tuple(data, attr_name):
'''
Converts a list of values and corresponding weights to a tuple of values
'''
if len(data['Value']) != len(data['Weight']):
raise ValueError('Number of weights do not correspond to number of '
'attributes in %s' % attr_name)... | [
"def",
"weight_list_to_tuple",
"(",
"data",
",",
"attr_name",
")",
":",
"if",
"len",
"(",
"data",
"[",
"'Value'",
"]",
")",
"!=",
"len",
"(",
"data",
"[",
"'Weight'",
"]",
")",
":",
"raise",
"ValueError",
"(",
"'Number of weights do not correspond to number of... | Converts a list of values and corresponding weights to a tuple of values | [
"Converts",
"a",
"list",
"of",
"values",
"and",
"corresponding",
"weights",
"to",
"a",
"tuple",
"of",
"values"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/faults/fault_yaml_parser.py#L71-L86 |
88 | gem/oq-engine | openquake/hmtk/parsers/faults/fault_yaml_parser.py | parse_tect_region_dict_to_tuples | def parse_tect_region_dict_to_tuples(region_dict):
'''
Parses the tectonic regionalisation dictionary attributes to tuples
'''
output_region_dict = []
tuple_keys = ['Displacement_Length_Ratio', 'Shear_Modulus']
# Convert MSR string name to openquake.hazardlib.scalerel object
for region in re... | python | def parse_tect_region_dict_to_tuples(region_dict):
'''
Parses the tectonic regionalisation dictionary attributes to tuples
'''
output_region_dict = []
tuple_keys = ['Displacement_Length_Ratio', 'Shear_Modulus']
# Convert MSR string name to openquake.hazardlib.scalerel object
for region in re... | [
"def",
"parse_tect_region_dict_to_tuples",
"(",
"region_dict",
")",
":",
"output_region_dict",
"=",
"[",
"]",
"tuple_keys",
"=",
"[",
"'Displacement_Length_Ratio'",
",",
"'Shear_Modulus'",
"]",
"# Convert MSR string name to openquake.hazardlib.scalerel object",
"for",
"region",... | Parses the tectonic regionalisation dictionary attributes to tuples | [
"Parses",
"the",
"tectonic",
"regionalisation",
"dictionary",
"attributes",
"to",
"tuples"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/faults/fault_yaml_parser.py#L89-L105 |
89 | gem/oq-engine | openquake/hmtk/parsers/faults/fault_yaml_parser.py | get_scaling_relation_tuple | def get_scaling_relation_tuple(msr_dict):
'''
For a dictionary of scaling relation values convert string list to
object list and then to tuple
'''
# Convert MSR string name to openquake.hazardlib.scalerel object
for iloc, value in enumerate(msr_dict['Value']):
if not value in SCALE_REL_... | python | def get_scaling_relation_tuple(msr_dict):
'''
For a dictionary of scaling relation values convert string list to
object list and then to tuple
'''
# Convert MSR string name to openquake.hazardlib.scalerel object
for iloc, value in enumerate(msr_dict['Value']):
if not value in SCALE_REL_... | [
"def",
"get_scaling_relation_tuple",
"(",
"msr_dict",
")",
":",
"# Convert MSR string name to openquake.hazardlib.scalerel object",
"for",
"iloc",
",",
"value",
"in",
"enumerate",
"(",
"msr_dict",
"[",
"'Value'",
"]",
")",
":",
"if",
"not",
"value",
"in",
"SCALE_REL_M... | For a dictionary of scaling relation values convert string list to
object list and then to tuple | [
"For",
"a",
"dictionary",
"of",
"scaling",
"relation",
"values",
"convert",
"string",
"list",
"to",
"object",
"list",
"and",
"then",
"to",
"tuple"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/faults/fault_yaml_parser.py#L108-L120 |
90 | gem/oq-engine | openquake/hmtk/parsers/faults/fault_yaml_parser.py | FaultYmltoSource.read_file | def read_file(self, mesh_spacing=1.0):
'''
Reads the file and returns an instance of the FaultSource class.
:param float mesh_spacing:
Fault mesh spacing (km)
'''
# Process the tectonic regionalisation
tectonic_reg = self.process_tectonic_regionalisation()
... | python | def read_file(self, mesh_spacing=1.0):
'''
Reads the file and returns an instance of the FaultSource class.
:param float mesh_spacing:
Fault mesh spacing (km)
'''
# Process the tectonic regionalisation
tectonic_reg = self.process_tectonic_regionalisation()
... | [
"def",
"read_file",
"(",
"self",
",",
"mesh_spacing",
"=",
"1.0",
")",
":",
"# Process the tectonic regionalisation",
"tectonic_reg",
"=",
"self",
".",
"process_tectonic_regionalisation",
"(",
")",
"model",
"=",
"mtkActiveFaultModel",
"(",
"self",
".",
"data",
"[",
... | Reads the file and returns an instance of the FaultSource class.
:param float mesh_spacing:
Fault mesh spacing (km) | [
"Reads",
"the",
"file",
"and",
"returns",
"an",
"instance",
"of",
"the",
"FaultSource",
"class",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/faults/fault_yaml_parser.py#L138-L189 |
91 | gem/oq-engine | openquake/hmtk/parsers/faults/fault_yaml_parser.py | FaultYmltoSource.process_tectonic_regionalisation | def process_tectonic_regionalisation(self):
'''
Processes the tectonic regionalisation from the yaml file
'''
if 'tectonic_regionalisation' in self.data.keys():
tectonic_reg = TectonicRegionalisation()
tectonic_reg.populate_regions(
parse_tect_reg... | python | def process_tectonic_regionalisation(self):
'''
Processes the tectonic regionalisation from the yaml file
'''
if 'tectonic_regionalisation' in self.data.keys():
tectonic_reg = TectonicRegionalisation()
tectonic_reg.populate_regions(
parse_tect_reg... | [
"def",
"process_tectonic_regionalisation",
"(",
"self",
")",
":",
"if",
"'tectonic_regionalisation'",
"in",
"self",
".",
"data",
".",
"keys",
"(",
")",
":",
"tectonic_reg",
"=",
"TectonicRegionalisation",
"(",
")",
"tectonic_reg",
".",
"populate_regions",
"(",
"pa... | Processes the tectonic regionalisation from the yaml file | [
"Processes",
"the",
"tectonic",
"regionalisation",
"from",
"the",
"yaml",
"file"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/faults/fault_yaml_parser.py#L191-L203 |
92 | gem/oq-engine | openquake/hmtk/parsers/faults/fault_yaml_parser.py | FaultYmltoSource.read_fault_geometry | def read_fault_geometry(self, geo_dict, mesh_spacing=1.0):
'''
Creates the fault geometry from the parameters specified in the
dictionary.
:param dict geo_dict:
Sub-dictionary of main fault dictionary containing only
the geometry attributes
:param float m... | python | def read_fault_geometry(self, geo_dict, mesh_spacing=1.0):
'''
Creates the fault geometry from the parameters specified in the
dictionary.
:param dict geo_dict:
Sub-dictionary of main fault dictionary containing only
the geometry attributes
:param float m... | [
"def",
"read_fault_geometry",
"(",
"self",
",",
"geo_dict",
",",
"mesh_spacing",
"=",
"1.0",
")",
":",
"if",
"geo_dict",
"[",
"'Fault_Typology'",
"]",
"==",
"'Simple'",
":",
"# Simple fault geometry",
"raw_trace",
"=",
"geo_dict",
"[",
"'Fault_Trace'",
"]",
"tra... | Creates the fault geometry from the parameters specified in the
dictionary.
:param dict geo_dict:
Sub-dictionary of main fault dictionary containing only
the geometry attributes
:param float mesh_spacing:
Fault mesh spacing (km)
:returns:
... | [
"Creates",
"the",
"fault",
"geometry",
"from",
"the",
"parameters",
"specified",
"in",
"the",
"dictionary",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/faults/fault_yaml_parser.py#L205-L242 |
93 | gem/oq-engine | openquake/hazardlib/gsim/cauzzi_2014.py | CauzziEtAl2014._get_distance_scaling_term | def _get_distance_scaling_term(self, C, mag, rrup):
"""
Returns the distance scaling parameter
"""
return (C["r1"] + C["r2"] * mag) * np.log10(rrup + C["r3"]) | python | def _get_distance_scaling_term(self, C, mag, rrup):
"""
Returns the distance scaling parameter
"""
return (C["r1"] + C["r2"] * mag) * np.log10(rrup + C["r3"]) | [
"def",
"_get_distance_scaling_term",
"(",
"self",
",",
"C",
",",
"mag",
",",
"rrup",
")",
":",
"return",
"(",
"C",
"[",
"\"r1\"",
"]",
"+",
"C",
"[",
"\"r2\"",
"]",
"*",
"mag",
")",
"*",
"np",
".",
"log10",
"(",
"rrup",
"+",
"C",
"[",
"\"r3\"",
... | Returns the distance scaling parameter | [
"Returns",
"the",
"distance",
"scaling",
"parameter"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/cauzzi_2014.py#L132-L136 |
94 | gem/oq-engine | openquake/hazardlib/gsim/cauzzi_2014.py | CauzziEtAl2014._get_style_of_faulting_term | def _get_style_of_faulting_term(self, C, rake):
"""
Returns the style of faulting term. Cauzzi et al. determind SOF from
the plunge of the B-, T- and P-axes. For consistency with existing
GMPEs the Wells & Coppersmith model is preferred
"""
if rake > -150.0 and rake <= -3... | python | def _get_style_of_faulting_term(self, C, rake):
"""
Returns the style of faulting term. Cauzzi et al. determind SOF from
the plunge of the B-, T- and P-axes. For consistency with existing
GMPEs the Wells & Coppersmith model is preferred
"""
if rake > -150.0 and rake <= -3... | [
"def",
"_get_style_of_faulting_term",
"(",
"self",
",",
"C",
",",
"rake",
")",
":",
"if",
"rake",
">",
"-",
"150.0",
"and",
"rake",
"<=",
"-",
"30.0",
":",
"return",
"C",
"[",
"'fN'",
"]",
"elif",
"rake",
">",
"30.0",
"and",
"rake",
"<=",
"150.0",
... | Returns the style of faulting term. Cauzzi et al. determind SOF from
the plunge of the B-, T- and P-axes. For consistency with existing
GMPEs the Wells & Coppersmith model is preferred | [
"Returns",
"the",
"style",
"of",
"faulting",
"term",
".",
"Cauzzi",
"et",
"al",
".",
"determind",
"SOF",
"from",
"the",
"plunge",
"of",
"the",
"B",
"-",
"T",
"-",
"and",
"P",
"-",
"axes",
".",
"For",
"consistency",
"with",
"existing",
"GMPEs",
"the",
... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/cauzzi_2014.py#L138-L149 |
95 | gem/oq-engine | openquake/hazardlib/gsim/cauzzi_2014.py | CauzziEtAl2014Eurocode8._get_site_amplification_term | def _get_site_amplification_term(self, C, vs30):
"""
Returns the site amplification term on the basis of Eurocode 8
site class
"""
s_b, s_c, s_d = self._get_site_dummy_variables(vs30)
return (C["sB"] * s_b) + (C["sC"] * s_c) + (C["sD"] * s_d) | python | def _get_site_amplification_term(self, C, vs30):
"""
Returns the site amplification term on the basis of Eurocode 8
site class
"""
s_b, s_c, s_d = self._get_site_dummy_variables(vs30)
return (C["sB"] * s_b) + (C["sC"] * s_c) + (C["sD"] * s_d) | [
"def",
"_get_site_amplification_term",
"(",
"self",
",",
"C",
",",
"vs30",
")",
":",
"s_b",
",",
"s_c",
",",
"s_d",
"=",
"self",
".",
"_get_site_dummy_variables",
"(",
"vs30",
")",
"return",
"(",
"C",
"[",
"\"sB\"",
"]",
"*",
"s_b",
")",
"+",
"(",
"C... | Returns the site amplification term on the basis of Eurocode 8
site class | [
"Returns",
"the",
"site",
"amplification",
"term",
"on",
"the",
"basis",
"of",
"Eurocode",
"8",
"site",
"class"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/cauzzi_2014.py#L471-L477 |
96 | gem/oq-engine | openquake/hazardlib/gsim/cauzzi_2014.py | CauzziEtAl2014Eurocode8._get_site_dummy_variables | def _get_site_dummy_variables(self, vs30):
"""
Returns the Eurocode 8 site class dummy variable
"""
s_b = np.zeros_like(vs30)
s_c = np.zeros_like(vs30)
s_d = np.zeros_like(vs30)
s_b[np.logical_and(vs30 >= 360., vs30 < 800.)] = 1.0
s_c[np.logical_and(vs30 >... | python | def _get_site_dummy_variables(self, vs30):
"""
Returns the Eurocode 8 site class dummy variable
"""
s_b = np.zeros_like(vs30)
s_c = np.zeros_like(vs30)
s_d = np.zeros_like(vs30)
s_b[np.logical_and(vs30 >= 360., vs30 < 800.)] = 1.0
s_c[np.logical_and(vs30 >... | [
"def",
"_get_site_dummy_variables",
"(",
"self",
",",
"vs30",
")",
":",
"s_b",
"=",
"np",
".",
"zeros_like",
"(",
"vs30",
")",
"s_c",
"=",
"np",
".",
"zeros_like",
"(",
"vs30",
")",
"s_d",
"=",
"np",
".",
"zeros_like",
"(",
"vs30",
")",
"s_b",
"[",
... | Returns the Eurocode 8 site class dummy variable | [
"Returns",
"the",
"Eurocode",
"8",
"site",
"class",
"dummy",
"variable"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/cauzzi_2014.py#L479-L489 |
97 | gem/oq-engine | openquake/hmtk/faults/fault_models.py | RecurrenceBranch.get_recurrence | def get_recurrence(self, config):
'''
Calculates the recurrence model for the given settings as
an instance of the openquake.hmtk.models.IncrementalMFD
:param dict config:
Configuration settings of the magnitude frequency distribution.
'''
model = MFD_MAP[con... | python | def get_recurrence(self, config):
'''
Calculates the recurrence model for the given settings as
an instance of the openquake.hmtk.models.IncrementalMFD
:param dict config:
Configuration settings of the magnitude frequency distribution.
'''
model = MFD_MAP[con... | [
"def",
"get_recurrence",
"(",
"self",
",",
"config",
")",
":",
"model",
"=",
"MFD_MAP",
"[",
"config",
"[",
"'Model_Name'",
"]",
"]",
"(",
")",
"model",
".",
"setUp",
"(",
"config",
")",
"model",
".",
"get_mmax",
"(",
"config",
",",
"self",
".",
"msr... | Calculates the recurrence model for the given settings as
an instance of the openquake.hmtk.models.IncrementalMFD
:param dict config:
Configuration settings of the magnitude frequency distribution. | [
"Calculates",
"the",
"recurrence",
"model",
"for",
"the",
"given",
"settings",
"as",
"an",
"instance",
"of",
"the",
"openquake",
".",
"hmtk",
".",
"models",
".",
"IncrementalMFD"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/fault_models.py#L145-L177 |
98 | gem/oq-engine | openquake/hmtk/faults/fault_models.py | mtkActiveFault.get_tectonic_regionalisation | def get_tectonic_regionalisation(self, regionalisation, region_type=None):
'''
Defines the tectonic region and updates the shear modulus,
magnitude scaling relation and displacement to length ratio using
the regional values, if not previously defined for the fault
:param regiona... | python | def get_tectonic_regionalisation(self, regionalisation, region_type=None):
'''
Defines the tectonic region and updates the shear modulus,
magnitude scaling relation and displacement to length ratio using
the regional values, if not previously defined for the fault
:param regiona... | [
"def",
"get_tectonic_regionalisation",
"(",
"self",
",",
"regionalisation",
",",
"region_type",
"=",
"None",
")",
":",
"if",
"region_type",
":",
"self",
".",
"trt",
"=",
"region_type",
"if",
"not",
"self",
".",
"trt",
"in",
"regionalisation",
".",
"key_list",
... | Defines the tectonic region and updates the shear modulus,
magnitude scaling relation and displacement to length ratio using
the regional values, if not previously defined for the fault
:param regionalistion:
Instance of the :class:
openquake.hmtk.faults.tectonic_regiona... | [
"Defines",
"the",
"tectonic",
"region",
"and",
"updates",
"the",
"shear",
"modulus",
"magnitude",
"scaling",
"relation",
"and",
"displacement",
"to",
"length",
"ratio",
"using",
"the",
"regional",
"values",
"if",
"not",
"previously",
"defined",
"for",
"the",
"fa... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/fault_models.py#L265-L301 |
99 | gem/oq-engine | openquake/hmtk/faults/fault_models.py | mtkActiveFault.select_catalogue | def select_catalogue(self, selector, distance, distance_metric="rupture",
upper_eq_depth=None, lower_eq_depth=None):
"""
Select earthquakes within a specied distance of the fault
"""
if selector.catalogue.get_number_events() < 1:
raise ValueError('No ... | python | def select_catalogue(self, selector, distance, distance_metric="rupture",
upper_eq_depth=None, lower_eq_depth=None):
"""
Select earthquakes within a specied distance of the fault
"""
if selector.catalogue.get_number_events() < 1:
raise ValueError('No ... | [
"def",
"select_catalogue",
"(",
"self",
",",
"selector",
",",
"distance",
",",
"distance_metric",
"=",
"\"rupture\"",
",",
"upper_eq_depth",
"=",
"None",
",",
"lower_eq_depth",
"=",
"None",
")",
":",
"if",
"selector",
".",
"catalogue",
".",
"get_number_events",
... | Select earthquakes within a specied distance of the fault | [
"Select",
"earthquakes",
"within",
"a",
"specied",
"distance",
"of",
"the",
"fault"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/fault_models.py#L303-L325 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.