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/calculators/base.py | get_idxs | def get_idxs(data, eid2idx):
"""
Convert from event IDs to event indices.
:param data: an array with a field eid
:param eid2idx: a dictionary eid -> idx
:returns: the array of event indices
"""
uniq, inv = numpy.unique(data['eid'], return_inverse=True)
idxs = numpy.array([eid2idx[eid] f... | python | def get_idxs(data, eid2idx):
"""
Convert from event IDs to event indices.
:param data: an array with a field eid
:param eid2idx: a dictionary eid -> idx
:returns: the array of event indices
"""
uniq, inv = numpy.unique(data['eid'], return_inverse=True)
idxs = numpy.array([eid2idx[eid] f... | [
"def",
"get_idxs",
"(",
"data",
",",
"eid2idx",
")",
":",
"uniq",
",",
"inv",
"=",
"numpy",
".",
"unique",
"(",
"data",
"[",
"'eid'",
"]",
",",
"return_inverse",
"=",
"True",
")",
"idxs",
"=",
"numpy",
".",
"array",
"(",
"[",
"eid2idx",
"[",
"eid",... | Convert from event IDs to event indices.
:param data: an array with a field eid
:param eid2idx: a dictionary eid -> idx
:returns: the array of event indices | [
"Convert",
"from",
"event",
"IDs",
"to",
"event",
"indices",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L959-L969 | train |
gem/oq-engine | openquake/calculators/base.py | import_gmfs | def import_gmfs(dstore, fname, sids):
"""
Import in the datastore a ground motion field CSV file.
:param dstore: the datastore
:param fname: the CSV file
:param sids: the site IDs (complete)
:returns: event_ids, num_rlzs
"""
array = writers.read_composite_array(fname).array
# has he... | python | def import_gmfs(dstore, fname, sids):
"""
Import in the datastore a ground motion field CSV file.
:param dstore: the datastore
:param fname: the CSV file
:param sids: the site IDs (complete)
:returns: event_ids, num_rlzs
"""
array = writers.read_composite_array(fname).array
# has he... | [
"def",
"import_gmfs",
"(",
"dstore",
",",
"fname",
",",
"sids",
")",
":",
"array",
"=",
"writers",
".",
"read_composite_array",
"(",
"fname",
")",
".",
"array",
"imts",
"=",
"[",
"name",
"[",
"4",
":",
"]",
"for",
"name",
"in",
"array",
".",
"dtype",... | Import in the datastore a ground motion field CSV file.
:param dstore: the datastore
:param fname: the CSV file
:param sids: the site IDs (complete)
:returns: event_ids, num_rlzs | [
"Import",
"in",
"the",
"datastore",
"a",
"ground",
"motion",
"field",
"CSV",
"file",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L972-L1013 | train |
gem/oq-engine | openquake/calculators/base.py | BaseCalculator.save_params | def save_params(self, **kw):
"""
Update the current calculation parameters and save engine_version
"""
if ('hazard_calculation_id' in kw and
kw['hazard_calculation_id'] is None):
del kw['hazard_calculation_id']
vars(self.oqparam).update(**kw)
s... | python | def save_params(self, **kw):
"""
Update the current calculation parameters and save engine_version
"""
if ('hazard_calculation_id' in kw and
kw['hazard_calculation_id'] is None):
del kw['hazard_calculation_id']
vars(self.oqparam).update(**kw)
s... | [
"def",
"save_params",
"(",
"self",
",",
"**",
"kw",
")",
":",
"if",
"(",
"'hazard_calculation_id'",
"in",
"kw",
"and",
"kw",
"[",
"'hazard_calculation_id'",
"]",
"is",
"None",
")",
":",
"del",
"kw",
"[",
"'hazard_calculation_id'",
"]",
"vars",
"(",
"self",... | Update the current calculation parameters and save engine_version | [
"Update",
"the",
"current",
"calculation",
"parameters",
"and",
"save",
"engine_version"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L142-L156 | train |
gem/oq-engine | openquake/calculators/base.py | BaseCalculator.run | def run(self, pre_execute=True, concurrent_tasks=None, close=True, **kw):
"""
Run the calculation and return the exported outputs.
"""
with self._monitor:
self._monitor.username = kw.get('username', '')
self._monitor.hdf5 = self.datastore.hdf5
if concu... | python | def run(self, pre_execute=True, concurrent_tasks=None, close=True, **kw):
"""
Run the calculation and return the exported outputs.
"""
with self._monitor:
self._monitor.username = kw.get('username', '')
self._monitor.hdf5 = self.datastore.hdf5
if concu... | [
"def",
"run",
"(",
"self",
",",
"pre_execute",
"=",
"True",
",",
"concurrent_tasks",
"=",
"None",
",",
"close",
"=",
"True",
",",
"**",
"kw",
")",
":",
"with",
"self",
".",
"_monitor",
":",
"self",
".",
"_monitor",
".",
"username",
"=",
"kw",
".",
... | Run the calculation and return the exported outputs. | [
"Run",
"the",
"calculation",
"and",
"return",
"the",
"exported",
"outputs",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L175-L231 | train |
gem/oq-engine | openquake/calculators/base.py | BaseCalculator.export | def export(self, exports=None):
"""
Export all the outputs in the datastore in the given export formats.
Individual outputs are not exported if there are multiple realizations.
"""
self.exported = getattr(self.precalc, 'exported', {})
if isinstance(exports, tuple):
... | python | def export(self, exports=None):
"""
Export all the outputs in the datastore in the given export formats.
Individual outputs are not exported if there are multiple realizations.
"""
self.exported = getattr(self.precalc, 'exported', {})
if isinstance(exports, tuple):
... | [
"def",
"export",
"(",
"self",
",",
"exports",
"=",
"None",
")",
":",
"self",
".",
"exported",
"=",
"getattr",
"(",
"self",
".",
"precalc",
",",
"'exported'",
",",
"{",
"}",
")",
"if",
"isinstance",
"(",
"exports",
",",
"tuple",
")",
":",
"fmts",
"=... | Export all the outputs in the datastore in the given export formats.
Individual outputs are not exported if there are multiple realizations. | [
"Export",
"all",
"the",
"outputs",
"in",
"the",
"datastore",
"in",
"the",
"given",
"export",
"formats",
".",
"Individual",
"outputs",
"are",
"not",
"exported",
"if",
"there",
"are",
"multiple",
"realizations",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L260-L289 | train |
gem/oq-engine | openquake/calculators/base.py | BaseCalculator.before_export | def before_export(self):
"""
Set the attributes nbytes
"""
# sanity check that eff_ruptures have been set, i.e. are not -1
try:
csm_info = self.datastore['csm_info']
except KeyError:
csm_info = self.datastore['csm_info'] = self.csm.info
for... | python | def before_export(self):
"""
Set the attributes nbytes
"""
# sanity check that eff_ruptures have been set, i.e. are not -1
try:
csm_info = self.datastore['csm_info']
except KeyError:
csm_info = self.datastore['csm_info'] = self.csm.info
for... | [
"def",
"before_export",
"(",
"self",
")",
":",
"try",
":",
"csm_info",
"=",
"self",
".",
"datastore",
"[",
"'csm_info'",
"]",
"except",
"KeyError",
":",
"csm_info",
"=",
"self",
".",
"datastore",
"[",
"'csm_info'",
"]",
"=",
"self",
".",
"csm",
".",
"i... | Set the attributes nbytes | [
"Set",
"the",
"attributes",
"nbytes"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L303-L318 | train |
gem/oq-engine | openquake/calculators/base.py | HazardCalculator.read_inputs | def read_inputs(self):
"""
Read risk data and sources if any
"""
oq = self.oqparam
self._read_risk_data()
self.check_overflow() # check if self.sitecol is too large
if ('source_model_logic_tree' in oq.inputs and
oq.hazard_calculation_id is None):
... | python | def read_inputs(self):
"""
Read risk data and sources if any
"""
oq = self.oqparam
self._read_risk_data()
self.check_overflow() # check if self.sitecol is too large
if ('source_model_logic_tree' in oq.inputs and
oq.hazard_calculation_id is None):
... | [
"def",
"read_inputs",
"(",
"self",
")",
":",
"oq",
"=",
"self",
".",
"oqparam",
"self",
".",
"_read_risk_data",
"(",
")",
"self",
".",
"check_overflow",
"(",
")",
"if",
"(",
"'source_model_logic_tree'",
"in",
"oq",
".",
"inputs",
"and",
"oq",
".",
"hazar... | Read risk data and sources if any | [
"Read",
"risk",
"data",
"and",
"sources",
"if",
"any"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L406-L417 | train |
gem/oq-engine | openquake/calculators/base.py | HazardCalculator.pre_execute | def pre_execute(self):
"""
Check if there is a previous calculation ID.
If yes, read the inputs by retrieving the previous calculation;
if not, read the inputs directly.
"""
oq = self.oqparam
if 'gmfs' in oq.inputs or 'multi_peril' in oq.inputs:
# read... | python | def pre_execute(self):
"""
Check if there is a previous calculation ID.
If yes, read the inputs by retrieving the previous calculation;
if not, read the inputs directly.
"""
oq = self.oqparam
if 'gmfs' in oq.inputs or 'multi_peril' in oq.inputs:
# read... | [
"def",
"pre_execute",
"(",
"self",
")",
":",
"oq",
"=",
"self",
".",
"oqparam",
"if",
"'gmfs'",
"in",
"oq",
".",
"inputs",
"or",
"'multi_peril'",
"in",
"oq",
".",
"inputs",
":",
"assert",
"not",
"oq",
".",
"hazard_calculation_id",
",",
"(",
"'You cannot ... | Check if there is a previous calculation ID.
If yes, read the inputs by retrieving the previous calculation;
if not, read the inputs directly. | [
"Check",
"if",
"there",
"is",
"a",
"previous",
"calculation",
"ID",
".",
"If",
"yes",
"read",
"the",
"inputs",
"by",
"retrieving",
"the",
"previous",
"calculation",
";",
"if",
"not",
"read",
"the",
"inputs",
"directly",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L422-L496 | train |
gem/oq-engine | openquake/calculators/base.py | HazardCalculator.init | def init(self):
"""
To be overridden to initialize the datasets needed by the calculation
"""
oq = self.oqparam
if not oq.risk_imtls:
if self.datastore.parent:
oq.risk_imtls = (
self.datastore.parent['oqparam'].risk_imtls)
i... | python | def init(self):
"""
To be overridden to initialize the datasets needed by the calculation
"""
oq = self.oqparam
if not oq.risk_imtls:
if self.datastore.parent:
oq.risk_imtls = (
self.datastore.parent['oqparam'].risk_imtls)
i... | [
"def",
"init",
"(",
"self",
")",
":",
"oq",
"=",
"self",
".",
"oqparam",
"if",
"not",
"oq",
".",
"risk_imtls",
":",
"if",
"self",
".",
"datastore",
".",
"parent",
":",
"oq",
".",
"risk_imtls",
"=",
"(",
"self",
".",
"datastore",
".",
"parent",
"[",... | To be overridden to initialize the datasets needed by the calculation | [
"To",
"be",
"overridden",
"to",
"initialize",
"the",
"datasets",
"needed",
"by",
"the",
"calculation"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L498-L522 | train |
gem/oq-engine | openquake/calculators/base.py | HazardCalculator.read_exposure | def read_exposure(self, haz_sitecol=None): # after load_risk_model
"""
Read the exposure, the riskmodel and update the attributes
.sitecol, .assetcol
"""
with self.monitor('reading exposure', autoflush=True):
self.sitecol, self.assetcol, discarded = (
... | python | def read_exposure(self, haz_sitecol=None): # after load_risk_model
"""
Read the exposure, the riskmodel and update the attributes
.sitecol, .assetcol
"""
with self.monitor('reading exposure', autoflush=True):
self.sitecol, self.assetcol, discarded = (
... | [
"def",
"read_exposure",
"(",
"self",
",",
"haz_sitecol",
"=",
"None",
")",
":",
"with",
"self",
".",
"monitor",
"(",
"'reading exposure'",
",",
"autoflush",
"=",
"True",
")",
":",
"self",
".",
"sitecol",
",",
"self",
".",
"assetcol",
",",
"discarded",
"=... | Read the exposure, the riskmodel and update the attributes
.sitecol, .assetcol | [
"Read",
"the",
"exposure",
"the",
"riskmodel",
"and",
"update",
"the",
"attributes",
".",
"sitecol",
".",
"assetcol"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L534-L566 | train |
gem/oq-engine | openquake/calculators/base.py | HazardCalculator.save_riskmodel | def save_riskmodel(self):
"""
Save the risk models in the datastore
"""
self.datastore['risk_model'] = rm = self.riskmodel
self.datastore['taxonomy_mapping'] = self.riskmodel.tmap
attrs = self.datastore.getitem('risk_model').attrs
attrs['min_iml'] = hdf5.array_of_... | python | def save_riskmodel(self):
"""
Save the risk models in the datastore
"""
self.datastore['risk_model'] = rm = self.riskmodel
self.datastore['taxonomy_mapping'] = self.riskmodel.tmap
attrs = self.datastore.getitem('risk_model').attrs
attrs['min_iml'] = hdf5.array_of_... | [
"def",
"save_riskmodel",
"(",
"self",
")",
":",
"self",
".",
"datastore",
"[",
"'risk_model'",
"]",
"=",
"rm",
"=",
"self",
".",
"riskmodel",
"self",
".",
"datastore",
"[",
"'taxonomy_mapping'",
"]",
"=",
"self",
".",
"riskmodel",
".",
"tmap",
"attrs",
"... | Save the risk models in the datastore | [
"Save",
"the",
"risk",
"models",
"in",
"the",
"datastore"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L588-L596 | train |
gem/oq-engine | openquake/calculators/base.py | HazardCalculator.store_rlz_info | def store_rlz_info(self, eff_ruptures=None):
"""
Save info about the composite source model inside the csm_info dataset
"""
if hasattr(self, 'csm'): # no scenario
self.csm.info.update_eff_ruptures(eff_ruptures)
self.rlzs_assoc = self.csm.info.get_rlzs_assoc(
... | python | def store_rlz_info(self, eff_ruptures=None):
"""
Save info about the composite source model inside the csm_info dataset
"""
if hasattr(self, 'csm'): # no scenario
self.csm.info.update_eff_ruptures(eff_ruptures)
self.rlzs_assoc = self.csm.info.get_rlzs_assoc(
... | [
"def",
"store_rlz_info",
"(",
"self",
",",
"eff_ruptures",
"=",
"None",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'csm'",
")",
":",
"self",
".",
"csm",
".",
"info",
".",
"update_eff_ruptures",
"(",
"eff_ruptures",
")",
"self",
".",
"rlzs_assoc",
"=",... | Save info about the composite source model inside the csm_info dataset | [
"Save",
"info",
"about",
"the",
"composite",
"source",
"model",
"inside",
"the",
"csm_info",
"dataset"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L701-L730 | train |
gem/oq-engine | openquake/calculators/base.py | RiskCalculator.read_shakemap | def read_shakemap(self, haz_sitecol, assetcol):
"""
Enabled only if there is a shakemap_id parameter in the job.ini.
Download, unzip, parse USGS shakemap files and build a corresponding
set of GMFs which are then filtered with the hazard site collection
and stored in the datastor... | python | def read_shakemap(self, haz_sitecol, assetcol):
"""
Enabled only if there is a shakemap_id parameter in the job.ini.
Download, unzip, parse USGS shakemap files and build a corresponding
set of GMFs which are then filtered with the hazard site collection
and stored in the datastor... | [
"def",
"read_shakemap",
"(",
"self",
",",
"haz_sitecol",
",",
"assetcol",
")",
":",
"oq",
"=",
"self",
".",
"oqparam",
"E",
"=",
"oq",
".",
"number_of_ground_motion_fields",
"oq",
".",
"risk_imtls",
"=",
"oq",
".",
"imtls",
"or",
"self",
".",
"datastore",
... | Enabled only if there is a shakemap_id parameter in the job.ini.
Download, unzip, parse USGS shakemap files and build a corresponding
set of GMFs which are then filtered with the hazard site collection
and stored in the datastore. | [
"Enabled",
"only",
"if",
"there",
"is",
"a",
"shakemap_id",
"parameter",
"in",
"the",
"job",
".",
"ini",
".",
"Download",
"unzip",
"parse",
"USGS",
"shakemap",
"files",
"and",
"build",
"a",
"corresponding",
"set",
"of",
"GMFs",
"which",
"are",
"then",
"fil... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L766-L800 | train |
gem/oq-engine | openquake/baselib/zeromq.py | bind | def bind(end_point, socket_type):
"""
Bind to a zmq URL; raise a proper error if the URL is invalid; return
a zmq socket.
"""
sock = context.socket(socket_type)
try:
sock.bind(end_point)
except zmq.error.ZMQError as exc:
sock.close()
raise exc.__class__('%s: %s' % (ex... | python | def bind(end_point, socket_type):
"""
Bind to a zmq URL; raise a proper error if the URL is invalid; return
a zmq socket.
"""
sock = context.socket(socket_type)
try:
sock.bind(end_point)
except zmq.error.ZMQError as exc:
sock.close()
raise exc.__class__('%s: %s' % (ex... | [
"def",
"bind",
"(",
"end_point",
",",
"socket_type",
")",
":",
"sock",
"=",
"context",
".",
"socket",
"(",
"socket_type",
")",
"try",
":",
"sock",
".",
"bind",
"(",
"end_point",
")",
"except",
"zmq",
".",
"error",
".",
"ZMQError",
"as",
"exc",
":",
"... | Bind to a zmq URL; raise a proper error if the URL is invalid; return
a zmq socket. | [
"Bind",
"to",
"a",
"zmq",
"URL",
";",
"raise",
"a",
"proper",
"error",
"if",
"the",
"URL",
"is",
"invalid",
";",
"return",
"a",
"zmq",
"socket",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/zeromq.py#L30-L41 | train |
gem/oq-engine | openquake/baselib/zeromq.py | Socket.send | def send(self, obj):
"""
Send an object to the remote server; block and return the reply
if the socket type is REQ.
:param obj:
the Python object to send
"""
self.zsocket.send_pyobj(obj)
self.num_sent += 1
if self.socket_type == zmq.REQ:
... | python | def send(self, obj):
"""
Send an object to the remote server; block and return the reply
if the socket type is REQ.
:param obj:
the Python object to send
"""
self.zsocket.send_pyobj(obj)
self.num_sent += 1
if self.socket_type == zmq.REQ:
... | [
"def",
"send",
"(",
"self",
",",
"obj",
")",
":",
"self",
".",
"zsocket",
".",
"send_pyobj",
"(",
"obj",
")",
"self",
".",
"num_sent",
"+=",
"1",
"if",
"self",
".",
"socket_type",
"==",
"zmq",
".",
"REQ",
":",
"return",
"self",
".",
"zsocket",
".",... | Send an object to the remote server; block and return the reply
if the socket type is REQ.
:param obj:
the Python object to send | [
"Send",
"an",
"object",
"to",
"the",
"remote",
"server",
";",
"block",
"and",
"return",
"the",
"reply",
"if",
"the",
"socket",
"type",
"is",
"REQ",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/zeromq.py#L139-L150 | train |
gem/oq-engine | openquake/hazardlib/geo/utils.py | angular_distance | def angular_distance(km, lat, lat2=None):
"""
Return the angular distance of two points at the given latitude.
>>> '%.3f' % angular_distance(100, lat=40)
'1.174'
>>> '%.3f' % angular_distance(100, lat=80)
'5.179'
"""
if lat2 is not None:
# use the largest latitude to compute the... | python | def angular_distance(km, lat, lat2=None):
"""
Return the angular distance of two points at the given latitude.
>>> '%.3f' % angular_distance(100, lat=40)
'1.174'
>>> '%.3f' % angular_distance(100, lat=80)
'5.179'
"""
if lat2 is not None:
# use the largest latitude to compute the... | [
"def",
"angular_distance",
"(",
"km",
",",
"lat",
",",
"lat2",
"=",
"None",
")",
":",
"if",
"lat2",
"is",
"not",
"None",
":",
"lat",
"=",
"max",
"(",
"abs",
"(",
"lat",
")",
",",
"abs",
"(",
"lat2",
")",
")",
"return",
"km",
"*",
"KM_TO_DEGREES",... | Return the angular distance of two points at the given latitude.
>>> '%.3f' % angular_distance(100, lat=40)
'1.174'
>>> '%.3f' % angular_distance(100, lat=80)
'5.179' | [
"Return",
"the",
"angular",
"distance",
"of",
"two",
"points",
"at",
"the",
"given",
"latitude",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L45-L57 | train |
gem/oq-engine | openquake/hazardlib/geo/utils.py | assoc | def assoc(objects, sitecol, assoc_dist, mode, asset_refs=()):
"""
Associate geographic objects to a site collection.
:param objects:
something with .lons, .lats or ['lon'] ['lat'], or a list of lists
of objects with a .location attribute (i.e. assets_by_site)
:param assoc_dist:
... | python | def assoc(objects, sitecol, assoc_dist, mode, asset_refs=()):
"""
Associate geographic objects to a site collection.
:param objects:
something with .lons, .lats or ['lon'] ['lat'], or a list of lists
of objects with a .location attribute (i.e. assets_by_site)
:param assoc_dist:
... | [
"def",
"assoc",
"(",
"objects",
",",
"sitecol",
",",
"assoc_dist",
",",
"mode",
",",
"asset_refs",
"=",
"(",
")",
")",
":",
"if",
"isinstance",
"(",
"objects",
",",
"numpy",
".",
"ndarray",
")",
"or",
"hasattr",
"(",
"objects",
",",
"'lons'",
")",
":... | Associate geographic objects to a site collection.
:param objects:
something with .lons, .lats or ['lon'] ['lat'], or a list of lists
of objects with a .location attribute (i.e. assets_by_site)
:param assoc_dist:
the maximum distance for association
:param mode:
if 'strict' ... | [
"Associate",
"geographic",
"objects",
"to",
"a",
"site",
"collection",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L177-L196 | train |
gem/oq-engine | openquake/hazardlib/geo/utils.py | line_intersects_itself | def line_intersects_itself(lons, lats, closed_shape=False):
"""
Return ``True`` if line of points intersects itself.
Line with the last point repeating the first one considered
intersecting itself.
The line is defined by lists (or numpy arrays) of points'
longitudes and latitudes (depth is not ... | python | def line_intersects_itself(lons, lats, closed_shape=False):
"""
Return ``True`` if line of points intersects itself.
Line with the last point repeating the first one considered
intersecting itself.
The line is defined by lists (or numpy arrays) of points'
longitudes and latitudes (depth is not ... | [
"def",
"line_intersects_itself",
"(",
"lons",
",",
"lats",
",",
"closed_shape",
"=",
"False",
")",
":",
"assert",
"len",
"(",
"lons",
")",
"==",
"len",
"(",
"lats",
")",
"if",
"len",
"(",
"lons",
")",
"<=",
"3",
":",
"return",
"False",
"west",
",",
... | Return ``True`` if line of points intersects itself.
Line with the last point repeating the first one considered
intersecting itself.
The line is defined by lists (or numpy arrays) of points'
longitudes and latitudes (depth is not taken into account).
:param closed_shape:
If ``True`` the l... | [
"Return",
"True",
"if",
"line",
"of",
"points",
"intersects",
"itself",
".",
"Line",
"with",
"the",
"last",
"point",
"repeating",
"the",
"first",
"one",
"considered",
"intersecting",
"itself",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L214-L250 | train |
gem/oq-engine | openquake/hazardlib/geo/utils.py | get_bounding_box | def get_bounding_box(obj, maxdist):
"""
Return the dilated bounding box of a geometric object.
:param obj:
an object with method .get_bounding_box, or with an attribute .polygon
or a list of locations
:param maxdist: maximum distance in km
"""
if hasattr(obj, 'get_bounding_box')... | python | def get_bounding_box(obj, maxdist):
"""
Return the dilated bounding box of a geometric object.
:param obj:
an object with method .get_bounding_box, or with an attribute .polygon
or a list of locations
:param maxdist: maximum distance in km
"""
if hasattr(obj, 'get_bounding_box')... | [
"def",
"get_bounding_box",
"(",
"obj",
",",
"maxdist",
")",
":",
"if",
"hasattr",
"(",
"obj",
",",
"'get_bounding_box'",
")",
":",
"return",
"obj",
".",
"get_bounding_box",
"(",
"maxdist",
")",
"elif",
"hasattr",
"(",
"obj",
",",
"'polygon'",
")",
":",
"... | Return the dilated bounding box of a geometric object.
:param obj:
an object with method .get_bounding_box, or with an attribute .polygon
or a list of locations
:param maxdist: maximum distance in km | [
"Return",
"the",
"dilated",
"bounding",
"box",
"of",
"a",
"geometric",
"object",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L267-L292 | train |
gem/oq-engine | openquake/hazardlib/geo/utils.py | get_spherical_bounding_box | def get_spherical_bounding_box(lons, lats):
"""
Given a collection of points find and return the bounding box,
as a pair of longitudes and a pair of latitudes.
Parameters define longitudes and latitudes of a point collection
respectively in a form of lists or numpy arrays.
:return:
A t... | python | def get_spherical_bounding_box(lons, lats):
"""
Given a collection of points find and return the bounding box,
as a pair of longitudes and a pair of latitudes.
Parameters define longitudes and latitudes of a point collection
respectively in a form of lists or numpy arrays.
:return:
A t... | [
"def",
"get_spherical_bounding_box",
"(",
"lons",
",",
"lats",
")",
":",
"north",
",",
"south",
"=",
"numpy",
".",
"max",
"(",
"lats",
")",
",",
"numpy",
".",
"min",
"(",
"lats",
")",
"west",
",",
"east",
"=",
"numpy",
".",
"min",
"(",
"lons",
")",... | Given a collection of points find and return the bounding box,
as a pair of longitudes and a pair of latitudes.
Parameters define longitudes and latitudes of a point collection
respectively in a form of lists or numpy arrays.
:return:
A tuple of four items. These items represent western, easte... | [
"Given",
"a",
"collection",
"of",
"points",
"find",
"and",
"return",
"the",
"bounding",
"box",
"as",
"a",
"pair",
"of",
"longitudes",
"and",
"a",
"pair",
"of",
"latitudes",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L295-L329 | train |
gem/oq-engine | openquake/hazardlib/geo/utils.py | get_middle_point | def get_middle_point(lon1, lat1, lon2, lat2):
"""
Given two points return the point exactly in the middle lying on the same
great circle arc.
Parameters are point coordinates in degrees.
:returns:
Tuple of longitude and latitude of the point in the middle.
"""
if lon1 == lon2 and l... | python | def get_middle_point(lon1, lat1, lon2, lat2):
"""
Given two points return the point exactly in the middle lying on the same
great circle arc.
Parameters are point coordinates in degrees.
:returns:
Tuple of longitude and latitude of the point in the middle.
"""
if lon1 == lon2 and l... | [
"def",
"get_middle_point",
"(",
"lon1",
",",
"lat1",
",",
"lon2",
",",
"lat2",
")",
":",
"if",
"lon1",
"==",
"lon2",
"and",
"lat1",
"==",
"lat2",
":",
"return",
"lon1",
",",
"lat1",
"dist",
"=",
"geodetic",
".",
"geodetic_distance",
"(",
"lon1",
",",
... | Given two points return the point exactly in the middle lying on the same
great circle arc.
Parameters are point coordinates in degrees.
:returns:
Tuple of longitude and latitude of the point in the middle. | [
"Given",
"two",
"points",
"return",
"the",
"point",
"exactly",
"in",
"the",
"middle",
"lying",
"on",
"the",
"same",
"great",
"circle",
"arc",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L428-L442 | train |
gem/oq-engine | openquake/hazardlib/geo/utils.py | cartesian_to_spherical | def cartesian_to_spherical(vectors):
"""
Return the spherical coordinates for coordinates in Cartesian space.
This function does an opposite to :func:`spherical_to_cartesian`.
:param vectors:
Array of 3d vectors in Cartesian space of shape (..., 3)
:returns:
Tuple of three arrays o... | python | def cartesian_to_spherical(vectors):
"""
Return the spherical coordinates for coordinates in Cartesian space.
This function does an opposite to :func:`spherical_to_cartesian`.
:param vectors:
Array of 3d vectors in Cartesian space of shape (..., 3)
:returns:
Tuple of three arrays o... | [
"def",
"cartesian_to_spherical",
"(",
"vectors",
")",
":",
"rr",
"=",
"numpy",
".",
"sqrt",
"(",
"numpy",
".",
"sum",
"(",
"vectors",
"*",
"vectors",
",",
"axis",
"=",
"-",
"1",
")",
")",
"xx",
",",
"yy",
",",
"zz",
"=",
"vectors",
".",
"T",
"lat... | Return the spherical coordinates for coordinates in Cartesian space.
This function does an opposite to :func:`spherical_to_cartesian`.
:param vectors:
Array of 3d vectors in Cartesian space of shape (..., 3)
:returns:
Tuple of three arrays of the same shape as ``vectors`` representing
... | [
"Return",
"the",
"spherical",
"coordinates",
"for",
"coordinates",
"in",
"Cartesian",
"space",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L445-L463 | train |
gem/oq-engine | openquake/hazardlib/geo/utils.py | triangle_area | def triangle_area(e1, e2, e3):
"""
Get the area of triangle formed by three vectors.
Parameters are three three-dimensional numpy arrays representing
vectors of triangle's edges in Cartesian space.
:returns:
Float number, the area of the triangle in squared units of coordinates,
or... | python | def triangle_area(e1, e2, e3):
"""
Get the area of triangle formed by three vectors.
Parameters are three three-dimensional numpy arrays representing
vectors of triangle's edges in Cartesian space.
:returns:
Float number, the area of the triangle in squared units of coordinates,
or... | [
"def",
"triangle_area",
"(",
"e1",
",",
"e2",
",",
"e3",
")",
":",
"e1_length",
"=",
"numpy",
".",
"sqrt",
"(",
"numpy",
".",
"sum",
"(",
"e1",
"*",
"e1",
",",
"axis",
"=",
"-",
"1",
")",
")",
"e2_length",
"=",
"numpy",
".",
"sqrt",
"(",
"numpy... | Get the area of triangle formed by three vectors.
Parameters are three three-dimensional numpy arrays representing
vectors of triangle's edges in Cartesian space.
:returns:
Float number, the area of the triangle in squared units of coordinates,
or numpy array of shape of edges with one dim... | [
"Get",
"the",
"area",
"of",
"triangle",
"formed",
"by",
"three",
"vectors",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L466-L486 | train |
gem/oq-engine | openquake/hazardlib/geo/utils.py | normalized | def normalized(vector):
"""
Get unit vector for a given one.
:param vector:
Numpy vector as coordinates in Cartesian space, or an array of such.
:returns:
Numpy array of the same shape and structure where all vectors are
normalized. That is, each coordinate component is divided ... | python | def normalized(vector):
"""
Get unit vector for a given one.
:param vector:
Numpy vector as coordinates in Cartesian space, or an array of such.
:returns:
Numpy array of the same shape and structure where all vectors are
normalized. That is, each coordinate component is divided ... | [
"def",
"normalized",
"(",
"vector",
")",
":",
"length",
"=",
"numpy",
".",
"sum",
"(",
"vector",
"*",
"vector",
",",
"axis",
"=",
"-",
"1",
")",
"length",
"=",
"numpy",
".",
"sqrt",
"(",
"length",
".",
"reshape",
"(",
"length",
".",
"shape",
"+",
... | Get unit vector for a given one.
:param vector:
Numpy vector as coordinates in Cartesian space, or an array of such.
:returns:
Numpy array of the same shape and structure where all vectors are
normalized. That is, each coordinate component is divided by its
vector's length. | [
"Get",
"unit",
"vector",
"for",
"a",
"given",
"one",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L489-L502 | train |
gem/oq-engine | openquake/hazardlib/geo/utils.py | point_to_polygon_distance | def point_to_polygon_distance(polygon, pxx, pyy):
"""
Calculate the distance to polygon for each point of the collection
on the 2d Cartesian plane.
:param polygon:
Shapely "Polygon" geometry object.
:param pxx:
List or numpy array of abscissae values of points to calculate
t... | python | def point_to_polygon_distance(polygon, pxx, pyy):
"""
Calculate the distance to polygon for each point of the collection
on the 2d Cartesian plane.
:param polygon:
Shapely "Polygon" geometry object.
:param pxx:
List or numpy array of abscissae values of points to calculate
t... | [
"def",
"point_to_polygon_distance",
"(",
"polygon",
",",
"pxx",
",",
"pyy",
")",
":",
"pxx",
"=",
"numpy",
".",
"array",
"(",
"pxx",
")",
"pyy",
"=",
"numpy",
".",
"array",
"(",
"pyy",
")",
"assert",
"pxx",
".",
"shape",
"==",
"pyy",
".",
"shape",
... | Calculate the distance to polygon for each point of the collection
on the 2d Cartesian plane.
:param polygon:
Shapely "Polygon" geometry object.
:param pxx:
List or numpy array of abscissae values of points to calculate
the distance from.
:param pyy:
Same structure as ``... | [
"Calculate",
"the",
"distance",
"to",
"polygon",
"for",
"each",
"point",
"of",
"the",
"collection",
"on",
"the",
"2d",
"Cartesian",
"plane",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L505-L531 | train |
gem/oq-engine | openquake/hazardlib/geo/utils.py | cross_idl | def cross_idl(lon1, lon2, *lons):
"""
Return True if two longitude values define line crossing international date
line.
>>> cross_idl(-45, 45)
False
>>> cross_idl(-180, -179)
False
>>> cross_idl(180, 179)
False
>>> cross_idl(45, -45)
False
>>> cross_idl(0, 0)
False
... | python | def cross_idl(lon1, lon2, *lons):
"""
Return True if two longitude values define line crossing international date
line.
>>> cross_idl(-45, 45)
False
>>> cross_idl(-180, -179)
False
>>> cross_idl(180, 179)
False
>>> cross_idl(45, -45)
False
>>> cross_idl(0, 0)
False
... | [
"def",
"cross_idl",
"(",
"lon1",
",",
"lon2",
",",
"*",
"lons",
")",
":",
"lons",
"=",
"(",
"lon1",
",",
"lon2",
")",
"+",
"lons",
"l1",
",",
"l2",
"=",
"min",
"(",
"lons",
")",
",",
"max",
"(",
"lons",
")",
"return",
"l1",
"*",
"l2",
"<",
... | Return True if two longitude values define line crossing international date
line.
>>> cross_idl(-45, 45)
False
>>> cross_idl(-180, -179)
False
>>> cross_idl(180, 179)
False
>>> cross_idl(45, -45)
False
>>> cross_idl(0, 0)
False
>>> cross_idl(-170, 170)
True
>>> c... | [
"Return",
"True",
"if",
"two",
"longitude",
"values",
"define",
"line",
"crossing",
"international",
"date",
"line",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L548-L574 | train |
gem/oq-engine | openquake/hazardlib/geo/utils.py | normalize_lons | def normalize_lons(l1, l2):
"""
An international date line safe way of returning a range of longitudes.
>>> normalize_lons(20, 30) # no IDL within the range
[(20, 30)]
>>> normalize_lons(-17, +17) # no IDL within the range
[(-17, 17)]
>>> normalize_lons(-178, +179)
[(-180, -178), (179... | python | def normalize_lons(l1, l2):
"""
An international date line safe way of returning a range of longitudes.
>>> normalize_lons(20, 30) # no IDL within the range
[(20, 30)]
>>> normalize_lons(-17, +17) # no IDL within the range
[(-17, 17)]
>>> normalize_lons(-178, +179)
[(-180, -178), (179... | [
"def",
"normalize_lons",
"(",
"l1",
",",
"l2",
")",
":",
"if",
"l1",
">",
"l2",
":",
"l1",
",",
"l2",
"=",
"l2",
",",
"l1",
"delta",
"=",
"l2",
"-",
"l1",
"if",
"l1",
"<",
"0",
"and",
"l2",
">",
"0",
"and",
"delta",
">",
"180",
":",
"return... | An international date line safe way of returning a range of longitudes.
>>> normalize_lons(20, 30) # no IDL within the range
[(20, 30)]
>>> normalize_lons(-17, +17) # no IDL within the range
[(-17, 17)]
>>> normalize_lons(-178, +179)
[(-180, -178), (179, 180)]
>>> normalize_lons(178, -179... | [
"An",
"international",
"date",
"line",
"safe",
"way",
"of",
"returning",
"a",
"range",
"of",
"longitudes",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L577-L603 | train |
gem/oq-engine | openquake/hazardlib/geo/utils.py | _GeographicObjects.get_closest | def get_closest(self, lon, lat, depth=0):
"""
Get the closest object to the given longitude and latitude
and its distance.
:param lon: longitude in degrees
:param lat: latitude in degrees
:param depth: depth in km (default 0)
:returns: (object, distance)
... | python | def get_closest(self, lon, lat, depth=0):
"""
Get the closest object to the given longitude and latitude
and its distance.
:param lon: longitude in degrees
:param lat: latitude in degrees
:param depth: depth in km (default 0)
:returns: (object, distance)
... | [
"def",
"get_closest",
"(",
"self",
",",
"lon",
",",
"lat",
",",
"depth",
"=",
"0",
")",
":",
"xyz",
"=",
"spherical_to_cartesian",
"(",
"lon",
",",
"lat",
",",
"depth",
")",
"min_dist",
",",
"idx",
"=",
"self",
".",
"kdtree",
".",
"query",
"(",
"xy... | Get the closest object to the given longitude and latitude
and its distance.
:param lon: longitude in degrees
:param lat: latitude in degrees
:param depth: depth in km (default 0)
:returns: (object, distance) | [
"Get",
"the",
"closest",
"object",
"to",
"the",
"given",
"longitude",
"and",
"latitude",
"and",
"its",
"distance",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L85-L97 | train |
gem/oq-engine | openquake/hazardlib/geo/utils.py | _GeographicObjects.assoc2 | def assoc2(self, assets_by_site, assoc_dist, mode, asset_refs):
"""
Associated a list of assets by site to the site collection used
to instantiate GeographicObjects.
:param assets_by_sites: a list of lists of assets
:param assoc_dist: the maximum distance for association
... | python | def assoc2(self, assets_by_site, assoc_dist, mode, asset_refs):
"""
Associated a list of assets by site to the site collection used
to instantiate GeographicObjects.
:param assets_by_sites: a list of lists of assets
:param assoc_dist: the maximum distance for association
... | [
"def",
"assoc2",
"(",
"self",
",",
"assets_by_site",
",",
"assoc_dist",
",",
"mode",
",",
"asset_refs",
")",
":",
"assert",
"mode",
"in",
"'strict filter'",
",",
"mode",
"self",
".",
"objects",
".",
"filtered",
"asset_dt",
"=",
"numpy",
".",
"dtype",
"(",
... | Associated a list of assets by site to the site collection used
to instantiate GeographicObjects.
:param assets_by_sites: a list of lists of assets
:param assoc_dist: the maximum distance for association
:param mode: 'strict', 'warn' or 'filter'
:param asset_ref: ID of the asset... | [
"Associated",
"a",
"list",
"of",
"assets",
"by",
"site",
"to",
"the",
"site",
"collection",
"used",
"to",
"instantiate",
"GeographicObjects",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L134-L174 | train |
gem/oq-engine | openquake/risklib/read_nrml.py | ffconvert | def ffconvert(fname, limit_states, ff, min_iml=1E-10):
"""
Convert a fragility function into a numpy array plus a bunch
of attributes.
:param fname: path to the fragility model file
:param limit_states: expected limit states
:param ff: fragility function node
:returns: a pair (array, dictio... | python | def ffconvert(fname, limit_states, ff, min_iml=1E-10):
"""
Convert a fragility function into a numpy array plus a bunch
of attributes.
:param fname: path to the fragility model file
:param limit_states: expected limit states
:param ff: fragility function node
:returns: a pair (array, dictio... | [
"def",
"ffconvert",
"(",
"fname",
",",
"limit_states",
",",
"ff",
",",
"min_iml",
"=",
"1E-10",
")",
":",
"with",
"context",
"(",
"fname",
",",
"ff",
")",
":",
"ffs",
"=",
"ff",
"[",
"1",
":",
"]",
"imls",
"=",
"ff",
".",
"imls",
"nodamage",
"=",... | Convert a fragility function into a numpy array plus a bunch
of attributes.
:param fname: path to the fragility model file
:param limit_states: expected limit states
:param ff: fragility function node
:returns: a pair (array, dictionary) | [
"Convert",
"a",
"fragility",
"function",
"into",
"a",
"numpy",
"array",
"plus",
"a",
"bunch",
"of",
"attributes",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/read_nrml.py#L152-L217 | train |
gem/oq-engine | openquake/risklib/read_nrml.py | taxonomy | def taxonomy(value):
"""
Any ASCII character goes into a taxonomy, except spaces.
"""
try:
value.encode('ascii')
except UnicodeEncodeError:
raise ValueError('tag %r is not ASCII' % value)
if re.search(r'\s', value):
raise ValueError('The taxonomy %r contains whitespace ch... | python | def taxonomy(value):
"""
Any ASCII character goes into a taxonomy, except spaces.
"""
try:
value.encode('ascii')
except UnicodeEncodeError:
raise ValueError('tag %r is not ASCII' % value)
if re.search(r'\s', value):
raise ValueError('The taxonomy %r contains whitespace ch... | [
"def",
"taxonomy",
"(",
"value",
")",
":",
"try",
":",
"value",
".",
"encode",
"(",
"'ascii'",
")",
"except",
"UnicodeEncodeError",
":",
"raise",
"ValueError",
"(",
"'tag %r is not ASCII'",
"%",
"value",
")",
"if",
"re",
".",
"search",
"(",
"r'\\s'",
",",
... | Any ASCII character goes into a taxonomy, except spaces. | [
"Any",
"ASCII",
"character",
"goes",
"into",
"a",
"taxonomy",
"except",
"spaces",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/read_nrml.py#L371-L381 | train |
gem/oq-engine | openquake/risklib/read_nrml.py | update_validators | def update_validators():
"""
Call this to updade the global nrml.validators
"""
validators.update({
'fragilityFunction.id': valid.utf8, # taxonomy
'vulnerabilityFunction.id': valid.utf8, # taxonomy
'consequenceFunction.id': valid.utf8, # taxonomy
'asset.id': valid.asse... | python | def update_validators():
"""
Call this to updade the global nrml.validators
"""
validators.update({
'fragilityFunction.id': valid.utf8, # taxonomy
'vulnerabilityFunction.id': valid.utf8, # taxonomy
'consequenceFunction.id': valid.utf8, # taxonomy
'asset.id': valid.asse... | [
"def",
"update_validators",
"(",
")",
":",
"validators",
".",
"update",
"(",
"{",
"'fragilityFunction.id'",
":",
"valid",
".",
"utf8",
",",
"'vulnerabilityFunction.id'",
":",
"valid",
".",
"utf8",
",",
"'consequenceFunction.id'",
":",
"valid",
".",
"utf8",
",",
... | Call this to updade the global nrml.validators | [
"Call",
"this",
"to",
"updade",
"the",
"global",
"nrml",
".",
"validators"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/read_nrml.py#L384-L437 | train |
gem/oq-engine | openquake/calculators/extract.py | barray | def barray(iterlines):
"""
Array of bytes
"""
lst = [line.encode('utf-8') for line in iterlines]
arr = numpy.array(lst)
return arr | python | def barray(iterlines):
"""
Array of bytes
"""
lst = [line.encode('utf-8') for line in iterlines]
arr = numpy.array(lst)
return arr | [
"def",
"barray",
"(",
"iterlines",
")",
":",
"lst",
"=",
"[",
"line",
".",
"encode",
"(",
"'utf-8'",
")",
"for",
"line",
"in",
"iterlines",
"]",
"arr",
"=",
"numpy",
".",
"array",
"(",
"lst",
")",
"return",
"arr"
] | Array of bytes | [
"Array",
"of",
"bytes"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/extract.py#L130-L136 | train |
gem/oq-engine | openquake/calculators/extract.py | losses_by_tag | def losses_by_tag(dstore, tag):
"""
Statistical average losses by tag. For instance call
$ oq extract losses_by_tag/occupancy
"""
dt = [(tag, vstr)] + dstore['oqparam'].loss_dt_list()
aids = dstore['assetcol/array'][tag]
dset, stats = _get(dstore, 'avg_losses')
arr = dset.value
tagv... | python | def losses_by_tag(dstore, tag):
"""
Statistical average losses by tag. For instance call
$ oq extract losses_by_tag/occupancy
"""
dt = [(tag, vstr)] + dstore['oqparam'].loss_dt_list()
aids = dstore['assetcol/array'][tag]
dset, stats = _get(dstore, 'avg_losses')
arr = dset.value
tagv... | [
"def",
"losses_by_tag",
"(",
"dstore",
",",
"tag",
")",
":",
"dt",
"=",
"[",
"(",
"tag",
",",
"vstr",
")",
"]",
"+",
"dstore",
"[",
"'oqparam'",
"]",
".",
"loss_dt_list",
"(",
")",
"aids",
"=",
"dstore",
"[",
"'assetcol/array'",
"]",
"[",
"tag",
"]... | Statistical average losses by tag. For instance call
$ oq extract losses_by_tag/occupancy | [
"Statistical",
"average",
"losses",
"by",
"tag",
".",
"For",
"instance",
"call"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/extract.py#L808-L827 | train |
gem/oq-engine | openquake/calculators/extract.py | WebExtractor.dump | def dump(self, fname):
"""
Dump the remote datastore on a local path.
"""
url = '%s/v1/calc/%d/datastore' % (self.server, self.calc_id)
resp = self.sess.get(url, stream=True)
down = 0
with open(fname, 'wb') as f:
logging.info('Saving %s', fname)
... | python | def dump(self, fname):
"""
Dump the remote datastore on a local path.
"""
url = '%s/v1/calc/%d/datastore' % (self.server, self.calc_id)
resp = self.sess.get(url, stream=True)
down = 0
with open(fname, 'wb') as f:
logging.info('Saving %s', fname)
... | [
"def",
"dump",
"(",
"self",
",",
"fname",
")",
":",
"url",
"=",
"'%s/v1/calc/%d/datastore'",
"%",
"(",
"self",
".",
"server",
",",
"self",
".",
"calc_id",
")",
"resp",
"=",
"self",
".",
"sess",
".",
"get",
"(",
"url",
",",
"stream",
"=",
"True",
")... | Dump the remote datastore on a local path. | [
"Dump",
"the",
"remote",
"datastore",
"on",
"a",
"local",
"path",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/extract.py#L988-L1001 | train |
gem/oq-engine | openquake/hazardlib/gsim/utils_swiss_gmpe.py | _compute_small_mag_correction_term | def _compute_small_mag_correction_term(C, mag, rhypo):
"""
small magnitude correction applied to the median values
"""
if mag >= 3.00 and mag < 5.5:
min_term = np.minimum(rhypo, C['Rm'])
max_term = np.maximum(min_term, 10)
term_ln = np.log(max_term / 20)
term_ratio = ((5.... | python | def _compute_small_mag_correction_term(C, mag, rhypo):
"""
small magnitude correction applied to the median values
"""
if mag >= 3.00 and mag < 5.5:
min_term = np.minimum(rhypo, C['Rm'])
max_term = np.maximum(min_term, 10)
term_ln = np.log(max_term / 20)
term_ratio = ((5.... | [
"def",
"_compute_small_mag_correction_term",
"(",
"C",
",",
"mag",
",",
"rhypo",
")",
":",
"if",
"mag",
">=",
"3.00",
"and",
"mag",
"<",
"5.5",
":",
"min_term",
"=",
"np",
".",
"minimum",
"(",
"rhypo",
",",
"C",
"[",
"'Rm'",
"]",
")",
"max_term",
"="... | small magnitude correction applied to the median values | [
"small",
"magnitude",
"correction",
"applied",
"to",
"the",
"median",
"values"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/utils_swiss_gmpe.py#L40-L52 | train |
gem/oq-engine | openquake/hazardlib/gsim/utils_swiss_gmpe.py | _apply_adjustments | def _apply_adjustments(COEFFS, C_ADJ, tau_ss, mean, stddevs, sites, rup, dists,
imt, stddev_types, log_phi_ss, NL=None, tau_value=None):
"""
This method applies adjustments to the mean and standard deviation.
The small-magnitude adjustments are applied to mean, whereas the
embeded... | python | def _apply_adjustments(COEFFS, C_ADJ, tau_ss, mean, stddevs, sites, rup, dists,
imt, stddev_types, log_phi_ss, NL=None, tau_value=None):
"""
This method applies adjustments to the mean and standard deviation.
The small-magnitude adjustments are applied to mean, whereas the
embeded... | [
"def",
"_apply_adjustments",
"(",
"COEFFS",
",",
"C_ADJ",
",",
"tau_ss",
",",
"mean",
",",
"stddevs",
",",
"sites",
",",
"rup",
",",
"dists",
",",
"imt",
",",
"stddev_types",
",",
"log_phi_ss",
",",
"NL",
"=",
"None",
",",
"tau_value",
"=",
"None",
")"... | This method applies adjustments to the mean and standard deviation.
The small-magnitude adjustments are applied to mean, whereas the
embeded single station sigma logic tree is applied to the
total standard deviation. | [
"This",
"method",
"applies",
"adjustments",
"to",
"the",
"mean",
"and",
"standard",
"deviation",
".",
"The",
"small",
"-",
"magnitude",
"adjustments",
"are",
"applied",
"to",
"mean",
"whereas",
"the",
"embeded",
"single",
"station",
"sigma",
"logic",
"tree",
"... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/utils_swiss_gmpe.py#L102-L125 | train |
gem/oq-engine | openquake/commonlib/source.py | CompositionInfo.get_info | def get_info(self, sm_id):
"""
Extract a CompositionInfo instance containing the single
model of index `sm_id`.
"""
sm = self.source_models[sm_id]
num_samples = sm.samples if self.num_samples else 0
return self.__class__(
self.gsim_lt, self.seed, num_s... | python | def get_info(self, sm_id):
"""
Extract a CompositionInfo instance containing the single
model of index `sm_id`.
"""
sm = self.source_models[sm_id]
num_samples = sm.samples if self.num_samples else 0
return self.__class__(
self.gsim_lt, self.seed, num_s... | [
"def",
"get_info",
"(",
"self",
",",
"sm_id",
")",
":",
"sm",
"=",
"self",
".",
"source_models",
"[",
"sm_id",
"]",
"num_samples",
"=",
"sm",
".",
"samples",
"if",
"self",
".",
"num_samples",
"else",
"0",
"return",
"self",
".",
"__class__",
"(",
"self"... | Extract a CompositionInfo instance containing the single
model of index `sm_id`. | [
"Extract",
"a",
"CompositionInfo",
"instance",
"containing",
"the",
"single",
"model",
"of",
"index",
"sm_id",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/source.py#L142-L150 | train |
gem/oq-engine | openquake/commonlib/source.py | CompositionInfo.get_source_model | def get_source_model(self, src_group_id):
"""
Return the source model for the given src_group_id
"""
for smodel in self.source_models:
for src_group in smodel.src_groups:
if src_group.id == src_group_id:
return smodel | python | def get_source_model(self, src_group_id):
"""
Return the source model for the given src_group_id
"""
for smodel in self.source_models:
for src_group in smodel.src_groups:
if src_group.id == src_group_id:
return smodel | [
"def",
"get_source_model",
"(",
"self",
",",
"src_group_id",
")",
":",
"for",
"smodel",
"in",
"self",
".",
"source_models",
":",
"for",
"src_group",
"in",
"smodel",
".",
"src_groups",
":",
"if",
"src_group",
".",
"id",
"==",
"src_group_id",
":",
"return",
... | Return the source model for the given src_group_id | [
"Return",
"the",
"source",
"model",
"for",
"the",
"given",
"src_group_id"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/source.py#L275-L282 | train |
gem/oq-engine | openquake/commonlib/source.py | CompositeSourceModel.get_model | def get_model(self, sm_id):
"""
Extract a CompositeSourceModel instance containing the single
model of index `sm_id`.
"""
sm = self.source_models[sm_id]
if self.source_model_lt.num_samples:
self.source_model_lt.num_samples = sm.samples
new = self.__cla... | python | def get_model(self, sm_id):
"""
Extract a CompositeSourceModel instance containing the single
model of index `sm_id`.
"""
sm = self.source_models[sm_id]
if self.source_model_lt.num_samples:
self.source_model_lt.num_samples = sm.samples
new = self.__cla... | [
"def",
"get_model",
"(",
"self",
",",
"sm_id",
")",
":",
"sm",
"=",
"self",
".",
"source_models",
"[",
"sm_id",
"]",
"if",
"self",
".",
"source_model_lt",
".",
"num_samples",
":",
"self",
".",
"source_model_lt",
".",
"num_samples",
"=",
"sm",
".",
"sampl... | Extract a CompositeSourceModel instance containing the single
model of index `sm_id`. | [
"Extract",
"a",
"CompositeSourceModel",
"instance",
"containing",
"the",
"single",
"model",
"of",
"index",
"sm_id",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/source.py#L381-L392 | train |
gem/oq-engine | openquake/commonlib/source.py | CompositeSourceModel.new | def new(self, sources_by_grp):
"""
Generate a new CompositeSourceModel from the given dictionary.
:param sources_by_group: a dictionary grp_id -> sources
:returns: a new CompositeSourceModel instance
"""
source_models = []
for sm in self.source_models:
... | python | def new(self, sources_by_grp):
"""
Generate a new CompositeSourceModel from the given dictionary.
:param sources_by_group: a dictionary grp_id -> sources
:returns: a new CompositeSourceModel instance
"""
source_models = []
for sm in self.source_models:
... | [
"def",
"new",
"(",
"self",
",",
"sources_by_grp",
")",
":",
"source_models",
"=",
"[",
"]",
"for",
"sm",
"in",
"self",
".",
"source_models",
":",
"src_groups",
"=",
"[",
"]",
"for",
"src_group",
"in",
"sm",
".",
"src_groups",
":",
"sg",
"=",
"copy",
... | Generate a new CompositeSourceModel from the given dictionary.
:param sources_by_group: a dictionary grp_id -> sources
:returns: a new CompositeSourceModel instance | [
"Generate",
"a",
"new",
"CompositeSourceModel",
"from",
"the",
"given",
"dictionary",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/source.py#L394-L417 | train |
gem/oq-engine | openquake/commonlib/source.py | CompositeSourceModel.check_dupl_sources | def check_dupl_sources(self): # used in print_csm_info
"""
Extracts duplicated sources, i.e. sources with the same source_id in
different source groups. Raise an exception if there are sources with
the same ID which are not duplicated.
:returns: a list of list of sources, order... | python | def check_dupl_sources(self): # used in print_csm_info
"""
Extracts duplicated sources, i.e. sources with the same source_id in
different source groups. Raise an exception if there are sources with
the same ID which are not duplicated.
:returns: a list of list of sources, order... | [
"def",
"check_dupl_sources",
"(",
"self",
")",
":",
"dd",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"for",
"src_group",
"in",
"self",
".",
"src_groups",
":",
"for",
"src",
"in",
"src_group",
":",
"try",
":",
"srcid",
"=",
"src",
".",
"s... | Extracts duplicated sources, i.e. sources with the same source_id in
different source groups. Raise an exception if there are sources with
the same ID which are not duplicated.
:returns: a list of list of sources, ordered by source_id | [
"Extracts",
"duplicated",
"sources",
"i",
".",
"e",
".",
"sources",
"with",
"the",
"same",
"source_id",
"in",
"different",
"source",
"groups",
".",
"Raise",
"an",
"exception",
"if",
"there",
"are",
"sources",
"with",
"the",
"same",
"ID",
"which",
"are",
"n... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/source.py#L443-L464 | train |
gem/oq-engine | openquake/commonlib/source.py | CompositeSourceModel.get_sources | def get_sources(self, kind='all'):
"""
Extract the sources contained in the source models by optionally
filtering and splitting them, depending on the passed parameter.
"""
assert kind in ('all', 'indep', 'mutex'), kind
sources = []
for sm in self.source_models:
... | python | def get_sources(self, kind='all'):
"""
Extract the sources contained in the source models by optionally
filtering and splitting them, depending on the passed parameter.
"""
assert kind in ('all', 'indep', 'mutex'), kind
sources = []
for sm in self.source_models:
... | [
"def",
"get_sources",
"(",
"self",
",",
"kind",
"=",
"'all'",
")",
":",
"assert",
"kind",
"in",
"(",
"'all'",
",",
"'indep'",
",",
"'mutex'",
")",
",",
"kind",
"sources",
"=",
"[",
"]",
"for",
"sm",
"in",
"self",
".",
"source_models",
":",
"for",
"... | Extract the sources contained in the source models by optionally
filtering and splitting them, depending on the passed parameter. | [
"Extract",
"the",
"sources",
"contained",
"in",
"the",
"source",
"models",
"by",
"optionally",
"filtering",
"and",
"splitting",
"them",
"depending",
"on",
"the",
"passed",
"parameter",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/source.py#L466-L480 | train |
gem/oq-engine | openquake/commonlib/source.py | CompositeSourceModel.init_serials | def init_serials(self, ses_seed):
"""
Generate unique seeds for each rupture with numpy.arange.
This should be called only in event based calculators
"""
sources = self.get_sources()
serial = ses_seed
for src in sources:
nr = src.num_ruptures
... | python | def init_serials(self, ses_seed):
"""
Generate unique seeds for each rupture with numpy.arange.
This should be called only in event based calculators
"""
sources = self.get_sources()
serial = ses_seed
for src in sources:
nr = src.num_ruptures
... | [
"def",
"init_serials",
"(",
"self",
",",
"ses_seed",
")",
":",
"sources",
"=",
"self",
".",
"get_sources",
"(",
")",
"serial",
"=",
"ses_seed",
"for",
"src",
"in",
"sources",
":",
"nr",
"=",
"src",
".",
"num_ruptures",
"src",
".",
"serial",
"=",
"seria... | Generate unique seeds for each rupture with numpy.arange.
This should be called only in event based calculators | [
"Generate",
"unique",
"seeds",
"for",
"each",
"rupture",
"with",
"numpy",
".",
"arange",
".",
"This",
"should",
"be",
"called",
"only",
"in",
"event",
"based",
"calculators"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/source.py#L525-L535 | train |
gem/oq-engine | openquake/commonlib/source.py | CompositeSourceModel.get_maxweight | def get_maxweight(self, weight, concurrent_tasks, minweight=MINWEIGHT):
"""
Return an appropriate maxweight for use in the block_splitter
"""
totweight = self.get_weight(weight)
ct = concurrent_tasks or 1
mw = math.ceil(totweight / ct)
return max(mw, minweight) | python | def get_maxweight(self, weight, concurrent_tasks, minweight=MINWEIGHT):
"""
Return an appropriate maxweight for use in the block_splitter
"""
totweight = self.get_weight(weight)
ct = concurrent_tasks or 1
mw = math.ceil(totweight / ct)
return max(mw, minweight) | [
"def",
"get_maxweight",
"(",
"self",
",",
"weight",
",",
"concurrent_tasks",
",",
"minweight",
"=",
"MINWEIGHT",
")",
":",
"totweight",
"=",
"self",
".",
"get_weight",
"(",
"weight",
")",
"ct",
"=",
"concurrent_tasks",
"or",
"1",
"mw",
"=",
"math",
".",
... | Return an appropriate maxweight for use in the block_splitter | [
"Return",
"an",
"appropriate",
"maxweight",
"for",
"use",
"in",
"the",
"block_splitter"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/source.py#L537-L544 | train |
gem/oq-engine | openquake/hmtk/parsers/faults/fault_yaml_parser.py | weight_list_to_tuple | def weight_list_to_tuple(data, attr_name):
'''
Converts a list of values and corresponding weights to a tuple of values
'''
if len(data['Value']) != len(data['Weight']):
raise ValueError('Number of weights do not correspond to number of '
'attributes in %s' % attr_name)... | python | def weight_list_to_tuple(data, attr_name):
'''
Converts a list of values and corresponding weights to a tuple of values
'''
if len(data['Value']) != len(data['Weight']):
raise ValueError('Number of weights do not correspond to number of '
'attributes in %s' % attr_name)... | [
"def",
"weight_list_to_tuple",
"(",
"data",
",",
"attr_name",
")",
":",
"if",
"len",
"(",
"data",
"[",
"'Value'",
"]",
")",
"!=",
"len",
"(",
"data",
"[",
"'Weight'",
"]",
")",
":",
"raise",
"ValueError",
"(",
"'Number of weights do not correspond to number of... | Converts a list of values and corresponding weights to a tuple of values | [
"Converts",
"a",
"list",
"of",
"values",
"and",
"corresponding",
"weights",
"to",
"a",
"tuple",
"of",
"values"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/faults/fault_yaml_parser.py#L71-L86 | train |
gem/oq-engine | openquake/hmtk/parsers/faults/fault_yaml_parser.py | parse_tect_region_dict_to_tuples | def parse_tect_region_dict_to_tuples(region_dict):
'''
Parses the tectonic regionalisation dictionary attributes to tuples
'''
output_region_dict = []
tuple_keys = ['Displacement_Length_Ratio', 'Shear_Modulus']
# Convert MSR string name to openquake.hazardlib.scalerel object
for region in re... | python | def parse_tect_region_dict_to_tuples(region_dict):
'''
Parses the tectonic regionalisation dictionary attributes to tuples
'''
output_region_dict = []
tuple_keys = ['Displacement_Length_Ratio', 'Shear_Modulus']
# Convert MSR string name to openquake.hazardlib.scalerel object
for region in re... | [
"def",
"parse_tect_region_dict_to_tuples",
"(",
"region_dict",
")",
":",
"output_region_dict",
"=",
"[",
"]",
"tuple_keys",
"=",
"[",
"'Displacement_Length_Ratio'",
",",
"'Shear_Modulus'",
"]",
"for",
"region",
"in",
"region_dict",
":",
"for",
"val_name",
"in",
"tup... | Parses the tectonic regionalisation dictionary attributes to tuples | [
"Parses",
"the",
"tectonic",
"regionalisation",
"dictionary",
"attributes",
"to",
"tuples"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/faults/fault_yaml_parser.py#L89-L105 | train |
gem/oq-engine | openquake/hmtk/parsers/faults/fault_yaml_parser.py | get_scaling_relation_tuple | def get_scaling_relation_tuple(msr_dict):
'''
For a dictionary of scaling relation values convert string list to
object list and then to tuple
'''
# Convert MSR string name to openquake.hazardlib.scalerel object
for iloc, value in enumerate(msr_dict['Value']):
if not value in SCALE_REL_... | python | def get_scaling_relation_tuple(msr_dict):
'''
For a dictionary of scaling relation values convert string list to
object list and then to tuple
'''
# Convert MSR string name to openquake.hazardlib.scalerel object
for iloc, value in enumerate(msr_dict['Value']):
if not value in SCALE_REL_... | [
"def",
"get_scaling_relation_tuple",
"(",
"msr_dict",
")",
":",
"for",
"iloc",
",",
"value",
"in",
"enumerate",
"(",
"msr_dict",
"[",
"'Value'",
"]",
")",
":",
"if",
"not",
"value",
"in",
"SCALE_REL_MAP",
".",
"keys",
"(",
")",
":",
"raise",
"ValueError",
... | For a dictionary of scaling relation values convert string list to
object list and then to tuple | [
"For",
"a",
"dictionary",
"of",
"scaling",
"relation",
"values",
"convert",
"string",
"list",
"to",
"object",
"list",
"and",
"then",
"to",
"tuple"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/faults/fault_yaml_parser.py#L108-L120 | train |
gem/oq-engine | openquake/hmtk/parsers/faults/fault_yaml_parser.py | FaultYmltoSource.read_file | def read_file(self, mesh_spacing=1.0):
'''
Reads the file and returns an instance of the FaultSource class.
:param float mesh_spacing:
Fault mesh spacing (km)
'''
# Process the tectonic regionalisation
tectonic_reg = self.process_tectonic_regionalisation()
... | python | def read_file(self, mesh_spacing=1.0):
'''
Reads the file and returns an instance of the FaultSource class.
:param float mesh_spacing:
Fault mesh spacing (km)
'''
# Process the tectonic regionalisation
tectonic_reg = self.process_tectonic_regionalisation()
... | [
"def",
"read_file",
"(",
"self",
",",
"mesh_spacing",
"=",
"1.0",
")",
":",
"tectonic_reg",
"=",
"self",
".",
"process_tectonic_regionalisation",
"(",
")",
"model",
"=",
"mtkActiveFaultModel",
"(",
"self",
".",
"data",
"[",
"'Fault_Model_ID'",
"]",
",",
"self"... | Reads the file and returns an instance of the FaultSource class.
:param float mesh_spacing:
Fault mesh spacing (km) | [
"Reads",
"the",
"file",
"and",
"returns",
"an",
"instance",
"of",
"the",
"FaultSource",
"class",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/faults/fault_yaml_parser.py#L138-L189 | train |
gem/oq-engine | openquake/hmtk/parsers/faults/fault_yaml_parser.py | FaultYmltoSource.process_tectonic_regionalisation | def process_tectonic_regionalisation(self):
'''
Processes the tectonic regionalisation from the yaml file
'''
if 'tectonic_regionalisation' in self.data.keys():
tectonic_reg = TectonicRegionalisation()
tectonic_reg.populate_regions(
parse_tect_reg... | python | def process_tectonic_regionalisation(self):
'''
Processes the tectonic regionalisation from the yaml file
'''
if 'tectonic_regionalisation' in self.data.keys():
tectonic_reg = TectonicRegionalisation()
tectonic_reg.populate_regions(
parse_tect_reg... | [
"def",
"process_tectonic_regionalisation",
"(",
"self",
")",
":",
"if",
"'tectonic_regionalisation'",
"in",
"self",
".",
"data",
".",
"keys",
"(",
")",
":",
"tectonic_reg",
"=",
"TectonicRegionalisation",
"(",
")",
"tectonic_reg",
".",
"populate_regions",
"(",
"pa... | Processes the tectonic regionalisation from the yaml file | [
"Processes",
"the",
"tectonic",
"regionalisation",
"from",
"the",
"yaml",
"file"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/faults/fault_yaml_parser.py#L191-L203 | train |
gem/oq-engine | openquake/hmtk/parsers/faults/fault_yaml_parser.py | FaultYmltoSource.read_fault_geometry | def read_fault_geometry(self, geo_dict, mesh_spacing=1.0):
'''
Creates the fault geometry from the parameters specified in the
dictionary.
:param dict geo_dict:
Sub-dictionary of main fault dictionary containing only
the geometry attributes
:param float m... | python | def read_fault_geometry(self, geo_dict, mesh_spacing=1.0):
'''
Creates the fault geometry from the parameters specified in the
dictionary.
:param dict geo_dict:
Sub-dictionary of main fault dictionary containing only
the geometry attributes
:param float m... | [
"def",
"read_fault_geometry",
"(",
"self",
",",
"geo_dict",
",",
"mesh_spacing",
"=",
"1.0",
")",
":",
"if",
"geo_dict",
"[",
"'Fault_Typology'",
"]",
"==",
"'Simple'",
":",
"raw_trace",
"=",
"geo_dict",
"[",
"'Fault_Trace'",
"]",
"trace",
"=",
"Line",
"(",
... | Creates the fault geometry from the parameters specified in the
dictionary.
:param dict geo_dict:
Sub-dictionary of main fault dictionary containing only
the geometry attributes
:param float mesh_spacing:
Fault mesh spacing (km)
:returns:
... | [
"Creates",
"the",
"fault",
"geometry",
"from",
"the",
"parameters",
"specified",
"in",
"the",
"dictionary",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/faults/fault_yaml_parser.py#L205-L242 | train |
gem/oq-engine | openquake/hazardlib/gsim/cauzzi_2014.py | CauzziEtAl2014._get_distance_scaling_term | def _get_distance_scaling_term(self, C, mag, rrup):
"""
Returns the distance scaling parameter
"""
return (C["r1"] + C["r2"] * mag) * np.log10(rrup + C["r3"]) | python | def _get_distance_scaling_term(self, C, mag, rrup):
"""
Returns the distance scaling parameter
"""
return (C["r1"] + C["r2"] * mag) * np.log10(rrup + C["r3"]) | [
"def",
"_get_distance_scaling_term",
"(",
"self",
",",
"C",
",",
"mag",
",",
"rrup",
")",
":",
"return",
"(",
"C",
"[",
"\"r1\"",
"]",
"+",
"C",
"[",
"\"r2\"",
"]",
"*",
"mag",
")",
"*",
"np",
".",
"log10",
"(",
"rrup",
"+",
"C",
"[",
"\"r3\"",
... | Returns the distance scaling parameter | [
"Returns",
"the",
"distance",
"scaling",
"parameter"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/cauzzi_2014.py#L132-L136 | train |
gem/oq-engine | openquake/hazardlib/gsim/cauzzi_2014.py | CauzziEtAl2014._get_style_of_faulting_term | def _get_style_of_faulting_term(self, C, rake):
"""
Returns the style of faulting term. Cauzzi et al. determind SOF from
the plunge of the B-, T- and P-axes. For consistency with existing
GMPEs the Wells & Coppersmith model is preferred
"""
if rake > -150.0 and rake <= -3... | python | def _get_style_of_faulting_term(self, C, rake):
"""
Returns the style of faulting term. Cauzzi et al. determind SOF from
the plunge of the B-, T- and P-axes. For consistency with existing
GMPEs the Wells & Coppersmith model is preferred
"""
if rake > -150.0 and rake <= -3... | [
"def",
"_get_style_of_faulting_term",
"(",
"self",
",",
"C",
",",
"rake",
")",
":",
"if",
"rake",
">",
"-",
"150.0",
"and",
"rake",
"<=",
"-",
"30.0",
":",
"return",
"C",
"[",
"'fN'",
"]",
"elif",
"rake",
">",
"30.0",
"and",
"rake",
"<=",
"150.0",
... | Returns the style of faulting term. Cauzzi et al. determind SOF from
the plunge of the B-, T- and P-axes. For consistency with existing
GMPEs the Wells & Coppersmith model is preferred | [
"Returns",
"the",
"style",
"of",
"faulting",
"term",
".",
"Cauzzi",
"et",
"al",
".",
"determind",
"SOF",
"from",
"the",
"plunge",
"of",
"the",
"B",
"-",
"T",
"-",
"and",
"P",
"-",
"axes",
".",
"For",
"consistency",
"with",
"existing",
"GMPEs",
"the",
... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/cauzzi_2014.py#L138-L149 | train |
gem/oq-engine | openquake/hazardlib/gsim/cauzzi_2014.py | CauzziEtAl2014Eurocode8._get_site_amplification_term | def _get_site_amplification_term(self, C, vs30):
"""
Returns the site amplification term on the basis of Eurocode 8
site class
"""
s_b, s_c, s_d = self._get_site_dummy_variables(vs30)
return (C["sB"] * s_b) + (C["sC"] * s_c) + (C["sD"] * s_d) | python | def _get_site_amplification_term(self, C, vs30):
"""
Returns the site amplification term on the basis of Eurocode 8
site class
"""
s_b, s_c, s_d = self._get_site_dummy_variables(vs30)
return (C["sB"] * s_b) + (C["sC"] * s_c) + (C["sD"] * s_d) | [
"def",
"_get_site_amplification_term",
"(",
"self",
",",
"C",
",",
"vs30",
")",
":",
"s_b",
",",
"s_c",
",",
"s_d",
"=",
"self",
".",
"_get_site_dummy_variables",
"(",
"vs30",
")",
"return",
"(",
"C",
"[",
"\"sB\"",
"]",
"*",
"s_b",
")",
"+",
"(",
"C... | Returns the site amplification term on the basis of Eurocode 8
site class | [
"Returns",
"the",
"site",
"amplification",
"term",
"on",
"the",
"basis",
"of",
"Eurocode",
"8",
"site",
"class"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/cauzzi_2014.py#L471-L477 | train |
gem/oq-engine | openquake/hazardlib/gsim/cauzzi_2014.py | CauzziEtAl2014Eurocode8._get_site_dummy_variables | def _get_site_dummy_variables(self, vs30):
"""
Returns the Eurocode 8 site class dummy variable
"""
s_b = np.zeros_like(vs30)
s_c = np.zeros_like(vs30)
s_d = np.zeros_like(vs30)
s_b[np.logical_and(vs30 >= 360., vs30 < 800.)] = 1.0
s_c[np.logical_and(vs30 >... | python | def _get_site_dummy_variables(self, vs30):
"""
Returns the Eurocode 8 site class dummy variable
"""
s_b = np.zeros_like(vs30)
s_c = np.zeros_like(vs30)
s_d = np.zeros_like(vs30)
s_b[np.logical_and(vs30 >= 360., vs30 < 800.)] = 1.0
s_c[np.logical_and(vs30 >... | [
"def",
"_get_site_dummy_variables",
"(",
"self",
",",
"vs30",
")",
":",
"s_b",
"=",
"np",
".",
"zeros_like",
"(",
"vs30",
")",
"s_c",
"=",
"np",
".",
"zeros_like",
"(",
"vs30",
")",
"s_d",
"=",
"np",
".",
"zeros_like",
"(",
"vs30",
")",
"s_b",
"[",
... | Returns the Eurocode 8 site class dummy variable | [
"Returns",
"the",
"Eurocode",
"8",
"site",
"class",
"dummy",
"variable"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/cauzzi_2014.py#L479-L489 | train |
gem/oq-engine | openquake/hmtk/faults/fault_models.py | RecurrenceBranch.get_recurrence | def get_recurrence(self, config):
'''
Calculates the recurrence model for the given settings as
an instance of the openquake.hmtk.models.IncrementalMFD
:param dict config:
Configuration settings of the magnitude frequency distribution.
'''
model = MFD_MAP[con... | python | def get_recurrence(self, config):
'''
Calculates the recurrence model for the given settings as
an instance of the openquake.hmtk.models.IncrementalMFD
:param dict config:
Configuration settings of the magnitude frequency distribution.
'''
model = MFD_MAP[con... | [
"def",
"get_recurrence",
"(",
"self",
",",
"config",
")",
":",
"model",
"=",
"MFD_MAP",
"[",
"config",
"[",
"'Model_Name'",
"]",
"]",
"(",
")",
"model",
".",
"setUp",
"(",
"config",
")",
"model",
".",
"get_mmax",
"(",
"config",
",",
"self",
".",
"msr... | Calculates the recurrence model for the given settings as
an instance of the openquake.hmtk.models.IncrementalMFD
:param dict config:
Configuration settings of the magnitude frequency distribution. | [
"Calculates",
"the",
"recurrence",
"model",
"for",
"the",
"given",
"settings",
"as",
"an",
"instance",
"of",
"the",
"openquake",
".",
"hmtk",
".",
"models",
".",
"IncrementalMFD"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/fault_models.py#L145-L177 | train |
gem/oq-engine | openquake/hmtk/faults/fault_models.py | mtkActiveFault.get_tectonic_regionalisation | def get_tectonic_regionalisation(self, regionalisation, region_type=None):
'''
Defines the tectonic region and updates the shear modulus,
magnitude scaling relation and displacement to length ratio using
the regional values, if not previously defined for the fault
:param regiona... | python | def get_tectonic_regionalisation(self, regionalisation, region_type=None):
'''
Defines the tectonic region and updates the shear modulus,
magnitude scaling relation and displacement to length ratio using
the regional values, if not previously defined for the fault
:param regiona... | [
"def",
"get_tectonic_regionalisation",
"(",
"self",
",",
"regionalisation",
",",
"region_type",
"=",
"None",
")",
":",
"if",
"region_type",
":",
"self",
".",
"trt",
"=",
"region_type",
"if",
"not",
"self",
".",
"trt",
"in",
"regionalisation",
".",
"key_list",
... | Defines the tectonic region and updates the shear modulus,
magnitude scaling relation and displacement to length ratio using
the regional values, if not previously defined for the fault
:param regionalistion:
Instance of the :class:
openquake.hmtk.faults.tectonic_regiona... | [
"Defines",
"the",
"tectonic",
"region",
"and",
"updates",
"the",
"shear",
"modulus",
"magnitude",
"scaling",
"relation",
"and",
"displacement",
"to",
"length",
"ratio",
"using",
"the",
"regional",
"values",
"if",
"not",
"previously",
"defined",
"for",
"the",
"fa... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/fault_models.py#L265-L301 | train |
gem/oq-engine | openquake/hmtk/faults/fault_models.py | mtkActiveFault.select_catalogue | def select_catalogue(self, selector, distance, distance_metric="rupture",
upper_eq_depth=None, lower_eq_depth=None):
"""
Select earthquakes within a specied distance of the fault
"""
if selector.catalogue.get_number_events() < 1:
raise ValueError('No ... | python | def select_catalogue(self, selector, distance, distance_metric="rupture",
upper_eq_depth=None, lower_eq_depth=None):
"""
Select earthquakes within a specied distance of the fault
"""
if selector.catalogue.get_number_events() < 1:
raise ValueError('No ... | [
"def",
"select_catalogue",
"(",
"self",
",",
"selector",
",",
"distance",
",",
"distance_metric",
"=",
"\"rupture\"",
",",
"upper_eq_depth",
"=",
"None",
",",
"lower_eq_depth",
"=",
"None",
")",
":",
"if",
"selector",
".",
"catalogue",
".",
"get_number_events",
... | Select earthquakes within a specied distance of the fault | [
"Select",
"earthquakes",
"within",
"a",
"specied",
"distance",
"of",
"the",
"fault"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/fault_models.py#L303-L325 | train |
gem/oq-engine | openquake/hmtk/faults/fault_models.py | mtkActiveFault.generate_config_set | def generate_config_set(self, config):
'''
Generates a list of magnitude frequency distributions and renders as
a tuple
:param dict/list config:
Configuration paramters of magnitude frequency distribution
'''
if isinstance(config, dict):
# Configu... | python | def generate_config_set(self, config):
'''
Generates a list of magnitude frequency distributions and renders as
a tuple
:param dict/list config:
Configuration paramters of magnitude frequency distribution
'''
if isinstance(config, dict):
# Configu... | [
"def",
"generate_config_set",
"(",
"self",
",",
"config",
")",
":",
"if",
"isinstance",
"(",
"config",
",",
"dict",
")",
":",
"self",
".",
"config",
"=",
"[",
"(",
"config",
",",
"1.0",
")",
"]",
"elif",
"isinstance",
"(",
"config",
",",
"list",
")",... | Generates a list of magnitude frequency distributions and renders as
a tuple
:param dict/list config:
Configuration paramters of magnitude frequency distribution | [
"Generates",
"a",
"list",
"of",
"magnitude",
"frequency",
"distributions",
"and",
"renders",
"as",
"a",
"tuple"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/fault_models.py#L365-L388 | train |
gem/oq-engine | openquake/hmtk/faults/fault_models.py | mtkActiveFault.collapse_branches | def collapse_branches(self, mmin, bin_width, mmax):
'''
Collapse the logic tree branches into a single IncrementalMFD
:param float mmin:
Minimum magnitude of reference mfd
:param float bin_width:
Bin width of reference mfd
:param float mmax:
M... | python | def collapse_branches(self, mmin, bin_width, mmax):
'''
Collapse the logic tree branches into a single IncrementalMFD
:param float mmin:
Minimum magnitude of reference mfd
:param float bin_width:
Bin width of reference mfd
:param float mmax:
M... | [
"def",
"collapse_branches",
"(",
"self",
",",
"mmin",
",",
"bin_width",
",",
"mmax",
")",
":",
"master_mags",
"=",
"np",
".",
"arange",
"(",
"mmin",
",",
"mmax",
"+",
"(",
"bin_width",
"/",
"2.",
")",
",",
"bin_width",
")",
"master_rates",
"=",
"np",
... | Collapse the logic tree branches into a single IncrementalMFD
:param float mmin:
Minimum magnitude of reference mfd
:param float bin_width:
Bin width of reference mfd
:param float mmax:
Maximum magnitude of reference mfd
:returns:
:class:... | [
"Collapse",
"the",
"logic",
"tree",
"branches",
"into",
"a",
"single",
"IncrementalMFD"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/fault_models.py#L479-L507 | train |
gem/oq-engine | openquake/hmtk/faults/fault_models.py | mtkActiveFault.generate_fault_source_model | def generate_fault_source_model(self):
'''
Creates a resulting `openquake.hmtk` fault source set.
:returns:
source_model - list of instances of either the :class:
`openquake.hmtk.sources.simple_fault_source.mtkSimpleFaultSource`
or :class:
`openqu... | python | def generate_fault_source_model(self):
'''
Creates a resulting `openquake.hmtk` fault source set.
:returns:
source_model - list of instances of either the :class:
`openquake.hmtk.sources.simple_fault_source.mtkSimpleFaultSource`
or :class:
`openqu... | [
"def",
"generate_fault_source_model",
"(",
"self",
")",
":",
"source_model",
"=",
"[",
"]",
"model_weight",
"=",
"[",
"]",
"for",
"iloc",
"in",
"range",
"(",
"0",
",",
"self",
".",
"get_number_mfd_models",
"(",
")",
")",
":",
"model_mfd",
"=",
"EvenlyDiscr... | Creates a resulting `openquake.hmtk` fault source set.
:returns:
source_model - list of instances of either the :class:
`openquake.hmtk.sources.simple_fault_source.mtkSimpleFaultSource`
or :class:
`openquake.hmtk.sources.complex_fault_source.mtkComplexFaultSource... | [
"Creates",
"a",
"resulting",
"openquake",
".",
"hmtk",
"fault",
"source",
"set",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/fault_models.py#L509-L557 | train |
gem/oq-engine | openquake/hmtk/models.py | SeismicSource.attrib | def attrib(self):
"""
General XML element attributes for a seismic source, as a dict.
"""
return dict([
('id', str(self.id)),
('name', str(self.name)),
('tectonicRegion', str(self.trt)),
]) | python | def attrib(self):
"""
General XML element attributes for a seismic source, as a dict.
"""
return dict([
('id', str(self.id)),
('name', str(self.name)),
('tectonicRegion', str(self.trt)),
]) | [
"def",
"attrib",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"[",
"(",
"'id'",
",",
"str",
"(",
"self",
".",
"id",
")",
")",
",",
"(",
"'name'",
",",
"str",
"(",
"self",
".",
"name",
")",
")",
",",
"(",
"'tectonicRegion'",
",",
"str",
"(",
... | General XML element attributes for a seismic source, as a dict. | [
"General",
"XML",
"element",
"attributes",
"for",
"a",
"seismic",
"source",
"as",
"a",
"dict",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/models.py#L53-L61 | train |
gem/oq-engine | openquake/hmtk/models.py | TGRMFD.attrib | def attrib(self):
"""
An dict of XML element attributes for this MFD.
"""
return dict([
('aValue', str(self.a_val)),
('bValue', str(self.b_val)),
('minMag', str(self.min_mag)),
('maxMag', str(self.max_mag)),
]) | python | def attrib(self):
"""
An dict of XML element attributes for this MFD.
"""
return dict([
('aValue', str(self.a_val)),
('bValue', str(self.b_val)),
('minMag', str(self.min_mag)),
('maxMag', str(self.max_mag)),
]) | [
"def",
"attrib",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"[",
"(",
"'aValue'",
",",
"str",
"(",
"self",
".",
"a_val",
")",
")",
",",
"(",
"'bValue'",
",",
"str",
"(",
"self",
".",
"b_val",
")",
")",
",",
"(",
"'minMag'",
",",
"str",
"(",
... | An dict of XML element attributes for this MFD. | [
"An",
"dict",
"of",
"XML",
"element",
"attributes",
"for",
"this",
"MFD",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/models.py#L325-L334 | train |
gem/oq-engine | openquake/hmtk/models.py | NodalPlane.attrib | def attrib(self):
"""
A dict of XML element attributes for this NodalPlane.
"""
return dict([
('probability', str(self.probability)),
('strike', str(self.strike)),
('dip', str(self.dip)),
('rake', str(self.rake)),
]) | python | def attrib(self):
"""
A dict of XML element attributes for this NodalPlane.
"""
return dict([
('probability', str(self.probability)),
('strike', str(self.strike)),
('dip', str(self.dip)),
('rake', str(self.rake)),
]) | [
"def",
"attrib",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"[",
"(",
"'probability'",
",",
"str",
"(",
"self",
".",
"probability",
")",
")",
",",
"(",
"'strike'",
",",
"str",
"(",
"self",
".",
"strike",
")",
")",
",",
"(",
"'dip'",
",",
"str"... | A dict of XML element attributes for this NodalPlane. | [
"A",
"dict",
"of",
"XML",
"element",
"attributes",
"for",
"this",
"NodalPlane",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/models.py#L359-L368 | train |
gem/oq-engine | openquake/hazardlib/correlation.py | jbcorrelation | def jbcorrelation(sites_or_distances, imt, vs30_clustering=False):
"""
Returns the Jayaram-Baker correlation model.
:param sites_or_distances:
SiteCollection instance o ristance matrix
:param imt:
Intensity Measure Type (PGA or SA)
:param vs30_clustering:... | python | def jbcorrelation(sites_or_distances, imt, vs30_clustering=False):
"""
Returns the Jayaram-Baker correlation model.
:param sites_or_distances:
SiteCollection instance o ristance matrix
:param imt:
Intensity Measure Type (PGA or SA)
:param vs30_clustering:... | [
"def",
"jbcorrelation",
"(",
"sites_or_distances",
",",
"imt",
",",
"vs30_clustering",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"sites_or_distances",
",",
"'mesh'",
")",
":",
"distances",
"=",
"sites_or_distances",
".",
"mesh",
".",
"get_distance_matrix",
"... | Returns the Jayaram-Baker correlation model.
:param sites_or_distances:
SiteCollection instance o ristance matrix
:param imt:
Intensity Measure Type (PGA or SA)
:param vs30_clustering:
flag, defalt false | [
"Returns",
"the",
"Jayaram",
"-",
"Baker",
"correlation",
"model",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/correlation.py#L116-L145 | train |
gem/oq-engine | openquake/hazardlib/correlation.py | hmcorrelation | def hmcorrelation(sites_or_distances, imt, uncertainty_multiplier=0):
"""
Returns the Heresi-Miranda correlation model.
:param sites_or_distances:
SiteCollection instance o distance matrix
:param imt:
Intensity Measure Type (PGA or SA)
:param uncertainty_multiplier:
Value to... | python | def hmcorrelation(sites_or_distances, imt, uncertainty_multiplier=0):
"""
Returns the Heresi-Miranda correlation model.
:param sites_or_distances:
SiteCollection instance o distance matrix
:param imt:
Intensity Measure Type (PGA or SA)
:param uncertainty_multiplier:
Value to... | [
"def",
"hmcorrelation",
"(",
"sites_or_distances",
",",
"imt",
",",
"uncertainty_multiplier",
"=",
"0",
")",
":",
"if",
"hasattr",
"(",
"sites_or_distances",
",",
"'mesh'",
")",
":",
"distances",
"=",
"sites_or_distances",
".",
"mesh",
".",
"get_distance_matrix",
... | Returns the Heresi-Miranda correlation model.
:param sites_or_distances:
SiteCollection instance o distance matrix
:param imt:
Intensity Measure Type (PGA or SA)
:param uncertainty_multiplier:
Value to be multiplied by the uncertainty in the correlation parameter
beta. If un... | [
"Returns",
"the",
"Heresi",
"-",
"Miranda",
"correlation",
"model",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/correlation.py#L225-L262 | train |
gem/oq-engine | openquake/hazardlib/correlation.py | JB2009CorrelationModel.get_lower_triangle_correlation_matrix | def get_lower_triangle_correlation_matrix(self, sites, imt):
"""
Get lower-triangle matrix as a result of Cholesky-decomposition
of correlation matrix.
The resulting matrix should have zeros on values above
the main diagonal.
The actual implementations of :class:`BaseCo... | python | def get_lower_triangle_correlation_matrix(self, sites, imt):
"""
Get lower-triangle matrix as a result of Cholesky-decomposition
of correlation matrix.
The resulting matrix should have zeros on values above
the main diagonal.
The actual implementations of :class:`BaseCo... | [
"def",
"get_lower_triangle_correlation_matrix",
"(",
"self",
",",
"sites",
",",
"imt",
")",
":",
"return",
"numpy",
".",
"linalg",
".",
"cholesky",
"(",
"self",
".",
"_get_correlation_matrix",
"(",
"sites",
",",
"imt",
")",
")"
] | Get lower-triangle matrix as a result of Cholesky-decomposition
of correlation matrix.
The resulting matrix should have zeros on values above
the main diagonal.
The actual implementations of :class:`BaseCorrelationModel` interface
might calculate the matrix considering site col... | [
"Get",
"lower",
"-",
"triangle",
"matrix",
"as",
"a",
"result",
"of",
"Cholesky",
"-",
"decomposition",
"of",
"correlation",
"matrix",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/correlation.py#L92-L113 | train |
gem/oq-engine | openquake/calculators/ebrisk.py | start_ebrisk | def start_ebrisk(rupgetter, srcfilter, param, monitor):
"""
Launcher for ebrisk tasks
"""
with monitor('weighting ruptures'):
rupgetter.set_weights(srcfilter, param['num_taxonomies'])
if rupgetter.weights.sum() <= param['maxweight']:
yield ebrisk(rupgetter, srcfilter, param, monitor)... | python | def start_ebrisk(rupgetter, srcfilter, param, monitor):
"""
Launcher for ebrisk tasks
"""
with monitor('weighting ruptures'):
rupgetter.set_weights(srcfilter, param['num_taxonomies'])
if rupgetter.weights.sum() <= param['maxweight']:
yield ebrisk(rupgetter, srcfilter, param, monitor)... | [
"def",
"start_ebrisk",
"(",
"rupgetter",
",",
"srcfilter",
",",
"param",
",",
"monitor",
")",
":",
"with",
"monitor",
"(",
"'weighting ruptures'",
")",
":",
"rupgetter",
".",
"set_weights",
"(",
"srcfilter",
",",
"param",
"[",
"'num_taxonomies'",
"]",
")",
"... | Launcher for ebrisk tasks | [
"Launcher",
"for",
"ebrisk",
"tasks"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/ebrisk.py#L38-L48 | train |
gem/oq-engine | openquake/hazardlib/mfd/youngs_coppersmith_1985.py | YoungsCoppersmith1985MFD.get_min_max_mag | def get_min_max_mag(self):
"Return the minimum and maximum magnitudes"
mag, num_bins = self._get_min_mag_and_num_bins()
return mag, mag + self. bin_width * (num_bins - 1) | python | def get_min_max_mag(self):
"Return the minimum and maximum magnitudes"
mag, num_bins = self._get_min_mag_and_num_bins()
return mag, mag + self. bin_width * (num_bins - 1) | [
"def",
"get_min_max_mag",
"(",
"self",
")",
":",
"\"Return the minimum and maximum magnitudes\"",
"mag",
",",
"num_bins",
"=",
"self",
".",
"_get_min_mag_and_num_bins",
"(",
")",
"return",
"mag",
",",
"mag",
"+",
"self",
".",
"bin_width",
"*",
"(",
"num_bins",
"... | Return the minimum and maximum magnitudes | [
"Return",
"the",
"minimum",
"and",
"maximum",
"magnitudes"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/mfd/youngs_coppersmith_1985.py#L91-L94 | train |
gem/oq-engine | openquake/hazardlib/mfd/youngs_coppersmith_1985.py | YoungsCoppersmith1985MFD._get_rate | def _get_rate(self, mag):
"""
Calculate and return the annual occurrence rate for a specific bin.
:param mag:
Magnitude value corresponding to the center of the bin of interest.
:returns:
Float number, the annual occurrence rate for the :param mag value.
... | python | def _get_rate(self, mag):
"""
Calculate and return the annual occurrence rate for a specific bin.
:param mag:
Magnitude value corresponding to the center of the bin of interest.
:returns:
Float number, the annual occurrence rate for the :param mag value.
... | [
"def",
"_get_rate",
"(",
"self",
",",
"mag",
")",
":",
"mag_lo",
"=",
"mag",
"-",
"self",
".",
"bin_width",
"/",
"2.0",
"mag_hi",
"=",
"mag",
"+",
"self",
".",
"bin_width",
"/",
"2.0",
"if",
"mag",
">=",
"self",
".",
"min_mag",
"and",
"mag",
"<",
... | Calculate and return the annual occurrence rate for a specific bin.
:param mag:
Magnitude value corresponding to the center of the bin of interest.
:returns:
Float number, the annual occurrence rate for the :param mag value. | [
"Calculate",
"and",
"return",
"the",
"annual",
"occurrence",
"rate",
"for",
"a",
"specific",
"bin",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/mfd/youngs_coppersmith_1985.py#L289-L308 | train |
gem/oq-engine | openquake/hazardlib/mfd/youngs_coppersmith_1985.py | YoungsCoppersmith1985MFD._get_min_mag_and_num_bins | def _get_min_mag_and_num_bins(self):
"""
Estimate the number of bins in the histogram and return it along with
the first bin center value.
Rounds ``min_mag`` and ``max_mag`` with respect to ``bin_width`` to
make the distance between them include integer number of bins.
... | python | def _get_min_mag_and_num_bins(self):
"""
Estimate the number of bins in the histogram and return it along with
the first bin center value.
Rounds ``min_mag`` and ``max_mag`` with respect to ``bin_width`` to
make the distance between them include integer number of bins.
... | [
"def",
"_get_min_mag_and_num_bins",
"(",
"self",
")",
":",
"min_mag",
"=",
"round",
"(",
"self",
".",
"min_mag",
"/",
"self",
".",
"bin_width",
")",
"*",
"self",
".",
"bin_width",
"max_mag",
"=",
"(",
"round",
"(",
"(",
"self",
".",
"char_mag",
"+",
"D... | Estimate the number of bins in the histogram and return it along with
the first bin center value.
Rounds ``min_mag`` and ``max_mag`` with respect to ``bin_width`` to
make the distance between them include integer number of bins.
:returns:
A tuple of 2 items: first bin cente... | [
"Estimate",
"the",
"number",
"of",
"bins",
"in",
"the",
"histogram",
"and",
"return",
"it",
"along",
"with",
"the",
"first",
"bin",
"center",
"value",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/mfd/youngs_coppersmith_1985.py#L310-L332 | train |
gem/oq-engine | openquake/hazardlib/mfd/youngs_coppersmith_1985.py | YoungsCoppersmith1985MFD.get_annual_occurrence_rates | def get_annual_occurrence_rates(self):
"""
Calculate and return the annual occurrence rates histogram.
:returns:
See :meth:
`openquake.hazardlib.mfd.base.BaseMFD.get_annual_occurrence_rates`.
"""
mag, num_bins = self._get_min_mag_and_num_bins()
ra... | python | def get_annual_occurrence_rates(self):
"""
Calculate and return the annual occurrence rates histogram.
:returns:
See :meth:
`openquake.hazardlib.mfd.base.BaseMFD.get_annual_occurrence_rates`.
"""
mag, num_bins = self._get_min_mag_and_num_bins()
ra... | [
"def",
"get_annual_occurrence_rates",
"(",
"self",
")",
":",
"mag",
",",
"num_bins",
"=",
"self",
".",
"_get_min_mag_and_num_bins",
"(",
")",
"rates",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"num_bins",
")",
":",
"rate",
"=",
"self",
".",
"_get_ra... | Calculate and return the annual occurrence rates histogram.
:returns:
See :meth:
`openquake.hazardlib.mfd.base.BaseMFD.get_annual_occurrence_rates`. | [
"Calculate",
"and",
"return",
"the",
"annual",
"occurrence",
"rates",
"histogram",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/mfd/youngs_coppersmith_1985.py#L334-L348 | train |
gem/oq-engine | openquake/hmtk/sources/area_source.py | mtkAreaSource.create_geometry | def create_geometry(self, input_geometry, upper_depth, lower_depth):
'''
If geometry is defined as a numpy array then create instance of
nhlib.geo.polygon.Polygon class, otherwise if already instance of class
accept class
:param input_geometry:
Input geometry (polygo... | python | def create_geometry(self, input_geometry, upper_depth, lower_depth):
'''
If geometry is defined as a numpy array then create instance of
nhlib.geo.polygon.Polygon class, otherwise if already instance of class
accept class
:param input_geometry:
Input geometry (polygo... | [
"def",
"create_geometry",
"(",
"self",
",",
"input_geometry",
",",
"upper_depth",
",",
"lower_depth",
")",
":",
"self",
".",
"_check_seismogenic_depths",
"(",
"upper_depth",
",",
"lower_depth",
")",
"if",
"not",
"isinstance",
"(",
"input_geometry",
",",
"Polygon",... | If geometry is defined as a numpy array then create instance of
nhlib.geo.polygon.Polygon class, otherwise if already instance of class
accept class
:param input_geometry:
Input geometry (polygon) as either
i) instance of nhlib.geo.polygon.Polygon class
ii) n... | [
"If",
"geometry",
"is",
"defined",
"as",
"a",
"numpy",
"array",
"then",
"create",
"instance",
"of",
"nhlib",
".",
"geo",
".",
"polygon",
".",
"Polygon",
"class",
"otherwise",
"if",
"already",
"instance",
"of",
"class",
"accept",
"class"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/sources/area_source.py#L118-L151 | train |
gem/oq-engine | openquake/hmtk/sources/area_source.py | mtkAreaSource.select_catalogue | def select_catalogue(self, selector, distance=None):
'''
Selects the catalogue of earthquakes attributable to the source
:param selector:
Populated instance of openquake.hmtk.seismicity.selector.CatalogueSelector
class
:param float distance:
Distance ... | python | def select_catalogue(self, selector, distance=None):
'''
Selects the catalogue of earthquakes attributable to the source
:param selector:
Populated instance of openquake.hmtk.seismicity.selector.CatalogueSelector
class
:param float distance:
Distance ... | [
"def",
"select_catalogue",
"(",
"self",
",",
"selector",
",",
"distance",
"=",
"None",
")",
":",
"if",
"selector",
".",
"catalogue",
".",
"get_number_events",
"(",
")",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"'No events found in catalogue!'",
")",
"self",
... | Selects the catalogue of earthquakes attributable to the source
:param selector:
Populated instance of openquake.hmtk.seismicity.selector.CatalogueSelector
class
:param float distance:
Distance (in km) to extend or contract (if negative) the zone for
sele... | [
"Selects",
"the",
"catalogue",
"of",
"earthquakes",
"attributable",
"to",
"the",
"source"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/sources/area_source.py#L180-L202 | train |
gem/oq-engine | openquake/baselib/performance.py | Monitor.new | def new(self, operation='no operation', **kw):
"""
Return a copy of the monitor usable for a different operation.
"""
self_vars = vars(self).copy()
del self_vars['operation']
del self_vars['children']
del self_vars['counts']
del self_vars['_flush']
... | python | def new(self, operation='no operation', **kw):
"""
Return a copy of the monitor usable for a different operation.
"""
self_vars = vars(self).copy()
del self_vars['operation']
del self_vars['children']
del self_vars['counts']
del self_vars['_flush']
... | [
"def",
"new",
"(",
"self",
",",
"operation",
"=",
"'no operation'",
",",
"**",
"kw",
")",
":",
"self_vars",
"=",
"vars",
"(",
"self",
")",
".",
"copy",
"(",
")",
"del",
"self_vars",
"[",
"'operation'",
"]",
"del",
"self_vars",
"[",
"'children'",
"]",
... | Return a copy of the monitor usable for a different operation. | [
"Return",
"a",
"copy",
"of",
"the",
"monitor",
"usable",
"for",
"a",
"different",
"operation",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/performance.py#L185-L197 | train |
gem/oq-engine | openquake/hazardlib/site.py | SiteCollection.from_shakemap | def from_shakemap(cls, shakemap_array):
"""
Build a site collection from a shakemap array
"""
self = object.__new__(cls)
self.complete = self
n = len(shakemap_array)
dtype = numpy.dtype([(p, site_param_dt[p])
for p in 'sids lon lat dep... | python | def from_shakemap(cls, shakemap_array):
"""
Build a site collection from a shakemap array
"""
self = object.__new__(cls)
self.complete = self
n = len(shakemap_array)
dtype = numpy.dtype([(p, site_param_dt[p])
for p in 'sids lon lat dep... | [
"def",
"from_shakemap",
"(",
"cls",
",",
"shakemap_array",
")",
":",
"self",
"=",
"object",
".",
"__new__",
"(",
"cls",
")",
"self",
".",
"complete",
"=",
"self",
"n",
"=",
"len",
"(",
"shakemap_array",
")",
"dtype",
"=",
"numpy",
".",
"dtype",
"(",
... | Build a site collection from a shakemap array | [
"Build",
"a",
"site",
"collection",
"from",
"a",
"shakemap",
"array"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/site.py#L164-L180 | train |
gem/oq-engine | openquake/hazardlib/site.py | SiteCollection.from_points | def from_points(cls, lons, lats, depths=None, sitemodel=None,
req_site_params=()):
"""
Build the site collection from
:param lons:
a sequence of longitudes
:param lats:
a sequence of latitudes
:param depths:
a sequence of d... | python | def from_points(cls, lons, lats, depths=None, sitemodel=None,
req_site_params=()):
"""
Build the site collection from
:param lons:
a sequence of longitudes
:param lats:
a sequence of latitudes
:param depths:
a sequence of d... | [
"def",
"from_points",
"(",
"cls",
",",
"lons",
",",
"lats",
",",
"depths",
"=",
"None",
",",
"sitemodel",
"=",
"None",
",",
"req_site_params",
"=",
"(",
")",
")",
":",
"assert",
"len",
"(",
"lons",
")",
"<",
"U32LIMIT",
",",
"len",
"(",
"lons",
")"... | Build the site collection from
:param lons:
a sequence of longitudes
:param lats:
a sequence of latitudes
:param depths:
a sequence of depths (or None)
:param sitemodel:
None or an object containing site parameters as attributes
:p... | [
"Build",
"the",
"site",
"collection",
"from"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/site.py#L183-L230 | train |
gem/oq-engine | openquake/hazardlib/site.py | SiteCollection.make_complete | def make_complete(self):
"""
Turns the site collection into a complete one, if needed
"""
# reset the site indices from 0 to N-1 and set self.complete to self
self.array['sids'] = numpy.arange(len(self), dtype=numpy.uint32)
self.complete = self | python | def make_complete(self):
"""
Turns the site collection into a complete one, if needed
"""
# reset the site indices from 0 to N-1 and set self.complete to self
self.array['sids'] = numpy.arange(len(self), dtype=numpy.uint32)
self.complete = self | [
"def",
"make_complete",
"(",
"self",
")",
":",
"self",
".",
"array",
"[",
"'sids'",
"]",
"=",
"numpy",
".",
"arange",
"(",
"len",
"(",
"self",
")",
",",
"dtype",
"=",
"numpy",
".",
"uint32",
")",
"self",
".",
"complete",
"=",
"self"
] | Turns the site collection into a complete one, if needed | [
"Turns",
"the",
"site",
"collection",
"into",
"a",
"complete",
"one",
"if",
"needed"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/site.py#L256-L262 | train |
gem/oq-engine | openquake/hazardlib/site.py | SiteCollection.filter | def filter(self, mask):
"""
Create a SiteCollection with only a subset of sites.
:param mask:
Numpy array of boolean values of the same length as the site
collection. ``True`` values should indicate that site with that
index should be included into the filter... | python | def filter(self, mask):
"""
Create a SiteCollection with only a subset of sites.
:param mask:
Numpy array of boolean values of the same length as the site
collection. ``True`` values should indicate that site with that
index should be included into the filter... | [
"def",
"filter",
"(",
"self",
",",
"mask",
")",
":",
"assert",
"len",
"(",
"mask",
")",
"==",
"len",
"(",
"self",
")",
",",
"(",
"len",
"(",
"mask",
")",
",",
"len",
"(",
"self",
")",
")",
"if",
"mask",
".",
"all",
"(",
")",
":",
"return",
... | Create a SiteCollection with only a subset of sites.
:param mask:
Numpy array of boolean values of the same length as the site
collection. ``True`` values should indicate that site with that
index should be included into the filtered collection.
:returns:
... | [
"Create",
"a",
"SiteCollection",
"with",
"only",
"a",
"subset",
"of",
"sites",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/site.py#L345-L370 | train |
gem/oq-engine | openquake/hazardlib/geo/point.py | Point.point_at | def point_at(self, horizontal_distance, vertical_increment, azimuth):
"""
Compute the point with given horizontal, vertical distances
and azimuth from this point.
:param horizontal_distance:
Horizontal distance, in km.
:type horizontal_distance:
float
... | python | def point_at(self, horizontal_distance, vertical_increment, azimuth):
"""
Compute the point with given horizontal, vertical distances
and azimuth from this point.
:param horizontal_distance:
Horizontal distance, in km.
:type horizontal_distance:
float
... | [
"def",
"point_at",
"(",
"self",
",",
"horizontal_distance",
",",
"vertical_increment",
",",
"azimuth",
")",
":",
"lon",
",",
"lat",
"=",
"geodetic",
".",
"point_at",
"(",
"self",
".",
"longitude",
",",
"self",
".",
"latitude",
",",
"azimuth",
",",
"horizon... | Compute the point with given horizontal, vertical distances
and azimuth from this point.
:param horizontal_distance:
Horizontal distance, in km.
:type horizontal_distance:
float
:param vertical_increment:
Vertical increment, in km. When positive, the ... | [
"Compute",
"the",
"point",
"with",
"given",
"horizontal",
"vertical",
"distances",
"and",
"azimuth",
"from",
"this",
"point",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/point.py#L94-L120 | train |
gem/oq-engine | openquake/hazardlib/geo/point.py | Point.equally_spaced_points | def equally_spaced_points(self, point, distance):
"""
Compute the set of points equally spaced between this point
and the given point.
:param point:
Destination point.
:type point:
Instance of :class:`Point`
:param distance:
Distance b... | python | def equally_spaced_points(self, point, distance):
"""
Compute the set of points equally spaced between this point
and the given point.
:param point:
Destination point.
:type point:
Instance of :class:`Point`
:param distance:
Distance b... | [
"def",
"equally_spaced_points",
"(",
"self",
",",
"point",
",",
"distance",
")",
":",
"lons",
",",
"lats",
",",
"depths",
"=",
"geodetic",
".",
"intervals_between",
"(",
"self",
".",
"longitude",
",",
"self",
".",
"latitude",
",",
"self",
".",
"depth",
"... | Compute the set of points equally spaced between this point
and the given point.
:param point:
Destination point.
:type point:
Instance of :class:`Point`
:param distance:
Distance between points (in km).
:type distance:
float
... | [
"Compute",
"the",
"set",
"of",
"points",
"equally",
"spaced",
"between",
"this",
"point",
"and",
"the",
"given",
"point",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/point.py#L235-L257 | train |
gem/oq-engine | openquake/hazardlib/geo/point.py | Point.to_polygon | def to_polygon(self, radius):
"""
Create a circular polygon with specified radius centered in the point.
:param radius:
Required radius of a new polygon, in km.
:returns:
Instance of :class:`~openquake.hazardlib.geo.polygon.Polygon` that
approximates ... | python | def to_polygon(self, radius):
"""
Create a circular polygon with specified radius centered in the point.
:param radius:
Required radius of a new polygon, in km.
:returns:
Instance of :class:`~openquake.hazardlib.geo.polygon.Polygon` that
approximates ... | [
"def",
"to_polygon",
"(",
"self",
",",
"radius",
")",
":",
"assert",
"radius",
">",
"0",
"from",
"openquake",
".",
"hazardlib",
".",
"geo",
".",
"polygon",
"import",
"Polygon",
"proj",
"=",
"geo_utils",
".",
"OrthographicProjection",
"(",
"self",
".",
"lon... | Create a circular polygon with specified radius centered in the point.
:param radius:
Required radius of a new polygon, in km.
:returns:
Instance of :class:`~openquake.hazardlib.geo.polygon.Polygon` that
approximates a circle around the point with specified radius. | [
"Create",
"a",
"circular",
"polygon",
"with",
"specified",
"radius",
"centered",
"in",
"the",
"point",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/point.py#L259-L283 | train |
gem/oq-engine | openquake/hazardlib/geo/point.py | Point.closer_than | def closer_than(self, mesh, radius):
"""
Check for proximity of points in the ``mesh``.
:param mesh:
:class:`openquake.hazardlib.geo.mesh.Mesh` instance.
:param radius:
Proximity measure in km.
:returns:
Numpy array of boolean values in the sa... | python | def closer_than(self, mesh, radius):
"""
Check for proximity of points in the ``mesh``.
:param mesh:
:class:`openquake.hazardlib.geo.mesh.Mesh` instance.
:param radius:
Proximity measure in km.
:returns:
Numpy array of boolean values in the sa... | [
"def",
"closer_than",
"(",
"self",
",",
"mesh",
",",
"radius",
")",
":",
"dists",
"=",
"geodetic",
".",
"distance",
"(",
"self",
".",
"longitude",
",",
"self",
".",
"latitude",
",",
"self",
".",
"depth",
",",
"mesh",
".",
"lons",
",",
"mesh",
".",
... | Check for proximity of points in the ``mesh``.
:param mesh:
:class:`openquake.hazardlib.geo.mesh.Mesh` instance.
:param radius:
Proximity measure in km.
:returns:
Numpy array of boolean values in the same shape as the mesh
coordinate arrays with `... | [
"Check",
"for",
"proximity",
"of",
"points",
"in",
"the",
"mesh",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/point.py#L285-L305 | train |
gem/oq-engine | openquake/commands/info.py | print_csm_info | def print_csm_info(fname):
"""
Parse the composite source model without instantiating the sources and
prints information about its composition and the full logic tree
"""
oqparam = readinput.get_oqparam(fname)
csm = readinput.get_composite_source_model(oqparam, in_memory=False)
print(csm.inf... | python | def print_csm_info(fname):
"""
Parse the composite source model without instantiating the sources and
prints information about its composition and the full logic tree
"""
oqparam = readinput.get_oqparam(fname)
csm = readinput.get_composite_source_model(oqparam, in_memory=False)
print(csm.inf... | [
"def",
"print_csm_info",
"(",
"fname",
")",
":",
"oqparam",
"=",
"readinput",
".",
"get_oqparam",
"(",
"fname",
")",
"csm",
"=",
"readinput",
".",
"get_composite_source_model",
"(",
"oqparam",
",",
"in_memory",
"=",
"False",
")",
"print",
"(",
"csm",
".",
... | Parse the composite source model without instantiating the sources and
prints information about its composition and the full logic tree | [
"Parse",
"the",
"composite",
"source",
"model",
"without",
"instantiating",
"the",
"sources",
"and",
"prints",
"information",
"about",
"its",
"composition",
"and",
"the",
"full",
"logic",
"tree"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/info.py#L65-L81 | train |
gem/oq-engine | openquake/commands/info.py | do_build_reports | def do_build_reports(directory):
"""
Walk the directory and builds pre-calculation reports for all the
job.ini files found.
"""
for cwd, dirs, files in os.walk(directory):
for f in sorted(files):
if f in ('job.ini', 'job_h.ini', 'job_haz.ini', 'job_hazard.ini'):
j... | python | def do_build_reports(directory):
"""
Walk the directory and builds pre-calculation reports for all the
job.ini files found.
"""
for cwd, dirs, files in os.walk(directory):
for f in sorted(files):
if f in ('job.ini', 'job_h.ini', 'job_haz.ini', 'job_hazard.ini'):
j... | [
"def",
"do_build_reports",
"(",
"directory",
")",
":",
"for",
"cwd",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"directory",
")",
":",
"for",
"f",
"in",
"sorted",
"(",
"files",
")",
":",
"if",
"f",
"in",
"(",
"'job.ini'",
",",
"'job_h... | Walk the directory and builds pre-calculation reports for all the
job.ini files found. | [
"Walk",
"the",
"directory",
"and",
"builds",
"pre",
"-",
"calculation",
"reports",
"for",
"all",
"the",
"job",
".",
"ini",
"files",
"found",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/info.py#L84-L97 | train |
gem/oq-engine | openquake/commands/info.py | info | def info(calculators, gsims, views, exports, extracts, parameters,
report, input_file=''):
"""
Give information. You can pass the name of an available calculator,
a job.ini file, or a zip archive with the input files.
"""
if calculators:
for calc in sorted(base.calculators):
... | python | def info(calculators, gsims, views, exports, extracts, parameters,
report, input_file=''):
"""
Give information. You can pass the name of an available calculator,
a job.ini file, or a zip archive with the input files.
"""
if calculators:
for calc in sorted(base.calculators):
... | [
"def",
"info",
"(",
"calculators",
",",
"gsims",
",",
"views",
",",
"exports",
",",
"extracts",
",",
"parameters",
",",
"report",
",",
"input_file",
"=",
"''",
")",
":",
"if",
"calculators",
":",
"for",
"calc",
"in",
"sorted",
"(",
"base",
".",
"calcul... | Give information. You can pass the name of an available calculator,
a job.ini file, or a zip archive with the input files. | [
"Give",
"information",
".",
"You",
"can",
"pass",
"the",
"name",
"of",
"an",
"available",
"calculator",
"a",
"job",
".",
"ini",
"file",
"or",
"a",
"zip",
"archive",
"with",
"the",
"input",
"files",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/info.py#L103-L171 | train |
gem/oq-engine | openquake/calculators/classical.py | classical_split_filter | def classical_split_filter(srcs, srcfilter, gsims, params, monitor):
"""
Split the given sources, filter the subsources and the compute the
PoEs. Yield back subtasks if the split sources contain more than
maxweight ruptures.
"""
# first check if we are sampling the sources
ss = int(os.enviro... | python | def classical_split_filter(srcs, srcfilter, gsims, params, monitor):
"""
Split the given sources, filter the subsources and the compute the
PoEs. Yield back subtasks if the split sources contain more than
maxweight ruptures.
"""
# first check if we are sampling the sources
ss = int(os.enviro... | [
"def",
"classical_split_filter",
"(",
"srcs",
",",
"srcfilter",
",",
"gsims",
",",
"params",
",",
"monitor",
")",
":",
"ss",
"=",
"int",
"(",
"os",
".",
"environ",
".",
"get",
"(",
"'OQ_SAMPLE_SOURCES'",
",",
"0",
")",
")",
"if",
"ss",
":",
"splits",
... | Split the given sources, filter the subsources and the compute the
PoEs. Yield back subtasks if the split sources contain more than
maxweight ruptures. | [
"Split",
"the",
"given",
"sources",
"filter",
"the",
"subsources",
"and",
"the",
"compute",
"the",
"PoEs",
".",
"Yield",
"back",
"subtasks",
"if",
"the",
"split",
"sources",
"contain",
"more",
"than",
"maxweight",
"ruptures",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/classical.py#L72-L100 | train |
gem/oq-engine | openquake/hmtk/seismicity/gcmt_utils.py | get_azimuth_plunge | def get_azimuth_plunge(vect, degrees=True):
'''
For a given vector in USE format, retrieve the azimuth and plunge
'''
if vect[0] > 0:
vect = -1. * np.copy(vect)
vect_hor = sqrt(vect[1] ** 2. + vect[2] ** 2.)
plunge = atan2(-vect[0], vect_hor)
azimuth = atan2(vect[2], -vect[1])
if... | python | def get_azimuth_plunge(vect, degrees=True):
'''
For a given vector in USE format, retrieve the azimuth and plunge
'''
if vect[0] > 0:
vect = -1. * np.copy(vect)
vect_hor = sqrt(vect[1] ** 2. + vect[2] ** 2.)
plunge = atan2(-vect[0], vect_hor)
azimuth = atan2(vect[2], -vect[1])
if... | [
"def",
"get_azimuth_plunge",
"(",
"vect",
",",
"degrees",
"=",
"True",
")",
":",
"if",
"vect",
"[",
"0",
"]",
">",
"0",
":",
"vect",
"=",
"-",
"1.",
"*",
"np",
".",
"copy",
"(",
"vect",
")",
"vect_hor",
"=",
"sqrt",
"(",
"vect",
"[",
"1",
"]",
... | For a given vector in USE format, retrieve the azimuth and plunge | [
"For",
"a",
"given",
"vector",
"in",
"USE",
"format",
"retrieve",
"the",
"azimuth",
"and",
"plunge"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/gcmt_utils.py#L77-L90 | train |
gem/oq-engine | openquake/hmtk/seismicity/gcmt_utils.py | use_to_ned | def use_to_ned(tensor):
'''
Converts a tensor in USE coordinate sytem to NED
'''
return np.array(ROT_NED_USE.T * np.matrix(tensor) * ROT_NED_USE) | python | def use_to_ned(tensor):
'''
Converts a tensor in USE coordinate sytem to NED
'''
return np.array(ROT_NED_USE.T * np.matrix(tensor) * ROT_NED_USE) | [
"def",
"use_to_ned",
"(",
"tensor",
")",
":",
"return",
"np",
".",
"array",
"(",
"ROT_NED_USE",
".",
"T",
"*",
"np",
".",
"matrix",
"(",
"tensor",
")",
"*",
"ROT_NED_USE",
")"
] | Converts a tensor in USE coordinate sytem to NED | [
"Converts",
"a",
"tensor",
"in",
"USE",
"coordinate",
"sytem",
"to",
"NED"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/gcmt_utils.py#L101-L105 | train |
gem/oq-engine | openquake/hmtk/seismicity/gcmt_utils.py | ned_to_use | def ned_to_use(tensor):
'''
Converts a tensor in NED coordinate sytem to USE
'''
return np.array(ROT_NED_USE * np.matrix(tensor) * ROT_NED_USE.T) | python | def ned_to_use(tensor):
'''
Converts a tensor in NED coordinate sytem to USE
'''
return np.array(ROT_NED_USE * np.matrix(tensor) * ROT_NED_USE.T) | [
"def",
"ned_to_use",
"(",
"tensor",
")",
":",
"return",
"np",
".",
"array",
"(",
"ROT_NED_USE",
"*",
"np",
".",
"matrix",
"(",
"tensor",
")",
"*",
"ROT_NED_USE",
".",
"T",
")"
] | Converts a tensor in NED coordinate sytem to USE | [
"Converts",
"a",
"tensor",
"in",
"NED",
"coordinate",
"sytem",
"to",
"USE"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/gcmt_utils.py#L108-L112 | train |
gem/oq-engine | openquake/hazardlib/gsim/boore_atkinson_2008.py | Atkinson2010Hawaii.get_mean_and_stddevs | def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
"""
Using a frequency dependent correction for the mean ground motion.
Standard deviation is fixed.
"""
mean, stddevs = super().get_mean_and_stddevs(sites, rup, dists,
... | python | def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
"""
Using a frequency dependent correction for the mean ground motion.
Standard deviation is fixed.
"""
mean, stddevs = super().get_mean_and_stddevs(sites, rup, dists,
... | [
"def",
"get_mean_and_stddevs",
"(",
"self",
",",
"sites",
",",
"rup",
",",
"dists",
",",
"imt",
",",
"stddev_types",
")",
":",
"mean",
",",
"stddevs",
"=",
"super",
"(",
")",
".",
"get_mean_and_stddevs",
"(",
"sites",
",",
"rup",
",",
"dists",
",",
"im... | Using a frequency dependent correction for the mean ground motion.
Standard deviation is fixed. | [
"Using",
"a",
"frequency",
"dependent",
"correction",
"for",
"the",
"mean",
"ground",
"motion",
".",
"Standard",
"deviation",
"is",
"fixed",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/boore_atkinson_2008.py#L383-L416 | train |
gem/oq-engine | openquake/commonlib/rlzs_assoc.py | RlzsAssoc.get_rlz | def get_rlz(self, rlzstr):
r"""
Get a Realization instance for a string of the form 'rlz-\d+'
"""
mo = re.match(r'rlz-(\d+)', rlzstr)
if not mo:
return
return self.realizations[int(mo.group(1))] | python | def get_rlz(self, rlzstr):
r"""
Get a Realization instance for a string of the form 'rlz-\d+'
"""
mo = re.match(r'rlz-(\d+)', rlzstr)
if not mo:
return
return self.realizations[int(mo.group(1))] | [
"def",
"get_rlz",
"(",
"self",
",",
"rlzstr",
")",
":",
"r",
"mo",
"=",
"re",
".",
"match",
"(",
"r'rlz-(\\d+)'",
",",
"rlzstr",
")",
"if",
"not",
"mo",
":",
"return",
"return",
"self",
".",
"realizations",
"[",
"int",
"(",
"mo",
".",
"group",
"(",... | r"""
Get a Realization instance for a string of the form 'rlz-\d+' | [
"r",
"Get",
"a",
"Realization",
"instance",
"for",
"a",
"string",
"of",
"the",
"form",
"rlz",
"-",
"\\",
"d",
"+"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/rlzs_assoc.py#L190-L197 | train |
gem/oq-engine | openquake/commands/export.py | export | def export(datastore_key, calc_id=-1, exports='csv', export_dir='.'):
"""
Export an output from the datastore.
"""
dstore = util.read(calc_id)
parent_id = dstore['oqparam'].hazard_calculation_id
if parent_id:
dstore.parent = util.read(parent_id)
dstore.export_dir = export_dir
... | python | def export(datastore_key, calc_id=-1, exports='csv', export_dir='.'):
"""
Export an output from the datastore.
"""
dstore = util.read(calc_id)
parent_id = dstore['oqparam'].hazard_calculation_id
if parent_id:
dstore.parent = util.read(parent_id)
dstore.export_dir = export_dir
... | [
"def",
"export",
"(",
"datastore_key",
",",
"calc_id",
"=",
"-",
"1",
",",
"exports",
"=",
"'csv'",
",",
"export_dir",
"=",
"'.'",
")",
":",
"dstore",
"=",
"util",
".",
"read",
"(",
"calc_id",
")",
"parent_id",
"=",
"dstore",
"[",
"'oqparam'",
"]",
"... | Export an output from the datastore. | [
"Export",
"an",
"output",
"from",
"the",
"datastore",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/export.py#L27-L43 | train |
gem/oq-engine | openquake/calculators/ucerf_base.py | convert_UCERFSource | def convert_UCERFSource(self, node):
"""
Converts the Ucerf Source node into an SES Control object
"""
dirname = os.path.dirname(self.fname) # where the source_model_file is
source_file = os.path.join(dirname, node["filename"])
if "startDate" in node.attrib and "investigationTime" in node.attri... | python | def convert_UCERFSource(self, node):
"""
Converts the Ucerf Source node into an SES Control object
"""
dirname = os.path.dirname(self.fname) # where the source_model_file is
source_file = os.path.join(dirname, node["filename"])
if "startDate" in node.attrib and "investigationTime" in node.attri... | [
"def",
"convert_UCERFSource",
"(",
"self",
",",
"node",
")",
":",
"dirname",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"self",
".",
"fname",
")",
"source_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dirname",
",",
"node",
"[",
"\"filename\"",
... | Converts the Ucerf Source node into an SES Control object | [
"Converts",
"the",
"Ucerf",
"Source",
"node",
"into",
"an",
"SES",
"Control",
"object"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/ucerf_base.py#L58-L88 | train |
gem/oq-engine | openquake/calculators/ucerf_base.py | build_idx_set | def build_idx_set(branch_id, start_date):
"""
Builds a dictionary of keys based on the branch code
"""
code_set = branch_id.split("/")
code_set.insert(3, "Rates")
idx_set = {
"sec": "/".join([code_set[0], code_set[1], "Sections"]),
"mag": "/".join([code_set[0], code_set[1], code_... | python | def build_idx_set(branch_id, start_date):
"""
Builds a dictionary of keys based on the branch code
"""
code_set = branch_id.split("/")
code_set.insert(3, "Rates")
idx_set = {
"sec": "/".join([code_set[0], code_set[1], "Sections"]),
"mag": "/".join([code_set[0], code_set[1], code_... | [
"def",
"build_idx_set",
"(",
"branch_id",
",",
"start_date",
")",
":",
"code_set",
"=",
"branch_id",
".",
"split",
"(",
"\"/\"",
")",
"code_set",
".",
"insert",
"(",
"3",
",",
"\"Rates\"",
")",
"idx_set",
"=",
"{",
"\"sec\"",
":",
"\"/\"",
".",
"join",
... | Builds a dictionary of keys based on the branch code | [
"Builds",
"a",
"dictionary",
"of",
"keys",
"based",
"on",
"the",
"branch",
"code"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/ucerf_base.py#L433-L452 | train |
gem/oq-engine | openquake/calculators/ucerf_base.py | get_rupture_surface | def get_rupture_surface(mag, nodal_plane, hypocenter, msr,
rupture_aspect_ratio, upper_seismogenic_depth,
lower_seismogenic_depth, mesh_spacing=1.0):
"""
Create and return rupture surface object with given properties.
:param mag:
Magnitude value, used... | python | def get_rupture_surface(mag, nodal_plane, hypocenter, msr,
rupture_aspect_ratio, upper_seismogenic_depth,
lower_seismogenic_depth, mesh_spacing=1.0):
"""
Create and return rupture surface object with given properties.
:param mag:
Magnitude value, used... | [
"def",
"get_rupture_surface",
"(",
"mag",
",",
"nodal_plane",
",",
"hypocenter",
",",
"msr",
",",
"rupture_aspect_ratio",
",",
"upper_seismogenic_depth",
",",
"lower_seismogenic_depth",
",",
"mesh_spacing",
"=",
"1.0",
")",
":",
"assert",
"(",
"upper_seismogenic_depth... | Create and return rupture surface object with given properties.
:param mag:
Magnitude value, used to calculate rupture dimensions,
see :meth:`_get_rupture_dimensions`.
:param nodal_plane:
Instance of :class:`openquake.hazardlib.geo.nodalplane.NodalPlane`
describing the rupture o... | [
"Create",
"and",
"return",
"rupture",
"surface",
"object",
"with",
"given",
"properties",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/ucerf_base.py#L492-L593 | train |
gem/oq-engine | openquake/calculators/ucerf_base.py | UCERFSource.get_ridx | def get_ridx(self, iloc):
"""List of rupture indices for the given iloc"""
with h5py.File(self.source_file, "r") as hdf5:
return hdf5[self.idx_set["geol"] + "/RuptureIndex"][iloc] | python | def get_ridx(self, iloc):
"""List of rupture indices for the given iloc"""
with h5py.File(self.source_file, "r") as hdf5:
return hdf5[self.idx_set["geol"] + "/RuptureIndex"][iloc] | [
"def",
"get_ridx",
"(",
"self",
",",
"iloc",
")",
":",
"with",
"h5py",
".",
"File",
"(",
"self",
".",
"source_file",
",",
"\"r\"",
")",
"as",
"hdf5",
":",
"return",
"hdf5",
"[",
"self",
".",
"idx_set",
"[",
"\"geol\"",
"]",
"+",
"\"/RuptureIndex\"",
... | List of rupture indices for the given iloc | [
"List",
"of",
"rupture",
"indices",
"for",
"the",
"given",
"iloc"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/ucerf_base.py#L271-L274 | train |
gem/oq-engine | openquake/calculators/ucerf_base.py | UCERFSource.get_background_sids | def get_background_sids(self, src_filter):
"""
We can apply the filtering of the background sites as a pre-processing
step - this is done here rather than in the sampling of the ruptures
themselves
"""
branch_key = self.idx_set["grid_key"]
idist = src_filter.integ... | python | def get_background_sids(self, src_filter):
"""
We can apply the filtering of the background sites as a pre-processing
step - this is done here rather than in the sampling of the ruptures
themselves
"""
branch_key = self.idx_set["grid_key"]
idist = src_filter.integ... | [
"def",
"get_background_sids",
"(",
"self",
",",
"src_filter",
")",
":",
"branch_key",
"=",
"self",
".",
"idx_set",
"[",
"\"grid_key\"",
"]",
"idist",
"=",
"src_filter",
".",
"integration_distance",
"(",
"DEFAULT_TRT",
")",
"with",
"h5py",
".",
"File",
"(",
"... | We can apply the filtering of the background sites as a pre-processing
step - this is done here rather than in the sampling of the ruptures
themselves | [
"We",
"can",
"apply",
"the",
"filtering",
"of",
"the",
"background",
"sites",
"as",
"a",
"pre",
"-",
"processing",
"step",
"-",
"this",
"is",
"done",
"here",
"rather",
"than",
"in",
"the",
"sampling",
"of",
"the",
"ruptures",
"themselves"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/ucerf_base.py#L297-L317 | train |
gem/oq-engine | openquake/calculators/ucerf_base.py | UCERFSource.iter_ruptures | def iter_ruptures(self):
"""
Yield ruptures for the current set of indices
"""
assert self.orig, '%s is not fully initialized' % self
for ridx in range(self.start, self.stop):
if self.orig.rate[ridx]: # ruptures may have have zero rate
rup = self.get_... | python | def iter_ruptures(self):
"""
Yield ruptures for the current set of indices
"""
assert self.orig, '%s is not fully initialized' % self
for ridx in range(self.start, self.stop):
if self.orig.rate[ridx]: # ruptures may have have zero rate
rup = self.get_... | [
"def",
"iter_ruptures",
"(",
"self",
")",
":",
"assert",
"self",
".",
"orig",
",",
"'%s is not fully initialized'",
"%",
"self",
"for",
"ridx",
"in",
"range",
"(",
"self",
".",
"start",
",",
"self",
".",
"stop",
")",
":",
"if",
"self",
".",
"orig",
"."... | Yield ruptures for the current set of indices | [
"Yield",
"ruptures",
"for",
"the",
"current",
"set",
"of",
"indices"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/ucerf_base.py#L359-L368 | train |
gem/oq-engine | openquake/calculators/ucerf_base.py | UCERFSource.get_background_sources | def get_background_sources(self, src_filter, sample_factor=None):
"""
Turn the background model of a given branch into a set of point sources
:param src_filter:
SourceFilter instance
:param sample_factor:
Used to reduce the sources if OQ_SAMPLE_SOURCES is set
... | python | def get_background_sources(self, src_filter, sample_factor=None):
"""
Turn the background model of a given branch into a set of point sources
:param src_filter:
SourceFilter instance
:param sample_factor:
Used to reduce the sources if OQ_SAMPLE_SOURCES is set
... | [
"def",
"get_background_sources",
"(",
"self",
",",
"src_filter",
",",
"sample_factor",
"=",
"None",
")",
":",
"background_sids",
"=",
"self",
".",
"get_background_sids",
"(",
"src_filter",
")",
"if",
"sample_factor",
"is",
"not",
"None",
":",
"background_sids",
... | Turn the background model of a given branch into a set of point sources
:param src_filter:
SourceFilter instance
:param sample_factor:
Used to reduce the sources if OQ_SAMPLE_SOURCES is set | [
"Turn",
"the",
"background",
"model",
"of",
"a",
"given",
"branch",
"into",
"a",
"set",
"of",
"point",
"sources"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/ucerf_base.py#L387-L427 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.