repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
gem/oq-engine | openquake/hmtk/seismicity/smoothing/utils.py | get_weichert_factor | def get_weichert_factor(beta, cmag, cyear, end_year):
'''
Gets the Weichert adjustment factor for each the magnitude bins
:param float beta:
Beta value of Gutenberg & Richter parameter (b * log(10.))
:param np.ndarray cmag:
Magnitude values of the completeness table
:param np.ndar... | python | def get_weichert_factor(beta, cmag, cyear, end_year):
'''
Gets the Weichert adjustment factor for each the magnitude bins
:param float beta:
Beta value of Gutenberg & Richter parameter (b * log(10.))
:param np.ndarray cmag:
Magnitude values of the completeness table
:param np.ndar... | [
"def",
"get_weichert_factor",
"(",
"beta",
",",
"cmag",
",",
"cyear",
",",
"end_year",
")",
":",
"if",
"len",
"(",
"cmag",
")",
">",
"1",
":",
"# cval corresponds to the mid-point of the completeness bins",
"# In the original code it requires that the magnitude bins be",
... | Gets the Weichert adjustment factor for each the magnitude bins
:param float beta:
Beta value of Gutenberg & Richter parameter (b * log(10.))
:param np.ndarray cmag:
Magnitude values of the completeness table
:param np.ndarray cyear:
Year values of the completeness table
:par... | [
"Gets",
"the",
"Weichert",
"adjustment",
"factor",
"for",
"each",
"the",
"magnitude",
"bins"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/smoothing/utils.py#L96-L127 | train |
gem/oq-engine | openquake/hmtk/seismicity/smoothing/utils.py | get_even_magnitude_completeness | def get_even_magnitude_completeness(completeness_table, catalogue=None):
'''
To make the magnitudes evenly spaced, render to a constant 0.1
magnitude unit
:param np.ndarray completeness_table:
Completeness table in format [[year, mag]]
:param catalogue:
Instance of openquake.hmtk.s... | python | def get_even_magnitude_completeness(completeness_table, catalogue=None):
'''
To make the magnitudes evenly spaced, render to a constant 0.1
magnitude unit
:param np.ndarray completeness_table:
Completeness table in format [[year, mag]]
:param catalogue:
Instance of openquake.hmtk.s... | [
"def",
"get_even_magnitude_completeness",
"(",
"completeness_table",
",",
"catalogue",
"=",
"None",
")",
":",
"mmax",
"=",
"np",
".",
"floor",
"(",
"10.",
"*",
"np",
".",
"max",
"(",
"catalogue",
".",
"data",
"[",
"'magnitude'",
"]",
")",
")",
"/",
"10."... | To make the magnitudes evenly spaced, render to a constant 0.1
magnitude unit
:param np.ndarray completeness_table:
Completeness table in format [[year, mag]]
:param catalogue:
Instance of openquake.hmtk.seismicity.catalogue.Catalogue class
:returns:
Correct completeness table | [
"To",
"make",
"the",
"magnitudes",
"evenly",
"spaced",
"render",
"to",
"a",
"constant",
"0",
".",
"1",
"magnitude",
"unit"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/smoothing/utils.py#L158-L195 | train |
gem/oq-engine | openquake/commonlib/logictree.py | unique | def unique(objects, key=None):
"""
Raise a ValueError if there is a duplicated object, otherwise
returns the objects as they are.
"""
dupl = []
for obj, group in itertools.groupby(sorted(objects), key):
if sum(1 for _ in group) > 1:
dupl.append(obj)
if dupl:
raise... | python | def unique(objects, key=None):
"""
Raise a ValueError if there is a duplicated object, otherwise
returns the objects as they are.
"""
dupl = []
for obj, group in itertools.groupby(sorted(objects), key):
if sum(1 for _ in group) > 1:
dupl.append(obj)
if dupl:
raise... | [
"def",
"unique",
"(",
"objects",
",",
"key",
"=",
"None",
")",
":",
"dupl",
"=",
"[",
"]",
"for",
"obj",
",",
"group",
"in",
"itertools",
".",
"groupby",
"(",
"sorted",
"(",
"objects",
")",
",",
"key",
")",
":",
"if",
"sum",
"(",
"1",
"for",
"_... | Raise a ValueError if there is a duplicated object, otherwise
returns the objects as they are. | [
"Raise",
"a",
"ValueError",
"if",
"there",
"is",
"a",
"duplicated",
"object",
"otherwise",
"returns",
"the",
"objects",
"as",
"they",
"are",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L60-L71 | train |
gem/oq-engine | openquake/commonlib/logictree.py | sample | def sample(weighted_objects, num_samples, seed):
"""
Take random samples of a sequence of weighted objects
:param weighted_objects:
A finite sequence of objects with a `.weight` attribute.
The weights must sum up to 1.
:param num_samples:
The number of samples to return
:par... | python | def sample(weighted_objects, num_samples, seed):
"""
Take random samples of a sequence of weighted objects
:param weighted_objects:
A finite sequence of objects with a `.weight` attribute.
The weights must sum up to 1.
:param num_samples:
The number of samples to return
:par... | [
"def",
"sample",
"(",
"weighted_objects",
",",
"num_samples",
",",
"seed",
")",
":",
"weights",
"=",
"[",
"]",
"for",
"obj",
"in",
"weighted_objects",
":",
"w",
"=",
"obj",
".",
"weight",
"if",
"isinstance",
"(",
"obj",
".",
"weight",
",",
"float",
")"... | Take random samples of a sequence of weighted objects
:param weighted_objects:
A finite sequence of objects with a `.weight` attribute.
The weights must sum up to 1.
:param num_samples:
The number of samples to return
:param seed:
A random seed
:return:
A subsequ... | [
"Take",
"random",
"samples",
"of",
"a",
"sequence",
"of",
"weighted",
"objects"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L170-L194 | train |
gem/oq-engine | openquake/commonlib/logictree.py | collect_info | def collect_info(smlt):
"""
Given a path to a source model logic tree, collect all of the
path names to the source models it contains and build
1. a dictionary source model branch ID -> paths
2. a dictionary source model branch ID -> source IDs in applyToSources
:param smlt: source model logic ... | python | def collect_info(smlt):
"""
Given a path to a source model logic tree, collect all of the
path names to the source models it contains and build
1. a dictionary source model branch ID -> paths
2. a dictionary source model branch ID -> source IDs in applyToSources
:param smlt: source model logic ... | [
"def",
"collect_info",
"(",
"smlt",
")",
":",
"n",
"=",
"nrml",
".",
"read",
"(",
"smlt",
")",
"try",
":",
"blevels",
"=",
"n",
".",
"logicTree",
"except",
"Exception",
":",
"raise",
"InvalidFile",
"(",
"'%s is not a valid source_model_logic_tree_file'",
"%",
... | Given a path to a source model logic tree, collect all of the
path names to the source models it contains and build
1. a dictionary source model branch ID -> paths
2. a dictionary source model branch ID -> source IDs in applyToSources
:param smlt: source model logic tree file
:returns: an Info name... | [
"Given",
"a",
"path",
"to",
"a",
"source",
"model",
"logic",
"tree",
"collect",
"all",
"of",
"the",
"path",
"names",
"to",
"the",
"source",
"models",
"it",
"contains",
"and",
"build",
"1",
".",
"a",
"dictionary",
"source",
"model",
"branch",
"ID",
"-",
... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L499-L526 | train |
gem/oq-engine | openquake/commonlib/logictree.py | toml | def toml(uncertainty):
"""
Converts an uncertainty node into a TOML string
"""
text = uncertainty.text.strip()
if not text.startswith('['): # a bare GSIM name was passed
text = '[%s]' % text
for k, v in uncertainty.attrib.items():
try:
v = ast.literal_eval(v)
... | python | def toml(uncertainty):
"""
Converts an uncertainty node into a TOML string
"""
text = uncertainty.text.strip()
if not text.startswith('['): # a bare GSIM name was passed
text = '[%s]' % text
for k, v in uncertainty.attrib.items():
try:
v = ast.literal_eval(v)
... | [
"def",
"toml",
"(",
"uncertainty",
")",
":",
"text",
"=",
"uncertainty",
".",
"text",
".",
"strip",
"(",
")",
"if",
"not",
"text",
".",
"startswith",
"(",
"'['",
")",
":",
"# a bare GSIM name was passed",
"text",
"=",
"'[%s]'",
"%",
"text",
"for",
"k",
... | Converts an uncertainty node into a TOML string | [
"Converts",
"an",
"uncertainty",
"node",
"into",
"a",
"TOML",
"string"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L1294-L1307 | train |
gem/oq-engine | openquake/commonlib/logictree.py | LtSourceModel.name | def name(self):
"""
Compact representation for the names
"""
names = self.names.split()
if len(names) == 1:
return names[0]
elif len(names) == 2:
return ' '.join(names)
else:
return ' '.join([names[0], '...', names[-1]]) | python | def name(self):
"""
Compact representation for the names
"""
names = self.names.split()
if len(names) == 1:
return names[0]
elif len(names) == 2:
return ' '.join(names)
else:
return ' '.join([names[0], '...', names[-1]]) | [
"def",
"name",
"(",
"self",
")",
":",
"names",
"=",
"self",
".",
"names",
".",
"split",
"(",
")",
"if",
"len",
"(",
"names",
")",
"==",
"1",
":",
"return",
"names",
"[",
"0",
"]",
"elif",
"len",
"(",
"names",
")",
"==",
"2",
":",
"return",
"'... | Compact representation for the names | [
"Compact",
"representation",
"for",
"the",
"names"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L90-L100 | train |
gem/oq-engine | openquake/commonlib/logictree.py | LtSourceModel.get_skeleton | def get_skeleton(self):
"""
Return an empty copy of the source model, i.e. without sources,
but with the proper attributes for each SourceGroup contained within.
"""
src_groups = []
for grp in self.src_groups:
sg = copy.copy(grp)
sg.sources = []
... | python | def get_skeleton(self):
"""
Return an empty copy of the source model, i.e. without sources,
but with the proper attributes for each SourceGroup contained within.
"""
src_groups = []
for grp in self.src_groups:
sg = copy.copy(grp)
sg.sources = []
... | [
"def",
"get_skeleton",
"(",
"self",
")",
":",
"src_groups",
"=",
"[",
"]",
"for",
"grp",
"in",
"self",
".",
"src_groups",
":",
"sg",
"=",
"copy",
".",
"copy",
"(",
"grp",
")",
"sg",
".",
"sources",
"=",
"[",
"]",
"src_groups",
".",
"append",
"(",
... | Return an empty copy of the source model, i.e. without sources,
but with the proper attributes for each SourceGroup contained within. | [
"Return",
"an",
"empty",
"copy",
"of",
"the",
"source",
"model",
"i",
".",
"e",
".",
"without",
"sources",
"but",
"with",
"the",
"proper",
"attributes",
"for",
"each",
"SourceGroup",
"contained",
"within",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L109-L120 | train |
gem/oq-engine | openquake/commonlib/logictree.py | BranchSet.enumerate_paths | def enumerate_paths(self):
"""
Generate all possible paths starting from this branch set.
:returns:
Generator of two-item tuples. Each tuple contains weight
of the path (calculated as a product of the weights of all path's
branches) and list of path's :class:... | python | def enumerate_paths(self):
"""
Generate all possible paths starting from this branch set.
:returns:
Generator of two-item tuples. Each tuple contains weight
of the path (calculated as a product of the weights of all path's
branches) and list of path's :class:... | [
"def",
"enumerate_paths",
"(",
"self",
")",
":",
"for",
"path",
"in",
"self",
".",
"_enumerate_paths",
"(",
"[",
"]",
")",
":",
"flat_path",
"=",
"[",
"]",
"weight",
"=",
"1.0",
"while",
"path",
":",
"path",
",",
"branch",
"=",
"path",
"weight",
"*="... | Generate all possible paths starting from this branch set.
:returns:
Generator of two-item tuples. Each tuple contains weight
of the path (calculated as a product of the weights of all path's
branches) and list of path's :class:`Branch` objects. Total sum
of all ... | [
"Generate",
"all",
"possible",
"paths",
"starting",
"from",
"this",
"branch",
"set",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L300-L317 | train |
gem/oq-engine | openquake/commonlib/logictree.py | BranchSet.filter_source | def filter_source(self, source):
# pylint: disable=R0911,R0912
"""
Apply filters to ``source`` and return ``True`` if uncertainty should
be applied to it.
"""
for key, value in self.filters.items():
if key == 'applyToTectonicRegionType':
if val... | python | def filter_source(self, source):
# pylint: disable=R0911,R0912
"""
Apply filters to ``source`` and return ``True`` if uncertainty should
be applied to it.
"""
for key, value in self.filters.items():
if key == 'applyToTectonicRegionType':
if val... | [
"def",
"filter_source",
"(",
"self",
",",
"source",
")",
":",
"# pylint: disable=R0911,R0912",
"for",
"key",
",",
"value",
"in",
"self",
".",
"filters",
".",
"items",
"(",
")",
":",
"if",
"key",
"==",
"'applyToTectonicRegionType'",
":",
"if",
"value",
"!=",
... | Apply filters to ``source`` and return ``True`` if uncertainty should
be applied to it. | [
"Apply",
"filters",
"to",
"source",
"and",
"return",
"True",
"if",
"uncertainty",
"should",
"be",
"applied",
"to",
"it",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L343-L379 | train |
gem/oq-engine | openquake/commonlib/logictree.py | BranchSet._apply_uncertainty_to_geometry | def _apply_uncertainty_to_geometry(self, source, value):
"""
Modify ``source`` geometry with the uncertainty value ``value``
"""
if self.uncertainty_type == 'simpleFaultDipRelative':
source.modify('adjust_dip', dict(increment=value))
elif self.uncertainty_type == 'sim... | python | def _apply_uncertainty_to_geometry(self, source, value):
"""
Modify ``source`` geometry with the uncertainty value ``value``
"""
if self.uncertainty_type == 'simpleFaultDipRelative':
source.modify('adjust_dip', dict(increment=value))
elif self.uncertainty_type == 'sim... | [
"def",
"_apply_uncertainty_to_geometry",
"(",
"self",
",",
"source",
",",
"value",
")",
":",
"if",
"self",
".",
"uncertainty_type",
"==",
"'simpleFaultDipRelative'",
":",
"source",
".",
"modify",
"(",
"'adjust_dip'",
",",
"dict",
"(",
"increment",
"=",
"value",
... | Modify ``source`` geometry with the uncertainty value ``value`` | [
"Modify",
"source",
"geometry",
"with",
"the",
"uncertainty",
"value",
"value"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L409-L427 | train |
gem/oq-engine | openquake/commonlib/logictree.py | BranchSet._apply_uncertainty_to_mfd | def _apply_uncertainty_to_mfd(self, mfd, value):
"""
Modify ``mfd`` object with uncertainty value ``value``.
"""
if self.uncertainty_type == 'abGRAbsolute':
a, b = value
mfd.modify('set_ab', dict(a_val=a, b_val=b))
elif self.uncertainty_type == 'bGRRelati... | python | def _apply_uncertainty_to_mfd(self, mfd, value):
"""
Modify ``mfd`` object with uncertainty value ``value``.
"""
if self.uncertainty_type == 'abGRAbsolute':
a, b = value
mfd.modify('set_ab', dict(a_val=a, b_val=b))
elif self.uncertainty_type == 'bGRRelati... | [
"def",
"_apply_uncertainty_to_mfd",
"(",
"self",
",",
"mfd",
",",
"value",
")",
":",
"if",
"self",
".",
"uncertainty_type",
"==",
"'abGRAbsolute'",
":",
"a",
",",
"b",
"=",
"value",
"mfd",
".",
"modify",
"(",
"'set_ab'",
",",
"dict",
"(",
"a_val",
"=",
... | Modify ``mfd`` object with uncertainty value ``value``. | [
"Modify",
"mfd",
"object",
"with",
"uncertainty",
"value",
"value",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L429-L449 | train |
gem/oq-engine | openquake/commonlib/logictree.py | FakeSmlt.gen_source_models | def gen_source_models(self, gsim_lt):
"""
Yield the underlying LtSourceModel, multiple times if there is sampling
"""
num_gsim_paths = 1 if self.num_samples else gsim_lt.get_num_paths()
for i, rlz in enumerate(self):
yield LtSourceModel(
rlz.value, rlz... | python | def gen_source_models(self, gsim_lt):
"""
Yield the underlying LtSourceModel, multiple times if there is sampling
"""
num_gsim_paths = 1 if self.num_samples else gsim_lt.get_num_paths()
for i, rlz in enumerate(self):
yield LtSourceModel(
rlz.value, rlz... | [
"def",
"gen_source_models",
"(",
"self",
",",
"gsim_lt",
")",
":",
"num_gsim_paths",
"=",
"1",
"if",
"self",
".",
"num_samples",
"else",
"gsim_lt",
".",
"get_num_paths",
"(",
")",
"for",
"i",
",",
"rlz",
"in",
"enumerate",
"(",
"self",
")",
":",
"yield",... | Yield the underlying LtSourceModel, multiple times if there is sampling | [
"Yield",
"the",
"underlying",
"LtSourceModel",
"multiple",
"times",
"if",
"there",
"is",
"sampling"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L470-L477 | train |
gem/oq-engine | openquake/commonlib/logictree.py | SourceModelLogicTree.on_each_source | def on_each_source(self):
"""
True if there is an applyToSources for each source.
"""
return (self.info.applytosources and
self.info.applytosources == self.source_ids) | python | def on_each_source(self):
"""
True if there is an applyToSources for each source.
"""
return (self.info.applytosources and
self.info.applytosources == self.source_ids) | [
"def",
"on_each_source",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"info",
".",
"applytosources",
"and",
"self",
".",
"info",
".",
"applytosources",
"==",
"self",
".",
"source_ids",
")"
] | True if there is an applyToSources for each source. | [
"True",
"if",
"there",
"is",
"an",
"applyToSources",
"for",
"each",
"source",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L598-L603 | train |
gem/oq-engine | openquake/commonlib/logictree.py | SourceModelLogicTree.parse_tree | def parse_tree(self, tree_node, validate):
"""
Parse the whole tree and point ``root_branchset`` attribute
to the tree's root.
"""
self.info = collect_info(self.filename)
self.source_ids = collections.defaultdict(list)
t0 = time.time()
for depth, branching... | python | def parse_tree(self, tree_node, validate):
"""
Parse the whole tree and point ``root_branchset`` attribute
to the tree's root.
"""
self.info = collect_info(self.filename)
self.source_ids = collections.defaultdict(list)
t0 = time.time()
for depth, branching... | [
"def",
"parse_tree",
"(",
"self",
",",
"tree_node",
",",
"validate",
")",
":",
"self",
".",
"info",
"=",
"collect_info",
"(",
"self",
".",
"filename",
")",
"self",
".",
"source_ids",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"t0",
"=",
... | Parse the whole tree and point ``root_branchset`` attribute
to the tree's root. | [
"Parse",
"the",
"whole",
"tree",
"and",
"point",
"root_branchset",
"attribute",
"to",
"the",
"tree",
"s",
"root",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L605-L618 | train |
gem/oq-engine | openquake/commonlib/logictree.py | SourceModelLogicTree.parse_branchinglevel | def parse_branchinglevel(self, branchinglevel_node, depth, validate):
"""
Parse one branching level.
:param branchinglevel_node:
``etree.Element`` object with tag "logicTreeBranchingLevel".
:param depth:
The sequential number of this branching level, based on 0.
... | python | def parse_branchinglevel(self, branchinglevel_node, depth, validate):
"""
Parse one branching level.
:param branchinglevel_node:
``etree.Element`` object with tag "logicTreeBranchingLevel".
:param depth:
The sequential number of this branching level, based on 0.
... | [
"def",
"parse_branchinglevel",
"(",
"self",
",",
"branchinglevel_node",
",",
"depth",
",",
"validate",
")",
":",
"new_open_ends",
"=",
"set",
"(",
")",
"branchsets",
"=",
"branchinglevel_node",
".",
"nodes",
"for",
"number",
",",
"branchset_node",
"in",
"enumera... | Parse one branching level.
:param branchinglevel_node:
``etree.Element`` object with tag "logicTreeBranchingLevel".
:param depth:
The sequential number of this branching level, based on 0.
:param validate:
Whether or not the branching level, its branchsets an... | [
"Parse",
"one",
"branching",
"level",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L620-L659 | train |
gem/oq-engine | openquake/commonlib/logictree.py | SourceModelLogicTree.parse_branches | def parse_branches(self, branchset_node, branchset, validate):
"""
Create and attach branches at ``branchset_node`` to ``branchset``.
:param branchset_node:
Same as for :meth:`parse_branchset`.
:param branchset:
An instance of :class:`BranchSet`.
:param v... | python | def parse_branches(self, branchset_node, branchset, validate):
"""
Create and attach branches at ``branchset_node`` to ``branchset``.
:param branchset_node:
Same as for :meth:`parse_branchset`.
:param branchset:
An instance of :class:`BranchSet`.
:param v... | [
"def",
"parse_branches",
"(",
"self",
",",
"branchset_node",
",",
"branchset",
",",
"validate",
")",
":",
"weight_sum",
"=",
"0",
"branches",
"=",
"branchset_node",
".",
"nodes",
"values",
"=",
"[",
"]",
"for",
"branchnode",
"in",
"branches",
":",
"weight",
... | Create and attach branches at ``branchset_node`` to ``branchset``.
:param branchset_node:
Same as for :meth:`parse_branchset`.
:param branchset:
An instance of :class:`BranchSet`.
:param validate:
Whether or not branches' uncertainty values should be validate... | [
"Create",
"and",
"attach",
"branches",
"at",
"branchset_node",
"to",
"branchset",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L690-L749 | train |
gem/oq-engine | openquake/commonlib/logictree.py | SourceModelLogicTree.sample_path | def sample_path(self, seed):
"""
Return the model name and a list of branch ids.
:param seed: the seed used for the sampling
"""
branchset = self.root_branchset
branch_ids = []
while branchset is not None:
[branch] = sample(branchset.branches, 1, seed... | python | def sample_path(self, seed):
"""
Return the model name and a list of branch ids.
:param seed: the seed used for the sampling
"""
branchset = self.root_branchset
branch_ids = []
while branchset is not None:
[branch] = sample(branchset.branches, 1, seed... | [
"def",
"sample_path",
"(",
"self",
",",
"seed",
")",
":",
"branchset",
"=",
"self",
".",
"root_branchset",
"branch_ids",
"=",
"[",
"]",
"while",
"branchset",
"is",
"not",
"None",
":",
"[",
"branch",
"]",
"=",
"sample",
"(",
"branchset",
".",
"branches",
... | Return the model name and a list of branch ids.
:param seed: the seed used for the sampling | [
"Return",
"the",
"model",
"name",
"and",
"a",
"list",
"of",
"branch",
"ids",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L765-L778 | train |
gem/oq-engine | openquake/commonlib/logictree.py | SourceModelLogicTree._parse_simple_fault_geometry_surface | def _parse_simple_fault_geometry_surface(self, node):
"""
Parses a simple fault geometry surface
"""
spacing = node["spacing"]
usd, lsd, dip = (~node.upperSeismoDepth, ~node.lowerSeismoDepth,
~node.dip)
# Parse the geometry
coords = split_... | python | def _parse_simple_fault_geometry_surface(self, node):
"""
Parses a simple fault geometry surface
"""
spacing = node["spacing"]
usd, lsd, dip = (~node.upperSeismoDepth, ~node.lowerSeismoDepth,
~node.dip)
# Parse the geometry
coords = split_... | [
"def",
"_parse_simple_fault_geometry_surface",
"(",
"self",
",",
"node",
")",
":",
"spacing",
"=",
"node",
"[",
"\"spacing\"",
"]",
"usd",
",",
"lsd",
",",
"dip",
"=",
"(",
"~",
"node",
".",
"upperSeismoDepth",
",",
"~",
"node",
".",
"lowerSeismoDepth",
",... | Parses a simple fault geometry surface | [
"Parses",
"a",
"simple",
"fault",
"geometry",
"surface"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L850-L860 | train |
gem/oq-engine | openquake/commonlib/logictree.py | SourceModelLogicTree._parse_complex_fault_geometry_surface | def _parse_complex_fault_geometry_surface(self, node):
"""
Parses a complex fault geometry surface
"""
spacing = node["spacing"]
edges = []
for edge_node in node.nodes:
coords = split_coords_3d(~edge_node.LineString.posList)
edges.append(geo.Line([... | python | def _parse_complex_fault_geometry_surface(self, node):
"""
Parses a complex fault geometry surface
"""
spacing = node["spacing"]
edges = []
for edge_node in node.nodes:
coords = split_coords_3d(~edge_node.LineString.posList)
edges.append(geo.Line([... | [
"def",
"_parse_complex_fault_geometry_surface",
"(",
"self",
",",
"node",
")",
":",
"spacing",
"=",
"node",
"[",
"\"spacing\"",
"]",
"edges",
"=",
"[",
"]",
"for",
"edge_node",
"in",
"node",
".",
"nodes",
":",
"coords",
"=",
"split_coords_3d",
"(",
"~",
"e... | Parses a complex fault geometry surface | [
"Parses",
"a",
"complex",
"fault",
"geometry",
"surface"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L862-L871 | train |
gem/oq-engine | openquake/commonlib/logictree.py | SourceModelLogicTree._parse_planar_geometry_surface | def _parse_planar_geometry_surface(self, node):
"""
Parses a planar geometry surface
"""
nodes = []
for key in ["topLeft", "topRight", "bottomRight", "bottomLeft"]:
nodes.append(geo.Point(getattr(node, key)["lon"],
getattr(node, key)... | python | def _parse_planar_geometry_surface(self, node):
"""
Parses a planar geometry surface
"""
nodes = []
for key in ["topLeft", "topRight", "bottomRight", "bottomLeft"]:
nodes.append(geo.Point(getattr(node, key)["lon"],
getattr(node, key)... | [
"def",
"_parse_planar_geometry_surface",
"(",
"self",
",",
"node",
")",
":",
"nodes",
"=",
"[",
"]",
"for",
"key",
"in",
"[",
"\"topLeft\"",
",",
"\"topRight\"",
",",
"\"bottomRight\"",
",",
"\"bottomLeft\"",
"]",
":",
"nodes",
".",
"append",
"(",
"geo",
"... | Parses a planar geometry surface | [
"Parses",
"a",
"planar",
"geometry",
"surface"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L873-L884 | train |
gem/oq-engine | openquake/commonlib/logictree.py | SourceModelLogicTree._validate_simple_fault_geometry | def _validate_simple_fault_geometry(self, node, _float_re):
"""
Validates a node representation of a simple fault geometry
"""
try:
# Parse the geometry
coords = split_coords_2d(~node.LineString.posList)
trace = geo.Line([geo.Point(*p) for p in coords]... | python | def _validate_simple_fault_geometry(self, node, _float_re):
"""
Validates a node representation of a simple fault geometry
"""
try:
# Parse the geometry
coords = split_coords_2d(~node.LineString.posList)
trace = geo.Line([geo.Point(*p) for p in coords]... | [
"def",
"_validate_simple_fault_geometry",
"(",
"self",
",",
"node",
",",
"_float_re",
")",
":",
"try",
":",
"# Parse the geometry",
"coords",
"=",
"split_coords_2d",
"(",
"~",
"node",
".",
"LineString",
".",
"posList",
")",
"trace",
"=",
"geo",
".",
"Line",
... | Validates a node representation of a simple fault geometry | [
"Validates",
"a",
"node",
"representation",
"of",
"a",
"simple",
"fault",
"geometry"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L948-L966 | train |
gem/oq-engine | openquake/commonlib/logictree.py | SourceModelLogicTree._validate_complex_fault_geometry | def _validate_complex_fault_geometry(self, node, _float_re):
"""
Validates a node representation of a complex fault geometry - this
check merely verifies that the format is correct. If the geometry
does not conform to the Aki & Richards convention this will not be
verified here, ... | python | def _validate_complex_fault_geometry(self, node, _float_re):
"""
Validates a node representation of a complex fault geometry - this
check merely verifies that the format is correct. If the geometry
does not conform to the Aki & Richards convention this will not be
verified here, ... | [
"def",
"_validate_complex_fault_geometry",
"(",
"self",
",",
"node",
",",
"_float_re",
")",
":",
"valid_edges",
"=",
"[",
"]",
"for",
"edge_node",
"in",
"node",
".",
"nodes",
":",
"try",
":",
"coords",
"=",
"split_coords_3d",
"(",
"edge_node",
".",
"LineStri... | Validates a node representation of a complex fault geometry - this
check merely verifies that the format is correct. If the geometry
does not conform to the Aki & Richards convention this will not be
verified here, but will raise an error when the surface is created. | [
"Validates",
"a",
"node",
"representation",
"of",
"a",
"complex",
"fault",
"geometry",
"-",
"this",
"check",
"merely",
"verifies",
"that",
"the",
"format",
"is",
"correct",
".",
"If",
"the",
"geometry",
"does",
"not",
"conform",
"to",
"the",
"Aki",
"&",
"R... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L968-L992 | train |
gem/oq-engine | openquake/commonlib/logictree.py | SourceModelLogicTree._validate_planar_fault_geometry | def _validate_planar_fault_geometry(self, node, _float_re):
"""
Validares a node representation of a planar fault geometry
"""
valid_spacing = node["spacing"]
for key in ["topLeft", "topRight", "bottomLeft", "bottomRight"]:
lon = getattr(node, key)["lon"]
... | python | def _validate_planar_fault_geometry(self, node, _float_re):
"""
Validares a node representation of a planar fault geometry
"""
valid_spacing = node["spacing"]
for key in ["topLeft", "topRight", "bottomLeft", "bottomRight"]:
lon = getattr(node, key)["lon"]
... | [
"def",
"_validate_planar_fault_geometry",
"(",
"self",
",",
"node",
",",
"_float_re",
")",
":",
"valid_spacing",
"=",
"node",
"[",
"\"spacing\"",
"]",
"for",
"key",
"in",
"[",
"\"topLeft\"",
",",
"\"topRight\"",
",",
"\"bottomLeft\"",
",",
"\"bottomRight\"",
"]"... | Validares a node representation of a planar fault geometry | [
"Validares",
"a",
"node",
"representation",
"of",
"a",
"planar",
"fault",
"geometry"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L994-L1010 | train |
gem/oq-engine | openquake/commonlib/logictree.py | SourceModelLogicTree.apply_uncertainties | def apply_uncertainties(self, branch_ids, source_group):
"""
Parse the path through the source model logic tree and return
"apply uncertainties" function.
:param branch_ids:
List of string identifiers of branches, representing the path
through source model logic ... | python | def apply_uncertainties(self, branch_ids, source_group):
"""
Parse the path through the source model logic tree and return
"apply uncertainties" function.
:param branch_ids:
List of string identifiers of branches, representing the path
through source model logic ... | [
"def",
"apply_uncertainties",
"(",
"self",
",",
"branch_ids",
",",
"source_group",
")",
":",
"branchset",
"=",
"self",
".",
"root_branchset",
"branchsets_and_uncertainties",
"=",
"[",
"]",
"branch_ids",
"=",
"list",
"(",
"branch_ids",
"[",
":",
":",
"-",
"1",
... | Parse the path through the source model logic tree and return
"apply uncertainties" function.
:param branch_ids:
List of string identifiers of branches, representing the path
through source model logic tree.
:param source_group:
A group of sources
:re... | [
"Parse",
"the",
"path",
"through",
"the",
"source",
"model",
"logic",
"tree",
"and",
"return",
"apply",
"uncertainties",
"function",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L1178-L1214 | train |
gem/oq-engine | openquake/commonlib/logictree.py | ImtWeight.is_one | def is_one(self):
"""
Check that all the inner weights are 1 up to the precision
"""
return all(abs(v - 1.) < pmf.PRECISION for v in self.dic.values()) | python | def is_one(self):
"""
Check that all the inner weights are 1 up to the precision
"""
return all(abs(v - 1.) < pmf.PRECISION for v in self.dic.values()) | [
"def",
"is_one",
"(",
"self",
")",
":",
"return",
"all",
"(",
"abs",
"(",
"v",
"-",
"1.",
")",
"<",
"pmf",
".",
"PRECISION",
"for",
"v",
"in",
"self",
".",
"dic",
".",
"values",
"(",
")",
")"
] | Check that all the inner weights are 1 up to the precision | [
"Check",
"that",
"all",
"the",
"inner",
"weights",
"are",
"1",
"up",
"to",
"the",
"precision"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L1278-L1282 | train |
gem/oq-engine | openquake/commonlib/logictree.py | GsimLogicTree.from_ | def from_(cls, gsim):
"""
Generate a trivial GsimLogicTree from a single GSIM instance.
"""
ltbranch = N('logicTreeBranch', {'branchID': 'b1'},
nodes=[N('uncertaintyModel', text=str(gsim)),
N('uncertaintyWeight', text='1.0')])
lt =... | python | def from_(cls, gsim):
"""
Generate a trivial GsimLogicTree from a single GSIM instance.
"""
ltbranch = N('logicTreeBranch', {'branchID': 'b1'},
nodes=[N('uncertaintyModel', text=str(gsim)),
N('uncertaintyWeight', text='1.0')])
lt =... | [
"def",
"from_",
"(",
"cls",
",",
"gsim",
")",
":",
"ltbranch",
"=",
"N",
"(",
"'logicTreeBranch'",
",",
"{",
"'branchID'",
":",
"'b1'",
"}",
",",
"nodes",
"=",
"[",
"N",
"(",
"'uncertaintyModel'",
",",
"text",
"=",
"str",
"(",
"gsim",
")",
")",
","... | Generate a trivial GsimLogicTree from a single GSIM instance. | [
"Generate",
"a",
"trivial",
"GsimLogicTree",
"from",
"a",
"single",
"GSIM",
"instance",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L1328-L1342 | train |
gem/oq-engine | openquake/commonlib/logictree.py | GsimLogicTree.check_imts | def check_imts(self, imts):
"""
Make sure the IMTs are recognized by all GSIMs in the logic tree
"""
for trt in self.values:
for gsim in self.values[trt]:
for attr in dir(gsim):
coeffs = getattr(gsim, attr)
if not isinst... | python | def check_imts(self, imts):
"""
Make sure the IMTs are recognized by all GSIMs in the logic tree
"""
for trt in self.values:
for gsim in self.values[trt]:
for attr in dir(gsim):
coeffs = getattr(gsim, attr)
if not isinst... | [
"def",
"check_imts",
"(",
"self",
",",
"imts",
")",
":",
"for",
"trt",
"in",
"self",
".",
"values",
":",
"for",
"gsim",
"in",
"self",
".",
"values",
"[",
"trt",
"]",
":",
"for",
"attr",
"in",
"dir",
"(",
"gsim",
")",
":",
"coeffs",
"=",
"getattr"... | Make sure the IMTs are recognized by all GSIMs in the logic tree | [
"Make",
"sure",
"the",
"IMTs",
"are",
"recognized",
"by",
"all",
"GSIMs",
"in",
"the",
"logic",
"tree"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L1365-L1382 | train |
gem/oq-engine | openquake/commonlib/logictree.py | GsimLogicTree.reduce | def reduce(self, trts):
"""
Reduce the GsimLogicTree.
:param trts: a subset of tectonic region types
:returns: a reduced GsimLogicTree instance
"""
new = object.__new__(self.__class__)
vars(new).update(vars(self))
if trts != {'*'}:
new.branche... | python | def reduce(self, trts):
"""
Reduce the GsimLogicTree.
:param trts: a subset of tectonic region types
:returns: a reduced GsimLogicTree instance
"""
new = object.__new__(self.__class__)
vars(new).update(vars(self))
if trts != {'*'}:
new.branche... | [
"def",
"reduce",
"(",
"self",
",",
"trts",
")",
":",
"new",
"=",
"object",
".",
"__new__",
"(",
"self",
".",
"__class__",
")",
"vars",
"(",
"new",
")",
".",
"update",
"(",
"vars",
"(",
"self",
")",
")",
"if",
"trts",
"!=",
"{",
"'*'",
"}",
":",... | Reduce the GsimLogicTree.
:param trts: a subset of tectonic region types
:returns: a reduced GsimLogicTree instance | [
"Reduce",
"the",
"GsimLogicTree",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L1432-L1447 | train |
gem/oq-engine | openquake/commonlib/logictree.py | GsimLogicTree.get_num_branches | def get_num_branches(self):
"""
Return the number of effective branches for tectonic region type,
as a dictionary.
"""
num = {}
for trt, branches in itertools.groupby(
self.branches, operator.attrgetter('trt')):
num[trt] = sum(1 for br in branc... | python | def get_num_branches(self):
"""
Return the number of effective branches for tectonic region type,
as a dictionary.
"""
num = {}
for trt, branches in itertools.groupby(
self.branches, operator.attrgetter('trt')):
num[trt] = sum(1 for br in branc... | [
"def",
"get_num_branches",
"(",
"self",
")",
":",
"num",
"=",
"{",
"}",
"for",
"trt",
",",
"branches",
"in",
"itertools",
".",
"groupby",
"(",
"self",
".",
"branches",
",",
"operator",
".",
"attrgetter",
"(",
"'trt'",
")",
")",
":",
"num",
"[",
"trt"... | Return the number of effective branches for tectonic region type,
as a dictionary. | [
"Return",
"the",
"number",
"of",
"effective",
"branches",
"for",
"tectonic",
"region",
"type",
"as",
"a",
"dictionary",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L1449-L1458 | train |
gem/oq-engine | openquake/commonlib/logictree.py | GsimLogicTree.get_num_paths | def get_num_paths(self):
"""
Return the effective number of paths in the tree.
"""
# NB: the algorithm assume a symmetric logic tree for the GSIMs;
# in the future we may relax such assumption
num_branches = self.get_num_branches()
if not sum(num_branches.values()... | python | def get_num_paths(self):
"""
Return the effective number of paths in the tree.
"""
# NB: the algorithm assume a symmetric logic tree for the GSIMs;
# in the future we may relax such assumption
num_branches = self.get_num_branches()
if not sum(num_branches.values()... | [
"def",
"get_num_paths",
"(",
"self",
")",
":",
"# NB: the algorithm assume a symmetric logic tree for the GSIMs;",
"# in the future we may relax such assumption",
"num_branches",
"=",
"self",
".",
"get_num_branches",
"(",
")",
"if",
"not",
"sum",
"(",
"num_branches",
".",
"... | Return the effective number of paths in the tree. | [
"Return",
"the",
"effective",
"number",
"of",
"paths",
"in",
"the",
"tree",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logictree.py#L1460-L1473 | train |
gem/oq-engine | openquake/hazardlib/gsim/campbell_2003.py | _compute_faulting_style_term | def _compute_faulting_style_term(Frss, pR, Fnss, pN, rake):
"""
Compute SHARE faulting style adjustment term.
"""
if rake > 30.0 and rake <= 150.0:
return np.power(Frss, 1 - pR) * np.power(Fnss, -pN)
elif rake > -120.0 and rake <= -60.0:
return np.power(Frss, - pR) * np.power(Fnss, 1... | python | def _compute_faulting_style_term(Frss, pR, Fnss, pN, rake):
"""
Compute SHARE faulting style adjustment term.
"""
if rake > 30.0 and rake <= 150.0:
return np.power(Frss, 1 - pR) * np.power(Fnss, -pN)
elif rake > -120.0 and rake <= -60.0:
return np.power(Frss, - pR) * np.power(Fnss, 1... | [
"def",
"_compute_faulting_style_term",
"(",
"Frss",
",",
"pR",
",",
"Fnss",
",",
"pN",
",",
"rake",
")",
":",
"if",
"rake",
">",
"30.0",
"and",
"rake",
"<=",
"150.0",
":",
"return",
"np",
".",
"power",
"(",
"Frss",
",",
"1",
"-",
"pR",
")",
"*",
... | Compute SHARE faulting style adjustment term. | [
"Compute",
"SHARE",
"faulting",
"style",
"adjustment",
"term",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_2003.py#L242-L251 | train |
gem/oq-engine | openquake/hazardlib/gsim/campbell_2003.py | Campbell2003._get_stddevs | def _get_stddevs(self, C, stddev_types, mag, num_sites):
"""
Return total standard deviation as for equation 35, page 1021.
"""
stddevs = []
for _ in stddev_types:
if mag < 7.16:
sigma = C['c11'] + C['c12'] * mag
elif mag >= 7.16:
... | python | def _get_stddevs(self, C, stddev_types, mag, num_sites):
"""
Return total standard deviation as for equation 35, page 1021.
"""
stddevs = []
for _ in stddev_types:
if mag < 7.16:
sigma = C['c11'] + C['c12'] * mag
elif mag >= 7.16:
... | [
"def",
"_get_stddevs",
"(",
"self",
",",
"C",
",",
"stddev_types",
",",
"mag",
",",
"num_sites",
")",
":",
"stddevs",
"=",
"[",
"]",
"for",
"_",
"in",
"stddev_types",
":",
"if",
"mag",
"<",
"7.16",
":",
"sigma",
"=",
"C",
"[",
"'c11'",
"]",
"+",
... | Return total standard deviation as for equation 35, page 1021. | [
"Return",
"total",
"standard",
"deviation",
"as",
"for",
"equation",
"35",
"page",
"1021",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_2003.py#L106-L118 | train |
gem/oq-engine | openquake/hazardlib/gsim/campbell_2003.py | Campbell2003._compute_term2 | def _compute_term2(self, C, mag, rrup):
"""
This computes the term f2 in equation 32, page 1021
"""
c78_factor = (C['c7'] * np.exp(C['c8'] * mag)) ** 2
R = np.sqrt(rrup ** 2 + c78_factor)
return C['c4'] * np.log(R) + (C['c5'] + C['c6'] * mag) * rrup | python | def _compute_term2(self, C, mag, rrup):
"""
This computes the term f2 in equation 32, page 1021
"""
c78_factor = (C['c7'] * np.exp(C['c8'] * mag)) ** 2
R = np.sqrt(rrup ** 2 + c78_factor)
return C['c4'] * np.log(R) + (C['c5'] + C['c6'] * mag) * rrup | [
"def",
"_compute_term2",
"(",
"self",
",",
"C",
",",
"mag",
",",
"rrup",
")",
":",
"c78_factor",
"=",
"(",
"C",
"[",
"'c7'",
"]",
"*",
"np",
".",
"exp",
"(",
"C",
"[",
"'c8'",
"]",
"*",
"mag",
")",
")",
"**",
"2",
"R",
"=",
"np",
".",
"sqrt... | This computes the term f2 in equation 32, page 1021 | [
"This",
"computes",
"the",
"term",
"f2",
"in",
"equation",
"32",
"page",
"1021"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_2003.py#L126-L133 | train |
gem/oq-engine | openquake/hazardlib/gsim/campbell_2003.py | Campbell2003._compute_term3 | def _compute_term3(self, C, rrup):
"""
This computes the term f3 in equation 34, page 1021 but corrected
according to the erratum.
"""
f3 = np.zeros_like(rrup)
idx_between_70_130 = (rrup > 70) & (rrup <= 130)
idx_greater_130 = rrup > 130
f3[idx_between_7... | python | def _compute_term3(self, C, rrup):
"""
This computes the term f3 in equation 34, page 1021 but corrected
according to the erratum.
"""
f3 = np.zeros_like(rrup)
idx_between_70_130 = (rrup > 70) & (rrup <= 130)
idx_greater_130 = rrup > 130
f3[idx_between_7... | [
"def",
"_compute_term3",
"(",
"self",
",",
"C",
",",
"rrup",
")",
":",
"f3",
"=",
"np",
".",
"zeros_like",
"(",
"rrup",
")",
"idx_between_70_130",
"=",
"(",
"rrup",
">",
"70",
")",
"&",
"(",
"rrup",
"<=",
"130",
")",
"idx_greater_130",
"=",
"rrup",
... | This computes the term f3 in equation 34, page 1021 but corrected
according to the erratum. | [
"This",
"computes",
"the",
"term",
"f3",
"in",
"equation",
"34",
"page",
"1021",
"but",
"corrected",
"according",
"to",
"the",
"erratum",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_2003.py#L135-L154 | train |
gem/oq-engine | openquake/hmtk/seismicity/declusterer/distance_time_windows.py | time_window_cutoff | def time_window_cutoff(sw_time, time_cutoff):
"""
Allows for cutting the declustering time window at a specific time, outside
of which an event of any magnitude is no longer identified as a cluster
"""
sw_time = np.array(
[(time_cutoff / DAYS) if x > (time_cutoff / DAYS)
else x f... | python | def time_window_cutoff(sw_time, time_cutoff):
"""
Allows for cutting the declustering time window at a specific time, outside
of which an event of any magnitude is no longer identified as a cluster
"""
sw_time = np.array(
[(time_cutoff / DAYS) if x > (time_cutoff / DAYS)
else x f... | [
"def",
"time_window_cutoff",
"(",
"sw_time",
",",
"time_cutoff",
")",
":",
"sw_time",
"=",
"np",
".",
"array",
"(",
"[",
"(",
"time_cutoff",
"/",
"DAYS",
")",
"if",
"x",
">",
"(",
"time_cutoff",
"/",
"DAYS",
")",
"else",
"x",
"for",
"x",
"in",
"sw_ti... | Allows for cutting the declustering time window at a specific time, outside
of which an event of any magnitude is no longer identified as a cluster | [
"Allows",
"for",
"cutting",
"the",
"declustering",
"time",
"window",
"at",
"a",
"specific",
"time",
"outside",
"of",
"which",
"an",
"event",
"of",
"any",
"magnitude",
"is",
"no",
"longer",
"identified",
"as",
"a",
"cluster"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/declusterer/distance_time_windows.py#L59-L67 | train |
gem/oq-engine | openquake/hmtk/sources/point_source.py | mtkPointSource.create_geometry | def create_geometry(self, input_geometry, upper_depth, lower_depth):
'''
If geometry is defined as a numpy array then create instance of
nhlib.geo.point.Point class, otherwise if already instance of class
accept class
:param input_geometry:
Input geometry (point) as ... | python | def create_geometry(self, input_geometry, upper_depth, lower_depth):
'''
If geometry is defined as a numpy array then create instance of
nhlib.geo.point.Point class, otherwise if already instance of class
accept class
:param input_geometry:
Input geometry (point) as ... | [
"def",
"create_geometry",
"(",
"self",
",",
"input_geometry",
",",
"upper_depth",
",",
"lower_depth",
")",
":",
"self",
".",
"_check_seismogenic_depths",
"(",
"upper_depth",
",",
"lower_depth",
")",
"# Check/create the geometry class",
"if",
"not",
"isinstance",
"(",
... | If geometry is defined as a numpy array then create instance of
nhlib.geo.point.Point class, otherwise if already instance of class
accept class
:param input_geometry:
Input geometry (point) as either
i) instance of nhlib.geo.point.Point class
ii) numpy.ndarr... | [
"If",
"geometry",
"is",
"defined",
"as",
"a",
"numpy",
"array",
"then",
"create",
"instance",
"of",
"nhlib",
".",
"geo",
".",
"point",
".",
"Point",
"class",
"otherwise",
"if",
"already",
"instance",
"of",
"class",
"accept",
"class"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/sources/point_source.py#L115-L141 | train |
gem/oq-engine | openquake/hmtk/sources/point_source.py | mtkPointSource.select_catalogue | def select_catalogue(self, selector, distance, selector_type='circle',
distance_metric='epicentral', point_depth=None,
upper_eq_depth=None, lower_eq_depth=None):
'''
Selects the catalogue associated to the point source.
Effectively a wrapper to t... | python | def select_catalogue(self, selector, distance, selector_type='circle',
distance_metric='epicentral', point_depth=None,
upper_eq_depth=None, lower_eq_depth=None):
'''
Selects the catalogue associated to the point source.
Effectively a wrapper to t... | [
"def",
"select_catalogue",
"(",
"self",
",",
"selector",
",",
"distance",
",",
"selector_type",
"=",
"'circle'",
",",
"distance_metric",
"=",
"'epicentral'",
",",
"point_depth",
"=",
"None",
",",
"upper_eq_depth",
"=",
"None",
",",
"lower_eq_depth",
"=",
"None",... | Selects the catalogue associated to the point source.
Effectively a wrapper to the two functions select catalogue within
a distance of the point and select catalogue within cell centred on
point
:param selector:
Populated instance of :class:
`openquake.hmtk.seism... | [
"Selects",
"the",
"catalogue",
"associated",
"to",
"the",
"point",
"source",
".",
"Effectively",
"a",
"wrapper",
"to",
"the",
"two",
"functions",
"select",
"catalogue",
"within",
"a",
"distance",
"of",
"the",
"point",
"and",
"select",
"catalogue",
"within",
"c... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/sources/point_source.py#L170-L213 | train |
gem/oq-engine | openquake/commands/plot.py | plot | def plot(what, calc_id=-1, other_id=None, webapi=False):
"""
Generic plotter for local and remote calculations.
"""
if '?' not in what:
raise SystemExit('Missing ? in %r' % what)
prefix, rest = what.split('?', 1)
assert prefix in 'source_geom hcurves hmaps uhs', prefix
if prefix in '... | python | def plot(what, calc_id=-1, other_id=None, webapi=False):
"""
Generic plotter for local and remote calculations.
"""
if '?' not in what:
raise SystemExit('Missing ? in %r' % what)
prefix, rest = what.split('?', 1)
assert prefix in 'source_geom hcurves hmaps uhs', prefix
if prefix in '... | [
"def",
"plot",
"(",
"what",
",",
"calc_id",
"=",
"-",
"1",
",",
"other_id",
"=",
"None",
",",
"webapi",
"=",
"False",
")",
":",
"if",
"'?'",
"not",
"in",
"what",
":",
"raise",
"SystemExit",
"(",
"'Missing ? in %r'",
"%",
"what",
")",
"prefix",
",",
... | Generic plotter for local and remote calculations. | [
"Generic",
"plotter",
"for",
"local",
"and",
"remote",
"calculations",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/plot.py#L144-L168 | train |
gem/oq-engine | openquake/hazardlib/gsim/multi.py | MultiGMPE.get_mean_and_stddevs | def get_mean_and_stddevs(self, sctx, rctx, dctx, imt, stddev_types):
"""
Call the get mean and stddevs of the GMPE for the respective IMT
"""
return self.kwargs[str(imt)].get_mean_and_stddevs(
sctx, rctx, dctx, imt, stddev_types) | python | def get_mean_and_stddevs(self, sctx, rctx, dctx, imt, stddev_types):
"""
Call the get mean and stddevs of the GMPE for the respective IMT
"""
return self.kwargs[str(imt)].get_mean_and_stddevs(
sctx, rctx, dctx, imt, stddev_types) | [
"def",
"get_mean_and_stddevs",
"(",
"self",
",",
"sctx",
",",
"rctx",
",",
"dctx",
",",
"imt",
",",
"stddev_types",
")",
":",
"return",
"self",
".",
"kwargs",
"[",
"str",
"(",
"imt",
")",
"]",
".",
"get_mean_and_stddevs",
"(",
"sctx",
",",
"rctx",
",",... | Call the get mean and stddevs of the GMPE for the respective IMT | [
"Call",
"the",
"get",
"mean",
"and",
"stddevs",
"of",
"the",
"GMPE",
"for",
"the",
"respective",
"IMT"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/multi.py#L97-L102 | train |
gem/oq-engine | openquake/commands/plot_agg_curve.py | plot_ac | def plot_ac(calc_id):
"""
Aggregate loss curves plotter.
"""
# read the hazard data
dstore = util.read(calc_id)
agg_curve = dstore['agg_curve-rlzs']
plt = make_figure(agg_curve)
plt.show() | python | def plot_ac(calc_id):
"""
Aggregate loss curves plotter.
"""
# read the hazard data
dstore = util.read(calc_id)
agg_curve = dstore['agg_curve-rlzs']
plt = make_figure(agg_curve)
plt.show() | [
"def",
"plot_ac",
"(",
"calc_id",
")",
":",
"# read the hazard data",
"dstore",
"=",
"util",
".",
"read",
"(",
"calc_id",
")",
"agg_curve",
"=",
"dstore",
"[",
"'agg_curve-rlzs'",
"]",
"plt",
"=",
"make_figure",
"(",
"agg_curve",
")",
"plt",
".",
"show",
"... | Aggregate loss curves plotter. | [
"Aggregate",
"loss",
"curves",
"plotter",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/plot_agg_curve.py#L42-L50 | train |
gem/oq-engine | openquake/hazardlib/gsim/allen_2012_ipe.py | AllenEtAl2012._get_stddevs | def _get_stddevs(self, C, distance, stddev_types):
"""
Returns the total standard deviation, which is a function of distance
"""
stddevs = []
for stddev_type in stddev_types:
assert stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
if stddev_type ==... | python | def _get_stddevs(self, C, distance, stddev_types):
"""
Returns the total standard deviation, which is a function of distance
"""
stddevs = []
for stddev_type in stddev_types:
assert stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
if stddev_type ==... | [
"def",
"_get_stddevs",
"(",
"self",
",",
"C",
",",
"distance",
",",
"stddev_types",
")",
":",
"stddevs",
"=",
"[",
"]",
"for",
"stddev_type",
"in",
"stddev_types",
":",
"assert",
"stddev_type",
"in",
"self",
".",
"DEFINED_FOR_STANDARD_DEVIATION_TYPES",
"if",
"... | Returns the total standard deviation, which is a function of distance | [
"Returns",
"the",
"total",
"standard",
"deviation",
"which",
"is",
"a",
"function",
"of",
"distance"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/allen_2012_ipe.py#L92-L103 | train |
gem/oq-engine | openquake/hazardlib/gsim/allen_2012.py | Allen2012._compute_mean | def _compute_mean(self, C, mag, rrup):
"""
Compute mean value according to equation 18, page 32.
"""
# see table 3, page 14
R1 = 90.
R2 = 150.
# see equation 19, page 32
m_ref = mag - 4
r1 = R1 + C['c8'] * m_ref
r2 = R2 + C['c11'] * m_ref
... | python | def _compute_mean(self, C, mag, rrup):
"""
Compute mean value according to equation 18, page 32.
"""
# see table 3, page 14
R1 = 90.
R2 = 150.
# see equation 19, page 32
m_ref = mag - 4
r1 = R1 + C['c8'] * m_ref
r2 = R2 + C['c11'] * m_ref
... | [
"def",
"_compute_mean",
"(",
"self",
",",
"C",
",",
"mag",
",",
"rrup",
")",
":",
"# see table 3, page 14",
"R1",
"=",
"90.",
"R2",
"=",
"150.",
"# see equation 19, page 32",
"m_ref",
"=",
"mag",
"-",
"4",
"r1",
"=",
"R1",
"+",
"C",
"[",
"'c8'",
"]",
... | Compute mean value according to equation 18, page 32. | [
"Compute",
"mean",
"value",
"according",
"to",
"equation",
"18",
"page",
"32",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/allen_2012.py#L93-L120 | train |
gem/oq-engine | openquake/commands/extract.py | extract | def extract(what, calc_id, webapi=True):
"""
Extract an output from the datastore and save it into an .hdf5 file.
By default uses the WebAPI, otherwise the extraction is done locally.
"""
with performance.Monitor('extract', measuremem=True) as mon:
if webapi:
obj = WebExtractor(c... | python | def extract(what, calc_id, webapi=True):
"""
Extract an output from the datastore and save it into an .hdf5 file.
By default uses the WebAPI, otherwise the extraction is done locally.
"""
with performance.Monitor('extract', measuremem=True) as mon:
if webapi:
obj = WebExtractor(c... | [
"def",
"extract",
"(",
"what",
",",
"calc_id",
",",
"webapi",
"=",
"True",
")",
":",
"with",
"performance",
".",
"Monitor",
"(",
"'extract'",
",",
"measuremem",
"=",
"True",
")",
"as",
"mon",
":",
"if",
"webapi",
":",
"obj",
"=",
"WebExtractor",
"(",
... | Extract an output from the datastore and save it into an .hdf5 file.
By default uses the WebAPI, otherwise the extraction is done locally. | [
"Extract",
"an",
"output",
"from",
"the",
"datastore",
"and",
"save",
"it",
"into",
"an",
".",
"hdf5",
"file",
".",
"By",
"default",
"uses",
"the",
"WebAPI",
"otherwise",
"the",
"extraction",
"is",
"done",
"locally",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/extract.py#L24-L39 | train |
gem/oq-engine | openquake/hmtk/strain/regionalisation/kreemer_regionalisation.py | KreemerRegionalisation.get_regionalisation | def get_regionalisation(self, strain_model):
'''
Gets the tectonic region type for every element inside the strain model
:paramm strain_model:
Input strain model as instance of
openquake.hmtk.strain.geodetic_strain.GeodeticStrain
:returns:
Strain mo... | python | def get_regionalisation(self, strain_model):
'''
Gets the tectonic region type for every element inside the strain model
:paramm strain_model:
Input strain model as instance of
openquake.hmtk.strain.geodetic_strain.GeodeticStrain
:returns:
Strain mo... | [
"def",
"get_regionalisation",
"(",
"self",
",",
"strain_model",
")",
":",
"self",
".",
"strain",
"=",
"strain_model",
"self",
".",
"strain",
".",
"data",
"[",
"'region'",
"]",
"=",
"np",
".",
"array",
"(",
"[",
"'IPL'",
"for",
"_",
"in",
"range",
"(",
... | Gets the tectonic region type for every element inside the strain model
:paramm strain_model:
Input strain model as instance of
openquake.hmtk.strain.geodetic_strain.GeodeticStrain
:returns:
Strain model with complete regionalisation | [
"Gets",
"the",
"tectonic",
"region",
"type",
"for",
"every",
"element",
"inside",
"the",
"strain",
"model"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/strain/regionalisation/kreemer_regionalisation.py#L100-L124 | train |
gem/oq-engine | openquake/hmtk/strain/regionalisation/kreemer_regionalisation.py | KreemerRegionalisation.define_kreemer_regionalisation | def define_kreemer_regionalisation(self, north=90., south=-90., east=180.,
west=-180.):
'''
Applies the regionalisation defined according to the regionalisation
typology of Corne Kreemer
'''
'''Applies the regionalisation of Kreemer (2003)
... | python | def define_kreemer_regionalisation(self, north=90., south=-90., east=180.,
west=-180.):
'''
Applies the regionalisation defined according to the regionalisation
typology of Corne Kreemer
'''
'''Applies the regionalisation of Kreemer (2003)
... | [
"def",
"define_kreemer_regionalisation",
"(",
"self",
",",
"north",
"=",
"90.",
",",
"south",
"=",
"-",
"90.",
",",
"east",
"=",
"180.",
",",
"west",
"=",
"-",
"180.",
")",
":",
"'''Applies the regionalisation of Kreemer (2003)\n :param input_file:\n ... | Applies the regionalisation defined according to the regionalisation
typology of Corne Kreemer | [
"Applies",
"the",
"regionalisation",
"defined",
"according",
"to",
"the",
"regionalisation",
"typology",
"of",
"Corne",
"Kreemer"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/strain/regionalisation/kreemer_regionalisation.py#L153-L204 | train |
gem/oq-engine | openquake/hazardlib/shakemap.py | urlextract | def urlextract(url, fname):
"""
Download and unzip an archive and extract the underlying fname
"""
with urlopen(url) as f:
data = io.BytesIO(f.read())
with zipfile.ZipFile(data) as z:
try:
return z.open(fname)
except KeyError:
# for instance the ShakeM... | python | def urlextract(url, fname):
"""
Download and unzip an archive and extract the underlying fname
"""
with urlopen(url) as f:
data = io.BytesIO(f.read())
with zipfile.ZipFile(data) as z:
try:
return z.open(fname)
except KeyError:
# for instance the ShakeM... | [
"def",
"urlextract",
"(",
"url",
",",
"fname",
")",
":",
"with",
"urlopen",
"(",
"url",
")",
"as",
"f",
":",
"data",
"=",
"io",
".",
"BytesIO",
"(",
"f",
".",
"read",
"(",
")",
")",
"with",
"zipfile",
".",
"ZipFile",
"(",
"data",
")",
"as",
"z"... | Download and unzip an archive and extract the underlying fname | [
"Download",
"and",
"unzip",
"an",
"archive",
"and",
"extract",
"the",
"underlying",
"fname"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/shakemap.py#L46-L64 | train |
gem/oq-engine | openquake/hazardlib/shakemap.py | amplify_gmfs | def amplify_gmfs(imts, vs30s, gmfs):
"""
Amplify the ground shaking depending on the vs30s
"""
n = len(vs30s)
out = [amplify_ground_shaking(im.period, vs30s[i], gmfs[m * n + i])
for m, im in enumerate(imts) for i in range(n)]
return numpy.array(out) | python | def amplify_gmfs(imts, vs30s, gmfs):
"""
Amplify the ground shaking depending on the vs30s
"""
n = len(vs30s)
out = [amplify_ground_shaking(im.period, vs30s[i], gmfs[m * n + i])
for m, im in enumerate(imts) for i in range(n)]
return numpy.array(out) | [
"def",
"amplify_gmfs",
"(",
"imts",
",",
"vs30s",
",",
"gmfs",
")",
":",
"n",
"=",
"len",
"(",
"vs30s",
")",
"out",
"=",
"[",
"amplify_ground_shaking",
"(",
"im",
".",
"period",
",",
"vs30s",
"[",
"i",
"]",
",",
"gmfs",
"[",
"m",
"*",
"n",
"+",
... | Amplify the ground shaking depending on the vs30s | [
"Amplify",
"the",
"ground",
"shaking",
"depending",
"on",
"the",
"vs30s"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/shakemap.py#L220-L227 | train |
gem/oq-engine | openquake/hazardlib/shakemap.py | cholesky | def cholesky(spatial_cov, cross_corr):
"""
Decompose the spatial covariance and cross correlation matrices.
:param spatial_cov: array of shape (M, N, N)
:param cross_corr: array of shape (M, M)
:returns: a triangular matrix of shape (M * N, M * N)
"""
M, N = spatial_cov.shape[:2]
L = nu... | python | def cholesky(spatial_cov, cross_corr):
"""
Decompose the spatial covariance and cross correlation matrices.
:param spatial_cov: array of shape (M, N, N)
:param cross_corr: array of shape (M, M)
:returns: a triangular matrix of shape (M * N, M * N)
"""
M, N = spatial_cov.shape[:2]
L = nu... | [
"def",
"cholesky",
"(",
"spatial_cov",
",",
"cross_corr",
")",
":",
"M",
",",
"N",
"=",
"spatial_cov",
".",
"shape",
"[",
":",
"2",
"]",
"L",
"=",
"numpy",
".",
"array",
"(",
"[",
"numpy",
".",
"linalg",
".",
"cholesky",
"(",
"spatial_cov",
"[",
"i... | Decompose the spatial covariance and cross correlation matrices.
:param spatial_cov: array of shape (M, N, N)
:param cross_corr: array of shape (M, M)
:returns: a triangular matrix of shape (M * N, M * N) | [
"Decompose",
"the",
"spatial",
"covariance",
"and",
"cross",
"correlation",
"matrices",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/shakemap.py#L257-L275 | train |
gem/oq-engine | openquake/commonlib/writers.py | build_header | def build_header(dtype):
"""
Convert a numpy nested dtype into a list of strings suitable as header
of csv file.
>>> imt_dt = numpy.dtype([('PGA', numpy.float32, 3),
... ('PGV', numpy.float32, 4)])
>>> build_header(imt_dt)
['PGA:3', 'PGV:4']
>>> gmf_dt = numpy.dtyp... | python | def build_header(dtype):
"""
Convert a numpy nested dtype into a list of strings suitable as header
of csv file.
>>> imt_dt = numpy.dtype([('PGA', numpy.float32, 3),
... ('PGV', numpy.float32, 4)])
>>> build_header(imt_dt)
['PGA:3', 'PGV:4']
>>> gmf_dt = numpy.dtyp... | [
"def",
"build_header",
"(",
"dtype",
")",
":",
"header",
"=",
"_build_header",
"(",
"dtype",
",",
"(",
")",
")",
"h",
"=",
"[",
"]",
"for",
"col",
"in",
"header",
":",
"name",
"=",
"'~'",
".",
"join",
"(",
"col",
"[",
":",
"-",
"2",
"]",
")",
... | Convert a numpy nested dtype into a list of strings suitable as header
of csv file.
>>> imt_dt = numpy.dtype([('PGA', numpy.float32, 3),
... ('PGV', numpy.float32, 4)])
>>> build_header(imt_dt)
['PGA:3', 'PGV:4']
>>> gmf_dt = numpy.dtype([('A', imt_dt), ('B', imt_dt),
... | [
"Convert",
"a",
"numpy",
"nested",
"dtype",
"into",
"a",
"list",
"of",
"strings",
"suitable",
"as",
"header",
"of",
"csv",
"file",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/writers.py#L143-L169 | train |
gem/oq-engine | openquake/commonlib/writers.py | read_composite_array | def read_composite_array(fname, sep=','):
r"""
Convert a CSV file with header into an ArrayWrapper object.
>>> from openquake.baselib.general import gettemp
>>> fname = gettemp('PGA:3,PGV:2,avg:1\n'
... '.1 .2 .3,.4 .5,.6\n')
>>> print(read_composite_array(fname).array) # arra... | python | def read_composite_array(fname, sep=','):
r"""
Convert a CSV file with header into an ArrayWrapper object.
>>> from openquake.baselib.general import gettemp
>>> fname = gettemp('PGA:3,PGV:2,avg:1\n'
... '.1 .2 .3,.4 .5,.6\n')
>>> print(read_composite_array(fname).array) # arra... | [
"def",
"read_composite_array",
"(",
"fname",
",",
"sep",
"=",
"','",
")",
":",
"with",
"open",
"(",
"fname",
")",
"as",
"f",
":",
"header",
"=",
"next",
"(",
"f",
")",
"if",
"header",
".",
"startswith",
"(",
"'#'",
")",
":",
"# the first line is a comm... | r"""
Convert a CSV file with header into an ArrayWrapper object.
>>> from openquake.baselib.general import gettemp
>>> fname = gettemp('PGA:3,PGV:2,avg:1\n'
... '.1 .2 .3,.4 .5,.6\n')
>>> print(read_composite_array(fname).array) # array of shape (1,)
[([0.1, 0.2, 0.3], [0.4, 0... | [
"r",
"Convert",
"a",
"CSV",
"file",
"with",
"header",
"into",
"an",
"ArrayWrapper",
"object",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/writers.py#L368-L412 | train |
gem/oq-engine | openquake/commonlib/writers.py | read_array | def read_array(fname, sep=','):
r"""
Convert a CSV file without header into a numpy array of floats.
>>> from openquake.baselib.general import gettemp
>>> print(read_array(gettemp('.1 .2, .3 .4, .5 .6\n')))
[[[0.1 0.2]
[0.3 0.4]
[0.5 0.6]]]
"""
with open(fname) as f:
rec... | python | def read_array(fname, sep=','):
r"""
Convert a CSV file without header into a numpy array of floats.
>>> from openquake.baselib.general import gettemp
>>> print(read_array(gettemp('.1 .2, .3 .4, .5 .6\n')))
[[[0.1 0.2]
[0.3 0.4]
[0.5 0.6]]]
"""
with open(fname) as f:
rec... | [
"def",
"read_array",
"(",
"fname",
",",
"sep",
"=",
"','",
")",
":",
"with",
"open",
"(",
"fname",
")",
"as",
"f",
":",
"records",
"=",
"[",
"]",
"for",
"line",
"in",
"f",
":",
"row",
"=",
"line",
".",
"split",
"(",
"sep",
")",
"record",
"=",
... | r"""
Convert a CSV file without header into a numpy array of floats.
>>> from openquake.baselib.general import gettemp
>>> print(read_array(gettemp('.1 .2, .3 .4, .5 .6\n')))
[[[0.1 0.2]
[0.3 0.4]
[0.5 0.6]]] | [
"r",
"Convert",
"a",
"CSV",
"file",
"without",
"header",
"into",
"a",
"numpy",
"array",
"of",
"floats",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/writers.py#L416-L432 | train |
gem/oq-engine | openquake/commonlib/writers.py | HeaderTranslator.read | def read(self, names):
"""
Convert names into descriptions
"""
descrs = []
for name in names:
mo = re.match(self.short_regex, name)
if mo:
idx = mo.lastindex # matching group index, starting from 1
suffix = self.suffix[idx ... | python | def read(self, names):
"""
Convert names into descriptions
"""
descrs = []
for name in names:
mo = re.match(self.short_regex, name)
if mo:
idx = mo.lastindex # matching group index, starting from 1
suffix = self.suffix[idx ... | [
"def",
"read",
"(",
"self",
",",
"names",
")",
":",
"descrs",
"=",
"[",
"]",
"for",
"name",
"in",
"names",
":",
"mo",
"=",
"re",
".",
"match",
"(",
"self",
".",
"short_regex",
",",
"name",
")",
"if",
"mo",
":",
"idx",
"=",
"mo",
".",
"lastindex... | Convert names into descriptions | [
"Convert",
"names",
"into",
"descriptions"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/writers.py#L58-L72 | train |
gem/oq-engine | openquake/commonlib/writers.py | HeaderTranslator.write | def write(self, descrs):
"""
Convert descriptions into names
"""
# example: '(poe-[\d\.]+):float32' -> 'poe-[\d\.]+'
names = []
for descr in descrs:
mo = re.match(self.long_regex, descr)
if mo:
names.append(mo.group(mo.lastindex) + ... | python | def write(self, descrs):
"""
Convert descriptions into names
"""
# example: '(poe-[\d\.]+):float32' -> 'poe-[\d\.]+'
names = []
for descr in descrs:
mo = re.match(self.long_regex, descr)
if mo:
names.append(mo.group(mo.lastindex) + ... | [
"def",
"write",
"(",
"self",
",",
"descrs",
")",
":",
"# example: '(poe-[\\d\\.]+):float32' -> 'poe-[\\d\\.]+'",
"names",
"=",
"[",
"]",
"for",
"descr",
"in",
"descrs",
":",
"mo",
"=",
"re",
".",
"match",
"(",
"self",
".",
"long_regex",
",",
"descr",
")",
... | Convert descriptions into names | [
"Convert",
"descriptions",
"into",
"names"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/writers.py#L74-L86 | train |
gem/oq-engine | openquake/commonlib/writers.py | CsvWriter.save | def save(self, data, fname, header=None):
"""
Save data on fname.
:param data: numpy array or list of lists
:param fname: path name
:param header: header to use
"""
write_csv(fname, data, self.sep, self.fmt, header)
self.fnames.add(getattr(fname, 'name', ... | python | def save(self, data, fname, header=None):
"""
Save data on fname.
:param data: numpy array or list of lists
:param fname: path name
:param header: header to use
"""
write_csv(fname, data, self.sep, self.fmt, header)
self.fnames.add(getattr(fname, 'name', ... | [
"def",
"save",
"(",
"self",
",",
"data",
",",
"fname",
",",
"header",
"=",
"None",
")",
":",
"write_csv",
"(",
"fname",
",",
"data",
",",
"self",
".",
"sep",
",",
"self",
".",
"fmt",
",",
"header",
")",
"self",
".",
"fnames",
".",
"add",
"(",
"... | Save data on fname.
:param data: numpy array or list of lists
:param fname: path name
:param header: header to use | [
"Save",
"data",
"on",
"fname",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/writers.py#L265-L274 | train |
gem/oq-engine | openquake/commonlib/writers.py | CsvWriter.save_block | def save_block(self, data, dest):
"""
Save data on dest, which is file open in 'a' mode
"""
write_csv(dest, data, self.sep, self.fmt, 'no-header') | python | def save_block(self, data, dest):
"""
Save data on dest, which is file open in 'a' mode
"""
write_csv(dest, data, self.sep, self.fmt, 'no-header') | [
"def",
"save_block",
"(",
"self",
",",
"data",
",",
"dest",
")",
":",
"write_csv",
"(",
"dest",
",",
"data",
",",
"self",
".",
"sep",
",",
"self",
".",
"fmt",
",",
"'no-header'",
")"
] | Save data on dest, which is file open in 'a' mode | [
"Save",
"data",
"on",
"dest",
"which",
"is",
"file",
"open",
"in",
"a",
"mode"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/writers.py#L276-L280 | train |
gem/oq-engine | openquake/hazardlib/gsim/raghukanth_iyengar_2007.py | RaghukanthIyengar2007._get_site_coeffs | def _get_site_coeffs(self, sites, imt):
"""
Extracts correct coefficients for each site from Table 5 on p. 208
for each site.
:raises UserWarning:
If vs30 is below limit for site class D, since "E- and F-type
sites [...] are susceptible for liquefaction and failu... | python | def _get_site_coeffs(self, sites, imt):
"""
Extracts correct coefficients for each site from Table 5 on p. 208
for each site.
:raises UserWarning:
If vs30 is below limit for site class D, since "E- and F-type
sites [...] are susceptible for liquefaction and failu... | [
"def",
"_get_site_coeffs",
"(",
"self",
",",
"sites",
",",
"imt",
")",
":",
"site_classes",
"=",
"self",
".",
"get_nehrp_classes",
"(",
"sites",
")",
"is_bedrock",
"=",
"self",
".",
"is_bedrock",
"(",
"sites",
")",
"if",
"'E'",
"in",
"site_classes",
":",
... | Extracts correct coefficients for each site from Table 5 on p. 208
for each site.
:raises UserWarning:
If vs30 is below limit for site class D, since "E- and F-type
sites [...] are susceptible for liquefaction and failure." p. 205. | [
"Extracts",
"correct",
"coefficients",
"for",
"each",
"site",
"from",
"Table",
"5",
"on",
"p",
".",
"208",
"for",
"each",
"site",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/raghukanth_iyengar_2007.py#L204-L235 | train |
gem/oq-engine | openquake/hazardlib/gsim/raghukanth_iyengar_2007.py | RaghukanthIyengar2007.get_nehrp_classes | def get_nehrp_classes(self, sites):
"""
Site classification threshholds from Section 4 "Site correction
coefficients" p. 205. Note that site classes E and F are not
supported.
"""
classes = sorted(self.NEHRP_VS30_UPPER_BOUNDS.keys())
bounds = [self.NEHRP_VS30_UPP... | python | def get_nehrp_classes(self, sites):
"""
Site classification threshholds from Section 4 "Site correction
coefficients" p. 205. Note that site classes E and F are not
supported.
"""
classes = sorted(self.NEHRP_VS30_UPPER_BOUNDS.keys())
bounds = [self.NEHRP_VS30_UPP... | [
"def",
"get_nehrp_classes",
"(",
"self",
",",
"sites",
")",
":",
"classes",
"=",
"sorted",
"(",
"self",
".",
"NEHRP_VS30_UPPER_BOUNDS",
".",
"keys",
"(",
")",
")",
"bounds",
"=",
"[",
"self",
".",
"NEHRP_VS30_UPPER_BOUNDS",
"[",
"item",
"]",
"for",
"item",... | Site classification threshholds from Section 4 "Site correction
coefficients" p. 205. Note that site classes E and F are not
supported. | [
"Site",
"classification",
"threshholds",
"from",
"Section",
"4",
"Site",
"correction",
"coefficients",
"p",
".",
"205",
".",
"Note",
"that",
"site",
"classes",
"E",
"and",
"F",
"are",
"not",
"supported",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/raghukanth_iyengar_2007.py#L246-L259 | train |
gem/oq-engine | openquake/server/utils.py | get_valid_users | def get_valid_users(request):
""""
Returns a list of `users` based on groups membership.
Returns a list made of a single user when it is not member of any group.
"""
users = [get_user(request)]
if settings.LOCKDOWN and hasattr(request, 'user'):
if request.user.is_authenticated:
... | python | def get_valid_users(request):
""""
Returns a list of `users` based on groups membership.
Returns a list made of a single user when it is not member of any group.
"""
users = [get_user(request)]
if settings.LOCKDOWN and hasattr(request, 'user'):
if request.user.is_authenticated:
... | [
"def",
"get_valid_users",
"(",
"request",
")",
":",
"users",
"=",
"[",
"get_user",
"(",
"request",
")",
"]",
"if",
"settings",
".",
"LOCKDOWN",
"and",
"hasattr",
"(",
"request",
",",
"'user'",
")",
":",
"if",
"request",
".",
"user",
".",
"is_authenticate... | Returns a list of `users` based on groups membership.
Returns a list made of a single user when it is not member of any group. | [
"Returns",
"a",
"list",
"of",
"users",
"based",
"on",
"groups",
"membership",
".",
"Returns",
"a",
"list",
"made",
"of",
"a",
"single",
"user",
"when",
"it",
"is",
"not",
"member",
"of",
"any",
"group",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/utils.py#L50-L65 | train |
gem/oq-engine | openquake/server/utils.py | get_acl_on | def get_acl_on(request):
"""
Returns `True` if ACL should be honorated, returns otherwise `False`.
"""
acl_on = settings.ACL_ON
if settings.LOCKDOWN and hasattr(request, 'user'):
# ACL is always disabled for superusers
if request.user.is_superuser:
acl_on = False
retu... | python | def get_acl_on(request):
"""
Returns `True` if ACL should be honorated, returns otherwise `False`.
"""
acl_on = settings.ACL_ON
if settings.LOCKDOWN and hasattr(request, 'user'):
# ACL is always disabled for superusers
if request.user.is_superuser:
acl_on = False
retu... | [
"def",
"get_acl_on",
"(",
"request",
")",
":",
"acl_on",
"=",
"settings",
".",
"ACL_ON",
"if",
"settings",
".",
"LOCKDOWN",
"and",
"hasattr",
"(",
"request",
",",
"'user'",
")",
":",
"# ACL is always disabled for superusers",
"if",
"request",
".",
"user",
".",... | Returns `True` if ACL should be honorated, returns otherwise `False`. | [
"Returns",
"True",
"if",
"ACL",
"should",
"be",
"honorated",
"returns",
"otherwise",
"False",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/utils.py#L68-L77 | train |
gem/oq-engine | openquake/server/utils.py | oq_server_context_processor | def oq_server_context_processor(request):
"""
A custom context processor which allows injection of additional
context variables.
"""
context = {}
context['oq_engine_server_url'] = ('//' +
request.META.get('HTTP_HOST',
... | python | def oq_server_context_processor(request):
"""
A custom context processor which allows injection of additional
context variables.
"""
context = {}
context['oq_engine_server_url'] = ('//' +
request.META.get('HTTP_HOST',
... | [
"def",
"oq_server_context_processor",
"(",
"request",
")",
":",
"context",
"=",
"{",
"}",
"context",
"[",
"'oq_engine_server_url'",
"]",
"=",
"(",
"'//'",
"+",
"request",
".",
"META",
".",
"get",
"(",
"'HTTP_HOST'",
",",
"'localhost:8800'",
")",
")",
"# this... | A custom context processor which allows injection of additional
context variables. | [
"A",
"custom",
"context",
"processor",
"which",
"allows",
"injection",
"of",
"additional",
"context",
"variables",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/utils.py#L88-L103 | train |
gem/oq-engine | openquake/server/utils.py | check_webserver_running | def check_webserver_running(url="http://localhost:8800", max_retries=30):
"""
Returns True if a given URL is responding within a given timeout.
"""
retry = 0
response = ''
success = False
while response != requests.codes.ok and retry < max_retries:
try:
response = reque... | python | def check_webserver_running(url="http://localhost:8800", max_retries=30):
"""
Returns True if a given URL is responding within a given timeout.
"""
retry = 0
response = ''
success = False
while response != requests.codes.ok and retry < max_retries:
try:
response = reque... | [
"def",
"check_webserver_running",
"(",
"url",
"=",
"\"http://localhost:8800\"",
",",
"max_retries",
"=",
"30",
")",
":",
"retry",
"=",
"0",
"response",
"=",
"''",
"success",
"=",
"False",
"while",
"response",
"!=",
"requests",
".",
"codes",
".",
"ok",
"and",... | Returns True if a given URL is responding within a given timeout. | [
"Returns",
"True",
"if",
"a",
"given",
"URL",
"is",
"responding",
"within",
"a",
"given",
"timeout",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/utils.py#L106-L127 | train |
gem/oq-engine | openquake/calculators/export/__init__.py | export_csv | def export_csv(ekey, dstore):
"""
Default csv exporter for arrays stored in the output.hdf5 file
:param ekey: export key
:param dstore: datastore object
:returns: a list with the path of the exported file
"""
name = ekey[0] + '.csv'
try:
array = dstore[ekey[0]].value
except ... | python | def export_csv(ekey, dstore):
"""
Default csv exporter for arrays stored in the output.hdf5 file
:param ekey: export key
:param dstore: datastore object
:returns: a list with the path of the exported file
"""
name = ekey[0] + '.csv'
try:
array = dstore[ekey[0]].value
except ... | [
"def",
"export_csv",
"(",
"ekey",
",",
"dstore",
")",
":",
"name",
"=",
"ekey",
"[",
"0",
"]",
"+",
"'.csv'",
"try",
":",
"array",
"=",
"dstore",
"[",
"ekey",
"[",
"0",
"]",
"]",
".",
"value",
"except",
"AttributeError",
":",
"# this happens if the key... | Default csv exporter for arrays stored in the output.hdf5 file
:param ekey: export key
:param dstore: datastore object
:returns: a list with the path of the exported file | [
"Default",
"csv",
"exporter",
"for",
"arrays",
"stored",
"in",
"the",
"output",
".",
"hdf5",
"file"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/export/__init__.py#L28-L44 | train |
gem/oq-engine | openquake/calculators/export/__init__.py | export_input_zip | def export_input_zip(ekey, dstore):
"""
Export the data in the `input_zip` dataset as a .zip file
"""
dest = dstore.export_path('input.zip')
nbytes = dstore.get_attr('input/zip', 'nbytes')
zbytes = dstore['input/zip'].value
# when reading input_zip some terminating null bytes are truncated (... | python | def export_input_zip(ekey, dstore):
"""
Export the data in the `input_zip` dataset as a .zip file
"""
dest = dstore.export_path('input.zip')
nbytes = dstore.get_attr('input/zip', 'nbytes')
zbytes = dstore['input/zip'].value
# when reading input_zip some terminating null bytes are truncated (... | [
"def",
"export_input_zip",
"(",
"ekey",
",",
"dstore",
")",
":",
"dest",
"=",
"dstore",
".",
"export_path",
"(",
"'input.zip'",
")",
"nbytes",
"=",
"dstore",
".",
"get_attr",
"(",
"'input/zip'",
",",
"'nbytes'",
")",
"zbytes",
"=",
"dstore",
"[",
"'input/z... | Export the data in the `input_zip` dataset as a .zip file | [
"Export",
"the",
"data",
"in",
"the",
"input_zip",
"dataset",
"as",
"a",
".",
"zip",
"file"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/export/__init__.py#L68-L79 | train |
gem/oq-engine | openquake/hmtk/parsers/source_model/nrml04_parser.py | node_to_point_geometry | def node_to_point_geometry(node):
"""
Reads the node and returns the point geometry, upper depth and lower depth
"""
assert "pointGeometry" in node.tag
for subnode in node.nodes:
if "Point" in subnode.tag:
# Position
lon, lat = map(float, subnode.nodes[0].text.split()... | python | def node_to_point_geometry(node):
"""
Reads the node and returns the point geometry, upper depth and lower depth
"""
assert "pointGeometry" in node.tag
for subnode in node.nodes:
if "Point" in subnode.tag:
# Position
lon, lat = map(float, subnode.nodes[0].text.split()... | [
"def",
"node_to_point_geometry",
"(",
"node",
")",
":",
"assert",
"\"pointGeometry\"",
"in",
"node",
".",
"tag",
"for",
"subnode",
"in",
"node",
".",
"nodes",
":",
"if",
"\"Point\"",
"in",
"subnode",
".",
"tag",
":",
"# Position",
"lon",
",",
"lat",
"=",
... | Reads the node and returns the point geometry, upper depth and lower depth | [
"Reads",
"the",
"node",
"and",
"returns",
"the",
"point",
"geometry",
"upper",
"depth",
"and",
"lower",
"depth"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/source_model/nrml04_parser.py#L125-L143 | train |
gem/oq-engine | openquake/hmtk/parsers/source_model/nrml04_parser.py | node_to_area_geometry | def node_to_area_geometry(node):
"""
Reads an area geometry node and returns the polygon, upper depth and lower
depth
"""
assert "areaGeometry" in node.tag
for subnode in node.nodes:
if "Polygon" in subnode.tag:
crds = [float(x)
for x in subnode.nodes[0].n... | python | def node_to_area_geometry(node):
"""
Reads an area geometry node and returns the polygon, upper depth and lower
depth
"""
assert "areaGeometry" in node.tag
for subnode in node.nodes:
if "Polygon" in subnode.tag:
crds = [float(x)
for x in subnode.nodes[0].n... | [
"def",
"node_to_area_geometry",
"(",
"node",
")",
":",
"assert",
"\"areaGeometry\"",
"in",
"node",
".",
"tag",
"for",
"subnode",
"in",
"node",
".",
"nodes",
":",
"if",
"\"Polygon\"",
"in",
"subnode",
".",
"tag",
":",
"crds",
"=",
"[",
"float",
"(",
"x",
... | Reads an area geometry node and returns the polygon, upper depth and lower
depth | [
"Reads",
"an",
"area",
"geometry",
"node",
"and",
"returns",
"the",
"polygon",
"upper",
"depth",
"and",
"lower",
"depth"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/source_model/nrml04_parser.py#L146-L166 | train |
gem/oq-engine | openquake/hmtk/parsers/source_model/nrml04_parser.py | node_to_simple_fault_geometry | def node_to_simple_fault_geometry(node):
"""
Reads a simple fault geometry node and returns an OpenQuake representation
:returns:
trace - Trace of fault as instance
"""
assert "simpleFaultGeometry" in node.tag
for subnode in node.nodes:
if "LineString" in subnode.tag:
... | python | def node_to_simple_fault_geometry(node):
"""
Reads a simple fault geometry node and returns an OpenQuake representation
:returns:
trace - Trace of fault as instance
"""
assert "simpleFaultGeometry" in node.tag
for subnode in node.nodes:
if "LineString" in subnode.tag:
... | [
"def",
"node_to_simple_fault_geometry",
"(",
"node",
")",
":",
"assert",
"\"simpleFaultGeometry\"",
"in",
"node",
".",
"tag",
"for",
"subnode",
"in",
"node",
".",
"nodes",
":",
"if",
"\"LineString\"",
"in",
"subnode",
".",
"tag",
":",
"trace",
"=",
"linestring... | Reads a simple fault geometry node and returns an OpenQuake representation
:returns:
trace - Trace of fault as instance | [
"Reads",
"a",
"simple",
"fault",
"geometry",
"node",
"and",
"returns",
"an",
"OpenQuake",
"representation"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/source_model/nrml04_parser.py#L169-L190 | train |
gem/oq-engine | openquake/hmtk/parsers/source_model/nrml04_parser.py | node_to_complex_fault_geometry | def node_to_complex_fault_geometry(node):
"""
Reads a complex fault geometry node and returns an
"""
assert "complexFaultGeometry" in node.tag
intermediate_edges = []
for subnode in node.nodes:
if "faultTopEdge" in subnode.tag:
top_edge = linestring_node_to_line(subnode.nodes... | python | def node_to_complex_fault_geometry(node):
"""
Reads a complex fault geometry node and returns an
"""
assert "complexFaultGeometry" in node.tag
intermediate_edges = []
for subnode in node.nodes:
if "faultTopEdge" in subnode.tag:
top_edge = linestring_node_to_line(subnode.nodes... | [
"def",
"node_to_complex_fault_geometry",
"(",
"node",
")",
":",
"assert",
"\"complexFaultGeometry\"",
"in",
"node",
".",
"tag",
"intermediate_edges",
"=",
"[",
"]",
"for",
"subnode",
"in",
"node",
".",
"nodes",
":",
"if",
"\"faultTopEdge\"",
"in",
"subnode",
"."... | Reads a complex fault geometry node and returns an | [
"Reads",
"a",
"complex",
"fault",
"geometry",
"node",
"and",
"returns",
"an"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/source_model/nrml04_parser.py#L193-L213 | train |
gem/oq-engine | openquake/hmtk/parsers/source_model/nrml04_parser.py | node_to_mfd | def node_to_mfd(node, taglist):
"""
Reads the node to return a magnitude frequency distribution
"""
if "incrementalMFD" in taglist:
mfd = node_to_evenly_discretized(
node.nodes[taglist.index("incrementalMFD")])
elif "truncGutenbergRichterMFD" in taglist:
mfd = node_to_tru... | python | def node_to_mfd(node, taglist):
"""
Reads the node to return a magnitude frequency distribution
"""
if "incrementalMFD" in taglist:
mfd = node_to_evenly_discretized(
node.nodes[taglist.index("incrementalMFD")])
elif "truncGutenbergRichterMFD" in taglist:
mfd = node_to_tru... | [
"def",
"node_to_mfd",
"(",
"node",
",",
"taglist",
")",
":",
"if",
"\"incrementalMFD\"",
"in",
"taglist",
":",
"mfd",
"=",
"node_to_evenly_discretized",
"(",
"node",
".",
"nodes",
"[",
"taglist",
".",
"index",
"(",
"\"incrementalMFD\"",
")",
"]",
")",
"elif"... | Reads the node to return a magnitude frequency distribution | [
"Reads",
"the",
"node",
"to",
"return",
"a",
"magnitude",
"frequency",
"distribution"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/source_model/nrml04_parser.py#L259-L271 | train |
gem/oq-engine | openquake/hmtk/parsers/source_model/nrml04_parser.py | node_to_nodal_planes | def node_to_nodal_planes(node):
"""
Parses the nodal plane distribution to a PMF
"""
if not len(node):
return None
npd_pmf = []
for plane in node.nodes:
if not all(plane.attrib[key] for key in plane.attrib):
# One plane fails - return None
return None
... | python | def node_to_nodal_planes(node):
"""
Parses the nodal plane distribution to a PMF
"""
if not len(node):
return None
npd_pmf = []
for plane in node.nodes:
if not all(plane.attrib[key] for key in plane.attrib):
# One plane fails - return None
return None
... | [
"def",
"node_to_nodal_planes",
"(",
"node",
")",
":",
"if",
"not",
"len",
"(",
"node",
")",
":",
"return",
"None",
"npd_pmf",
"=",
"[",
"]",
"for",
"plane",
"in",
"node",
".",
"nodes",
":",
"if",
"not",
"all",
"(",
"plane",
".",
"attrib",
"[",
"key... | Parses the nodal plane distribution to a PMF | [
"Parses",
"the",
"nodal",
"plane",
"distribution",
"to",
"a",
"PMF"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/source_model/nrml04_parser.py#L274-L289 | train |
gem/oq-engine | openquake/hmtk/parsers/source_model/nrml04_parser.py | node_to_hdd | def node_to_hdd(node):
"""
Parses the node to a hpyocentral depth distribution PMF
"""
if not len(node):
return None
hdds = []
for subnode in node.nodes:
if not all([subnode.attrib[key] for key in ["depth", "probability"]]):
return None
hdds.append((float(subn... | python | def node_to_hdd(node):
"""
Parses the node to a hpyocentral depth distribution PMF
"""
if not len(node):
return None
hdds = []
for subnode in node.nodes:
if not all([subnode.attrib[key] for key in ["depth", "probability"]]):
return None
hdds.append((float(subn... | [
"def",
"node_to_hdd",
"(",
"node",
")",
":",
"if",
"not",
"len",
"(",
"node",
")",
":",
"return",
"None",
"hdds",
"=",
"[",
"]",
"for",
"subnode",
"in",
"node",
".",
"nodes",
":",
"if",
"not",
"all",
"(",
"[",
"subnode",
".",
"attrib",
"[",
"key"... | Parses the node to a hpyocentral depth distribution PMF | [
"Parses",
"the",
"node",
"to",
"a",
"hpyocentral",
"depth",
"distribution",
"PMF"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/source_model/nrml04_parser.py#L292-L304 | train |
gem/oq-engine | openquake/hazardlib/gsim/atkinson_boore_2003.py | AtkinsonBoore2003SInter._compute_mean | def _compute_mean(self, C, g, mag, hypo_depth, rrup, vs30, pga_rock, imt):
"""
Compute mean according to equation 1, page 1706.
"""
if hypo_depth > 100:
hypo_depth = 100
delta = 0.00724 * 10 ** (0.507 * mag)
R = np.sqrt(rrup ** 2 + delta ** 2)
s_amp =... | python | def _compute_mean(self, C, g, mag, hypo_depth, rrup, vs30, pga_rock, imt):
"""
Compute mean according to equation 1, page 1706.
"""
if hypo_depth > 100:
hypo_depth = 100
delta = 0.00724 * 10 ** (0.507 * mag)
R = np.sqrt(rrup ** 2 + delta ** 2)
s_amp =... | [
"def",
"_compute_mean",
"(",
"self",
",",
"C",
",",
"g",
",",
"mag",
",",
"hypo_depth",
",",
"rrup",
",",
"vs30",
",",
"pga_rock",
",",
"imt",
")",
":",
"if",
"hypo_depth",
">",
"100",
":",
"hypo_depth",
"=",
"100",
"delta",
"=",
"0.00724",
"*",
"1... | Compute mean according to equation 1, page 1706. | [
"Compute",
"mean",
"according",
"to",
"equation",
"1",
"page",
"1706",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/atkinson_boore_2003.py#L149-L173 | train |
gem/oq-engine | openquake/hazardlib/gsim/atkinson_boore_2003.py | AtkinsonBoore2003SInter._compute_soil_linear_factor | def _compute_soil_linear_factor(cls, pga_rock, imt):
"""
Compute soil linear factor as explained in paragraph 'Functional
Form', page 1706.
"""
if imt.period >= 1:
return np.ones_like(pga_rock)
else:
sl = np.zeros_like(pga_rock)
pga_be... | python | def _compute_soil_linear_factor(cls, pga_rock, imt):
"""
Compute soil linear factor as explained in paragraph 'Functional
Form', page 1706.
"""
if imt.period >= 1:
return np.ones_like(pga_rock)
else:
sl = np.zeros_like(pga_rock)
pga_be... | [
"def",
"_compute_soil_linear_factor",
"(",
"cls",
",",
"pga_rock",
",",
"imt",
")",
":",
"if",
"imt",
".",
"period",
">=",
"1",
":",
"return",
"np",
".",
"ones_like",
"(",
"pga_rock",
")",
"else",
":",
"sl",
"=",
"np",
".",
"zeros_like",
"(",
"pga_rock... | Compute soil linear factor as explained in paragraph 'Functional
Form', page 1706. | [
"Compute",
"soil",
"linear",
"factor",
"as",
"explained",
"in",
"paragraph",
"Functional",
"Form",
"page",
"1706",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/atkinson_boore_2003.py#L203-L232 | train |
gem/oq-engine | openquake/hazardlib/gsim/mcverry_2006.py | McVerry2006Asc._get_stddevs | def _get_stddevs(self, C, mag, stddev_types, sites):
"""
Return standard deviation as defined on page 29 in
equation 8a,b,c and 9.
"""
num_sites = sites.vs30.size
sigma_intra = np.zeros(num_sites)
# interevent stddev
tau = sigma_intra + C['tau']
... | python | def _get_stddevs(self, C, mag, stddev_types, sites):
"""
Return standard deviation as defined on page 29 in
equation 8a,b,c and 9.
"""
num_sites = sites.vs30.size
sigma_intra = np.zeros(num_sites)
# interevent stddev
tau = sigma_intra + C['tau']
... | [
"def",
"_get_stddevs",
"(",
"self",
",",
"C",
",",
"mag",
",",
"stddev_types",
",",
"sites",
")",
":",
"num_sites",
"=",
"sites",
".",
"vs30",
".",
"size",
"sigma_intra",
"=",
"np",
".",
"zeros",
"(",
"num_sites",
")",
"# interevent stddev",
"tau",
"=",
... | Return standard deviation as defined on page 29 in
equation 8a,b,c and 9. | [
"Return",
"standard",
"deviation",
"as",
"defined",
"on",
"page",
"29",
"in",
"equation",
"8a",
"b",
"c",
"and",
"9",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/mcverry_2006.py#L218-L248 | train |
gem/oq-engine | openquake/hazardlib/gsim/mcverry_2006.py | McVerry2006AscSC._get_deltas | def _get_deltas(self, sites):
"""
Return delta's for equation 4
delta_C = 1 for site class C, 0 otherwise
delta_D = 1 for site class D, 0 otherwise
"""
siteclass = sites.siteclass
delta_C = np.zeros_like(siteclass, dtype=np.float)
delta_C[siteclass == b'C'... | python | def _get_deltas(self, sites):
"""
Return delta's for equation 4
delta_C = 1 for site class C, 0 otherwise
delta_D = 1 for site class D, 0 otherwise
"""
siteclass = sites.siteclass
delta_C = np.zeros_like(siteclass, dtype=np.float)
delta_C[siteclass == b'C'... | [
"def",
"_get_deltas",
"(",
"self",
",",
"sites",
")",
":",
"siteclass",
"=",
"sites",
".",
"siteclass",
"delta_C",
"=",
"np",
".",
"zeros_like",
"(",
"siteclass",
",",
"dtype",
"=",
"np",
".",
"float",
")",
"delta_C",
"[",
"siteclass",
"==",
"b'C'",
"]... | Return delta's for equation 4
delta_C = 1 for site class C, 0 otherwise
delta_D = 1 for site class D, 0 otherwise | [
"Return",
"delta",
"s",
"for",
"equation",
"4",
"delta_C",
"=",
"1",
"for",
"site",
"class",
"C",
"0",
"otherwise",
"delta_D",
"=",
"1",
"for",
"site",
"class",
"D",
"0",
"otherwise"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/mcverry_2006.py#L546-L559 | train |
gem/oq-engine | openquake/risklib/riskinput.py | CompositeRiskModel.gen_outputs | def gen_outputs(self, riskinput, monitor, epspath=None, hazard=None):
"""
Group the assets per taxonomy and compute the outputs by using the
underlying riskmodels. Yield one output per realization.
:param riskinput: a RiskInput instance
:param monitor: a monitor object used to m... | python | def gen_outputs(self, riskinput, monitor, epspath=None, hazard=None):
"""
Group the assets per taxonomy and compute the outputs by using the
underlying riskmodels. Yield one output per realization.
:param riskinput: a RiskInput instance
:param monitor: a monitor object used to m... | [
"def",
"gen_outputs",
"(",
"self",
",",
"riskinput",
",",
"monitor",
",",
"epspath",
"=",
"None",
",",
"hazard",
"=",
"None",
")",
":",
"self",
".",
"monitor",
"=",
"monitor",
"hazard_getter",
"=",
"riskinput",
".",
"hazard_getter",
"if",
"hazard",
"is",
... | Group the assets per taxonomy and compute the outputs by using the
underlying riskmodels. Yield one output per realization.
:param riskinput: a RiskInput instance
:param monitor: a monitor object used to measure the performance | [
"Group",
"the",
"assets",
"per",
"taxonomy",
"and",
"compute",
"the",
"outputs",
"by",
"using",
"the",
"underlying",
"riskmodels",
".",
"Yield",
"one",
"output",
"per",
"realization",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/riskinput.py#L347-L371 | train |
gem/oq-engine | openquake/hmtk/faults/mfd/__init__.py | get_available_mfds | def get_available_mfds():
'''
Returns an ordered dictionary with the available GSIM classes
keyed by class name
'''
mfds = {}
for fname in os.listdir(os.path.dirname(__file__)):
if fname.endswith('.py'):
modname, _ext = os.path.splitext(fname)
mod = importlib.impo... | python | def get_available_mfds():
'''
Returns an ordered dictionary with the available GSIM classes
keyed by class name
'''
mfds = {}
for fname in os.listdir(os.path.dirname(__file__)):
if fname.endswith('.py'):
modname, _ext = os.path.splitext(fname)
mod = importlib.impo... | [
"def",
"get_available_mfds",
"(",
")",
":",
"mfds",
"=",
"{",
"}",
"for",
"fname",
"in",
"os",
".",
"listdir",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
":",
"if",
"fname",
".",
"endswith",
"(",
"'.py'",
")",
":",
"modname"... | Returns an ordered dictionary with the available GSIM classes
keyed by class name | [
"Returns",
"an",
"ordered",
"dictionary",
"with",
"the",
"available",
"GSIM",
"classes",
"keyed",
"by",
"class",
"name"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/mfd/__init__.py#L25-L39 | train |
gem/oq-engine | openquake/hmtk/seismicity/max_magnitude/kijko_sellevol_fixed_b.py | check_config | def check_config(config, data):
'''Checks that the config file contains all required parameters
:param dict config:
Configuration file
:returns:
Configuration file with all correct parameters
'''
if 'tolerance' not in config.keys() or not config['tolerance']:
config['tolera... | python | def check_config(config, data):
'''Checks that the config file contains all required parameters
:param dict config:
Configuration file
:returns:
Configuration file with all correct parameters
'''
if 'tolerance' not in config.keys() or not config['tolerance']:
config['tolera... | [
"def",
"check_config",
"(",
"config",
",",
"data",
")",
":",
"if",
"'tolerance'",
"not",
"in",
"config",
".",
"keys",
"(",
")",
"or",
"not",
"config",
"[",
"'tolerance'",
"]",
":",
"config",
"[",
"'tolerance'",
"]",
"=",
"1E-5",
"if",
"not",
"config",
... | Checks that the config file contains all required parameters
:param dict config:
Configuration file
:returns:
Configuration file with all correct parameters | [
"Checks",
"that",
"the",
"config",
"file",
"contains",
"all",
"required",
"parameters"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/max_magnitude/kijko_sellevol_fixed_b.py#L61-L83 | train |
gem/oq-engine | openquake/hazardlib/valid.py | disagg_outputs | def disagg_outputs(value):
"""
Validate disaggregation outputs. For instance
>>> disagg_outputs('TRT Mag_Dist')
['TRT', 'Mag_Dist']
>>> disagg_outputs('TRT, Mag_Dist')
['TRT', 'Mag_Dist']
"""
values = value.replace(',', ' ').split()
for val in values:
if val not in disagg.pm... | python | def disagg_outputs(value):
"""
Validate disaggregation outputs. For instance
>>> disagg_outputs('TRT Mag_Dist')
['TRT', 'Mag_Dist']
>>> disagg_outputs('TRT, Mag_Dist')
['TRT', 'Mag_Dist']
"""
values = value.replace(',', ' ').split()
for val in values:
if val not in disagg.pm... | [
"def",
"disagg_outputs",
"(",
"value",
")",
":",
"values",
"=",
"value",
".",
"replace",
"(",
"','",
",",
"' '",
")",
".",
"split",
"(",
")",
"for",
"val",
"in",
"values",
":",
"if",
"val",
"not",
"in",
"disagg",
".",
"pmf_map",
":",
"raise",
"Valu... | Validate disaggregation outputs. For instance
>>> disagg_outputs('TRT Mag_Dist')
['TRT', 'Mag_Dist']
>>> disagg_outputs('TRT, Mag_Dist')
['TRT', 'Mag_Dist'] | [
"Validate",
"disaggregation",
"outputs",
".",
"For",
"instance"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/valid.py#L43-L56 | train |
gem/oq-engine | openquake/hazardlib/valid.py | gsim | def gsim(value):
"""
Convert a string in TOML format into a GSIM instance
>>> gsim('[BooreAtkinson2011]')
[BooreAtkinson2011]
"""
if not value.startswith('['): # assume the GSIM name
value = '[%s]' % value
[(gsim_name, kwargs)] = toml.loads(value).items()
minimum_distance = flo... | python | def gsim(value):
"""
Convert a string in TOML format into a GSIM instance
>>> gsim('[BooreAtkinson2011]')
[BooreAtkinson2011]
"""
if not value.startswith('['): # assume the GSIM name
value = '[%s]' % value
[(gsim_name, kwargs)] = toml.loads(value).items()
minimum_distance = flo... | [
"def",
"gsim",
"(",
"value",
")",
":",
"if",
"not",
"value",
".",
"startswith",
"(",
"'['",
")",
":",
"# assume the GSIM name",
"value",
"=",
"'[%s]'",
"%",
"value",
"[",
"(",
"gsim_name",
",",
"kwargs",
")",
"]",
"=",
"toml",
".",
"loads",
"(",
"val... | Convert a string in TOML format into a GSIM instance
>>> gsim('[BooreAtkinson2011]')
[BooreAtkinson2011] | [
"Convert",
"a",
"string",
"in",
"TOML",
"format",
"into",
"a",
"GSIM",
"instance"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/valid.py#L76-L96 | train |
gem/oq-engine | openquake/hazardlib/valid.py | compose | def compose(*validators):
"""
Implement composition of validators. For instance
>>> utf8_not_empty = compose(utf8, not_empty)
"""
def composed_validator(value):
out = value
for validator in reversed(validators):
out = validator(out)
return out
composed_valida... | python | def compose(*validators):
"""
Implement composition of validators. For instance
>>> utf8_not_empty = compose(utf8, not_empty)
"""
def composed_validator(value):
out = value
for validator in reversed(validators):
out = validator(out)
return out
composed_valida... | [
"def",
"compose",
"(",
"*",
"validators",
")",
":",
"def",
"composed_validator",
"(",
"value",
")",
":",
"out",
"=",
"value",
"for",
"validator",
"in",
"reversed",
"(",
"validators",
")",
":",
"out",
"=",
"validator",
"(",
"out",
")",
"return",
"out",
... | Implement composition of validators. For instance
>>> utf8_not_empty = compose(utf8, not_empty) | [
"Implement",
"composition",
"of",
"validators",
".",
"For",
"instance"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/valid.py#L107-L120 | train |
gem/oq-engine | openquake/hazardlib/valid.py | utf8 | def utf8(value):
r"""
Check that the string is UTF-8. Returns an encode bytestring.
>>> utf8(b'\xe0') # doctest: +ELLIPSIS
Traceback (most recent call last):
...
ValueError: Not UTF-8: ...
"""
try:
if isinstance(value, bytes):
return value.decode('utf-8')
el... | python | def utf8(value):
r"""
Check that the string is UTF-8. Returns an encode bytestring.
>>> utf8(b'\xe0') # doctest: +ELLIPSIS
Traceback (most recent call last):
...
ValueError: Not UTF-8: ...
"""
try:
if isinstance(value, bytes):
return value.decode('utf-8')
el... | [
"def",
"utf8",
"(",
"value",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"value",
",",
"bytes",
")",
":",
"return",
"value",
".",
"decode",
"(",
"'utf-8'",
")",
"else",
":",
"return",
"value",
"except",
"Exception",
":",
"raise",
"ValueError",
"(",
... | r"""
Check that the string is UTF-8. Returns an encode bytestring.
>>> utf8(b'\xe0') # doctest: +ELLIPSIS
Traceback (most recent call last):
...
ValueError: Not UTF-8: ... | [
"r",
"Check",
"that",
"the",
"string",
"is",
"UTF",
"-",
"8",
".",
"Returns",
"an",
"encode",
"bytestring",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/valid.py#L310-L325 | train |
gem/oq-engine | openquake/hazardlib/valid.py | coordinates | def coordinates(value):
"""
Convert a non-empty string into a list of lon-lat coordinates.
>>> coordinates('')
Traceback (most recent call last):
...
ValueError: Empty list of coordinates: ''
>>> coordinates('1.1 1.2')
[(1.1, 1.2, 0.0)]
>>> coordinates('1.1 1.2, 2.2 2.3')
[(1.1,... | python | def coordinates(value):
"""
Convert a non-empty string into a list of lon-lat coordinates.
>>> coordinates('')
Traceback (most recent call last):
...
ValueError: Empty list of coordinates: ''
>>> coordinates('1.1 1.2')
[(1.1, 1.2, 0.0)]
>>> coordinates('1.1 1.2, 2.2 2.3')
[(1.1,... | [
"def",
"coordinates",
"(",
"value",
")",
":",
"if",
"not",
"value",
".",
"strip",
"(",
")",
":",
"raise",
"ValueError",
"(",
"'Empty list of coordinates: %r'",
"%",
"value",
")",
"points",
"=",
"[",
"]",
"pointset",
"=",
"set",
"(",
")",
"for",
"i",
",... | Convert a non-empty string into a list of lon-lat coordinates.
>>> coordinates('')
Traceback (most recent call last):
...
ValueError: Empty list of coordinates: ''
>>> coordinates('1.1 1.2')
[(1.1, 1.2, 0.0)]
>>> coordinates('1.1 1.2, 2.2 2.3')
[(1.1, 1.2, 0.0), (2.2, 2.3, 0.0)]
>>>... | [
"Convert",
"a",
"non",
"-",
"empty",
"string",
"into",
"a",
"list",
"of",
"lon",
"-",
"lat",
"coordinates",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/valid.py#L464-L493 | train |
gem/oq-engine | openquake/hazardlib/valid.py | wkt_polygon | def wkt_polygon(value):
"""
Convert a string with a comma separated list of coordinates into
a WKT polygon, by closing the ring.
"""
points = ['%s %s' % (lon, lat) for lon, lat, dep in coordinates(value)]
# close the linear polygon ring by appending the first coord to the end
points.append(p... | python | def wkt_polygon(value):
"""
Convert a string with a comma separated list of coordinates into
a WKT polygon, by closing the ring.
"""
points = ['%s %s' % (lon, lat) for lon, lat, dep in coordinates(value)]
# close the linear polygon ring by appending the first coord to the end
points.append(p... | [
"def",
"wkt_polygon",
"(",
"value",
")",
":",
"points",
"=",
"[",
"'%s %s'",
"%",
"(",
"lon",
",",
"lat",
")",
"for",
"lon",
",",
"lat",
",",
"dep",
"in",
"coordinates",
"(",
"value",
")",
"]",
"# close the linear polygon ring by appending the first coord to t... | Convert a string with a comma separated list of coordinates into
a WKT polygon, by closing the ring. | [
"Convert",
"a",
"string",
"with",
"a",
"comma",
"separated",
"list",
"of",
"coordinates",
"into",
"a",
"WKT",
"polygon",
"by",
"closing",
"the",
"ring",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/valid.py#L496-L504 | train |
gem/oq-engine | openquake/hazardlib/valid.py | check_levels | def check_levels(imls, imt, min_iml=1E-10):
"""
Raise a ValueError if the given levels are invalid.
:param imls: a list of intensity measure and levels
:param imt: the intensity measure type
:param min_iml: minimum intensity measure level (default 1E-10)
>>> check_levels([0.1, 0.2], 'PGA') # ... | python | def check_levels(imls, imt, min_iml=1E-10):
"""
Raise a ValueError if the given levels are invalid.
:param imls: a list of intensity measure and levels
:param imt: the intensity measure type
:param min_iml: minimum intensity measure level (default 1E-10)
>>> check_levels([0.1, 0.2], 'PGA') # ... | [
"def",
"check_levels",
"(",
"imls",
",",
"imt",
",",
"min_iml",
"=",
"1E-10",
")",
":",
"if",
"len",
"(",
"imls",
")",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"'No imls for %s: %s'",
"%",
"(",
"imt",
",",
"imls",
")",
")",
"elif",
"imls",
"!=",
... | Raise a ValueError if the given levels are invalid.
:param imls: a list of intensity measure and levels
:param imt: the intensity measure type
:param min_iml: minimum intensity measure level (default 1E-10)
>>> check_levels([0.1, 0.2], 'PGA') # ok
>>> check_levels([], 'PGA')
Traceback (most r... | [
"Raise",
"a",
"ValueError",
"if",
"the",
"given",
"levels",
"are",
"invalid",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/valid.py#L681-L713 | train |
gem/oq-engine | openquake/hazardlib/valid.py | pmf | def pmf(value):
"""
Comvert a string into a Probability Mass Function.
:param value:
a sequence of probabilities summing up to 1 (no commas)
:returns:
a list of pairs [(probability, index), ...] with index starting from 0
>>> pmf("0.157 0.843")
[(0.157, 0), (0.843, 1)]
"""
... | python | def pmf(value):
"""
Comvert a string into a Probability Mass Function.
:param value:
a sequence of probabilities summing up to 1 (no commas)
:returns:
a list of pairs [(probability, index), ...] with index starting from 0
>>> pmf("0.157 0.843")
[(0.157, 0), (0.843, 1)]
"""
... | [
"def",
"pmf",
"(",
"value",
")",
":",
"probs",
"=",
"probabilities",
"(",
"value",
")",
"if",
"abs",
"(",
"1.",
"-",
"sum",
"(",
"map",
"(",
"float",
",",
"value",
".",
"split",
"(",
")",
")",
")",
")",
">",
"1e-12",
":",
"raise",
"ValueError",
... | Comvert a string into a Probability Mass Function.
:param value:
a sequence of probabilities summing up to 1 (no commas)
:returns:
a list of pairs [(probability, index), ...] with index starting from 0
>>> pmf("0.157 0.843")
[(0.157, 0), (0.843, 1)] | [
"Comvert",
"a",
"string",
"into",
"a",
"Probability",
"Mass",
"Function",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/valid.py#L862-L877 | train |
gem/oq-engine | openquake/hazardlib/valid.py | check_weights | def check_weights(nodes_with_a_weight):
"""
Ensure that the sum of the values is 1
:param nodes_with_a_weight: a list of Node objects with a weight attribute
"""
weights = [n['weight'] for n in nodes_with_a_weight]
if abs(sum(weights) - 1.) > PRECISION:
raise ValueError('The weights do ... | python | def check_weights(nodes_with_a_weight):
"""
Ensure that the sum of the values is 1
:param nodes_with_a_weight: a list of Node objects with a weight attribute
"""
weights = [n['weight'] for n in nodes_with_a_weight]
if abs(sum(weights) - 1.) > PRECISION:
raise ValueError('The weights do ... | [
"def",
"check_weights",
"(",
"nodes_with_a_weight",
")",
":",
"weights",
"=",
"[",
"n",
"[",
"'weight'",
"]",
"for",
"n",
"in",
"nodes_with_a_weight",
"]",
"if",
"abs",
"(",
"sum",
"(",
"weights",
")",
"-",
"1.",
")",
">",
"PRECISION",
":",
"raise",
"V... | Ensure that the sum of the values is 1
:param nodes_with_a_weight: a list of Node objects with a weight attribute | [
"Ensure",
"that",
"the",
"sum",
"of",
"the",
"values",
"is",
"1"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/valid.py#L880-L889 | train |
gem/oq-engine | openquake/hazardlib/valid.py | ab_values | def ab_values(value):
"""
a and b values of the GR magniture-scaling relation.
a is a positive float, b is just a float.
"""
a, b = value.split()
return positivefloat(a), float_(b) | python | def ab_values(value):
"""
a and b values of the GR magniture-scaling relation.
a is a positive float, b is just a float.
"""
a, b = value.split()
return positivefloat(a), float_(b) | [
"def",
"ab_values",
"(",
"value",
")",
":",
"a",
",",
"b",
"=",
"value",
".",
"split",
"(",
")",
"return",
"positivefloat",
"(",
"a",
")",
",",
"float_",
"(",
"b",
")"
] | a and b values of the GR magniture-scaling relation.
a is a positive float, b is just a float. | [
"a",
"and",
"b",
"values",
"of",
"the",
"GR",
"magniture",
"-",
"scaling",
"relation",
".",
"a",
"is",
"a",
"positive",
"float",
"b",
"is",
"just",
"a",
"float",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/valid.py#L971-L977 | train |
gem/oq-engine | openquake/hazardlib/valid.py | site_param | def site_param(dic):
"""
Convert a dictionary site_model_param -> string into a dictionary
of valid casted site parameters.
"""
new = {}
for name, val in dic.items():
if name == 'vs30Type':
# avoid "Unrecognized parameter vs30Type"
new['vs30measured'] = val == 'me... | python | def site_param(dic):
"""
Convert a dictionary site_model_param -> string into a dictionary
of valid casted site parameters.
"""
new = {}
for name, val in dic.items():
if name == 'vs30Type':
# avoid "Unrecognized parameter vs30Type"
new['vs30measured'] = val == 'me... | [
"def",
"site_param",
"(",
"dic",
")",
":",
"new",
"=",
"{",
"}",
"for",
"name",
",",
"val",
"in",
"dic",
".",
"items",
"(",
")",
":",
"if",
"name",
"==",
"'vs30Type'",
":",
"# avoid \"Unrecognized parameter vs30Type\"",
"new",
"[",
"'vs30measured'",
"]",
... | Convert a dictionary site_model_param -> string into a dictionary
of valid casted site parameters. | [
"Convert",
"a",
"dictionary",
"site_model_param",
"-",
">",
"string",
"into",
"a",
"dictionary",
"of",
"valid",
"casted",
"site",
"parameters",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/valid.py#L1043-L1057 | train |
gem/oq-engine | openquake/hazardlib/valid.py | ParamSet.check | def check(cls, dic):
"""
Convert a dictionary name->string into a dictionary name->value
by converting the string. If the name does not correspond to a
known parameter, just ignore it and print a warning.
"""
res = {}
for name, text in dic.items():
try... | python | def check(cls, dic):
"""
Convert a dictionary name->string into a dictionary name->value
by converting the string. If the name does not correspond to a
known parameter, just ignore it and print a warning.
"""
res = {}
for name, text in dic.items():
try... | [
"def",
"check",
"(",
"cls",
",",
"dic",
")",
":",
"res",
"=",
"{",
"}",
"for",
"name",
",",
"text",
"in",
"dic",
".",
"items",
"(",
")",
":",
"try",
":",
"p",
"=",
"getattr",
"(",
"cls",
",",
"name",
")",
"except",
"AttributeError",
":",
"loggi... | Convert a dictionary name->string into a dictionary name->value
by converting the string. If the name does not correspond to a
known parameter, just ignore it and print a warning. | [
"Convert",
"a",
"dictionary",
"name",
"-",
">",
"string",
"into",
"a",
"dictionary",
"name",
"-",
">",
"value",
"by",
"converting",
"the",
"string",
".",
"If",
"the",
"name",
"does",
"not",
"correspond",
"to",
"a",
"known",
"parameter",
"just",
"ignore",
... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/valid.py#L1149-L1163 | train |
gem/oq-engine | openquake/hazardlib/valid.py | ParamSet.from_ | def from_(cls, dic):
"""
Build a new ParamSet from a dictionary of string-valued parameters
which are assumed to be already valid.
"""
self = cls.__new__(cls)
for k, v in dic.items():
setattr(self, k, ast.literal_eval(v))
return self | python | def from_(cls, dic):
"""
Build a new ParamSet from a dictionary of string-valued parameters
which are assumed to be already valid.
"""
self = cls.__new__(cls)
for k, v in dic.items():
setattr(self, k, ast.literal_eval(v))
return self | [
"def",
"from_",
"(",
"cls",
",",
"dic",
")",
":",
"self",
"=",
"cls",
".",
"__new__",
"(",
"cls",
")",
"for",
"k",
",",
"v",
"in",
"dic",
".",
"items",
"(",
")",
":",
"setattr",
"(",
"self",
",",
"k",
",",
"ast",
".",
"literal_eval",
"(",
"v"... | Build a new ParamSet from a dictionary of string-valued parameters
which are assumed to be already valid. | [
"Build",
"a",
"new",
"ParamSet",
"from",
"a",
"dictionary",
"of",
"string",
"-",
"valued",
"parameters",
"which",
"are",
"assumed",
"to",
"be",
"already",
"valid",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/valid.py#L1166-L1174 | train |
gem/oq-engine | openquake/hazardlib/valid.py | ParamSet.validate | def validate(self):
"""
Apply the `is_valid` methods to self and possibly raise a ValueError.
"""
# it is important to have the validator applied in a fixed order
valids = [getattr(self, valid)
for valid in sorted(dir(self.__class__))
if valid.... | python | def validate(self):
"""
Apply the `is_valid` methods to self and possibly raise a ValueError.
"""
# it is important to have the validator applied in a fixed order
valids = [getattr(self, valid)
for valid in sorted(dir(self.__class__))
if valid.... | [
"def",
"validate",
"(",
"self",
")",
":",
"# it is important to have the validator applied in a fixed order",
"valids",
"=",
"[",
"getattr",
"(",
"self",
",",
"valid",
")",
"for",
"valid",
"in",
"sorted",
"(",
"dir",
"(",
"self",
".",
"__class__",
")",
")",
"i... | Apply the `is_valid` methods to self and possibly raise a ValueError. | [
"Apply",
"the",
"is_valid",
"methods",
"to",
"self",
"and",
"possibly",
"raise",
"a",
"ValueError",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/valid.py#L1203-L1216 | train |
gem/oq-engine | openquake/hazardlib/gsim/idriss_2014.py | Idriss2014._get_magnitude_scaling_term | def _get_magnitude_scaling_term(self, C, mag):
"""
Returns the magnitude scaling term defined in equation 3
"""
if mag < 6.75:
return C["a1_lo"] + C["a2_lo"] * mag + C["a3"] *\
((8.5 - mag) ** 2.0)
else:
return C["a1_hi"] + C["a2_hi"] * mag... | python | def _get_magnitude_scaling_term(self, C, mag):
"""
Returns the magnitude scaling term defined in equation 3
"""
if mag < 6.75:
return C["a1_lo"] + C["a2_lo"] * mag + C["a3"] *\
((8.5 - mag) ** 2.0)
else:
return C["a1_hi"] + C["a2_hi"] * mag... | [
"def",
"_get_magnitude_scaling_term",
"(",
"self",
",",
"C",
",",
"mag",
")",
":",
"if",
"mag",
"<",
"6.75",
":",
"return",
"C",
"[",
"\"a1_lo\"",
"]",
"+",
"C",
"[",
"\"a2_lo\"",
"]",
"*",
"mag",
"+",
"C",
"[",
"\"a3\"",
"]",
"*",
"(",
"(",
"8.5... | Returns the magnitude scaling term defined in equation 3 | [
"Returns",
"the",
"magnitude",
"scaling",
"term",
"defined",
"in",
"equation",
"3"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/idriss_2014.py#L89-L98 | train |
gem/oq-engine | openquake/hazardlib/gsim/idriss_2014.py | Idriss2014._get_distance_scaling_term | def _get_distance_scaling_term(self, C, mag, rrup):
"""
Returns the magnitude dependent distance scaling term
"""
if mag < 6.75:
mag_factor = -(C["b1_lo"] + C["b2_lo"] * mag)
else:
mag_factor = -(C["b1_hi"] + C["b2_hi"] * mag)
return mag_factor * n... | python | def _get_distance_scaling_term(self, C, mag, rrup):
"""
Returns the magnitude dependent distance scaling term
"""
if mag < 6.75:
mag_factor = -(C["b1_lo"] + C["b2_lo"] * mag)
else:
mag_factor = -(C["b1_hi"] + C["b2_hi"] * mag)
return mag_factor * n... | [
"def",
"_get_distance_scaling_term",
"(",
"self",
",",
"C",
",",
"mag",
",",
"rrup",
")",
":",
"if",
"mag",
"<",
"6.75",
":",
"mag_factor",
"=",
"-",
"(",
"C",
"[",
"\"b1_lo\"",
"]",
"+",
"C",
"[",
"\"b2_lo\"",
"]",
"*",
"mag",
")",
"else",
":",
... | Returns the magnitude dependent distance scaling term | [
"Returns",
"the",
"magnitude",
"dependent",
"distance",
"scaling",
"term"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/idriss_2014.py#L100-L108 | train |
gem/oq-engine | openquake/hazardlib/gsim/abrahamson_silva_2008.py | AbrahamsonSilva2008._compute_base_term | def _compute_base_term(self, C, rup, dists):
"""
Compute and return base model term, that is the first term in equation
1, page 74. The calculation of this term is explained in paragraph
'Base Model', page 75.
"""
c1 = self.CONSTS['c1']
R = np.sqrt(dists.rrup ** 2... | python | def _compute_base_term(self, C, rup, dists):
"""
Compute and return base model term, that is the first term in equation
1, page 74. The calculation of this term is explained in paragraph
'Base Model', page 75.
"""
c1 = self.CONSTS['c1']
R = np.sqrt(dists.rrup ** 2... | [
"def",
"_compute_base_term",
"(",
"self",
",",
"C",
",",
"rup",
",",
"dists",
")",
":",
"c1",
"=",
"self",
".",
"CONSTS",
"[",
"'c1'",
"]",
"R",
"=",
"np",
".",
"sqrt",
"(",
"dists",
".",
"rrup",
"**",
"2",
"+",
"self",
".",
"CONSTS",
"[",
"'c4... | Compute and return base model term, that is the first term in equation
1, page 74. The calculation of this term is explained in paragraph
'Base Model', page 75. | [
"Compute",
"and",
"return",
"base",
"model",
"term",
"that",
"is",
"the",
"first",
"term",
"in",
"equation",
"1",
"page",
"74",
".",
"The",
"calculation",
"of",
"this",
"term",
"is",
"explained",
"in",
"paragraph",
"Base",
"Model",
"page",
"75",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/abrahamson_silva_2008.py#L110-L127 | train |
gem/oq-engine | openquake/hazardlib/gsim/abrahamson_silva_2008.py | AbrahamsonSilva2008._compute_site_response_term | def _compute_site_response_term(self, C, imt, sites, pga1100):
"""
Compute and return site response model term, that is the fifth term
in equation 1, page 74.
"""
site_resp_term = np.zeros_like(sites.vs30)
vs30_star, _ = self._compute_vs30_star_factor(imt, sites.vs30)
... | python | def _compute_site_response_term(self, C, imt, sites, pga1100):
"""
Compute and return site response model term, that is the fifth term
in equation 1, page 74.
"""
site_resp_term = np.zeros_like(sites.vs30)
vs30_star, _ = self._compute_vs30_star_factor(imt, sites.vs30)
... | [
"def",
"_compute_site_response_term",
"(",
"self",
",",
"C",
",",
"imt",
",",
"sites",
",",
"pga1100",
")",
":",
"site_resp_term",
"=",
"np",
".",
"zeros_like",
"(",
"sites",
".",
"vs30",
")",
"vs30_star",
",",
"_",
"=",
"self",
".",
"_compute_vs30_star_fa... | Compute and return site response model term, that is the fifth term
in equation 1, page 74. | [
"Compute",
"and",
"return",
"site",
"response",
"model",
"term",
"that",
"is",
"the",
"fifth",
"term",
"in",
"equation",
"1",
"page",
"74",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/abrahamson_silva_2008.py#L139-L159 | train |
gem/oq-engine | openquake/hazardlib/gsim/abrahamson_silva_2008.py | AbrahamsonSilva2008._compute_hanging_wall_term | def _compute_hanging_wall_term(self, C, dists, rup):
"""
Compute and return hanging wall model term, that is the sixth term in
equation 1, page 74. The calculation of this term is explained in
paragraph 'Hanging-Wall Model', page 77.
"""
if rup.dip == 90.0:
re... | python | def _compute_hanging_wall_term(self, C, dists, rup):
"""
Compute and return hanging wall model term, that is the sixth term in
equation 1, page 74. The calculation of this term is explained in
paragraph 'Hanging-Wall Model', page 77.
"""
if rup.dip == 90.0:
re... | [
"def",
"_compute_hanging_wall_term",
"(",
"self",
",",
"C",
",",
"dists",
",",
"rup",
")",
":",
"if",
"rup",
".",
"dip",
"==",
"90.0",
":",
"return",
"np",
".",
"zeros_like",
"(",
"dists",
".",
"rx",
")",
"else",
":",
"idx",
"=",
"dists",
".",
"rx"... | Compute and return hanging wall model term, that is the sixth term in
equation 1, page 74. The calculation of this term is explained in
paragraph 'Hanging-Wall Model', page 77. | [
"Compute",
"and",
"return",
"hanging",
"wall",
"model",
"term",
"that",
"is",
"the",
"sixth",
"term",
"in",
"equation",
"1",
"page",
"74",
".",
"The",
"calculation",
"of",
"this",
"term",
"is",
"explained",
"in",
"paragraph",
"Hanging",
"-",
"Wall",
"Model... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/abrahamson_silva_2008.py#L161-L205 | train |
gem/oq-engine | openquake/hazardlib/gsim/abrahamson_silva_2008.py | AbrahamsonSilva2008._compute_top_of_rupture_depth_term | def _compute_top_of_rupture_depth_term(self, C, rup):
"""
Compute and return top of rupture depth term, that is the seventh term
in equation 1, page 74. The calculation of this term is explained in
paragraph 'Depth-to-Top of Rupture Model', page 78.
"""
if rup.ztor >= 10.... | python | def _compute_top_of_rupture_depth_term(self, C, rup):
"""
Compute and return top of rupture depth term, that is the seventh term
in equation 1, page 74. The calculation of this term is explained in
paragraph 'Depth-to-Top of Rupture Model', page 78.
"""
if rup.ztor >= 10.... | [
"def",
"_compute_top_of_rupture_depth_term",
"(",
"self",
",",
"C",
",",
"rup",
")",
":",
"if",
"rup",
".",
"ztor",
">=",
"10.0",
":",
"return",
"C",
"[",
"'a16'",
"]",
"else",
":",
"return",
"C",
"[",
"'a16'",
"]",
"*",
"rup",
".",
"ztor",
"/",
"1... | Compute and return top of rupture depth term, that is the seventh term
in equation 1, page 74. The calculation of this term is explained in
paragraph 'Depth-to-Top of Rupture Model', page 78. | [
"Compute",
"and",
"return",
"top",
"of",
"rupture",
"depth",
"term",
"that",
"is",
"the",
"seventh",
"term",
"in",
"equation",
"1",
"page",
"74",
".",
"The",
"calculation",
"of",
"this",
"term",
"is",
"explained",
"in",
"paragraph",
"Depth",
"-",
"to",
"... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/abrahamson_silva_2008.py#L207-L216 | train |
gem/oq-engine | openquake/hazardlib/gsim/abrahamson_silva_2008.py | AbrahamsonSilva2008._compute_large_distance_term | def _compute_large_distance_term(self, C, dists, rup):
"""
Compute and return large distance model term, that is the 8-th term
in equation 1, page 74. The calculation of this term is explained in
paragraph 'Large Distance Model', page 78.
"""
# equation 15, page 79
... | python | def _compute_large_distance_term(self, C, dists, rup):
"""
Compute and return large distance model term, that is the 8-th term
in equation 1, page 74. The calculation of this term is explained in
paragraph 'Large Distance Model', page 78.
"""
# equation 15, page 79
... | [
"def",
"_compute_large_distance_term",
"(",
"self",
",",
"C",
",",
"dists",
",",
"rup",
")",
":",
"# equation 15, page 79",
"if",
"rup",
".",
"mag",
"<",
"5.5",
":",
"T6",
"=",
"1.0",
"elif",
"rup",
".",
"mag",
">=",
"5.5",
"and",
"rup",
".",
"mag",
... | Compute and return large distance model term, that is the 8-th term
in equation 1, page 74. The calculation of this term is explained in
paragraph 'Large Distance Model', page 78. | [
"Compute",
"and",
"return",
"large",
"distance",
"model",
"term",
"that",
"is",
"the",
"8",
"-",
"th",
"term",
"in",
"equation",
"1",
"page",
"74",
".",
"The",
"calculation",
"of",
"this",
"term",
"is",
"explained",
"in",
"paragraph",
"Large",
"Distance",
... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/abrahamson_silva_2008.py#L218-L237 | train |
gem/oq-engine | openquake/hazardlib/gsim/abrahamson_silva_2008.py | AbrahamsonSilva2008._compute_soil_depth_term | def _compute_soil_depth_term(self, C, imt, z1pt0, vs30):
"""
Compute and return soil depth model term, that is the 9-th term in
equation 1, page 74. The calculation of this term is explained in
paragraph 'Soil Depth Model', page 79.
"""
a21 = self._compute_a21_factor(C, i... | python | def _compute_soil_depth_term(self, C, imt, z1pt0, vs30):
"""
Compute and return soil depth model term, that is the 9-th term in
equation 1, page 74. The calculation of this term is explained in
paragraph 'Soil Depth Model', page 79.
"""
a21 = self._compute_a21_factor(C, i... | [
"def",
"_compute_soil_depth_term",
"(",
"self",
",",
"C",
",",
"imt",
",",
"z1pt0",
",",
"vs30",
")",
":",
"a21",
"=",
"self",
".",
"_compute_a21_factor",
"(",
"C",
",",
"imt",
",",
"z1pt0",
",",
"vs30",
")",
"a22",
"=",
"self",
".",
"_compute_a22_fact... | Compute and return soil depth model term, that is the 9-th term in
equation 1, page 74. The calculation of this term is explained in
paragraph 'Soil Depth Model', page 79. | [
"Compute",
"and",
"return",
"soil",
"depth",
"model",
"term",
"that",
"is",
"the",
"9",
"-",
"th",
"term",
"in",
"equation",
"1",
"page",
"74",
".",
"The",
"calculation",
"of",
"this",
"term",
"is",
"explained",
"in",
"paragraph",
"Soil",
"Depth",
"Model... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/abrahamson_silva_2008.py#L239-L255 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.