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/baselib/workerpool.py | WorkerMaster.start | def start(self, streamer=False):
"""
Start multiple workerpools, possibly on remote servers via ssh,
and possibly a streamer, depending on the `streamercls`.
:param streamer:
if True, starts a streamer with multiprocessing.Process
"""
if streamer and not gene... | python | def start(self, streamer=False):
"""
Start multiple workerpools, possibly on remote servers via ssh,
and possibly a streamer, depending on the `streamercls`.
:param streamer:
if True, starts a streamer with multiprocessing.Process
"""
if streamer and not gene... | [
"def",
"start",
"(",
"self",
",",
"streamer",
"=",
"False",
")",
":",
"if",
"streamer",
"and",
"not",
"general",
".",
"socket_ready",
"(",
"self",
".",
"task_in_url",
")",
":",
"# started",
"self",
".",
"streamer",
"=",
"multiprocessing",
".",
"Process",
... | Start multiple workerpools, possibly on remote servers via ssh,
and possibly a streamer, depending on the `streamercls`.
:param streamer:
if True, starts a streamer with multiprocessing.Process | [
"Start",
"multiple",
"workerpools",
"possibly",
"on",
"remote",
"servers",
"via",
"ssh",
"and",
"possibly",
"a",
"streamer",
"depending",
"on",
"the",
"streamercls",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/workerpool.py#L59-L87 | train |
gem/oq-engine | openquake/baselib/workerpool.py | WorkerMaster.stop | def stop(self):
"""
Send a "stop" command to all worker pools
"""
stopped = []
for host, _ in self.host_cores:
if self.status(host)[0][1] == 'not-running':
print('%s not running' % host)
continue
ctrl_url = 'tcp://%s:%s' % (... | python | def stop(self):
"""
Send a "stop" command to all worker pools
"""
stopped = []
for host, _ in self.host_cores:
if self.status(host)[0][1] == 'not-running':
print('%s not running' % host)
continue
ctrl_url = 'tcp://%s:%s' % (... | [
"def",
"stop",
"(",
"self",
")",
":",
"stopped",
"=",
"[",
"]",
"for",
"host",
",",
"_",
"in",
"self",
".",
"host_cores",
":",
"if",
"self",
".",
"status",
"(",
"host",
")",
"[",
"0",
"]",
"[",
"1",
"]",
"==",
"'not-running'",
":",
"print",
"("... | Send a "stop" command to all worker pools | [
"Send",
"a",
"stop",
"command",
"to",
"all",
"worker",
"pools"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/workerpool.py#L89-L104 | train |
gem/oq-engine | openquake/baselib/workerpool.py | WorkerPool.start | def start(self):
"""
Start worker processes and a control loop
"""
setproctitle('oq-zworkerpool %s' % self.ctrl_url[6:]) # strip tcp://
# start workers
self.workers = []
for _ in range(self.num_workers):
sock = z.Socket(self.task_out_port, z.zmq.PULL,... | python | def start(self):
"""
Start worker processes and a control loop
"""
setproctitle('oq-zworkerpool %s' % self.ctrl_url[6:]) # strip tcp://
# start workers
self.workers = []
for _ in range(self.num_workers):
sock = z.Socket(self.task_out_port, z.zmq.PULL,... | [
"def",
"start",
"(",
"self",
")",
":",
"setproctitle",
"(",
"'oq-zworkerpool %s'",
"%",
"self",
".",
"ctrl_url",
"[",
"6",
":",
"]",
")",
"# strip tcp://",
"# start workers",
"self",
".",
"workers",
"=",
"[",
"]",
"for",
"_",
"in",
"range",
"(",
"self",
... | Start worker processes and a control loop | [
"Start",
"worker",
"processes",
"and",
"a",
"control",
"loop"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/workerpool.py#L157-L181 | train |
gem/oq-engine | openquake/baselib/workerpool.py | WorkerPool.stop | def stop(self):
"""
Send a SIGTERM to all worker processes
"""
for sock in self.workers:
os.kill(sock.pid, signal.SIGTERM)
return 'WorkerPool %s stopped' % self.ctrl_url | python | def stop(self):
"""
Send a SIGTERM to all worker processes
"""
for sock in self.workers:
os.kill(sock.pid, signal.SIGTERM)
return 'WorkerPool %s stopped' % self.ctrl_url | [
"def",
"stop",
"(",
"self",
")",
":",
"for",
"sock",
"in",
"self",
".",
"workers",
":",
"os",
".",
"kill",
"(",
"sock",
".",
"pid",
",",
"signal",
".",
"SIGTERM",
")",
"return",
"'WorkerPool %s stopped'",
"%",
"self",
".",
"ctrl_url"
] | Send a SIGTERM to all worker processes | [
"Send",
"a",
"SIGTERM",
"to",
"all",
"worker",
"processes"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/workerpool.py#L183-L189 | train |
gem/oq-engine | openquake/baselib/workerpool.py | WorkerPool.kill | def kill(self):
"""
Send a SIGKILL to all worker processes
"""
for sock in self.workers:
os.kill(sock.pid, signal.SIGKILL)
return 'WorkerPool %s killed' % self.ctrl_url | python | def kill(self):
"""
Send a SIGKILL to all worker processes
"""
for sock in self.workers:
os.kill(sock.pid, signal.SIGKILL)
return 'WorkerPool %s killed' % self.ctrl_url | [
"def",
"kill",
"(",
"self",
")",
":",
"for",
"sock",
"in",
"self",
".",
"workers",
":",
"os",
".",
"kill",
"(",
"sock",
".",
"pid",
",",
"signal",
".",
"SIGKILL",
")",
"return",
"'WorkerPool %s killed'",
"%",
"self",
".",
"ctrl_url"
] | Send a SIGKILL to all worker processes | [
"Send",
"a",
"SIGKILL",
"to",
"all",
"worker",
"processes"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/workerpool.py#L191-L197 | train |
gem/oq-engine | openquake/server/dbserver.py | get_status | def get_status(address=None):
"""
Check if the DbServer is up.
:param address: pair (hostname, port)
:returns: 'running' or 'not-running'
"""
address = address or (config.dbserver.host, DBSERVER_PORT)
return 'running' if socket_ready(address) else 'not-running' | python | def get_status(address=None):
"""
Check if the DbServer is up.
:param address: pair (hostname, port)
:returns: 'running' or 'not-running'
"""
address = address or (config.dbserver.host, DBSERVER_PORT)
return 'running' if socket_ready(address) else 'not-running' | [
"def",
"get_status",
"(",
"address",
"=",
"None",
")",
":",
"address",
"=",
"address",
"or",
"(",
"config",
".",
"dbserver",
".",
"host",
",",
"DBSERVER_PORT",
")",
"return",
"'running'",
"if",
"socket_ready",
"(",
"address",
")",
"else",
"'not-running'"
] | Check if the DbServer is up.
:param address: pair (hostname, port)
:returns: 'running' or 'not-running' | [
"Check",
"if",
"the",
"DbServer",
"is",
"up",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/dbserver.py#L134-L142 | train |
gem/oq-engine | openquake/server/dbserver.py | check_foreign | def check_foreign():
"""
Check if we the DbServer is the right one
"""
if not config.dbserver.multi_user:
remote_server_path = logs.dbcmd('get_path')
if different_paths(server_path, remote_server_path):
return('You are trying to contact a DbServer from another'
... | python | def check_foreign():
"""
Check if we the DbServer is the right one
"""
if not config.dbserver.multi_user:
remote_server_path = logs.dbcmd('get_path')
if different_paths(server_path, remote_server_path):
return('You are trying to contact a DbServer from another'
... | [
"def",
"check_foreign",
"(",
")",
":",
"if",
"not",
"config",
".",
"dbserver",
".",
"multi_user",
":",
"remote_server_path",
"=",
"logs",
".",
"dbcmd",
"(",
"'get_path'",
")",
"if",
"different_paths",
"(",
"server_path",
",",
"remote_server_path",
")",
":",
... | Check if we the DbServer is the right one | [
"Check",
"if",
"we",
"the",
"DbServer",
"is",
"the",
"right",
"one"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/dbserver.py#L145-L155 | train |
gem/oq-engine | openquake/server/dbserver.py | ensure_on | def ensure_on():
"""
Start the DbServer if it is off
"""
if get_status() == 'not-running':
if config.dbserver.multi_user:
sys.exit('Please start the DbServer: '
'see the documentation for details')
# otherwise start the DbServer automatically; NB: I tried... | python | def ensure_on():
"""
Start the DbServer if it is off
"""
if get_status() == 'not-running':
if config.dbserver.multi_user:
sys.exit('Please start the DbServer: '
'see the documentation for details')
# otherwise start the DbServer automatically; NB: I tried... | [
"def",
"ensure_on",
"(",
")",
":",
"if",
"get_status",
"(",
")",
"==",
"'not-running'",
":",
"if",
"config",
".",
"dbserver",
".",
"multi_user",
":",
"sys",
".",
"exit",
"(",
"'Please start the DbServer: '",
"'see the documentation for details'",
")",
"# otherwise... | Start the DbServer if it is off | [
"Start",
"the",
"DbServer",
"if",
"it",
"is",
"off"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/dbserver.py#L158-L180 | train |
gem/oq-engine | openquake/server/dbserver.py | run_server | def run_server(dbpath=os.path.expanduser(config.dbserver.file),
dbhostport=None, loglevel='WARN'):
"""
Run the DbServer on the given database file and port. If not given,
use the settings in openquake.cfg.
"""
if dbhostport: # assume a string of the form "dbhost:port"
dbhost,... | python | def run_server(dbpath=os.path.expanduser(config.dbserver.file),
dbhostport=None, loglevel='WARN'):
"""
Run the DbServer on the given database file and port. If not given,
use the settings in openquake.cfg.
"""
if dbhostport: # assume a string of the form "dbhost:port"
dbhost,... | [
"def",
"run_server",
"(",
"dbpath",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"config",
".",
"dbserver",
".",
"file",
")",
",",
"dbhostport",
"=",
"None",
",",
"loglevel",
"=",
"'WARN'",
")",
":",
"if",
"dbhostport",
":",
"# assume a string of the fo... | Run the DbServer on the given database file and port. If not given,
use the settings in openquake.cfg. | [
"Run",
"the",
"DbServer",
"on",
"the",
"given",
"database",
"file",
"and",
"port",
".",
"If",
"not",
"given",
"use",
"the",
"settings",
"in",
"openquake",
".",
"cfg",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/dbserver.py#L184-L213 | train |
gem/oq-engine | openquake/server/dbserver.py | DbServer.start | def start(self):
"""
Start database worker threads
"""
# give a nice name to the process
w.setproctitle('oq-dbserver')
dworkers = []
for _ in range(self.num_workers):
sock = z.Socket(self.backend, z.zmq.REP, 'connect')
threading.Thread(tar... | python | def start(self):
"""
Start database worker threads
"""
# give a nice name to the process
w.setproctitle('oq-dbserver')
dworkers = []
for _ in range(self.num_workers):
sock = z.Socket(self.backend, z.zmq.REP, 'connect')
threading.Thread(tar... | [
"def",
"start",
"(",
"self",
")",
":",
"# give a nice name to the process",
"w",
".",
"setproctitle",
"(",
"'oq-dbserver'",
")",
"dworkers",
"=",
"[",
"]",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"num_workers",
")",
":",
"sock",
"=",
"z",
".",
"Sock... | Start database worker threads | [
"Start",
"database",
"worker",
"threads"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/dbserver.py#L78-L117 | train |
gem/oq-engine | openquake/server/dbserver.py | DbServer.stop | def stop(self):
"""Stop the DbServer and the zworkers if any"""
if ZMQ:
logging.warning(self.master.stop())
z.context.term()
self.db.close() | python | def stop(self):
"""Stop the DbServer and the zworkers if any"""
if ZMQ:
logging.warning(self.master.stop())
z.context.term()
self.db.close() | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"ZMQ",
":",
"logging",
".",
"warning",
"(",
"self",
".",
"master",
".",
"stop",
"(",
")",
")",
"z",
".",
"context",
".",
"term",
"(",
")",
"self",
".",
"db",
".",
"close",
"(",
")"
] | Stop the DbServer and the zworkers if any | [
"Stop",
"the",
"DbServer",
"and",
"the",
"zworkers",
"if",
"any"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/dbserver.py#L119-L124 | train |
gem/oq-engine | openquake/hazardlib/gsim/climent_1994.py | ClimentEtAl1994._compute_term_3_4 | def _compute_term_3_4(self, dists, C):
"""
Compute term 3 and 4 in equation 1 page 1.
"""
cutoff = 6.056877878
rhypo = dists.rhypo.copy()
rhypo[rhypo <= cutoff] = cutoff
return C['c3'] * np.log(rhypo) + C['c4'] * rhypo | python | def _compute_term_3_4(self, dists, C):
"""
Compute term 3 and 4 in equation 1 page 1.
"""
cutoff = 6.056877878
rhypo = dists.rhypo.copy()
rhypo[rhypo <= cutoff] = cutoff
return C['c3'] * np.log(rhypo) + C['c4'] * rhypo | [
"def",
"_compute_term_3_4",
"(",
"self",
",",
"dists",
",",
"C",
")",
":",
"cutoff",
"=",
"6.056877878",
"rhypo",
"=",
"dists",
".",
"rhypo",
".",
"copy",
"(",
")",
"rhypo",
"[",
"rhypo",
"<=",
"cutoff",
"]",
"=",
"cutoff",
"return",
"C",
"[",
"'c3'"... | Compute term 3 and 4 in equation 1 page 1. | [
"Compute",
"term",
"3",
"and",
"4",
"in",
"equation",
"1",
"page",
"1",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/climent_1994.py#L111-L118 | train |
gem/oq-engine | openquake/hazardlib/gsim/convertito_2012.py | ConvertitoEtAl2012Geysers._compute_distance_scaling | def _compute_distance_scaling(self, C, rhypo):
"""
Returns the distance scaling term accounting for geometric and
anelastic attenuation
"""
return C["c"] * np.log10(np.sqrt((rhypo ** 2.) + (C["h"] ** 2.))) +\
(C["d"] * rhypo) | python | def _compute_distance_scaling(self, C, rhypo):
"""
Returns the distance scaling term accounting for geometric and
anelastic attenuation
"""
return C["c"] * np.log10(np.sqrt((rhypo ** 2.) + (C["h"] ** 2.))) +\
(C["d"] * rhypo) | [
"def",
"_compute_distance_scaling",
"(",
"self",
",",
"C",
",",
"rhypo",
")",
":",
"return",
"C",
"[",
"\"c\"",
"]",
"*",
"np",
".",
"log10",
"(",
"np",
".",
"sqrt",
"(",
"(",
"rhypo",
"**",
"2.",
")",
"+",
"(",
"C",
"[",
"\"h\"",
"]",
"**",
"2... | Returns the distance scaling term accounting for geometric and
anelastic attenuation | [
"Returns",
"the",
"distance",
"scaling",
"term",
"accounting",
"for",
"geometric",
"and",
"anelastic",
"attenuation"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/convertito_2012.py#L101-L107 | train |
gem/oq-engine | openquake/hazardlib/gsim/convertito_2012.py | ConvertitoEtAl2012Geysers._compute_site_scaling | def _compute_site_scaling(self, C, vs30):
"""
Returns the site scaling term as a simple coefficient
"""
site_term = np.zeros(len(vs30), dtype=float)
# For soil sites add on the site coefficient
site_term[vs30 < 760.0] = C["e"]
return site_term | python | def _compute_site_scaling(self, C, vs30):
"""
Returns the site scaling term as a simple coefficient
"""
site_term = np.zeros(len(vs30), dtype=float)
# For soil sites add on the site coefficient
site_term[vs30 < 760.0] = C["e"]
return site_term | [
"def",
"_compute_site_scaling",
"(",
"self",
",",
"C",
",",
"vs30",
")",
":",
"site_term",
"=",
"np",
".",
"zeros",
"(",
"len",
"(",
"vs30",
")",
",",
"dtype",
"=",
"float",
")",
"# For soil sites add on the site coefficient",
"site_term",
"[",
"vs30",
"<",
... | Returns the site scaling term as a simple coefficient | [
"Returns",
"the",
"site",
"scaling",
"term",
"as",
"a",
"simple",
"coefficient"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/convertito_2012.py#L109-L116 | train |
gem/oq-engine | openquake/hazardlib/contexts.py | ContextMaker.filter | def filter(self, sites, rupture):
"""
Filter the site collection with respect to the rupture.
:param sites:
Instance of :class:`openquake.hazardlib.site.SiteCollection`.
:param rupture:
Instance of
:class:`openquake.hazardlib.source.rupture.BaseRuptur... | python | def filter(self, sites, rupture):
"""
Filter the site collection with respect to the rupture.
:param sites:
Instance of :class:`openquake.hazardlib.site.SiteCollection`.
:param rupture:
Instance of
:class:`openquake.hazardlib.source.rupture.BaseRuptur... | [
"def",
"filter",
"(",
"self",
",",
"sites",
",",
"rupture",
")",
":",
"distances",
"=",
"get_distances",
"(",
"rupture",
",",
"sites",
",",
"self",
".",
"filter_distance",
")",
"if",
"self",
".",
"maximum_distance",
":",
"mask",
"=",
"distances",
"<=",
"... | Filter the site collection with respect to the rupture.
:param sites:
Instance of :class:`openquake.hazardlib.site.SiteCollection`.
:param rupture:
Instance of
:class:`openquake.hazardlib.source.rupture.BaseRupture`
:returns:
(filtered sites, dist... | [
"Filter",
"the",
"site",
"collection",
"with",
"respect",
"to",
"the",
"rupture",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/contexts.py#L123-L144 | train |
gem/oq-engine | openquake/hazardlib/contexts.py | ContextMaker.add_rup_params | def add_rup_params(self, rupture):
"""
Add .REQUIRES_RUPTURE_PARAMETERS to the rupture
"""
for param in self.REQUIRES_RUPTURE_PARAMETERS:
if param == 'mag':
value = rupture.mag
elif param == 'strike':
value = rupture.surface.get_str... | python | def add_rup_params(self, rupture):
"""
Add .REQUIRES_RUPTURE_PARAMETERS to the rupture
"""
for param in self.REQUIRES_RUPTURE_PARAMETERS:
if param == 'mag':
value = rupture.mag
elif param == 'strike':
value = rupture.surface.get_str... | [
"def",
"add_rup_params",
"(",
"self",
",",
"rupture",
")",
":",
"for",
"param",
"in",
"self",
".",
"REQUIRES_RUPTURE_PARAMETERS",
":",
"if",
"param",
"==",
"'mag'",
":",
"value",
"=",
"rupture",
".",
"mag",
"elif",
"param",
"==",
"'strike'",
":",
"value",
... | Add .REQUIRES_RUPTURE_PARAMETERS to the rupture | [
"Add",
".",
"REQUIRES_RUPTURE_PARAMETERS",
"to",
"the",
"rupture"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/contexts.py#L146-L172 | train |
gem/oq-engine | openquake/hazardlib/contexts.py | ContextMaker.make_contexts | def make_contexts(self, sites, rupture):
"""
Filter the site collection with respect to the rupture and
create context objects.
:param sites:
Instance of :class:`openquake.hazardlib.site.SiteCollection`.
:param rupture:
Instance of
:class:`op... | python | def make_contexts(self, sites, rupture):
"""
Filter the site collection with respect to the rupture and
create context objects.
:param sites:
Instance of :class:`openquake.hazardlib.site.SiteCollection`.
:param rupture:
Instance of
:class:`op... | [
"def",
"make_contexts",
"(",
"self",
",",
"sites",
",",
"rupture",
")",
":",
"sites",
",",
"dctx",
"=",
"self",
".",
"filter",
"(",
"sites",
",",
"rupture",
")",
"for",
"param",
"in",
"self",
".",
"REQUIRES_DISTANCES",
"-",
"set",
"(",
"[",
"self",
"... | Filter the site collection with respect to the rupture and
create context objects.
:param sites:
Instance of :class:`openquake.hazardlib.site.SiteCollection`.
:param rupture:
Instance of
:class:`openquake.hazardlib.source.rupture.BaseRupture`
:retur... | [
"Filter",
"the",
"site",
"collection",
"with",
"respect",
"to",
"the",
"rupture",
"and",
"create",
"context",
"objects",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/contexts.py#L174-L210 | train |
gem/oq-engine | openquake/hazardlib/contexts.py | DistancesContext.roundup | def roundup(self, minimum_distance):
"""
If the minimum_distance is nonzero, returns a copy of the
DistancesContext with updated distances, i.e. the ones below
minimum_distance are rounded up to the minimum_distance. Otherwise,
returns the original DistancesContext unchanged.
... | python | def roundup(self, minimum_distance):
"""
If the minimum_distance is nonzero, returns a copy of the
DistancesContext with updated distances, i.e. the ones below
minimum_distance are rounded up to the minimum_distance. Otherwise,
returns the original DistancesContext unchanged.
... | [
"def",
"roundup",
"(",
"self",
",",
"minimum_distance",
")",
":",
"if",
"not",
"minimum_distance",
":",
"return",
"self",
"ctx",
"=",
"DistancesContext",
"(",
")",
"for",
"dist",
",",
"array",
"in",
"vars",
"(",
"self",
")",
".",
"items",
"(",
")",
":"... | If the minimum_distance is nonzero, returns a copy of the
DistancesContext with updated distances, i.e. the ones below
minimum_distance are rounded up to the minimum_distance. Otherwise,
returns the original DistancesContext unchanged. | [
"If",
"the",
"minimum_distance",
"is",
"nonzero",
"returns",
"a",
"copy",
"of",
"the",
"DistancesContext",
"with",
"updated",
"distances",
"i",
".",
"e",
".",
"the",
"ones",
"below",
"minimum_distance",
"are",
"rounded",
"up",
"to",
"the",
"minimum_distance",
... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/contexts.py#L432-L448 | train |
gem/oq-engine | openquake/hazardlib/contexts.py | RuptureContext.get_probability_no_exceedance | def get_probability_no_exceedance(self, poes):
"""
Compute and return the probability that in the time span for which the
rupture is defined, the rupture itself never generates a ground motion
value higher than a given level at a given site.
Such calculation is performed startin... | python | def get_probability_no_exceedance(self, poes):
"""
Compute and return the probability that in the time span for which the
rupture is defined, the rupture itself never generates a ground motion
value higher than a given level at a given site.
Such calculation is performed startin... | [
"def",
"get_probability_no_exceedance",
"(",
"self",
",",
"poes",
")",
":",
"if",
"numpy",
".",
"isnan",
"(",
"self",
".",
"occurrence_rate",
")",
":",
"# nonparametric rupture",
"# Uses the formula",
"#",
"# ∑ p(k|T) * p(X<x|rup)^k",
"#",
"# where `p(k|T)` is the pr... | Compute and return the probability that in the time span for which the
rupture is defined, the rupture itself never generates a ground motion
value higher than a given level at a given site.
Such calculation is performed starting from the conditional probability
that an occurrence of th... | [
"Compute",
"and",
"return",
"the",
"probability",
"that",
"in",
"the",
"time",
"span",
"for",
"which",
"the",
"rupture",
"is",
"defined",
"the",
"rupture",
"itself",
"never",
"generates",
"a",
"ground",
"motion",
"value",
"higher",
"than",
"a",
"given",
"lev... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/contexts.py#L473-L519 | train |
gem/oq-engine | openquake/hmtk/parsers/catalogue/csv_catalogue_parser.py | CsvCatalogueParser._float_check | def _float_check(self, attribute_array, value, irow, key):
'''Checks if value is valid float, appends to array if valid, appends
nan if not'''
value = value.strip(' ')
try:
if value:
attribute_array = np.hstack([attribute_array, float(value)])
else... | python | def _float_check(self, attribute_array, value, irow, key):
'''Checks if value is valid float, appends to array if valid, appends
nan if not'''
value = value.strip(' ')
try:
if value:
attribute_array = np.hstack([attribute_array, float(value)])
else... | [
"def",
"_float_check",
"(",
"self",
",",
"attribute_array",
",",
"value",
",",
"irow",
",",
"key",
")",
":",
"value",
"=",
"value",
".",
"strip",
"(",
"' '",
")",
"try",
":",
"if",
"value",
":",
"attribute_array",
"=",
"np",
".",
"hstack",
"(",
"[",
... | Checks if value is valid float, appends to array if valid, appends
nan if not | [
"Checks",
"if",
"value",
"is",
"valid",
"float",
"appends",
"to",
"array",
"if",
"valid",
"appends",
"nan",
"if",
"not"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/csv_catalogue_parser.py#L114-L128 | train |
gem/oq-engine | openquake/hmtk/parsers/catalogue/csv_catalogue_parser.py | CsvCatalogueParser._int_check | def _int_check(self, attribute_array, value, irow, key):
'''Checks if value is valid integer, appends to array if valid, appends
nan if not'''
value = value.strip(' ')
try:
if value:
attribute_array = np.hstack([attribute_array, int(value)])
else:
... | python | def _int_check(self, attribute_array, value, irow, key):
'''Checks if value is valid integer, appends to array if valid, appends
nan if not'''
value = value.strip(' ')
try:
if value:
attribute_array = np.hstack([attribute_array, int(value)])
else:
... | [
"def",
"_int_check",
"(",
"self",
",",
"attribute_array",
",",
"value",
",",
"irow",
",",
"key",
")",
":",
"value",
"=",
"value",
".",
"strip",
"(",
"' '",
")",
"try",
":",
"if",
"value",
":",
"attribute_array",
"=",
"np",
".",
"hstack",
"(",
"[",
... | Checks if value is valid integer, appends to array if valid, appends
nan if not | [
"Checks",
"if",
"value",
"is",
"valid",
"integer",
"appends",
"to",
"array",
"if",
"valid",
"appends",
"nan",
"if",
"not"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/csv_catalogue_parser.py#L130-L143 | train |
gem/oq-engine | openquake/hmtk/parsers/catalogue/csv_catalogue_parser.py | CsvCatalogueWriter.write_file | def write_file(self, catalogue, flag_vector=None, magnitude_table=None):
'''
Writes the catalogue to file, purging events if necessary.
:param catalogue:
Earthquake catalogue as instance of :class:
openquake.hmtk.seismicity.catalogue.Catalogue
:param numpy.array ... | python | def write_file(self, catalogue, flag_vector=None, magnitude_table=None):
'''
Writes the catalogue to file, purging events if necessary.
:param catalogue:
Earthquake catalogue as instance of :class:
openquake.hmtk.seismicity.catalogue.Catalogue
:param numpy.array ... | [
"def",
"write_file",
"(",
"self",
",",
"catalogue",
",",
"flag_vector",
"=",
"None",
",",
"magnitude_table",
"=",
"None",
")",
":",
"# First apply purging conditions",
"output_catalogue",
"=",
"self",
".",
"apply_purging",
"(",
"catalogue",
",",
"flag_vector",
","... | Writes the catalogue to file, purging events if necessary.
:param catalogue:
Earthquake catalogue as instance of :class:
openquake.hmtk.seismicity.catalogue.Catalogue
:param numpy.array flag_vector:
Boolean vector specifying whether each event is valid (therefore
... | [
"Writes",
"the",
"catalogue",
"to",
"file",
"purging",
"events",
"if",
"necessary",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/csv_catalogue_parser.py#L169-L206 | train |
gem/oq-engine | openquake/hmtk/parsers/catalogue/csv_catalogue_parser.py | CsvCatalogueWriter.apply_purging | def apply_purging(self, catalogue, flag_vector, magnitude_table):
'''
Apply all the various purging conditions, if specified.
:param catalogue:
Earthquake catalogue as instance of :class:`openquake.hmtk.seismicity.catalogue.Catalogue`
:param numpy.array flag_vector:
... | python | def apply_purging(self, catalogue, flag_vector, magnitude_table):
'''
Apply all the various purging conditions, if specified.
:param catalogue:
Earthquake catalogue as instance of :class:`openquake.hmtk.seismicity.catalogue.Catalogue`
:param numpy.array flag_vector:
... | [
"def",
"apply_purging",
"(",
"self",
",",
"catalogue",
",",
"flag_vector",
",",
"magnitude_table",
")",
":",
"output_catalogue",
"=",
"deepcopy",
"(",
"catalogue",
")",
"if",
"magnitude_table",
"is",
"not",
"None",
":",
"if",
"flag_vector",
"is",
"not",
"None"... | Apply all the various purging conditions, if specified.
:param catalogue:
Earthquake catalogue as instance of :class:`openquake.hmtk.seismicity.catalogue.Catalogue`
:param numpy.array flag_vector:
Boolean vector specifying whether each event is valid (therefore
writt... | [
"Apply",
"all",
"the",
"various",
"purging",
"conditions",
"if",
"specified",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/csv_catalogue_parser.py#L208-L234 | train |
gem/oq-engine | openquake/hazardlib/near_fault.py | get_xyz_from_ll | def get_xyz_from_ll(projected, reference):
"""
This method computes the x, y and z coordinates of a set of points
provided a reference point
:param projected:
:class:`~openquake.hazardlib.geo.point.Point` object
representing the coordinates of target point to be projected
:param ref... | python | def get_xyz_from_ll(projected, reference):
"""
This method computes the x, y and z coordinates of a set of points
provided a reference point
:param projected:
:class:`~openquake.hazardlib.geo.point.Point` object
representing the coordinates of target point to be projected
:param ref... | [
"def",
"get_xyz_from_ll",
"(",
"projected",
",",
"reference",
")",
":",
"azims",
"=",
"geod",
".",
"azimuth",
"(",
"reference",
".",
"longitude",
",",
"reference",
".",
"latitude",
",",
"projected",
".",
"longitude",
",",
"projected",
".",
"latitude",
")",
... | This method computes the x, y and z coordinates of a set of points
provided a reference point
:param projected:
:class:`~openquake.hazardlib.geo.point.Point` object
representing the coordinates of target point to be projected
:param reference:
:class:`~openquake.hazardlib.geo.point.... | [
"This",
"method",
"computes",
"the",
"x",
"y",
"and",
"z",
"coordinates",
"of",
"a",
"set",
"of",
"points",
"provided",
"a",
"reference",
"point"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/near_fault.py#L30-L57 | train |
gem/oq-engine | openquake/hazardlib/gsim/zhao_2016.py | ZhaoEtAl2016Asc.get_magnitude_scaling_term | def get_magnitude_scaling_term(self, C, rup):
"""
Returns the magnitude scaling term in equations 1 and 2
"""
if rup.mag <= self.CONSTANTS["m_c"]:
return C["ccr"] * rup.mag
else:
return (C["ccr"] * self.CONSTANTS["m_c"]) +\
(C["dcr"] * (rup... | python | def get_magnitude_scaling_term(self, C, rup):
"""
Returns the magnitude scaling term in equations 1 and 2
"""
if rup.mag <= self.CONSTANTS["m_c"]:
return C["ccr"] * rup.mag
else:
return (C["ccr"] * self.CONSTANTS["m_c"]) +\
(C["dcr"] * (rup... | [
"def",
"get_magnitude_scaling_term",
"(",
"self",
",",
"C",
",",
"rup",
")",
":",
"if",
"rup",
".",
"mag",
"<=",
"self",
".",
"CONSTANTS",
"[",
"\"m_c\"",
"]",
":",
"return",
"C",
"[",
"\"ccr\"",
"]",
"*",
"rup",
".",
"mag",
"else",
":",
"return",
... | Returns the magnitude scaling term in equations 1 and 2 | [
"Returns",
"the",
"magnitude",
"scaling",
"term",
"in",
"equations",
"1",
"and",
"2"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2016.py#L104-L112 | train |
gem/oq-engine | openquake/hazardlib/gsim/zhao_2016.py | ZhaoEtAl2016Asc.add_site_amplification | def add_site_amplification(self, C, C_SITE, sites, sa_rock, idx, rup):
"""
Applies the site amplification scaling defined in equations from 10
to 15
"""
n_sites = sites.vs30.shape
# Convert from reference rock to hard rock
hard_rock_sa = sa_rock - C["lnSC1AM"]
... | python | def add_site_amplification(self, C, C_SITE, sites, sa_rock, idx, rup):
"""
Applies the site amplification scaling defined in equations from 10
to 15
"""
n_sites = sites.vs30.shape
# Convert from reference rock to hard rock
hard_rock_sa = sa_rock - C["lnSC1AM"]
... | [
"def",
"add_site_amplification",
"(",
"self",
",",
"C",
",",
"C_SITE",
",",
"sites",
",",
"sa_rock",
",",
"idx",
",",
"rup",
")",
":",
"n_sites",
"=",
"sites",
".",
"vs30",
".",
"shape",
"# Convert from reference rock to hard rock",
"hard_rock_sa",
"=",
"sa_ro... | Applies the site amplification scaling defined in equations from 10
to 15 | [
"Applies",
"the",
"site",
"amplification",
"scaling",
"defined",
"in",
"equations",
"from",
"10",
"to",
"15"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2016.py#L154-L213 | train |
gem/oq-engine | openquake/hazardlib/gsim/zhao_2016.py | ZhaoEtAl2016Asc._get_smr_coeffs | def _get_smr_coeffs(self, C, C_SITE, idx, n_sites, sa_rock):
"""
Returns the SReff and SReffC terms needed for equation 14 and 15
"""
# Get SR
sreff = np.zeros(n_sites)
sreffc = np.zeros(n_sites)
f_sr = np.zeros(n_sites)
for i in range(1, 5):
s... | python | def _get_smr_coeffs(self, C, C_SITE, idx, n_sites, sa_rock):
"""
Returns the SReff and SReffC terms needed for equation 14 and 15
"""
# Get SR
sreff = np.zeros(n_sites)
sreffc = np.zeros(n_sites)
f_sr = np.zeros(n_sites)
for i in range(1, 5):
s... | [
"def",
"_get_smr_coeffs",
"(",
"self",
",",
"C",
",",
"C_SITE",
",",
"idx",
",",
"n_sites",
",",
"sa_rock",
")",
":",
"# Get SR",
"sreff",
"=",
"np",
".",
"zeros",
"(",
"n_sites",
")",
"sreffc",
"=",
"np",
".",
"zeros",
"(",
"n_sites",
")",
"f_sr",
... | Returns the SReff and SReffC terms needed for equation 14 and 15 | [
"Returns",
"the",
"SReff",
"and",
"SReffC",
"terms",
"needed",
"for",
"equation",
"14",
"and",
"15"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2016.py#L215-L228 | train |
gem/oq-engine | openquake/hazardlib/gsim/zhao_2016.py | ZhaoEtAl2016Asc._get_ln_a_n_max | def _get_ln_a_n_max(self, C, n_sites, idx, rup):
"""
Defines the rock site amplification defined in equations 10a and 10b
"""
ln_a_n_max = C["lnSC1AM"] * np.ones(n_sites)
for i in [2, 3, 4]:
if np.any(idx[i]):
ln_a_n_max[idx[i]] += C["S{:g}".format(i)]... | python | def _get_ln_a_n_max(self, C, n_sites, idx, rup):
"""
Defines the rock site amplification defined in equations 10a and 10b
"""
ln_a_n_max = C["lnSC1AM"] * np.ones(n_sites)
for i in [2, 3, 4]:
if np.any(idx[i]):
ln_a_n_max[idx[i]] += C["S{:g}".format(i)]... | [
"def",
"_get_ln_a_n_max",
"(",
"self",
",",
"C",
",",
"n_sites",
",",
"idx",
",",
"rup",
")",
":",
"ln_a_n_max",
"=",
"C",
"[",
"\"lnSC1AM\"",
"]",
"*",
"np",
".",
"ones",
"(",
"n_sites",
")",
"for",
"i",
"in",
"[",
"2",
",",
"3",
",",
"4",
"]"... | Defines the rock site amplification defined in equations 10a and 10b | [
"Defines",
"the",
"rock",
"site",
"amplification",
"defined",
"in",
"equations",
"10a",
"and",
"10b"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2016.py#L230-L238 | train |
gem/oq-engine | openquake/hazardlib/gsim/zhao_2016.py | ZhaoEtAl2016Asc._get_ln_sf | def _get_ln_sf(self, C, C_SITE, idx, n_sites, rup):
"""
Returns the log SF term required for equation 12
"""
ln_sf = np.zeros(n_sites)
for i in range(1, 5):
ln_sf_i = (C["lnSC1AM"] - C_SITE["LnAmax1D{:g}".format(i)])
if i > 1:
ln_sf_i += C[... | python | def _get_ln_sf(self, C, C_SITE, idx, n_sites, rup):
"""
Returns the log SF term required for equation 12
"""
ln_sf = np.zeros(n_sites)
for i in range(1, 5):
ln_sf_i = (C["lnSC1AM"] - C_SITE["LnAmax1D{:g}".format(i)])
if i > 1:
ln_sf_i += C[... | [
"def",
"_get_ln_sf",
"(",
"self",
",",
"C",
",",
"C_SITE",
",",
"idx",
",",
"n_sites",
",",
"rup",
")",
":",
"ln_sf",
"=",
"np",
".",
"zeros",
"(",
"n_sites",
")",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"5",
")",
":",
"ln_sf_i",
"=",
"(",
... | Returns the log SF term required for equation 12 | [
"Returns",
"the",
"log",
"SF",
"term",
"required",
"for",
"equation",
"12"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2016.py#L240-L250 | train |
gem/oq-engine | openquake/hazardlib/gsim/zhao_2016.py | ZhaoEtAl2016Asc._get_site_classification | def _get_site_classification(self, vs30):
"""
Define the site class categories based on Vs30. Returns a
vector of site class values and a dictionary containing logical
vectors for each of the site classes
"""
site_class = np.ones(vs30.shape, dtype=int)
idx = {}
... | python | def _get_site_classification(self, vs30):
"""
Define the site class categories based on Vs30. Returns a
vector of site class values and a dictionary containing logical
vectors for each of the site classes
"""
site_class = np.ones(vs30.shape, dtype=int)
idx = {}
... | [
"def",
"_get_site_classification",
"(",
"self",
",",
"vs30",
")",
":",
"site_class",
"=",
"np",
".",
"ones",
"(",
"vs30",
".",
"shape",
",",
"dtype",
"=",
"int",
")",
"idx",
"=",
"{",
"}",
"idx",
"[",
"1",
"]",
"=",
"vs30",
">",
"600.",
"idx",
"[... | Define the site class categories based on Vs30. Returns a
vector of site class values and a dictionary containing logical
vectors for each of the site classes | [
"Define",
"the",
"site",
"class",
"categories",
"based",
"on",
"Vs30",
".",
"Returns",
"a",
"vector",
"of",
"site",
"class",
"values",
"and",
"a",
"dictionary",
"containing",
"logical",
"vectors",
"for",
"each",
"of",
"the",
"site",
"classes"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2016.py#L252-L266 | train |
gem/oq-engine | openquake/hazardlib/gsim/zhao_2016.py | ZhaoEtAl2016UpperMantle.get_sof_term | def get_sof_term(self, C, rup):
"""
In the case of the upper mantle events separate coefficients
are considered for normal, reverse and strike-slip
"""
if rup.rake <= -45.0 and rup.rake >= -135.0:
# Normal faulting
return C["FN_UM"]
elif rup.rake >... | python | def get_sof_term(self, C, rup):
"""
In the case of the upper mantle events separate coefficients
are considered for normal, reverse and strike-slip
"""
if rup.rake <= -45.0 and rup.rake >= -135.0:
# Normal faulting
return C["FN_UM"]
elif rup.rake >... | [
"def",
"get_sof_term",
"(",
"self",
",",
"C",
",",
"rup",
")",
":",
"if",
"rup",
".",
"rake",
"<=",
"-",
"45.0",
"and",
"rup",
".",
"rake",
">=",
"-",
"135.0",
":",
"# Normal faulting",
"return",
"C",
"[",
"\"FN_UM\"",
"]",
"elif",
"rup",
".",
"rak... | In the case of the upper mantle events separate coefficients
are considered for normal, reverse and strike-slip | [
"In",
"the",
"case",
"of",
"the",
"upper",
"mantle",
"events",
"separate",
"coefficients",
"are",
"considered",
"for",
"normal",
"reverse",
"and",
"strike",
"-",
"slip"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2016.py#L421-L434 | train |
gem/oq-engine | openquake/hazardlib/gsim/zhao_2016.py | ZhaoEtAl2016UpperMantle.get_distance_term | def get_distance_term(self, C, dists, rup):
"""
Returns the distance attenuation term
"""
x_ij = dists.rrup
gn_exp = np.exp(C["c1"] + 6.5 * C["c2"])
g_n = C["gcrN"] * np.log(self.CONSTANTS["xcro"] + 30. + gn_exp) *\
np.ones_like(x_ij)
idx = x_ij <= 30.... | python | def get_distance_term(self, C, dists, rup):
"""
Returns the distance attenuation term
"""
x_ij = dists.rrup
gn_exp = np.exp(C["c1"] + 6.5 * C["c2"])
g_n = C["gcrN"] * np.log(self.CONSTANTS["xcro"] + 30. + gn_exp) *\
np.ones_like(x_ij)
idx = x_ij <= 30.... | [
"def",
"get_distance_term",
"(",
"self",
",",
"C",
",",
"dists",
",",
"rup",
")",
":",
"x_ij",
"=",
"dists",
".",
"rrup",
"gn_exp",
"=",
"np",
".",
"exp",
"(",
"C",
"[",
"\"c1\"",
"]",
"+",
"6.5",
"*",
"C",
"[",
"\"c2\"",
"]",
")",
"g_n",
"=",
... | Returns the distance attenuation term | [
"Returns",
"the",
"distance",
"attenuation",
"term"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2016.py#L442-L458 | train |
gem/oq-engine | openquake/hazardlib/gsim/zhao_2016.py | ZhaoEtAl2016SInter.get_magnitude_scaling_term | def get_magnitude_scaling_term(self, C, rup):
"""
Returns magnitude scaling term, which is dependent on top of rupture
depth - as described in equations 1 and 2
"""
if rup.ztor > 25.0:
# Deep interface events
c_int = C["cint"]
else:
c_i... | python | def get_magnitude_scaling_term(self, C, rup):
"""
Returns magnitude scaling term, which is dependent on top of rupture
depth - as described in equations 1 and 2
"""
if rup.ztor > 25.0:
# Deep interface events
c_int = C["cint"]
else:
c_i... | [
"def",
"get_magnitude_scaling_term",
"(",
"self",
",",
"C",
",",
"rup",
")",
":",
"if",
"rup",
".",
"ztor",
">",
"25.0",
":",
"# Deep interface events",
"c_int",
"=",
"C",
"[",
"\"cint\"",
"]",
"else",
":",
"c_int",
"=",
"C",
"[",
"\"cintS\"",
"]",
"if... | Returns magnitude scaling term, which is dependent on top of rupture
depth - as described in equations 1 and 2 | [
"Returns",
"magnitude",
"scaling",
"term",
"which",
"is",
"dependent",
"on",
"top",
"of",
"rupture",
"depth",
"-",
"as",
"described",
"in",
"equations",
"1",
"and",
"2"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2016.py#L549-L564 | train |
gem/oq-engine | openquake/hazardlib/gsim/zhao_2016.py | ZhaoEtAl2016SSlab.get_magnitude_scaling_term | def get_magnitude_scaling_term(self, C, rup):
"""
Returns the magnitude scaling defined in equation 1
"""
m_c = self.CONSTANTS["m_c"]
if rup.mag <= m_c:
return C["cSL"] * rup.mag +\
C["cSL2"] * ((rup.mag - self.CONSTANTS["m_sc"]) ** 2.)
else:
... | python | def get_magnitude_scaling_term(self, C, rup):
"""
Returns the magnitude scaling defined in equation 1
"""
m_c = self.CONSTANTS["m_c"]
if rup.mag <= m_c:
return C["cSL"] * rup.mag +\
C["cSL2"] * ((rup.mag - self.CONSTANTS["m_sc"]) ** 2.)
else:
... | [
"def",
"get_magnitude_scaling_term",
"(",
"self",
",",
"C",
",",
"rup",
")",
":",
"m_c",
"=",
"self",
".",
"CONSTANTS",
"[",
"\"m_c\"",
"]",
"if",
"rup",
".",
"mag",
"<=",
"m_c",
":",
"return",
"C",
"[",
"\"cSL\"",
"]",
"*",
"rup",
".",
"mag",
"+",... | Returns the magnitude scaling defined in equation 1 | [
"Returns",
"the",
"magnitude",
"scaling",
"defined",
"in",
"equation",
"1"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2016.py#L774-L785 | train |
gem/oq-engine | openquake/hazardlib/gsim/zhao_2016.py | ZhaoEtAl2016SSlab.get_distance_term | def get_distance_term(self, C, dists, rup):
"""
Returns the distance scaling term in equation 2a
Note that the paper describes a lower and upper cap on Rvolc that
is not found in the Fortran code, and is thus neglected here.
"""
x_ij = dists.rrup
# Get anelastic ... | python | def get_distance_term(self, C, dists, rup):
"""
Returns the distance scaling term in equation 2a
Note that the paper describes a lower and upper cap on Rvolc that
is not found in the Fortran code, and is thus neglected here.
"""
x_ij = dists.rrup
# Get anelastic ... | [
"def",
"get_distance_term",
"(",
"self",
",",
"C",
",",
"dists",
",",
"rup",
")",
":",
"x_ij",
"=",
"dists",
".",
"rrup",
"# Get anelastic scaling term in quation 5",
"if",
"rup",
".",
"ztor",
">=",
"50.",
":",
"qslh",
"=",
"C",
"[",
"\"eSLH\"",
"]",
"*"... | Returns the distance scaling term in equation 2a
Note that the paper describes a lower and upper cap on Rvolc that
is not found in the Fortran code, and is thus neglected here. | [
"Returns",
"the",
"distance",
"scaling",
"term",
"in",
"equation",
"2a"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2016.py#L806-L828 | train |
gem/oq-engine | openquake/hazardlib/gsim/edwards_fah_2013a.py | EdwardsFah2013Alpine10Bars._get_stddevs | def _get_stddevs(self, C, stddev_types, num_sites, mag, c1_rrup,
log_phi_ss, mean_phi_ss):
"""
Return standard deviations
"""
phi_ss = _compute_phi_ss(C, mag, c1_rrup, log_phi_ss, mean_phi_ss)
stddevs = []
for stddev_type in stddev_types:
... | python | def _get_stddevs(self, C, stddev_types, num_sites, mag, c1_rrup,
log_phi_ss, mean_phi_ss):
"""
Return standard deviations
"""
phi_ss = _compute_phi_ss(C, mag, c1_rrup, log_phi_ss, mean_phi_ss)
stddevs = []
for stddev_type in stddev_types:
... | [
"def",
"_get_stddevs",
"(",
"self",
",",
"C",
",",
"stddev_types",
",",
"num_sites",
",",
"mag",
",",
"c1_rrup",
",",
"log_phi_ss",
",",
"mean_phi_ss",
")",
":",
"phi_ss",
"=",
"_compute_phi_ss",
"(",
"C",
",",
"mag",
",",
"c1_rrup",
",",
"log_phi_ss",
"... | Return standard deviations | [
"Return",
"standard",
"deviations"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/edwards_fah_2013a.py#L129-L151 | train |
gem/oq-engine | openquake/commonlib/util.py | max_rel_diff | def max_rel_diff(curve_ref, curve, min_value=0.01):
"""
Compute the maximum relative difference between two curves. Only values
greather or equal than the min_value are considered.
>>> curve_ref = [0.01, 0.02, 0.03, 0.05, 1.0]
>>> curve = [0.011, 0.021, 0.031, 0.051, 1.0]
>>> round(max_rel_diff... | python | def max_rel_diff(curve_ref, curve, min_value=0.01):
"""
Compute the maximum relative difference between two curves. Only values
greather or equal than the min_value are considered.
>>> curve_ref = [0.01, 0.02, 0.03, 0.05, 1.0]
>>> curve = [0.011, 0.021, 0.031, 0.051, 1.0]
>>> round(max_rel_diff... | [
"def",
"max_rel_diff",
"(",
"curve_ref",
",",
"curve",
",",
"min_value",
"=",
"0.01",
")",
":",
"assert",
"len",
"(",
"curve_ref",
")",
"==",
"len",
"(",
"curve",
")",
",",
"(",
"len",
"(",
"curve_ref",
")",
",",
"len",
"(",
"curve",
")",
")",
"ass... | Compute the maximum relative difference between two curves. Only values
greather or equal than the min_value are considered.
>>> curve_ref = [0.01, 0.02, 0.03, 0.05, 1.0]
>>> curve = [0.011, 0.021, 0.031, 0.051, 1.0]
>>> round(max_rel_diff(curve_ref, curve), 2)
0.1 | [
"Compute",
"the",
"maximum",
"relative",
"difference",
"between",
"two",
"curves",
".",
"Only",
"values",
"greather",
"or",
"equal",
"than",
"the",
"min_value",
"are",
"considered",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/util.py#L43-L59 | train |
gem/oq-engine | openquake/commonlib/util.py | rmsep | def rmsep(array_ref, array, min_value=0):
"""
Root Mean Square Error Percentage for two arrays.
:param array_ref: reference array
:param array: another array
:param min_value: compare only the elements larger than min_value
:returns: the relative distance between the arrays
>>> curve_ref =... | python | def rmsep(array_ref, array, min_value=0):
"""
Root Mean Square Error Percentage for two arrays.
:param array_ref: reference array
:param array: another array
:param min_value: compare only the elements larger than min_value
:returns: the relative distance between the arrays
>>> curve_ref =... | [
"def",
"rmsep",
"(",
"array_ref",
",",
"array",
",",
"min_value",
"=",
"0",
")",
":",
"bigvalues",
"=",
"array_ref",
">",
"min_value",
"reldiffsquare",
"=",
"(",
"1.",
"-",
"array",
"[",
"bigvalues",
"]",
"/",
"array_ref",
"[",
"bigvalues",
"]",
")",
"... | Root Mean Square Error Percentage for two arrays.
:param array_ref: reference array
:param array: another array
:param min_value: compare only the elements larger than min_value
:returns: the relative distance between the arrays
>>> curve_ref = numpy.array([[0.01, 0.02, 0.03, 0.05],
... [0.01,... | [
"Root",
"Mean",
"Square",
"Error",
"Percentage",
"for",
"two",
"arrays",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/util.py#L82-L100 | train |
gem/oq-engine | openquake/commonlib/util.py | log | def log(array, cutoff):
"""
Compute the logarithm of an array with a cutoff on the small values
"""
arr = numpy.copy(array)
arr[arr < cutoff] = cutoff
return numpy.log(arr) | python | def log(array, cutoff):
"""
Compute the logarithm of an array with a cutoff on the small values
"""
arr = numpy.copy(array)
arr[arr < cutoff] = cutoff
return numpy.log(arr) | [
"def",
"log",
"(",
"array",
",",
"cutoff",
")",
":",
"arr",
"=",
"numpy",
".",
"copy",
"(",
"array",
")",
"arr",
"[",
"arr",
"<",
"cutoff",
"]",
"=",
"cutoff",
"return",
"numpy",
".",
"log",
"(",
"arr",
")"
] | Compute the logarithm of an array with a cutoff on the small values | [
"Compute",
"the",
"logarithm",
"of",
"an",
"array",
"with",
"a",
"cutoff",
"on",
"the",
"small",
"values"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/util.py#L103-L109 | train |
gem/oq-engine | openquake/commonlib/util.py | compose_arrays | def compose_arrays(a1, a2, firstfield='etag'):
"""
Compose composite arrays by generating an extended datatype containing
all the fields. The two arrays must have the same length.
"""
assert len(a1) == len(a2), (len(a1), len(a2))
if a1.dtype.names is None and len(a1.shape) == 1:
# the f... | python | def compose_arrays(a1, a2, firstfield='etag'):
"""
Compose composite arrays by generating an extended datatype containing
all the fields. The two arrays must have the same length.
"""
assert len(a1) == len(a2), (len(a1), len(a2))
if a1.dtype.names is None and len(a1.shape) == 1:
# the f... | [
"def",
"compose_arrays",
"(",
"a1",
",",
"a2",
",",
"firstfield",
"=",
"'etag'",
")",
":",
"assert",
"len",
"(",
"a1",
")",
"==",
"len",
"(",
"a2",
")",
",",
"(",
"len",
"(",
"a1",
")",
",",
"len",
"(",
"a2",
")",
")",
"if",
"a1",
".",
"dtype... | Compose composite arrays by generating an extended datatype containing
all the fields. The two arrays must have the same length. | [
"Compose",
"composite",
"arrays",
"by",
"generating",
"an",
"extended",
"datatype",
"containing",
"all",
"the",
"fields",
".",
"The",
"two",
"arrays",
"must",
"have",
"the",
"same",
"length",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/util.py#L128-L156 | train |
gem/oq-engine | openquake/server/db/upgrade_manager.py | check_script | def check_script(upgrade, conn, dry_run=True, debug=True):
"""
An utility to debug upgrade scripts written in Python
:param upgrade: upgrade procedure
:param conn: a DB API 2 connection
:param dry_run: if True, do not change the database
:param debug: if True, print the queries which are execut... | python | def check_script(upgrade, conn, dry_run=True, debug=True):
"""
An utility to debug upgrade scripts written in Python
:param upgrade: upgrade procedure
:param conn: a DB API 2 connection
:param dry_run: if True, do not change the database
:param debug: if True, print the queries which are execut... | [
"def",
"check_script",
"(",
"upgrade",
",",
"conn",
",",
"dry_run",
"=",
"True",
",",
"debug",
"=",
"True",
")",
":",
"conn",
"=",
"WrappedConnection",
"(",
"conn",
",",
"debug",
"=",
"debug",
")",
"try",
":",
"upgrade",
"(",
"conn",
")",
"except",
"... | An utility to debug upgrade scripts written in Python
:param upgrade: upgrade procedure
:param conn: a DB API 2 connection
:param dry_run: if True, do not change the database
:param debug: if True, print the queries which are executed | [
"An",
"utility",
"to",
"debug",
"upgrade",
"scripts",
"written",
"in",
"Python"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/upgrade_manager.py#L87-L106 | train |
gem/oq-engine | openquake/server/db/upgrade_manager.py | apply_sql_script | def apply_sql_script(conn, fname):
"""
Apply the given SQL script to the database
:param conn: a DB API 2 connection
:param fname: full path to the creation script
"""
sql = open(fname).read()
try:
# we cannot use conn.executescript which is non transactional
for query in sq... | python | def apply_sql_script(conn, fname):
"""
Apply the given SQL script to the database
:param conn: a DB API 2 connection
:param fname: full path to the creation script
"""
sql = open(fname).read()
try:
# we cannot use conn.executescript which is non transactional
for query in sq... | [
"def",
"apply_sql_script",
"(",
"conn",
",",
"fname",
")",
":",
"sql",
"=",
"open",
"(",
"fname",
")",
".",
"read",
"(",
")",
"try",
":",
"# we cannot use conn.executescript which is non transactional",
"for",
"query",
"in",
"sql",
".",
"split",
"(",
"'\\n\\n'... | Apply the given SQL script to the database
:param conn: a DB API 2 connection
:param fname: full path to the creation script | [
"Apply",
"the",
"given",
"SQL",
"script",
"to",
"the",
"database"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/upgrade_manager.py#L109-L123 | train |
gem/oq-engine | openquake/server/db/upgrade_manager.py | upgrade_db | def upgrade_db(conn, pkg_name='openquake.server.db.schema.upgrades',
skip_versions=()):
"""
Upgrade a database by running several scripts in a single transaction.
:param conn: a DB API 2 connection
:param str pkg_name: the name of the package with the upgrade scripts
:param list skip... | python | def upgrade_db(conn, pkg_name='openquake.server.db.schema.upgrades',
skip_versions=()):
"""
Upgrade a database by running several scripts in a single transaction.
:param conn: a DB API 2 connection
:param str pkg_name: the name of the package with the upgrade scripts
:param list skip... | [
"def",
"upgrade_db",
"(",
"conn",
",",
"pkg_name",
"=",
"'openquake.server.db.schema.upgrades'",
",",
"skip_versions",
"=",
"(",
")",
")",
":",
"upgrader",
"=",
"UpgradeManager",
".",
"instance",
"(",
"conn",
",",
"pkg_name",
")",
"t0",
"=",
"time",
".",
"ti... | Upgrade a database by running several scripts in a single transaction.
:param conn: a DB API 2 connection
:param str pkg_name: the name of the package with the upgrade scripts
:param list skip_versions: the versions to skip
:returns: the version numbers of the new scripts applied the database | [
"Upgrade",
"a",
"database",
"by",
"running",
"several",
"scripts",
"in",
"a",
"single",
"transaction",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/upgrade_manager.py#L331-L353 | train |
gem/oq-engine | openquake/server/db/upgrade_manager.py | WrappedConnection.run | def run(self, templ, *args):
"""
A simple utility to run SQL queries.
:param templ: a query or query template
:param args: the arguments (or the empty tuple)
:returns: the DB API 2 cursor used to run the query
"""
curs = self._conn.cursor()
query = curs.m... | python | def run(self, templ, *args):
"""
A simple utility to run SQL queries.
:param templ: a query or query template
:param args: the arguments (or the empty tuple)
:returns: the DB API 2 cursor used to run the query
"""
curs = self._conn.cursor()
query = curs.m... | [
"def",
"run",
"(",
"self",
",",
"templ",
",",
"*",
"args",
")",
":",
"curs",
"=",
"self",
".",
"_conn",
".",
"cursor",
"(",
")",
"query",
"=",
"curs",
".",
"mogrify",
"(",
"templ",
",",
"args",
")",
"if",
"self",
".",
"debug",
":",
"print",
"("... | A simple utility to run SQL queries.
:param templ: a query or query template
:param args: the arguments (or the empty tuple)
:returns: the DB API 2 cursor used to run the query | [
"A",
"simple",
"utility",
"to",
"run",
"SQL",
"queries",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/upgrade_manager.py#L70-L83 | train |
gem/oq-engine | openquake/server/db/upgrade_manager.py | UpgradeManager.install_versioning | def install_versioning(self, conn):
"""
Create the version table into an already populated database
and insert the base script.
:param conn: a DB API 2 connection
"""
logging.info('Creating the versioning table %s', self.version_table)
conn.executescript(CREATE_V... | python | def install_versioning(self, conn):
"""
Create the version table into an already populated database
and insert the base script.
:param conn: a DB API 2 connection
"""
logging.info('Creating the versioning table %s', self.version_table)
conn.executescript(CREATE_V... | [
"def",
"install_versioning",
"(",
"self",
",",
"conn",
")",
":",
"logging",
".",
"info",
"(",
"'Creating the versioning table %s'",
",",
"self",
".",
"version_table",
")",
"conn",
".",
"executescript",
"(",
"CREATE_VERSIONING",
"%",
"self",
".",
"version_table",
... | Create the version table into an already populated database
and insert the base script.
:param conn: a DB API 2 connection | [
"Create",
"the",
"version",
"table",
"into",
"an",
"already",
"populated",
"database",
"and",
"insert",
"the",
"base",
"script",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/upgrade_manager.py#L163-L172 | train |
gem/oq-engine | openquake/server/db/upgrade_manager.py | UpgradeManager.init | def init(self, conn):
"""
Create the version table and run the base script on an empty database.
:param conn: a DB API 2 connection
"""
base = self.read_scripts()[0]['fname']
logging.info('Creating the initial schema from %s', base)
apply_sql_script(conn, os.pat... | python | def init(self, conn):
"""
Create the version table and run the base script on an empty database.
:param conn: a DB API 2 connection
"""
base = self.read_scripts()[0]['fname']
logging.info('Creating the initial schema from %s', base)
apply_sql_script(conn, os.pat... | [
"def",
"init",
"(",
"self",
",",
"conn",
")",
":",
"base",
"=",
"self",
".",
"read_scripts",
"(",
")",
"[",
"0",
"]",
"[",
"'fname'",
"]",
"logging",
".",
"info",
"(",
"'Creating the initial schema from %s'",
",",
"base",
")",
"apply_sql_script",
"(",
"c... | Create the version table and run the base script on an empty database.
:param conn: a DB API 2 connection | [
"Create",
"the",
"version",
"table",
"and",
"run",
"the",
"base",
"script",
"on",
"an",
"empty",
"database",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/upgrade_manager.py#L174-L183 | train |
gem/oq-engine | openquake/server/db/upgrade_manager.py | UpgradeManager.upgrade | def upgrade(self, conn, skip_versions=()):
'''
Upgrade the database from the current version to the maximum
version in the upgrade scripts.
:param conn: a DBAPI 2 connection
:param skip_versions: the versions to skip
'''
db_versions = self.get_db_versions(conn)
... | python | def upgrade(self, conn, skip_versions=()):
'''
Upgrade the database from the current version to the maximum
version in the upgrade scripts.
:param conn: a DBAPI 2 connection
:param skip_versions: the versions to skip
'''
db_versions = self.get_db_versions(conn)
... | [
"def",
"upgrade",
"(",
"self",
",",
"conn",
",",
"skip_versions",
"=",
"(",
")",
")",
":",
"db_versions",
"=",
"self",
".",
"get_db_versions",
"(",
"conn",
")",
"self",
".",
"starting_version",
"=",
"max",
"(",
"db_versions",
")",
"to_skip",
"=",
"sorted... | Upgrade the database from the current version to the maximum
version in the upgrade scripts.
:param conn: a DBAPI 2 connection
:param skip_versions: the versions to skip | [
"Upgrade",
"the",
"database",
"from",
"the",
"current",
"version",
"to",
"the",
"maximum",
"version",
"in",
"the",
"upgrade",
"scripts",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/upgrade_manager.py#L185-L200 | train |
gem/oq-engine | openquake/server/db/upgrade_manager.py | UpgradeManager.get_db_versions | def get_db_versions(self, conn):
"""
Get all the versions stored in the database as a set.
:param conn: a DB API 2 connection
"""
curs = conn.cursor()
query = 'select version from {}'.format(self.version_table)
try:
curs.execute(query)
ret... | python | def get_db_versions(self, conn):
"""
Get all the versions stored in the database as a set.
:param conn: a DB API 2 connection
"""
curs = conn.cursor()
query = 'select version from {}'.format(self.version_table)
try:
curs.execute(query)
ret... | [
"def",
"get_db_versions",
"(",
"self",
",",
"conn",
")",
":",
"curs",
"=",
"conn",
".",
"cursor",
"(",
")",
"query",
"=",
"'select version from {}'",
".",
"format",
"(",
"self",
".",
"version_table",
")",
"try",
":",
"curs",
".",
"execute",
"(",
"query",... | Get all the versions stored in the database as a set.
:param conn: a DB API 2 connection | [
"Get",
"all",
"the",
"versions",
"stored",
"in",
"the",
"database",
"as",
"a",
"set",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/upgrade_manager.py#L231-L243 | train |
gem/oq-engine | openquake/server/db/upgrade_manager.py | UpgradeManager.read_scripts | def read_scripts(self, minversion=None, maxversion=None, skip_versions=()):
"""
Extract the upgrade scripts from a directory as a list of
dictionaries, ordered by version.
:param minversion: the minimum version to consider
:param maxversion: the maximum version to consider
... | python | def read_scripts(self, minversion=None, maxversion=None, skip_versions=()):
"""
Extract the upgrade scripts from a directory as a list of
dictionaries, ordered by version.
:param minversion: the minimum version to consider
:param maxversion: the maximum version to consider
... | [
"def",
"read_scripts",
"(",
"self",
",",
"minversion",
"=",
"None",
",",
"maxversion",
"=",
"None",
",",
"skip_versions",
"=",
"(",
")",
")",
":",
"scripts",
"=",
"[",
"]",
"versions",
"=",
"{",
"}",
"# a script is unique per version",
"for",
"scriptname",
... | Extract the upgrade scripts from a directory as a list of
dictionaries, ordered by version.
:param minversion: the minimum version to consider
:param maxversion: the maximum version to consider
:param skipversions: the versions to skip | [
"Extract",
"the",
"upgrade",
"scripts",
"from",
"a",
"directory",
"as",
"a",
"list",
"of",
"dictionaries",
"ordered",
"by",
"version",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/upgrade_manager.py#L259-L289 | train |
gem/oq-engine | openquake/server/db/upgrade_manager.py | UpgradeManager.extract_upgrade_scripts | def extract_upgrade_scripts(self):
"""
Extract the OpenQuake upgrade scripts from the links in the GitHub page
"""
link_pattern = '>\s*{0}\s*<'.format(self.pattern[1:-1])
page = urllib.request.urlopen(self.upgrades_url).read()
for mo in re.finditer(link_pattern, page):
... | python | def extract_upgrade_scripts(self):
"""
Extract the OpenQuake upgrade scripts from the links in the GitHub page
"""
link_pattern = '>\s*{0}\s*<'.format(self.pattern[1:-1])
page = urllib.request.urlopen(self.upgrades_url).read()
for mo in re.finditer(link_pattern, page):
... | [
"def",
"extract_upgrade_scripts",
"(",
"self",
")",
":",
"link_pattern",
"=",
"'>\\s*{0}\\s*<'",
".",
"format",
"(",
"self",
".",
"pattern",
"[",
"1",
":",
"-",
"1",
"]",
")",
"page",
"=",
"urllib",
".",
"request",
".",
"urlopen",
"(",
"self",
".",
"up... | Extract the OpenQuake upgrade scripts from the links in the GitHub page | [
"Extract",
"the",
"OpenQuake",
"upgrade",
"scripts",
"from",
"the",
"links",
"in",
"the",
"GitHub",
"page"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/upgrade_manager.py#L291-L299 | train |
gem/oq-engine | openquake/hazardlib/geo/line.py | Line.average_azimuth | def average_azimuth(self):
"""
Calculate and return weighted average azimuth of all line's segments
in decimal degrees.
Uses formula from
http://en.wikipedia.org/wiki/Mean_of_circular_quantities
>>> from openquake.hazardlib.geo.point import Point as P
>>> '%.1f'... | python | def average_azimuth(self):
"""
Calculate and return weighted average azimuth of all line's segments
in decimal degrees.
Uses formula from
http://en.wikipedia.org/wiki/Mean_of_circular_quantities
>>> from openquake.hazardlib.geo.point import Point as P
>>> '%.1f'... | [
"def",
"average_azimuth",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"points",
")",
"==",
"2",
":",
"return",
"self",
".",
"points",
"[",
"0",
"]",
".",
"azimuth",
"(",
"self",
".",
"points",
"[",
"1",
"]",
")",
"lons",
"=",
"numpy",
... | Calculate and return weighted average azimuth of all line's segments
in decimal degrees.
Uses formula from
http://en.wikipedia.org/wiki/Mean_of_circular_quantities
>>> from openquake.hazardlib.geo.point import Point as P
>>> '%.1f' % Line([P(0, 0), P(1e-5, 1e-5)]).average_azimu... | [
"Calculate",
"and",
"return",
"weighted",
"average",
"azimuth",
"of",
"all",
"line",
"s",
"segments",
"in",
"decimal",
"degrees",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/line.py#L93-L126 | train |
gem/oq-engine | openquake/hazardlib/geo/line.py | Line.resample | def resample(self, section_length):
"""
Resample this line into sections.
The first point in the resampled line corresponds
to the first point in the original line.
Starting from the first point in the original line, a line
segment is defined as the line connecting the ... | python | def resample(self, section_length):
"""
Resample this line into sections.
The first point in the resampled line corresponds
to the first point in the original line.
Starting from the first point in the original line, a line
segment is defined as the line connecting the ... | [
"def",
"resample",
"(",
"self",
",",
"section_length",
")",
":",
"if",
"len",
"(",
"self",
".",
"points",
")",
"<",
"2",
":",
"return",
"Line",
"(",
"self",
".",
"points",
")",
"resampled_points",
"=",
"[",
"]",
"# 1. Resample the first section. 2. Loop over... | Resample this line into sections.
The first point in the resampled line corresponds
to the first point in the original line.
Starting from the first point in the original line, a line
segment is defined as the line connecting the last point in the
resampled line and the next po... | [
"Resample",
"this",
"line",
"into",
"sections",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/line.py#L128-L189 | train |
gem/oq-engine | openquake/hazardlib/geo/line.py | Line.get_length | def get_length(self):
"""
Calculate and return the length of the line as a sum of lengths
of all its segments.
:returns:
Total length in km.
"""
length = 0
for i, point in enumerate(self.points):
if i != 0:
length += point.... | python | def get_length(self):
"""
Calculate and return the length of the line as a sum of lengths
of all its segments.
:returns:
Total length in km.
"""
length = 0
for i, point in enumerate(self.points):
if i != 0:
length += point.... | [
"def",
"get_length",
"(",
"self",
")",
":",
"length",
"=",
"0",
"for",
"i",
",",
"point",
"in",
"enumerate",
"(",
"self",
".",
"points",
")",
":",
"if",
"i",
"!=",
"0",
":",
"length",
"+=",
"point",
".",
"distance",
"(",
"self",
".",
"points",
"[... | Calculate and return the length of the line as a sum of lengths
of all its segments.
:returns:
Total length in km. | [
"Calculate",
"and",
"return",
"the",
"length",
"of",
"the",
"line",
"as",
"a",
"sum",
"of",
"lengths",
"of",
"all",
"its",
"segments",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/line.py#L191-L203 | train |
gem/oq-engine | openquake/hazardlib/geo/line.py | Line.resample_to_num_points | def resample_to_num_points(self, num_points):
"""
Resample the line to a specified number of points.
:param num_points:
Integer number of points the resulting line should have.
:returns:
A new line with that many points as requested.
"""
assert le... | python | def resample_to_num_points(self, num_points):
"""
Resample the line to a specified number of points.
:param num_points:
Integer number of points the resulting line should have.
:returns:
A new line with that many points as requested.
"""
assert le... | [
"def",
"resample_to_num_points",
"(",
"self",
",",
"num_points",
")",
":",
"assert",
"len",
"(",
"self",
".",
"points",
")",
">",
"1",
",",
"\"can not resample the line of one point\"",
"section_length",
"=",
"self",
".",
"get_length",
"(",
")",
"/",
"(",
"num... | Resample the line to a specified number of points.
:param num_points:
Integer number of points the resulting line should have.
:returns:
A new line with that many points as requested. | [
"Resample",
"the",
"line",
"to",
"a",
"specified",
"number",
"of",
"points",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/line.py#L205-L243 | train |
gem/oq-engine | openquake/hazardlib/gsim/nga_east.py | cena_tau | def cena_tau(imt, mag, params):
"""
Returns the inter-event standard deviation, tau, for the CENA case
"""
if imt.name == "PGV":
C = params["PGV"]
else:
C = params["SA"]
if mag > 6.5:
return C["tau3"]
elif (mag > 5.5) and (mag <= 6.5):
return ITPL(mag, C["tau3... | python | def cena_tau(imt, mag, params):
"""
Returns the inter-event standard deviation, tau, for the CENA case
"""
if imt.name == "PGV":
C = params["PGV"]
else:
C = params["SA"]
if mag > 6.5:
return C["tau3"]
elif (mag > 5.5) and (mag <= 6.5):
return ITPL(mag, C["tau3... | [
"def",
"cena_tau",
"(",
"imt",
",",
"mag",
",",
"params",
")",
":",
"if",
"imt",
".",
"name",
"==",
"\"PGV\"",
":",
"C",
"=",
"params",
"[",
"\"PGV\"",
"]",
"else",
":",
"C",
"=",
"params",
"[",
"\"SA\"",
"]",
"if",
"mag",
">",
"6.5",
":",
"ret... | Returns the inter-event standard deviation, tau, for the CENA case | [
"Returns",
"the",
"inter",
"-",
"event",
"standard",
"deviation",
"tau",
"for",
"the",
"CENA",
"case"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/nga_east.py#L174-L189 | train |
gem/oq-engine | openquake/hazardlib/gsim/nga_east.py | get_tau_at_quantile | def get_tau_at_quantile(mean, stddev, quantile):
"""
Returns the value of tau at a given quantile in the form of a dictionary
organised by intensity measure
"""
tau_model = {}
for imt in mean:
tau_model[imt] = {}
for key in mean[imt]:
if quantile is None:
... | python | def get_tau_at_quantile(mean, stddev, quantile):
"""
Returns the value of tau at a given quantile in the form of a dictionary
organised by intensity measure
"""
tau_model = {}
for imt in mean:
tau_model[imt] = {}
for key in mean[imt]:
if quantile is None:
... | [
"def",
"get_tau_at_quantile",
"(",
"mean",
",",
"stddev",
",",
"quantile",
")",
":",
"tau_model",
"=",
"{",
"}",
"for",
"imt",
"in",
"mean",
":",
"tau_model",
"[",
"imt",
"]",
"=",
"{",
"}",
"for",
"key",
"in",
"mean",
"[",
"imt",
"]",
":",
"if",
... | Returns the value of tau at a given quantile in the form of a dictionary
organised by intensity measure | [
"Returns",
"the",
"value",
"of",
"tau",
"at",
"a",
"given",
"quantile",
"in",
"the",
"form",
"of",
"a",
"dictionary",
"organised",
"by",
"intensity",
"measure"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/nga_east.py#L192-L207 | train |
gem/oq-engine | openquake/hazardlib/gsim/nga_east.py | NGAEastBaseGMPE.get_stddevs | def get_stddevs(self, mag, imt, stddev_types, num_sites):
"""
Returns the standard deviations for either the ergodic or
non-ergodic models
"""
tau = self._get_tau(imt, mag)
phi = self._get_phi(imt, mag)
sigma = np.sqrt(tau ** 2. + phi ** 2.)
stddevs = []
... | python | def get_stddevs(self, mag, imt, stddev_types, num_sites):
"""
Returns the standard deviations for either the ergodic or
non-ergodic models
"""
tau = self._get_tau(imt, mag)
phi = self._get_phi(imt, mag)
sigma = np.sqrt(tau ** 2. + phi ** 2.)
stddevs = []
... | [
"def",
"get_stddevs",
"(",
"self",
",",
"mag",
",",
"imt",
",",
"stddev_types",
",",
"num_sites",
")",
":",
"tau",
"=",
"self",
".",
"_get_tau",
"(",
"imt",
",",
"mag",
")",
"phi",
"=",
"self",
".",
"_get_phi",
"(",
"imt",
",",
"mag",
")",
"sigma",... | Returns the standard deviations for either the ergodic or
non-ergodic models | [
"Returns",
"the",
"standard",
"deviations",
"for",
"either",
"the",
"ergodic",
"or",
"non",
"-",
"ergodic",
"models"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/nga_east.py#L511-L528 | train |
gem/oq-engine | openquake/hazardlib/gsim/nga_east.py | NGAEastBaseGMPETotalSigma.get_stddevs | def get_stddevs(self, mag, imt, stddev_types, num_sites):
"""
Returns the total standard deviation
"""
stddevs = []
for stddev_type in stddev_types:
assert stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
if stddev_type == const.StdDev.TOTAL:
... | python | def get_stddevs(self, mag, imt, stddev_types, num_sites):
"""
Returns the total standard deviation
"""
stddevs = []
for stddev_type in stddev_types:
assert stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
if stddev_type == const.StdDev.TOTAL:
... | [
"def",
"get_stddevs",
"(",
"self",
",",
"mag",
",",
"imt",
",",
"stddev_types",
",",
"num_sites",
")",
":",
"stddevs",
"=",
"[",
"]",
"for",
"stddev_type",
"in",
"stddev_types",
":",
"assert",
"stddev_type",
"in",
"self",
".",
"DEFINED_FOR_STANDARD_DEVIATION_T... | Returns the total standard deviation | [
"Returns",
"the",
"total",
"standard",
"deviation"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/nga_east.py#L627-L637 | train |
gem/oq-engine | openquake/hazardlib/gsim/nga_east.py | NGAEastBaseGMPETotalSigma._get_sigma_at_quantile | def _get_sigma_at_quantile(self, sigma_quantile):
"""
Calculates the total standard deviation at the specified quantile
"""
# Mean mean is found in self.TAU. Get the variance in tau
tau_std = TAU_SETUP[self.tau_model]["STD"]
# Mean phiss is found in self.PHI_SS. Get the v... | python | def _get_sigma_at_quantile(self, sigma_quantile):
"""
Calculates the total standard deviation at the specified quantile
"""
# Mean mean is found in self.TAU. Get the variance in tau
tau_std = TAU_SETUP[self.tau_model]["STD"]
# Mean phiss is found in self.PHI_SS. Get the v... | [
"def",
"_get_sigma_at_quantile",
"(",
"self",
",",
"sigma_quantile",
")",
":",
"# Mean mean is found in self.TAU. Get the variance in tau",
"tau_std",
"=",
"TAU_SETUP",
"[",
"self",
".",
"tau_model",
"]",
"[",
"\"STD\"",
"]",
"# Mean phiss is found in self.PHI_SS. Get the var... | Calculates the total standard deviation at the specified quantile | [
"Calculates",
"the",
"total",
"standard",
"deviation",
"at",
"the",
"specified",
"quantile"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/nga_east.py#L639-L681 | train |
gem/oq-engine | openquake/hazardlib/gsim/nga_east.py | NGAEastBaseGMPETotalSigma._get_tau_vector | def _get_tau_vector(self, tau_mean, tau_std, imt_list):
"""
Gets the vector of mean and variance of tau values corresponding to
the specific model and returns them as dictionaries
"""
self.magnitude_limits = MAG_LIMS_KEYS[self.tau_model]["mag"]
self.tau_keys = MAG_LIMS_KE... | python | def _get_tau_vector(self, tau_mean, tau_std, imt_list):
"""
Gets the vector of mean and variance of tau values corresponding to
the specific model and returns them as dictionaries
"""
self.magnitude_limits = MAG_LIMS_KEYS[self.tau_model]["mag"]
self.tau_keys = MAG_LIMS_KE... | [
"def",
"_get_tau_vector",
"(",
"self",
",",
"tau_mean",
",",
"tau_std",
",",
"imt_list",
")",
":",
"self",
".",
"magnitude_limits",
"=",
"MAG_LIMS_KEYS",
"[",
"self",
".",
"tau_model",
"]",
"[",
"\"mag\"",
"]",
"self",
".",
"tau_keys",
"=",
"MAG_LIMS_KEYS",
... | Gets the vector of mean and variance of tau values corresponding to
the specific model and returns them as dictionaries | [
"Gets",
"the",
"vector",
"of",
"mean",
"and",
"variance",
"of",
"tau",
"values",
"corresponding",
"to",
"the",
"specific",
"model",
"and",
"returns",
"them",
"as",
"dictionaries"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/nga_east.py#L683-L700 | train |
gem/oq-engine | openquake/hazardlib/gsim/nga_east.py | NGAEastBaseGMPETotalSigma._get_phi_vector | def _get_phi_vector(self, phi_mean, phi_std, imt_list):
"""
Gets the vector of mean and variance of phi values corresponding to
the specific model and returns them as dictionaries
"""
p_bar = {}
p_std = {}
for imt in imt_list:
p_bar[imt] = []
... | python | def _get_phi_vector(self, phi_mean, phi_std, imt_list):
"""
Gets the vector of mean and variance of phi values corresponding to
the specific model and returns them as dictionaries
"""
p_bar = {}
p_std = {}
for imt in imt_list:
p_bar[imt] = []
... | [
"def",
"_get_phi_vector",
"(",
"self",
",",
"phi_mean",
",",
"phi_std",
",",
"imt_list",
")",
":",
"p_bar",
"=",
"{",
"}",
"p_std",
"=",
"{",
"}",
"for",
"imt",
"in",
"imt_list",
":",
"p_bar",
"[",
"imt",
"]",
"=",
"[",
"]",
"p_std",
"[",
"imt",
... | Gets the vector of mean and variance of phi values corresponding to
the specific model and returns them as dictionaries | [
"Gets",
"the",
"vector",
"of",
"mean",
"and",
"variance",
"of",
"phi",
"values",
"corresponding",
"to",
"the",
"specific",
"model",
"and",
"returns",
"them",
"as",
"dictionaries"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/nga_east.py#L702-L729 | train |
gem/oq-engine | openquake/hazardlib/gsim/nga_east.py | NGAEastBaseGMPETotalSigma._get_total_sigma | def _get_total_sigma(self, imt, mag):
"""
Returns the estimated total standard deviation for a given intensity
measure type and magnitude
"""
C = self.SIGMA[imt]
if mag <= self.magnitude_limits[0]:
# The CENA constant model is always returned here
... | python | def _get_total_sigma(self, imt, mag):
"""
Returns the estimated total standard deviation for a given intensity
measure type and magnitude
"""
C = self.SIGMA[imt]
if mag <= self.magnitude_limits[0]:
# The CENA constant model is always returned here
... | [
"def",
"_get_total_sigma",
"(",
"self",
",",
"imt",
",",
"mag",
")",
":",
"C",
"=",
"self",
".",
"SIGMA",
"[",
"imt",
"]",
"if",
"mag",
"<=",
"self",
".",
"magnitude_limits",
"[",
"0",
"]",
":",
"# The CENA constant model is always returned here",
"return",
... | Returns the estimated total standard deviation for a given intensity
measure type and magnitude | [
"Returns",
"the",
"estimated",
"total",
"standard",
"deviation",
"for",
"a",
"given",
"intensity",
"measure",
"type",
"and",
"magnitude"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/nga_east.py#L731-L752 | train |
gem/oq-engine | openquake/commands/show.py | get_hcurves_and_means | def get_hcurves_and_means(dstore):
"""
Extract hcurves from the datastore and compute their means.
:returns: curves_by_rlz, mean_curves
"""
rlzs_assoc = dstore['csm_info'].get_rlzs_assoc()
getter = getters.PmapGetter(dstore, rlzs_assoc)
pmaps = getter.get_pmaps()
return dict(zip(getter.... | python | def get_hcurves_and_means(dstore):
"""
Extract hcurves from the datastore and compute their means.
:returns: curves_by_rlz, mean_curves
"""
rlzs_assoc = dstore['csm_info'].get_rlzs_assoc()
getter = getters.PmapGetter(dstore, rlzs_assoc)
pmaps = getter.get_pmaps()
return dict(zip(getter.... | [
"def",
"get_hcurves_and_means",
"(",
"dstore",
")",
":",
"rlzs_assoc",
"=",
"dstore",
"[",
"'csm_info'",
"]",
".",
"get_rlzs_assoc",
"(",
")",
"getter",
"=",
"getters",
".",
"PmapGetter",
"(",
"dstore",
",",
"rlzs_assoc",
")",
"pmaps",
"=",
"getter",
".",
... | Extract hcurves from the datastore and compute their means.
:returns: curves_by_rlz, mean_curves | [
"Extract",
"hcurves",
"from",
"the",
"datastore",
"and",
"compute",
"their",
"means",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/show.py#L33-L42 | train |
gem/oq-engine | openquake/hazardlib/gsim/lin_lee_2008.py | LinLee2008SInter._compute_mean | def _compute_mean(self, C, mag, rhypo, hypo_depth, mean, idx):
"""
Compute mean value according to equations 10 and 11 page 226.
"""
mean[idx] = (C['C1'] + C['C2'] * mag + C['C3'] * np.log(rhypo[idx] +
C['C4'] * np.exp(C['C5'] * mag)) + C['C6'] * hypo_depth) | python | def _compute_mean(self, C, mag, rhypo, hypo_depth, mean, idx):
"""
Compute mean value according to equations 10 and 11 page 226.
"""
mean[idx] = (C['C1'] + C['C2'] * mag + C['C3'] * np.log(rhypo[idx] +
C['C4'] * np.exp(C['C5'] * mag)) + C['C6'] * hypo_depth) | [
"def",
"_compute_mean",
"(",
"self",
",",
"C",
",",
"mag",
",",
"rhypo",
",",
"hypo_depth",
",",
"mean",
",",
"idx",
")",
":",
"mean",
"[",
"idx",
"]",
"=",
"(",
"C",
"[",
"'C1'",
"]",
"+",
"C",
"[",
"'C2'",
"]",
"*",
"mag",
"+",
"C",
"[",
... | Compute mean value according to equations 10 and 11 page 226. | [
"Compute",
"mean",
"value",
"according",
"to",
"equations",
"10",
"and",
"11",
"page",
"226",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/lin_lee_2008.py#L102-L107 | train |
gem/oq-engine | openquake/hazardlib/gsim/lin_lee_2008.py | LinLee2008SInter._compute_std | def _compute_std(self, C, stddevs, idx):
"""
Compute total standard deviation, see tables 3 and 4, pages 227 and
228.
"""
for stddev in stddevs:
stddev[idx] += C['sigma'] | python | def _compute_std(self, C, stddevs, idx):
"""
Compute total standard deviation, see tables 3 and 4, pages 227 and
228.
"""
for stddev in stddevs:
stddev[idx] += C['sigma'] | [
"def",
"_compute_std",
"(",
"self",
",",
"C",
",",
"stddevs",
",",
"idx",
")",
":",
"for",
"stddev",
"in",
"stddevs",
":",
"stddev",
"[",
"idx",
"]",
"+=",
"C",
"[",
"'sigma'",
"]"
] | Compute total standard deviation, see tables 3 and 4, pages 227 and
228. | [
"Compute",
"total",
"standard",
"deviation",
"see",
"tables",
"3",
"and",
"4",
"pages",
"227",
"and",
"228",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/lin_lee_2008.py#L109-L115 | train |
gem/oq-engine | openquake/hmtk/seismicity/max_magnitude/kijko_nonparametric_gaussian.py | check_config | def check_config(config):
'''Check config file inputs and overwrite bad values with the defaults'''
essential_keys = ['number_earthquakes']
for key in essential_keys:
if key not in config:
raise ValueError('For Kijko Nonparametric Gaussian the key %s '
'need... | python | def check_config(config):
'''Check config file inputs and overwrite bad values with the defaults'''
essential_keys = ['number_earthquakes']
for key in essential_keys:
if key not in config:
raise ValueError('For Kijko Nonparametric Gaussian the key %s '
'need... | [
"def",
"check_config",
"(",
"config",
")",
":",
"essential_keys",
"=",
"[",
"'number_earthquakes'",
"]",
"for",
"key",
"in",
"essential_keys",
":",
"if",
"key",
"not",
"in",
"config",
":",
"raise",
"ValueError",
"(",
"'For Kijko Nonparametric Gaussian the key %s '",... | Check config file inputs and overwrite bad values with the defaults | [
"Check",
"config",
"file",
"inputs",
"and",
"overwrite",
"bad",
"values",
"with",
"the",
"defaults"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/max_magnitude/kijko_nonparametric_gaussian.py#L59-L77 | train |
gem/oq-engine | openquake/hmtk/seismicity/max_magnitude/kijko_nonparametric_gaussian.py | _get_exponential_spaced_values | def _get_exponential_spaced_values(mmin, mmax, number_samples):
'''
Function to return a set of exponentially spaced values between mmin and
mmax
:param float mmin:
Minimum value
:param float mmax:
Maximum value
:param float number_samples:
Number of exponentially spaced... | python | def _get_exponential_spaced_values(mmin, mmax, number_samples):
'''
Function to return a set of exponentially spaced values between mmin and
mmax
:param float mmin:
Minimum value
:param float mmax:
Maximum value
:param float number_samples:
Number of exponentially spaced... | [
"def",
"_get_exponential_spaced_values",
"(",
"mmin",
",",
"mmax",
",",
"number_samples",
")",
":",
"lhs",
"=",
"np",
".",
"exp",
"(",
"mmin",
")",
"+",
"np",
".",
"arange",
"(",
"0.",
",",
"number_samples",
"-",
"1.",
",",
"1.",
")",
"*",
"(",
"(",
... | Function to return a set of exponentially spaced values between mmin and
mmax
:param float mmin:
Minimum value
:param float mmax:
Maximum value
:param float number_samples:
Number of exponentially spaced samples
:return np.ndarray:
Set of 'number_samples' exponential... | [
"Function",
"to",
"return",
"a",
"set",
"of",
"exponentially",
"spaced",
"values",
"between",
"mmin",
"and",
"mmax"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/max_magnitude/kijko_nonparametric_gaussian.py#L80-L98 | train |
gem/oq-engine | openquake/commonlib/logs.py | dbcmd | def dbcmd(action, *args):
"""
A dispatcher to the database server.
:param action: database action to perform
:param args: arguments
"""
global sock
if sock is None:
sock = zeromq.Socket(
'tcp://%s:%s' % (config.dbserver.host, DBSERVER_PORT),
zeromq.zmq.REQ, '... | python | def dbcmd(action, *args):
"""
A dispatcher to the database server.
:param action: database action to perform
:param args: arguments
"""
global sock
if sock is None:
sock = zeromq.Socket(
'tcp://%s:%s' % (config.dbserver.host, DBSERVER_PORT),
zeromq.zmq.REQ, '... | [
"def",
"dbcmd",
"(",
"action",
",",
"*",
"args",
")",
":",
"global",
"sock",
"if",
"sock",
"is",
"None",
":",
"sock",
"=",
"zeromq",
".",
"Socket",
"(",
"'tcp://%s:%s'",
"%",
"(",
"config",
".",
"dbserver",
".",
"host",
",",
"DBSERVER_PORT",
")",
","... | A dispatcher to the database server.
:param action: database action to perform
:param args: arguments | [
"A",
"dispatcher",
"to",
"the",
"database",
"server",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logs.py#L40-L56 | train |
gem/oq-engine | openquake/commonlib/logs.py | _update_log_record | def _update_log_record(self, record):
"""
Massage a log record before emitting it. Intended to be used by the
custom log handlers defined in this module.
"""
if not hasattr(record, 'hostname'):
record.hostname = '-'
if not hasattr(record, 'job_id'):
record.job_id = self.job_id | python | def _update_log_record(self, record):
"""
Massage a log record before emitting it. Intended to be used by the
custom log handlers defined in this module.
"""
if not hasattr(record, 'hostname'):
record.hostname = '-'
if not hasattr(record, 'job_id'):
record.job_id = self.job_id | [
"def",
"_update_log_record",
"(",
"self",
",",
"record",
")",
":",
"if",
"not",
"hasattr",
"(",
"record",
",",
"'hostname'",
")",
":",
"record",
".",
"hostname",
"=",
"'-'",
"if",
"not",
"hasattr",
"(",
"record",
",",
"'job_id'",
")",
":",
"record",
".... | Massage a log record before emitting it. Intended to be used by the
custom log handlers defined in this module. | [
"Massage",
"a",
"log",
"record",
"before",
"emitting",
"it",
".",
"Intended",
"to",
"be",
"used",
"by",
"the",
"custom",
"log",
"handlers",
"defined",
"in",
"this",
"module",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logs.py#L68-L76 | train |
gem/oq-engine | openquake/commonlib/logs.py | handle | def handle(job_id, log_level='info', log_file=None):
"""
Context manager adding and removing log handlers.
:param job_id:
ID of the current job
:param log_level:
one of debug, info, warn, error, critical
:param log_file:
log file path (if None, logs on stdout only)
""... | python | def handle(job_id, log_level='info', log_file=None):
"""
Context manager adding and removing log handlers.
:param job_id:
ID of the current job
:param log_level:
one of debug, info, warn, error, critical
:param log_file:
log file path (if None, logs on stdout only)
""... | [
"def",
"handle",
"(",
"job_id",
",",
"log_level",
"=",
"'info'",
",",
"log_file",
"=",
"None",
")",
":",
"handlers",
"=",
"[",
"LogDatabaseHandler",
"(",
"job_id",
")",
"]",
"# log on db always",
"if",
"log_file",
"is",
"None",
":",
"# add a StreamHandler if n... | Context manager adding and removing log handlers.
:param job_id:
ID of the current job
:param log_level:
one of debug, info, warn, error, critical
:param log_file:
log file path (if None, logs on stdout only) | [
"Context",
"manager",
"adding",
"and",
"removing",
"log",
"handlers",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/logs.py#L122-L152 | train |
gem/oq-engine | openquake/hazardlib/scalerel/wc1994_qcss.py | WC1994_QCSS.get_median_area | def get_median_area(self, mag, rake):
"""
The values are a function of magnitude.
"""
# strike slip
length = 10.0 ** (-2.57 + 0.62 * mag)
seis_wid = 20.0
# estimate area based on length
if length < seis_wid:
return length ** 2.
else:
... | python | def get_median_area(self, mag, rake):
"""
The values are a function of magnitude.
"""
# strike slip
length = 10.0 ** (-2.57 + 0.62 * mag)
seis_wid = 20.0
# estimate area based on length
if length < seis_wid:
return length ** 2.
else:
... | [
"def",
"get_median_area",
"(",
"self",
",",
"mag",
",",
"rake",
")",
":",
"# strike slip",
"length",
"=",
"10.0",
"**",
"(",
"-",
"2.57",
"+",
"0.62",
"*",
"mag",
")",
"seis_wid",
"=",
"20.0",
"# estimate area based on length",
"if",
"length",
"<",
"seis_w... | The values are a function of magnitude. | [
"The",
"values",
"are",
"a",
"function",
"of",
"magnitude",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/scalerel/wc1994_qcss.py#L43-L55 | train |
gem/oq-engine | openquake/hazardlib/gsim/si_midorikawa_1999.py | _construct_surface | def _construct_surface(lons, lats, upper_depth, lower_depth):
"""
Utility method that constructs and return a simple fault surface with top
edge specified by `lons` and `lats` and extending vertically from
`upper_depth` to `lower_depth`.
The underlying mesh is built by repeating the same coordinate... | python | def _construct_surface(lons, lats, upper_depth, lower_depth):
"""
Utility method that constructs and return a simple fault surface with top
edge specified by `lons` and `lats` and extending vertically from
`upper_depth` to `lower_depth`.
The underlying mesh is built by repeating the same coordinate... | [
"def",
"_construct_surface",
"(",
"lons",
",",
"lats",
",",
"upper_depth",
",",
"lower_depth",
")",
":",
"depths",
"=",
"np",
".",
"array",
"(",
"[",
"np",
".",
"zeros_like",
"(",
"lons",
")",
"+",
"upper_depth",
",",
"np",
".",
"zeros_like",
"(",
"lat... | Utility method that constructs and return a simple fault surface with top
edge specified by `lons` and `lats` and extending vertically from
`upper_depth` to `lower_depth`.
The underlying mesh is built by repeating the same coordinates
(`lons` and `lats`) at the two specified depth levels. | [
"Utility",
"method",
"that",
"constructs",
"and",
"return",
"a",
"simple",
"fault",
"surface",
"with",
"top",
"edge",
"specified",
"by",
"lons",
"and",
"lats",
"and",
"extending",
"vertically",
"from",
"upper_depth",
"to",
"lower_depth",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/si_midorikawa_1999.py#L57-L74 | train |
gem/oq-engine | openquake/hazardlib/gsim/si_midorikawa_1999.py | _get_min_distance_to_sub_trench | def _get_min_distance_to_sub_trench(lons, lats):
"""
Compute and return minimum distance between subduction trench
and points specified by 'lon' and 'lat'
The method creates an instance of
:class:`openquake.hazardlib.geo.SimpleFaultSurface` to model the subduction
trench. The surface is assumed... | python | def _get_min_distance_to_sub_trench(lons, lats):
"""
Compute and return minimum distance between subduction trench
and points specified by 'lon' and 'lat'
The method creates an instance of
:class:`openquake.hazardlib.geo.SimpleFaultSurface` to model the subduction
trench. The surface is assumed... | [
"def",
"_get_min_distance_to_sub_trench",
"(",
"lons",
",",
"lats",
")",
":",
"trench",
"=",
"_construct_surface",
"(",
"SUB_TRENCH_LONS",
",",
"SUB_TRENCH_LATS",
",",
"0.",
",",
"10.",
")",
"sites",
"=",
"Mesh",
"(",
"lons",
",",
"lats",
",",
"None",
")",
... | Compute and return minimum distance between subduction trench
and points specified by 'lon' and 'lat'
The method creates an instance of
:class:`openquake.hazardlib.geo.SimpleFaultSurface` to model the subduction
trench. The surface is assumed vertical and extending from 0 to 10 km
depth.
The 10... | [
"Compute",
"and",
"return",
"minimum",
"distance",
"between",
"subduction",
"trench",
"and",
"points",
"specified",
"by",
"lon",
"and",
"lat"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/si_midorikawa_1999.py#L77-L93 | train |
gem/oq-engine | openquake/hazardlib/gsim/si_midorikawa_1999.py | _get_min_distance_to_volcanic_front | def _get_min_distance_to_volcanic_front(lons, lats):
"""
Compute and return minimum distance between volcanic front and points
specified by 'lon' and 'lat'.
Distance is negative if point is located east of the volcanic front,
positive otherwise.
The method uses the same approach as :meth:`_get... | python | def _get_min_distance_to_volcanic_front(lons, lats):
"""
Compute and return minimum distance between volcanic front and points
specified by 'lon' and 'lat'.
Distance is negative if point is located east of the volcanic front,
positive otherwise.
The method uses the same approach as :meth:`_get... | [
"def",
"_get_min_distance_to_volcanic_front",
"(",
"lons",
",",
"lats",
")",
":",
"vf",
"=",
"_construct_surface",
"(",
"VOLCANIC_FRONT_LONS",
",",
"VOLCANIC_FRONT_LATS",
",",
"0.",
",",
"10.",
")",
"sites",
"=",
"Mesh",
"(",
"lons",
",",
"lats",
",",
"None",
... | Compute and return minimum distance between volcanic front and points
specified by 'lon' and 'lat'.
Distance is negative if point is located east of the volcanic front,
positive otherwise.
The method uses the same approach as :meth:`_get_min_distance_to_sub_trench`
but final distance is returned w... | [
"Compute",
"and",
"return",
"minimum",
"distance",
"between",
"volcanic",
"front",
"and",
"points",
"specified",
"by",
"lon",
"and",
"lat",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/si_midorikawa_1999.py#L96-L109 | train |
gem/oq-engine | openquake/hazardlib/gsim/si_midorikawa_1999.py | _apply_subduction_trench_correction | def _apply_subduction_trench_correction(mean, x_tr, H, rrup, imt):
"""
Implement equation for subduction trench correction as described in
equation 3.5.2-1, page 3-148 of "Technical Reports on National Seismic
Hazard Maps for Japan"
"""
if imt.name == 'PGV':
V1 = 10 ** ((-4.021e-5 * x_tr... | python | def _apply_subduction_trench_correction(mean, x_tr, H, rrup, imt):
"""
Implement equation for subduction trench correction as described in
equation 3.5.2-1, page 3-148 of "Technical Reports on National Seismic
Hazard Maps for Japan"
"""
if imt.name == 'PGV':
V1 = 10 ** ((-4.021e-5 * x_tr... | [
"def",
"_apply_subduction_trench_correction",
"(",
"mean",
",",
"x_tr",
",",
"H",
",",
"rrup",
",",
"imt",
")",
":",
"if",
"imt",
".",
"name",
"==",
"'PGV'",
":",
"V1",
"=",
"10",
"**",
"(",
"(",
"-",
"4.021e-5",
"*",
"x_tr",
"+",
"9.905e-3",
")",
... | Implement equation for subduction trench correction as described in
equation 3.5.2-1, page 3-148 of "Technical Reports on National Seismic
Hazard Maps for Japan" | [
"Implement",
"equation",
"for",
"subduction",
"trench",
"correction",
"as",
"described",
"in",
"equation",
"3",
".",
"5",
".",
"2",
"-",
"1",
"page",
"3",
"-",
"148",
"of",
"Technical",
"Reports",
"on",
"National",
"Seismic",
"Hazard",
"Maps",
"for",
"Japa... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/si_midorikawa_1999.py#L112-L130 | train |
gem/oq-engine | openquake/hazardlib/gsim/si_midorikawa_1999.py | _apply_volcanic_front_correction | def _apply_volcanic_front_correction(mean, x_vf, H, imt):
"""
Implement equation for volcanic front correction as described in equation
3.5.2.-2, page 3-149 of "Technical Reports on National Seismic
Hazard Maps for Japan"
"""
V1 = np.zeros_like(x_vf)
if imt.name == 'PGV':
idx = x_vf ... | python | def _apply_volcanic_front_correction(mean, x_vf, H, imt):
"""
Implement equation for volcanic front correction as described in equation
3.5.2.-2, page 3-149 of "Technical Reports on National Seismic
Hazard Maps for Japan"
"""
V1 = np.zeros_like(x_vf)
if imt.name == 'PGV':
idx = x_vf ... | [
"def",
"_apply_volcanic_front_correction",
"(",
"mean",
",",
"x_vf",
",",
"H",
",",
"imt",
")",
":",
"V1",
"=",
"np",
".",
"zeros_like",
"(",
"x_vf",
")",
"if",
"imt",
".",
"name",
"==",
"'PGV'",
":",
"idx",
"=",
"x_vf",
"<=",
"75",
"V1",
"[",
"idx... | Implement equation for volcanic front correction as described in equation
3.5.2.-2, page 3-149 of "Technical Reports on National Seismic
Hazard Maps for Japan" | [
"Implement",
"equation",
"for",
"volcanic",
"front",
"correction",
"as",
"described",
"in",
"equation",
"3",
".",
"5",
".",
"2",
".",
"-",
"2",
"page",
"3",
"-",
"149",
"of",
"Technical",
"Reports",
"on",
"National",
"Seismic",
"Hazard",
"Maps",
"for",
"... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/si_midorikawa_1999.py#L133-L152 | train |
gem/oq-engine | openquake/hazardlib/gsim/si_midorikawa_1999.py | SiMidorikawa1999Asc.get_mean_and_stddevs | def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
"""
Implements equation 3.5.1-1 page 148 for mean value and equation
3.5.5-2 page 151 for total standard deviation.
See :meth:`superclass method
<.base.GroundShakingIntensityModel.get_mean_and_stddevs>`
... | python | def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
"""
Implements equation 3.5.1-1 page 148 for mean value and equation
3.5.5-2 page 151 for total standard deviation.
See :meth:`superclass method
<.base.GroundShakingIntensityModel.get_mean_and_stddevs>`
... | [
"def",
"get_mean_and_stddevs",
"(",
"self",
",",
"sites",
",",
"rup",
",",
"dists",
",",
"imt",
",",
"stddev_types",
")",
":",
"mean",
"=",
"self",
".",
"_get_mean",
"(",
"imt",
",",
"rup",
".",
"mag",
",",
"rup",
".",
"hypo_depth",
",",
"dists",
"."... | Implements equation 3.5.1-1 page 148 for mean value and equation
3.5.5-2 page 151 for total standard deviation.
See :meth:`superclass method
<.base.GroundShakingIntensityModel.get_mean_and_stddevs>`
for spec of input and result values. | [
"Implements",
"equation",
"3",
".",
"5",
".",
"1",
"-",
"1",
"page",
"148",
"for",
"mean",
"value",
"and",
"equation",
"3",
".",
"5",
".",
"5",
"-",
"2",
"page",
"151",
"for",
"total",
"standard",
"deviation",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/si_midorikawa_1999.py#L195-L207 | train |
gem/oq-engine | openquake/hazardlib/gsim/si_midorikawa_1999.py | SiMidorikawa1999Asc._get_mean | def _get_mean(self, imt, mag, hypo_depth, rrup, d):
"""
Return mean value as defined in equation 3.5.1-1 page 148
"""
# clip magnitude at 8.3 as per note at page 3-36 in table Table 3.3.2-6
# in "Technical Reports on National Seismic Hazard Maps for Japan"
mag = min(mag, ... | python | def _get_mean(self, imt, mag, hypo_depth, rrup, d):
"""
Return mean value as defined in equation 3.5.1-1 page 148
"""
# clip magnitude at 8.3 as per note at page 3-36 in table Table 3.3.2-6
# in "Technical Reports on National Seismic Hazard Maps for Japan"
mag = min(mag, ... | [
"def",
"_get_mean",
"(",
"self",
",",
"imt",
",",
"mag",
",",
"hypo_depth",
",",
"rrup",
",",
"d",
")",
":",
"# clip magnitude at 8.3 as per note at page 3-36 in table Table 3.3.2-6",
"# in \"Technical Reports on National Seismic Hazard Maps for Japan\"",
"mag",
"=",
"min",
... | Return mean value as defined in equation 3.5.1-1 page 148 | [
"Return",
"mean",
"value",
"as",
"defined",
"in",
"equation",
"3",
".",
"5",
".",
"1",
"-",
"1",
"page",
"148"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/si_midorikawa_1999.py#L209-L236 | train |
gem/oq-engine | openquake/hazardlib/gsim/si_midorikawa_1999.py | SiMidorikawa1999Asc._get_stddevs | def _get_stddevs(self, stddev_types, rrup):
"""
Return standard deviations as defined in equation 3.5.5-2 page 151
"""
assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
for stddev_type in stddev_types)
std = np.zeros_like(rrup)
std[rru... | python | def _get_stddevs(self, stddev_types, rrup):
"""
Return standard deviations as defined in equation 3.5.5-2 page 151
"""
assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
for stddev_type in stddev_types)
std = np.zeros_like(rrup)
std[rru... | [
"def",
"_get_stddevs",
"(",
"self",
",",
"stddev_types",
",",
"rrup",
")",
":",
"assert",
"all",
"(",
"stddev_type",
"in",
"self",
".",
"DEFINED_FOR_STANDARD_DEVIATION_TYPES",
"for",
"stddev_type",
"in",
"stddev_types",
")",
"std",
"=",
"np",
".",
"zeros_like",
... | Return standard deviations as defined in equation 3.5.5-2 page 151 | [
"Return",
"standard",
"deviations",
"as",
"defined",
"in",
"equation",
"3",
".",
"5",
".",
"5",
"-",
"2",
"page",
"151"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/si_midorikawa_1999.py#L238-L251 | train |
gem/oq-engine | openquake/hazardlib/gsim/si_midorikawa_1999.py | SiMidorikawa1999SInter._get_stddevs | def _get_stddevs(self, stddev_types, pgv):
"""
Return standard deviations as defined in equation 3.5.5-1 page 151
"""
assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
for stddev_type in stddev_types)
std = np.zeros_like(pgv)
std[pgv <... | python | def _get_stddevs(self, stddev_types, pgv):
"""
Return standard deviations as defined in equation 3.5.5-1 page 151
"""
assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
for stddev_type in stddev_types)
std = np.zeros_like(pgv)
std[pgv <... | [
"def",
"_get_stddevs",
"(",
"self",
",",
"stddev_types",
",",
"pgv",
")",
":",
"assert",
"all",
"(",
"stddev_type",
"in",
"self",
".",
"DEFINED_FOR_STANDARD_DEVIATION_TYPES",
"for",
"stddev_type",
"in",
"stddev_types",
")",
"std",
"=",
"np",
".",
"zeros_like",
... | Return standard deviations as defined in equation 3.5.5-1 page 151 | [
"Return",
"standard",
"deviations",
"as",
"defined",
"in",
"equation",
"3",
".",
"5",
".",
"5",
"-",
"1",
"page",
"151"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/si_midorikawa_1999.py#L305-L318 | train |
gem/oq-engine | openquake/commands/plot_memory.py | plot_memory | def plot_memory(calc_id=-1):
"""
Plot the memory occupation
"""
dstore = util.read(calc_id)
plots = []
for task_name in dstore['task_info']:
mem = dstore['task_info/' + task_name]['mem_gb']
plots.append((task_name, mem))
plt = make_figure(plots)
plt.show() | python | def plot_memory(calc_id=-1):
"""
Plot the memory occupation
"""
dstore = util.read(calc_id)
plots = []
for task_name in dstore['task_info']:
mem = dstore['task_info/' + task_name]['mem_gb']
plots.append((task_name, mem))
plt = make_figure(plots)
plt.show() | [
"def",
"plot_memory",
"(",
"calc_id",
"=",
"-",
"1",
")",
":",
"dstore",
"=",
"util",
".",
"read",
"(",
"calc_id",
")",
"plots",
"=",
"[",
"]",
"for",
"task_name",
"in",
"dstore",
"[",
"'task_info'",
"]",
":",
"mem",
"=",
"dstore",
"[",
"'task_info/'... | Plot the memory occupation | [
"Plot",
"the",
"memory",
"occupation"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/plot_memory.py#L42-L52 | train |
gem/oq-engine | openquake/commonlib/calc.py | convert_to_array | def convert_to_array(pmap, nsites, imtls, inner_idx=0):
"""
Convert the probability map into a composite array with header
of the form PGA-0.1, PGA-0.2 ...
:param pmap: probability map
:param nsites: total number of sites
:param imtls: a DictArray with IMT and levels
:returns: a composite a... | python | def convert_to_array(pmap, nsites, imtls, inner_idx=0):
"""
Convert the probability map into a composite array with header
of the form PGA-0.1, PGA-0.2 ...
:param pmap: probability map
:param nsites: total number of sites
:param imtls: a DictArray with IMT and levels
:returns: a composite a... | [
"def",
"convert_to_array",
"(",
"pmap",
",",
"nsites",
",",
"imtls",
",",
"inner_idx",
"=",
"0",
")",
":",
"lst",
"=",
"[",
"]",
"# build the export dtype, of the form PGA-0.1, PGA-0.2 ...",
"for",
"imt",
",",
"imls",
"in",
"imtls",
".",
"items",
"(",
")",
"... | Convert the probability map into a composite array with header
of the form PGA-0.1, PGA-0.2 ...
:param pmap: probability map
:param nsites: total number of sites
:param imtls: a DictArray with IMT and levels
:returns: a composite array of lenght nsites | [
"Convert",
"the",
"probability",
"map",
"into",
"a",
"composite",
"array",
"with",
"header",
"of",
"the",
"form",
"PGA",
"-",
"0",
".",
"1",
"PGA",
"-",
"0",
".",
"2",
"..."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/calc.py#L45-L68 | train |
gem/oq-engine | openquake/commonlib/calc.py | compute_hazard_maps | def compute_hazard_maps(curves, imls, poes):
"""
Given a set of hazard curve poes, interpolate a hazard map at the specified
``poe``.
:param curves:
2D array of floats. Each row represents a curve, where the values
in the row are the PoEs (Probabilities of Exceedance) corresponding to
... | python | def compute_hazard_maps(curves, imls, poes):
"""
Given a set of hazard curve poes, interpolate a hazard map at the specified
``poe``.
:param curves:
2D array of floats. Each row represents a curve, where the values
in the row are the PoEs (Probabilities of Exceedance) corresponding to
... | [
"def",
"compute_hazard_maps",
"(",
"curves",
",",
"imls",
",",
"poes",
")",
":",
"poes",
"=",
"numpy",
".",
"array",
"(",
"poes",
")",
"if",
"len",
"(",
"poes",
".",
"shape",
")",
"==",
"0",
":",
"# `poes` was passed in as a scalar;",
"# convert it to 1D arr... | Given a set of hazard curve poes, interpolate a hazard map at the specified
``poe``.
:param curves:
2D array of floats. Each row represents a curve, where the values
in the row are the PoEs (Probabilities of Exceedance) corresponding to
``imls``. Each curve corresponds to a geographical... | [
"Given",
"a",
"set",
"of",
"hazard",
"curve",
"poes",
"interpolate",
"a",
"hazard",
"map",
"at",
"the",
"specified",
"poe",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/calc.py#L77-L139 | train |
gem/oq-engine | openquake/commonlib/calc.py | make_hmap | def make_hmap(pmap, imtls, poes):
"""
Compute the hazard maps associated to the passed probability map.
:param pmap: hazard curves in the form of a ProbabilityMap
:param imtls: DictArray with M intensity measure types
:param poes: P PoEs where to compute the maps
:returns: a ProbabilityMap with... | python | def make_hmap(pmap, imtls, poes):
"""
Compute the hazard maps associated to the passed probability map.
:param pmap: hazard curves in the form of a ProbabilityMap
:param imtls: DictArray with M intensity measure types
:param poes: P PoEs where to compute the maps
:returns: a ProbabilityMap with... | [
"def",
"make_hmap",
"(",
"pmap",
",",
"imtls",
",",
"poes",
")",
":",
"M",
",",
"P",
"=",
"len",
"(",
"imtls",
")",
",",
"len",
"(",
"poes",
")",
"hmap",
"=",
"probability_map",
".",
"ProbabilityMap",
".",
"build",
"(",
"M",
",",
"P",
",",
"pmap"... | Compute the hazard maps associated to the passed probability map.
:param pmap: hazard curves in the form of a ProbabilityMap
:param imtls: DictArray with M intensity measure types
:param poes: P PoEs where to compute the maps
:returns: a ProbabilityMap with size (N, M, P) | [
"Compute",
"the",
"hazard",
"maps",
"associated",
"to",
"the",
"passed",
"probability",
"map",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/calc.py#L184-L205 | train |
gem/oq-engine | openquake/commonlib/calc.py | make_uhs | def make_uhs(hmap, info):
"""
Make Uniform Hazard Spectra curves for each location.
:param hmap:
array of shape (N, M, P)
:param info:
a dictionary with keys poes, imtls, uhs_dt
:returns:
a composite array containing uniform hazard spectra
"""
uhs = numpy.zeros(len(h... | python | def make_uhs(hmap, info):
"""
Make Uniform Hazard Spectra curves for each location.
:param hmap:
array of shape (N, M, P)
:param info:
a dictionary with keys poes, imtls, uhs_dt
:returns:
a composite array containing uniform hazard spectra
"""
uhs = numpy.zeros(len(h... | [
"def",
"make_uhs",
"(",
"hmap",
",",
"info",
")",
":",
"uhs",
"=",
"numpy",
".",
"zeros",
"(",
"len",
"(",
"hmap",
")",
",",
"info",
"[",
"'uhs_dt'",
"]",
")",
"for",
"p",
",",
"poe",
"in",
"enumerate",
"(",
"info",
"[",
"'poes'",
"]",
")",
":"... | Make Uniform Hazard Spectra curves for each location.
:param hmap:
array of shape (N, M, P)
:param info:
a dictionary with keys poes, imtls, uhs_dt
:returns:
a composite array containing uniform hazard spectra | [
"Make",
"Uniform",
"Hazard",
"Spectra",
"curves",
"for",
"each",
"location",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/calc.py#L232-L248 | train |
gem/oq-engine | openquake/commonlib/calc.py | RuptureData.to_array | def to_array(self, ebruptures):
"""
Convert a list of ebruptures into an array of dtype RuptureRata.dt
"""
data = []
for ebr in ebruptures:
rup = ebr.rupture
self.cmaker.add_rup_params(rup)
ruptparams = tuple(getattr(rup, param) for param in se... | python | def to_array(self, ebruptures):
"""
Convert a list of ebruptures into an array of dtype RuptureRata.dt
"""
data = []
for ebr in ebruptures:
rup = ebr.rupture
self.cmaker.add_rup_params(rup)
ruptparams = tuple(getattr(rup, param) for param in se... | [
"def",
"to_array",
"(",
"self",
",",
"ebruptures",
")",
":",
"data",
"=",
"[",
"]",
"for",
"ebr",
"in",
"ebruptures",
":",
"rup",
"=",
"ebr",
".",
"rupture",
"self",
".",
"cmaker",
".",
"add_rup_params",
"(",
"rup",
")",
"ruptparams",
"=",
"tuple",
"... | Convert a list of ebruptures into an array of dtype RuptureRata.dt | [
"Convert",
"a",
"list",
"of",
"ebruptures",
"into",
"an",
"array",
"of",
"dtype",
"RuptureRata",
".",
"dt"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/calc.py#L268-L291 | train |
gem/oq-engine | openquake/commonlib/calc.py | RuptureSerializer.save | def save(self, rup_array):
"""
Store the ruptures in array format.
"""
self.nruptures += len(rup_array)
offset = len(self.datastore['rupgeoms'])
rup_array.array['gidx1'] += offset
rup_array.array['gidx2'] += offset
previous = self.datastore.get_attr('rupt... | python | def save(self, rup_array):
"""
Store the ruptures in array format.
"""
self.nruptures += len(rup_array)
offset = len(self.datastore['rupgeoms'])
rup_array.array['gidx1'] += offset
rup_array.array['gidx2'] += offset
previous = self.datastore.get_attr('rupt... | [
"def",
"save",
"(",
"self",
",",
"rup_array",
")",
":",
"self",
".",
"nruptures",
"+=",
"len",
"(",
"rup_array",
")",
"offset",
"=",
"len",
"(",
"self",
".",
"datastore",
"[",
"'rupgeoms'",
"]",
")",
"rup_array",
".",
"array",
"[",
"'gidx1'",
"]",
"+... | Store the ruptures in array format. | [
"Store",
"the",
"ruptures",
"in",
"array",
"format",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/calc.py#L307-L320 | train |
gem/oq-engine | openquake/commonlib/calc.py | RuptureSerializer.close | def close(self):
"""
Save information about the rupture codes as attributes of the
'ruptures' dataset.
"""
if 'ruptures' not in self.datastore: # for UCERF
return
codes = numpy.unique(self.datastore['ruptures']['code'])
attr = {'code_%d' % code: ' '.j... | python | def close(self):
"""
Save information about the rupture codes as attributes of the
'ruptures' dataset.
"""
if 'ruptures' not in self.datastore: # for UCERF
return
codes = numpy.unique(self.datastore['ruptures']['code'])
attr = {'code_%d' % code: ' '.j... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"'ruptures'",
"not",
"in",
"self",
".",
"datastore",
":",
"# for UCERF",
"return",
"codes",
"=",
"numpy",
".",
"unique",
"(",
"self",
".",
"datastore",
"[",
"'ruptures'",
"]",
"[",
"'code'",
"]",
")",
"attr"... | Save information about the rupture codes as attributes of the
'ruptures' dataset. | [
"Save",
"information",
"about",
"the",
"rupture",
"codes",
"as",
"attributes",
"of",
"the",
"ruptures",
"dataset",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/calc.py#L322-L333 | train |
gem/oq-engine | openquake/hazardlib/gsim/hong_goda_2007.py | HongGoda2007._compute_nonlinear_magnitude_term | def _compute_nonlinear_magnitude_term(self, C, mag):
"""
Computes the non-linear magnitude term
"""
return self._compute_linear_magnitude_term(C, mag) +\
C["b3"] * ((mag - 7.0) ** 2.) | python | def _compute_nonlinear_magnitude_term(self, C, mag):
"""
Computes the non-linear magnitude term
"""
return self._compute_linear_magnitude_term(C, mag) +\
C["b3"] * ((mag - 7.0) ** 2.) | [
"def",
"_compute_nonlinear_magnitude_term",
"(",
"self",
",",
"C",
",",
"mag",
")",
":",
"return",
"self",
".",
"_compute_linear_magnitude_term",
"(",
"C",
",",
"mag",
")",
"+",
"C",
"[",
"\"b3\"",
"]",
"*",
"(",
"(",
"mag",
"-",
"7.0",
")",
"**",
"2."... | Computes the non-linear magnitude term | [
"Computes",
"the",
"non",
"-",
"linear",
"magnitude",
"term"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/hong_goda_2007.py#L110-L115 | train |
gem/oq-engine | openquake/hazardlib/gsim/hong_goda_2007.py | HongGoda2007._compute_magnitude_distance_term | def _compute_magnitude_distance_term(self, C, rjb, mag):
"""
Returns the magntude dependent distance term
"""
rval = np.sqrt(rjb ** 2. + C["h"] ** 2.)
return (C["b4"] + C["b5"] * (mag - 4.5)) * np.log(rval) | python | def _compute_magnitude_distance_term(self, C, rjb, mag):
"""
Returns the magntude dependent distance term
"""
rval = np.sqrt(rjb ** 2. + C["h"] ** 2.)
return (C["b4"] + C["b5"] * (mag - 4.5)) * np.log(rval) | [
"def",
"_compute_magnitude_distance_term",
"(",
"self",
",",
"C",
",",
"rjb",
",",
"mag",
")",
":",
"rval",
"=",
"np",
".",
"sqrt",
"(",
"rjb",
"**",
"2.",
"+",
"C",
"[",
"\"h\"",
"]",
"**",
"2.",
")",
"return",
"(",
"C",
"[",
"\"b4\"",
"]",
"+",... | Returns the magntude dependent distance term | [
"Returns",
"the",
"magntude",
"dependent",
"distance",
"term"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/hong_goda_2007.py#L123-L128 | train |
gem/oq-engine | openquake/hazardlib/gsim/hong_goda_2007.py | HongGoda2007._get_bnl | def _get_bnl(self, C_AMP, vs30):
"""
Gets the nonlinear term, given by equation 8 of Atkinson & Boore 2006
"""
# Default case 8d
bnl = np.zeros_like(vs30)
if np.all(vs30 >= self.CONSTS["Vref"]):
return bnl
# Case 8a
bnl[vs30 < self.CONSTS["v1"]... | python | def _get_bnl(self, C_AMP, vs30):
"""
Gets the nonlinear term, given by equation 8 of Atkinson & Boore 2006
"""
# Default case 8d
bnl = np.zeros_like(vs30)
if np.all(vs30 >= self.CONSTS["Vref"]):
return bnl
# Case 8a
bnl[vs30 < self.CONSTS["v1"]... | [
"def",
"_get_bnl",
"(",
"self",
",",
"C_AMP",
",",
"vs30",
")",
":",
"# Default case 8d",
"bnl",
"=",
"np",
".",
"zeros_like",
"(",
"vs30",
")",
"if",
"np",
".",
"all",
"(",
"vs30",
">=",
"self",
".",
"CONSTS",
"[",
"\"Vref\"",
"]",
")",
":",
"retu... | Gets the nonlinear term, given by equation 8 of Atkinson & Boore 2006 | [
"Gets",
"the",
"nonlinear",
"term",
"given",
"by",
"equation",
"8",
"of",
"Atkinson",
"&",
"Boore",
"2006"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/hong_goda_2007.py#L145-L170 | train |
gem/oq-engine | openquake/hazardlib/gsim/hong_goda_2007.py | HongGoda2007._get_stddevs | def _get_stddevs(self, C, stddev_types, stddev_shape):
"""
Returns the standard deviations given in Table 2
"""
stddevs = []
for stddev_type in stddev_types:
assert stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
if stddev_type == const.StdDev.TOT... | python | def _get_stddevs(self, C, stddev_types, stddev_shape):
"""
Returns the standard deviations given in Table 2
"""
stddevs = []
for stddev_type in stddev_types:
assert stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
if stddev_type == const.StdDev.TOT... | [
"def",
"_get_stddevs",
"(",
"self",
",",
"C",
",",
"stddev_types",
",",
"stddev_shape",
")",
":",
"stddevs",
"=",
"[",
"]",
"for",
"stddev_type",
"in",
"stddev_types",
":",
"assert",
"stddev_type",
"in",
"self",
".",
"DEFINED_FOR_STANDARD_DEVIATION_TYPES",
"if",... | Returns the standard deviations given in Table 2 | [
"Returns",
"the",
"standard",
"deviations",
"given",
"in",
"Table",
"2"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/hong_goda_2007.py#L172-L185 | train |
gem/oq-engine | openquake/commands/tidy.py | tidy | def tidy(fnames):
"""
Reformat a NRML file in a canonical form. That also means reducing the
precision of the floats to a standard value. If the file is invalid,
a clear error message is shown.
"""
for fname in fnames:
try:
node = nrml.read(fname)
except ValueError as... | python | def tidy(fnames):
"""
Reformat a NRML file in a canonical form. That also means reducing the
precision of the floats to a standard value. If the file is invalid,
a clear error message is shown.
"""
for fname in fnames:
try:
node = nrml.read(fname)
except ValueError as... | [
"def",
"tidy",
"(",
"fnames",
")",
":",
"for",
"fname",
"in",
"fnames",
":",
"try",
":",
"node",
"=",
"nrml",
".",
"read",
"(",
"fname",
")",
"except",
"ValueError",
"as",
"err",
":",
"print",
"(",
"err",
")",
"return",
"with",
"open",
"(",
"fname"... | Reformat a NRML file in a canonical form. That also means reducing the
precision of the floats to a standard value. If the file is invalid,
a clear error message is shown. | [
"Reformat",
"a",
"NRML",
"file",
"in",
"a",
"canonical",
"form",
".",
"That",
"also",
"means",
"reducing",
"the",
"precision",
"of",
"the",
"floats",
"to",
"a",
"standard",
"value",
".",
"If",
"the",
"file",
"is",
"invalid",
"a",
"clear",
"error",
"messa... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/tidy.py#L24-L41 | train |
gem/oq-engine | openquake/commands/to_hdf5.py | to_hdf5 | def to_hdf5(input):
"""
Convert .xml and .npz files to .hdf5 files.
"""
with performance.Monitor('to_hdf5') as mon:
for input_file in input:
if input_file.endswith('.npz'):
output = convert_npz_hdf5(input_file, input_file[:-3] + 'hdf5')
elif input_file... | python | def to_hdf5(input):
"""
Convert .xml and .npz files to .hdf5 files.
"""
with performance.Monitor('to_hdf5') as mon:
for input_file in input:
if input_file.endswith('.npz'):
output = convert_npz_hdf5(input_file, input_file[:-3] + 'hdf5')
elif input_file... | [
"def",
"to_hdf5",
"(",
"input",
")",
":",
"with",
"performance",
".",
"Monitor",
"(",
"'to_hdf5'",
")",
"as",
"mon",
":",
"for",
"input_file",
"in",
"input",
":",
"if",
"input_file",
".",
"endswith",
"(",
"'.npz'",
")",
":",
"output",
"=",
"convert_npz_h... | Convert .xml and .npz files to .hdf5 files. | [
"Convert",
".",
"xml",
"and",
".",
"npz",
"files",
"to",
".",
"hdf5",
"files",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/to_hdf5.py#L47-L60 | train |
gem/oq-engine | openquake/hazardlib/calc/stochastic.py | get_rup_array | def get_rup_array(ebruptures, srcfilter=nofilter):
"""
Convert a list of EBRuptures into a numpy composite array, by filtering
out the ruptures far away from every site
"""
if not BaseRupture._code:
BaseRupture.init() # initialize rupture codes
rups = []
geoms = []
nbytes = 0
... | python | def get_rup_array(ebruptures, srcfilter=nofilter):
"""
Convert a list of EBRuptures into a numpy composite array, by filtering
out the ruptures far away from every site
"""
if not BaseRupture._code:
BaseRupture.init() # initialize rupture codes
rups = []
geoms = []
nbytes = 0
... | [
"def",
"get_rup_array",
"(",
"ebruptures",
",",
"srcfilter",
"=",
"nofilter",
")",
":",
"if",
"not",
"BaseRupture",
".",
"_code",
":",
"BaseRupture",
".",
"init",
"(",
")",
"# initialize rupture codes",
"rups",
"=",
"[",
"]",
"geoms",
"=",
"[",
"]",
"nbyte... | Convert a list of EBRuptures into a numpy composite array, by filtering
out the ruptures far away from every site | [
"Convert",
"a",
"list",
"of",
"EBRuptures",
"into",
"a",
"numpy",
"composite",
"array",
"by",
"filtering",
"out",
"the",
"ruptures",
"far",
"away",
"from",
"every",
"site"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/calc/stochastic.py#L97-L138 | train |
gem/oq-engine | openquake/hazardlib/calc/stochastic.py | sample_cluster | def sample_cluster(sources, srcfilter, num_ses, param):
"""
Yields ruptures generated by a cluster of sources.
:param sources:
A sequence of sources of the same group
:param num_ses:
Number of stochastic event sets
:param param:
a dictionary of additional parameters includin... | python | def sample_cluster(sources, srcfilter, num_ses, param):
"""
Yields ruptures generated by a cluster of sources.
:param sources:
A sequence of sources of the same group
:param num_ses:
Number of stochastic event sets
:param param:
a dictionary of additional parameters includin... | [
"def",
"sample_cluster",
"(",
"sources",
",",
"srcfilter",
",",
"num_ses",
",",
"param",
")",
":",
"eb_ruptures",
"=",
"[",
"]",
"numpy",
".",
"random",
".",
"seed",
"(",
"sources",
"[",
"0",
"]",
".",
"serial",
")",
"[",
"grp_id",
"]",
"=",
"set",
... | Yields ruptures generated by a cluster of sources.
:param sources:
A sequence of sources of the same group
:param num_ses:
Number of stochastic event sets
:param param:
a dictionary of additional parameters including
ses_per_logic_tree_path
:yields:
dictionaries ... | [
"Yields",
"ruptures",
"generated",
"by",
"a",
"cluster",
"of",
"sources",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/calc/stochastic.py#L141-L216 | train |
gem/oq-engine | openquake/commands/plot_sites.py | plot_sites | def plot_sites(calc_id=-1):
"""
Plot the sites
"""
# NB: matplotlib is imported inside since it is a costly import
import matplotlib.pyplot as p
dstore = util.read(calc_id)
sitecol = dstore['sitecol']
lons, lats = sitecol.lons, sitecol.lats
if len(lons) > 1 and cross_idl(*lons):
... | python | def plot_sites(calc_id=-1):
"""
Plot the sites
"""
# NB: matplotlib is imported inside since it is a costly import
import matplotlib.pyplot as p
dstore = util.read(calc_id)
sitecol = dstore['sitecol']
lons, lats = sitecol.lons, sitecol.lats
if len(lons) > 1 and cross_idl(*lons):
... | [
"def",
"plot_sites",
"(",
"calc_id",
"=",
"-",
"1",
")",
":",
"# NB: matplotlib is imported inside since it is a costly import",
"import",
"matplotlib",
".",
"pyplot",
"as",
"p",
"dstore",
"=",
"util",
".",
"read",
"(",
"calc_id",
")",
"sitecol",
"=",
"dstore",
... | Plot the sites | [
"Plot",
"the",
"sites"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/plot_sites.py#L24-L45 | train |
gem/oq-engine | openquake/hazardlib/gsim/ghofrani_atkinson_2014.py | GhofraniAtkinson2014._get_distance_term | def _get_distance_term(self, C, rrup, backarc):
"""
Returns the distance scaling term, which varies depending on whether
the site is in the forearc or the backarc
"""
# Geometric attenuation function
distance_scale = -np.log10(np.sqrt(rrup ** 2 + 3600.0))
# Anelas... | python | def _get_distance_term(self, C, rrup, backarc):
"""
Returns the distance scaling term, which varies depending on whether
the site is in the forearc or the backarc
"""
# Geometric attenuation function
distance_scale = -np.log10(np.sqrt(rrup ** 2 + 3600.0))
# Anelas... | [
"def",
"_get_distance_term",
"(",
"self",
",",
"C",
",",
"rrup",
",",
"backarc",
")",
":",
"# Geometric attenuation function",
"distance_scale",
"=",
"-",
"np",
".",
"log10",
"(",
"np",
".",
"sqrt",
"(",
"rrup",
"**",
"2",
"+",
"3600.0",
")",
")",
"# Ane... | Returns the distance scaling term, which varies depending on whether
the site is in the forearc or the backarc | [
"Returns",
"the",
"distance",
"scaling",
"term",
"which",
"varies",
"depending",
"on",
"whether",
"the",
"site",
"is",
"in",
"the",
"forearc",
"or",
"the",
"backarc"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/ghofrani_atkinson_2014.py#L103-L115 | train |
gem/oq-engine | openquake/hazardlib/gsim/ghofrani_atkinson_2014.py | GhofraniAtkinson2014CascadiaUpper._get_scaling_term | def _get_scaling_term(self, C, rrup):
"""
Applies the Cascadia correction factor from Table 2 and the positive
correction factor given on Page 567
"""
a_f = 0.15 + 0.0007 * rrup
a_f[a_f > 0.35] = 0.35
return C["af"] + a_f | python | def _get_scaling_term(self, C, rrup):
"""
Applies the Cascadia correction factor from Table 2 and the positive
correction factor given on Page 567
"""
a_f = 0.15 + 0.0007 * rrup
a_f[a_f > 0.35] = 0.35
return C["af"] + a_f | [
"def",
"_get_scaling_term",
"(",
"self",
",",
"C",
",",
"rrup",
")",
":",
"a_f",
"=",
"0.15",
"+",
"0.0007",
"*",
"rrup",
"a_f",
"[",
"a_f",
">",
"0.35",
"]",
"=",
"0.35",
"return",
"C",
"[",
"\"af\"",
"]",
"+",
"a_f"
] | Applies the Cascadia correction factor from Table 2 and the positive
correction factor given on Page 567 | [
"Applies",
"the",
"Cascadia",
"correction",
"factor",
"from",
"Table",
"2",
"and",
"the",
"positive",
"correction",
"factor",
"given",
"on",
"Page",
"567"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/ghofrani_atkinson_2014.py#L225-L232 | train |
gem/oq-engine | openquake/hazardlib/gsim/somerville_2009.py | SomervilleEtAl2009NonCratonic._compute_mean | def _compute_mean(self, C, mag, rjb):
"""
Compute mean value, see table 2.
"""
m1 = 6.4
r1 = 50.
h = 6.
R = np.sqrt(rjb ** 2 + h ** 2)
R1 = np.sqrt(r1 ** 2 + h ** 2)
less_r1 = rjb < r1
ge_r1 = rjb >= r1
mean = (C['c1'] + C['c4'] * ... | python | def _compute_mean(self, C, mag, rjb):
"""
Compute mean value, see table 2.
"""
m1 = 6.4
r1 = 50.
h = 6.
R = np.sqrt(rjb ** 2 + h ** 2)
R1 = np.sqrt(r1 ** 2 + h ** 2)
less_r1 = rjb < r1
ge_r1 = rjb >= r1
mean = (C['c1'] + C['c4'] * ... | [
"def",
"_compute_mean",
"(",
"self",
",",
"C",
",",
"mag",
",",
"rjb",
")",
":",
"m1",
"=",
"6.4",
"r1",
"=",
"50.",
"h",
"=",
"6.",
"R",
"=",
"np",
".",
"sqrt",
"(",
"rjb",
"**",
"2",
"+",
"h",
"**",
"2",
")",
"R1",
"=",
"np",
".",
"sqrt... | Compute mean value, see table 2. | [
"Compute",
"mean",
"value",
"see",
"table",
"2",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/somerville_2009.py#L86-L110 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.