repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.hmap_dt | def hmap_dt(self): # used for CSV export
"""
:returns: a composite dtype (imt, poe)
"""
return numpy.dtype([('%s-%s' % (imt, poe), F32)
for imt in self.imtls for poe in self.poes]) | python | def hmap_dt(self): # used for CSV export
"""
:returns: a composite dtype (imt, poe)
"""
return numpy.dtype([('%s-%s' % (imt, poe), F32)
for imt in self.imtls for poe in self.poes]) | [
"def",
"hmap_dt",
"(",
"self",
")",
":",
"# used for CSV export",
"return",
"numpy",
".",
"dtype",
"(",
"[",
"(",
"'%s-%s'",
"%",
"(",
"imt",
",",
"poe",
")",
",",
"F32",
")",
"for",
"imt",
"in",
"self",
".",
"imtls",
"for",
"poe",
"in",
"self",
".... | :returns: a composite dtype (imt, poe) | [
":",
"returns",
":",
"a",
"composite",
"dtype",
"(",
"imt",
"poe",
")"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L435-L440 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.uhs_dt | def uhs_dt(self): # used for CSV and NPZ export
"""
:returns: a composity dtype (poe, imt)
"""
imts_dt = numpy.dtype([(imt, F32) for imt in self.imtls
if imt.startswith(('PGA', 'SA'))])
return numpy.dtype([(str(poe), imts_dt) for poe in self.poes]) | python | def uhs_dt(self): # used for CSV and NPZ export
"""
:returns: a composity dtype (poe, imt)
"""
imts_dt = numpy.dtype([(imt, F32) for imt in self.imtls
if imt.startswith(('PGA', 'SA'))])
return numpy.dtype([(str(poe), imts_dt) for poe in self.poes]) | [
"def",
"uhs_dt",
"(",
"self",
")",
":",
"# used for CSV and NPZ export",
"imts_dt",
"=",
"numpy",
".",
"dtype",
"(",
"[",
"(",
"imt",
",",
"F32",
")",
"for",
"imt",
"in",
"self",
".",
"imtls",
"if",
"imt",
".",
"startswith",
"(",
"(",
"'PGA'",
",",
"... | :returns: a composity dtype (poe, imt) | [
":",
"returns",
":",
"a",
"composity",
"dtype",
"(",
"poe",
"imt",
")"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L442-L448 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.imt_periods | def imt_periods(self):
"""
:returns: the IMTs with a period, as objects
"""
imts = []
for im in self.imtls:
imt = from_string(im)
if hasattr(imt, 'period'):
imts.append(imt)
return imts | python | def imt_periods(self):
"""
:returns: the IMTs with a period, as objects
"""
imts = []
for im in self.imtls:
imt = from_string(im)
if hasattr(imt, 'period'):
imts.append(imt)
return imts | [
"def",
"imt_periods",
"(",
"self",
")",
":",
"imts",
"=",
"[",
"]",
"for",
"im",
"in",
"self",
".",
"imtls",
":",
"imt",
"=",
"from_string",
"(",
"im",
")",
"if",
"hasattr",
"(",
"imt",
",",
"'period'",
")",
":",
"imts",
".",
"append",
"(",
"imt"... | :returns: the IMTs with a period, as objects | [
":",
"returns",
":",
"the",
"IMTs",
"with",
"a",
"period",
"as",
"objects"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L450-L459 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.imt_dt | def imt_dt(self, dtype=F64):
"""
:returns: a numpy dtype {imt: float}
"""
return numpy.dtype([(imt, dtype) for imt in self.imtls]) | python | def imt_dt(self, dtype=F64):
"""
:returns: a numpy dtype {imt: float}
"""
return numpy.dtype([(imt, dtype) for imt in self.imtls]) | [
"def",
"imt_dt",
"(",
"self",
",",
"dtype",
"=",
"F64",
")",
":",
"return",
"numpy",
".",
"dtype",
"(",
"[",
"(",
"imt",
",",
"dtype",
")",
"for",
"imt",
"in",
"self",
".",
"imtls",
"]",
")"
] | :returns: a numpy dtype {imt: float} | [
":",
"returns",
":",
"a",
"numpy",
"dtype",
"{",
"imt",
":",
"float",
"}"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L461-L465 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.lti | def lti(self):
"""
Dictionary extended_loss_type -> extended_loss_type index
"""
return {lt: i for i, (lt, dt) in enumerate(self.loss_dt_list())} | python | def lti(self):
"""
Dictionary extended_loss_type -> extended_loss_type index
"""
return {lt: i for i, (lt, dt) in enumerate(self.loss_dt_list())} | [
"def",
"lti",
"(",
"self",
")",
":",
"return",
"{",
"lt",
":",
"i",
"for",
"i",
",",
"(",
"lt",
",",
"dt",
")",
"in",
"enumerate",
"(",
"self",
".",
"loss_dt_list",
"(",
")",
")",
"}"
] | Dictionary extended_loss_type -> extended_loss_type index | [
"Dictionary",
"extended_loss_type",
"-",
">",
"extended_loss_type",
"index"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L468-L472 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.loss_dt_list | def loss_dt_list(self, dtype=F32):
"""
Return a data type list [(loss_name, dtype), ...]
"""
loss_types = self.all_cost_types
dts = [(str(lt), dtype) for lt in loss_types]
return dts | python | def loss_dt_list(self, dtype=F32):
"""
Return a data type list [(loss_name, dtype), ...]
"""
loss_types = self.all_cost_types
dts = [(str(lt), dtype) for lt in loss_types]
return dts | [
"def",
"loss_dt_list",
"(",
"self",
",",
"dtype",
"=",
"F32",
")",
":",
"loss_types",
"=",
"self",
".",
"all_cost_types",
"dts",
"=",
"[",
"(",
"str",
"(",
"lt",
")",
",",
"dtype",
")",
"for",
"lt",
"in",
"loss_types",
"]",
"return",
"dts"
] | Return a data type list [(loss_name, dtype), ...] | [
"Return",
"a",
"data",
"type",
"list",
"[",
"(",
"loss_name",
"dtype",
")",
"...",
"]"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L480-L486 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.loss_maps_dt | def loss_maps_dt(self, dtype=F32):
"""
Return a composite data type for loss maps
"""
ltypes = self.loss_dt(dtype).names
lst = [('poe-%s' % poe, dtype) for poe in self.conditional_loss_poes]
return numpy.dtype([(lt, lst) for lt in ltypes]) | python | def loss_maps_dt(self, dtype=F32):
"""
Return a composite data type for loss maps
"""
ltypes = self.loss_dt(dtype).names
lst = [('poe-%s' % poe, dtype) for poe in self.conditional_loss_poes]
return numpy.dtype([(lt, lst) for lt in ltypes]) | [
"def",
"loss_maps_dt",
"(",
"self",
",",
"dtype",
"=",
"F32",
")",
":",
"ltypes",
"=",
"self",
".",
"loss_dt",
"(",
"dtype",
")",
".",
"names",
"lst",
"=",
"[",
"(",
"'poe-%s'",
"%",
"poe",
",",
"dtype",
")",
"for",
"poe",
"in",
"self",
".",
"con... | Return a composite data type for loss maps | [
"Return",
"a",
"composite",
"data",
"type",
"for",
"loss",
"maps"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L488-L494 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.gmf_data_dt | def gmf_data_dt(self):
"""
Return a composite data type for the GMFs
"""
return numpy.dtype(
[('rlzi', U16), ('sid', U32),
('eid', U64), ('gmv', (F32, (len(self.imtls),)))]) | python | def gmf_data_dt(self):
"""
Return a composite data type for the GMFs
"""
return numpy.dtype(
[('rlzi', U16), ('sid', U32),
('eid', U64), ('gmv', (F32, (len(self.imtls),)))]) | [
"def",
"gmf_data_dt",
"(",
"self",
")",
":",
"return",
"numpy",
".",
"dtype",
"(",
"[",
"(",
"'rlzi'",
",",
"U16",
")",
",",
"(",
"'sid'",
",",
"U32",
")",
",",
"(",
"'eid'",
",",
"U64",
")",
",",
"(",
"'gmv'",
",",
"(",
"F32",
",",
"(",
"len... | Return a composite data type for the GMFs | [
"Return",
"a",
"composite",
"data",
"type",
"for",
"the",
"GMFs"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L496-L502 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.no_imls | def no_imls(self):
"""
Return True if there are no intensity measure levels
"""
return all(numpy.isnan(ls).any() for ls in self.imtls.values()) | python | def no_imls(self):
"""
Return True if there are no intensity measure levels
"""
return all(numpy.isnan(ls).any() for ls in self.imtls.values()) | [
"def",
"no_imls",
"(",
"self",
")",
":",
"return",
"all",
"(",
"numpy",
".",
"isnan",
"(",
"ls",
")",
".",
"any",
"(",
")",
"for",
"ls",
"in",
"self",
".",
"imtls",
".",
"values",
"(",
")",
")"
] | Return True if there are no intensity measure levels | [
"Return",
"True",
"if",
"there",
"are",
"no",
"intensity",
"measure",
"levels"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L504-L508 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.correl_model | def correl_model(self):
"""
Return a correlation object. See :mod:`openquake.hazardlib.correlation`
for more info.
"""
correl_name = self.ground_motion_correlation_model
if correl_name is None: # no correlation model
return
correl_model_cls = getattr(... | python | def correl_model(self):
"""
Return a correlation object. See :mod:`openquake.hazardlib.correlation`
for more info.
"""
correl_name = self.ground_motion_correlation_model
if correl_name is None: # no correlation model
return
correl_model_cls = getattr(... | [
"def",
"correl_model",
"(",
"self",
")",
":",
"correl_name",
"=",
"self",
".",
"ground_motion_correlation_model",
"if",
"correl_name",
"is",
"None",
":",
"# no correlation model",
"return",
"correl_model_cls",
"=",
"getattr",
"(",
"correlation",
",",
"'%sCorrelationMo... | Return a correlation object. See :mod:`openquake.hazardlib.correlation`
for more info. | [
"Return",
"a",
"correlation",
"object",
".",
"See",
":",
"mod",
":",
"openquake",
".",
"hazardlib",
".",
"correlation",
"for",
"more",
"info",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L511-L521 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.get_kinds | def get_kinds(self, kind, R):
"""
Yield 'rlz-000', 'rlz-001', ...', 'mean', 'quantile-0.1', ...
"""
stats = self.hazard_stats()
if kind == 'stats':
yield from stats
return
elif kind == 'rlzs':
for r in range(R):
yield 'r... | python | def get_kinds(self, kind, R):
"""
Yield 'rlz-000', 'rlz-001', ...', 'mean', 'quantile-0.1', ...
"""
stats = self.hazard_stats()
if kind == 'stats':
yield from stats
return
elif kind == 'rlzs':
for r in range(R):
yield 'r... | [
"def",
"get_kinds",
"(",
"self",
",",
"kind",
",",
"R",
")",
":",
"stats",
"=",
"self",
".",
"hazard_stats",
"(",
")",
"if",
"kind",
"==",
"'stats'",
":",
"yield",
"from",
"stats",
"return",
"elif",
"kind",
"==",
"'rlzs'",
":",
"for",
"r",
"in",
"r... | Yield 'rlz-000', 'rlz-001', ...', 'mean', 'quantile-0.1', ... | [
"Yield",
"rlz",
"-",
"000",
"rlz",
"-",
"001",
"...",
"mean",
"quantile",
"-",
"0",
".",
"1",
"..."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L523-L542 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.hazard_stats | def hazard_stats(self):
"""
Return a list of item with the statistical functions defined for the
hazard calculation
"""
names = [] # name of statistical functions
funcs = [] # statistical functions of kind func(values, weights)
if self.mean_hazard_curves:
... | python | def hazard_stats(self):
"""
Return a list of item with the statistical functions defined for the
hazard calculation
"""
names = [] # name of statistical functions
funcs = [] # statistical functions of kind func(values, weights)
if self.mean_hazard_curves:
... | [
"def",
"hazard_stats",
"(",
"self",
")",
":",
"names",
"=",
"[",
"]",
"# name of statistical functions",
"funcs",
"=",
"[",
"]",
"# statistical functions of kind func(values, weights)",
"if",
"self",
".",
"mean_hazard_curves",
":",
"names",
".",
"append",
"(",
"'mea... | Return a list of item with the statistical functions defined for the
hazard calculation | [
"Return",
"a",
"list",
"of",
"item",
"with",
"the",
"statistical",
"functions",
"defined",
"for",
"the",
"hazard",
"calculation"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L544-L563 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.is_valid_geometry | def is_valid_geometry(self):
"""
It is possible to infer the geometry only if exactly
one of sites, sites_csv, hazard_curves_csv, gmfs_csv,
region is set. You did set more than one, or nothing.
"""
has_sites = (self.sites is not None or 'sites' in self.inputs
... | python | def is_valid_geometry(self):
"""
It is possible to infer the geometry only if exactly
one of sites, sites_csv, hazard_curves_csv, gmfs_csv,
region is set. You did set more than one, or nothing.
"""
has_sites = (self.sites is not None or 'sites' in self.inputs
... | [
"def",
"is_valid_geometry",
"(",
"self",
")",
":",
"has_sites",
"=",
"(",
"self",
".",
"sites",
"is",
"not",
"None",
"or",
"'sites'",
"in",
"self",
".",
"inputs",
"or",
"'site_model'",
"in",
"self",
".",
"inputs",
")",
"if",
"not",
"has_sites",
"and",
... | It is possible to infer the geometry only if exactly
one of sites, sites_csv, hazard_curves_csv, gmfs_csv,
region is set. You did set more than one, or nothing. | [
"It",
"is",
"possible",
"to",
"infer",
"the",
"geometry",
"only",
"if",
"exactly",
"one",
"of",
"sites",
"sites_csv",
"hazard_curves_csv",
"gmfs_csv",
"region",
"is",
"set",
".",
"You",
"did",
"set",
"more",
"than",
"one",
"or",
"nothing",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L595-L622 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.is_valid_poes | def is_valid_poes(self):
"""
When computing hazard maps and/or uniform hazard spectra,
the poes list must be non-empty.
"""
if self.hazard_maps or self.uniform_hazard_spectra:
return bool(self.poes)
else:
return True | python | def is_valid_poes(self):
"""
When computing hazard maps and/or uniform hazard spectra,
the poes list must be non-empty.
"""
if self.hazard_maps or self.uniform_hazard_spectra:
return bool(self.poes)
else:
return True | [
"def",
"is_valid_poes",
"(",
"self",
")",
":",
"if",
"self",
".",
"hazard_maps",
"or",
"self",
".",
"uniform_hazard_spectra",
":",
"return",
"bool",
"(",
"self",
".",
"poes",
")",
"else",
":",
"return",
"True"
] | When computing hazard maps and/or uniform hazard spectra,
the poes list must be non-empty. | [
"When",
"computing",
"hazard",
"maps",
"and",
"/",
"or",
"uniform",
"hazard",
"spectra",
"the",
"poes",
"list",
"must",
"be",
"non",
"-",
"empty",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L624-L632 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.is_valid_maximum_distance | def is_valid_maximum_distance(self):
"""
Invalid maximum_distance={maximum_distance}: {error}
"""
if 'gsim_logic_tree' not in self.inputs:
return True # don't apply validation
gsim_lt = self.inputs['gsim_logic_tree']
trts = set(self.maximum_distance)
... | python | def is_valid_maximum_distance(self):
"""
Invalid maximum_distance={maximum_distance}: {error}
"""
if 'gsim_logic_tree' not in self.inputs:
return True # don't apply validation
gsim_lt = self.inputs['gsim_logic_tree']
trts = set(self.maximum_distance)
... | [
"def",
"is_valid_maximum_distance",
"(",
"self",
")",
":",
"if",
"'gsim_logic_tree'",
"not",
"in",
"self",
".",
"inputs",
":",
"return",
"True",
"# don't apply validation",
"gsim_lt",
"=",
"self",
".",
"inputs",
"[",
"'gsim_logic_tree'",
"]",
"trts",
"=",
"set",... | Invalid maximum_distance={maximum_distance}: {error} | [
"Invalid",
"maximum_distance",
"=",
"{",
"maximum_distance",
"}",
":",
"{",
"error",
"}"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L634-L658 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.is_valid_intensity_measure_types | def is_valid_intensity_measure_types(self):
"""
If the IMTs and levels are extracted from the risk models,
they must not be set directly. Moreover, if
`intensity_measure_types_and_levels` is set directly,
`intensity_measure_types` must not be set.
"""
if self.grou... | python | def is_valid_intensity_measure_types(self):
"""
If the IMTs and levels are extracted from the risk models,
they must not be set directly. Moreover, if
`intensity_measure_types_and_levels` is set directly,
`intensity_measure_types` must not be set.
"""
if self.grou... | [
"def",
"is_valid_intensity_measure_types",
"(",
"self",
")",
":",
"if",
"self",
".",
"ground_motion_correlation_model",
":",
"for",
"imt",
"in",
"self",
".",
"imtls",
":",
"if",
"not",
"(",
"imt",
".",
"startswith",
"(",
"'SA'",
")",
"or",
"imt",
"==",
"'P... | If the IMTs and levels are extracted from the risk models,
they must not be set directly. Moreover, if
`intensity_measure_types_and_levels` is set directly,
`intensity_measure_types` must not be set. | [
"If",
"the",
"IMTs",
"and",
"levels",
"are",
"extracted",
"from",
"the",
"risk",
"models",
"they",
"must",
"not",
"be",
"set",
"directly",
".",
"Moreover",
"if",
"intensity_measure_types_and_levels",
"is",
"set",
"directly",
"intensity_measure_types",
"must",
"not... | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L660-L679 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.is_valid_intensity_measure_levels | def is_valid_intensity_measure_levels(self):
"""
In order to compute hazard curves, `intensity_measure_types_and_levels`
must be set or extracted from the risk models.
"""
invalid = self.no_imls() and not self.risk_files and (
self.hazard_curves_from_gmfs or self.calc... | python | def is_valid_intensity_measure_levels(self):
"""
In order to compute hazard curves, `intensity_measure_types_and_levels`
must be set or extracted from the risk models.
"""
invalid = self.no_imls() and not self.risk_files and (
self.hazard_curves_from_gmfs or self.calc... | [
"def",
"is_valid_intensity_measure_levels",
"(",
"self",
")",
":",
"invalid",
"=",
"self",
".",
"no_imls",
"(",
")",
"and",
"not",
"self",
".",
"risk_files",
"and",
"(",
"self",
".",
"hazard_curves_from_gmfs",
"or",
"self",
".",
"calculation_mode",
"in",
"(",
... | In order to compute hazard curves, `intensity_measure_types_and_levels`
must be set or extracted from the risk models. | [
"In",
"order",
"to",
"compute",
"hazard",
"curves",
"intensity_measure_types_and_levels",
"must",
"be",
"set",
"or",
"extracted",
"from",
"the",
"risk",
"models",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L681-L689 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.is_valid_export_dir | def is_valid_export_dir(self):
"""
export_dir={export_dir} must refer to a directory,
and the user must have the permission to write on it.
"""
if self.export_dir and not os.path.isabs(self.export_dir):
self.export_dir = os.path.normpath(
os.path.join(... | python | def is_valid_export_dir(self):
"""
export_dir={export_dir} must refer to a directory,
and the user must have the permission to write on it.
"""
if self.export_dir and not os.path.isabs(self.export_dir):
self.export_dir = os.path.normpath(
os.path.join(... | [
"def",
"is_valid_export_dir",
"(",
"self",
")",
":",
"if",
"self",
".",
"export_dir",
"and",
"not",
"os",
".",
"path",
".",
"isabs",
"(",
"self",
".",
"export_dir",
")",
":",
"self",
".",
"export_dir",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"o... | export_dir={export_dir} must refer to a directory,
and the user must have the permission to write on it. | [
"export_dir",
"=",
"{",
"export_dir",
"}",
"must",
"refer",
"to",
"a",
"directory",
"and",
"the",
"user",
"must",
"have",
"the",
"permission",
"to",
"write",
"on",
"it",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L711-L731 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.is_valid_sites | def is_valid_sites(self):
"""
The sites are overdetermined
"""
if 'site_model' in self.inputs and 'sites' in self.inputs:
return False
elif 'site_model' in self.inputs and self.sites:
return False
elif 'sites' in self.inputs and self.sites:
... | python | def is_valid_sites(self):
"""
The sites are overdetermined
"""
if 'site_model' in self.inputs and 'sites' in self.inputs:
return False
elif 'site_model' in self.inputs and self.sites:
return False
elif 'sites' in self.inputs and self.sites:
... | [
"def",
"is_valid_sites",
"(",
"self",
")",
":",
"if",
"'site_model'",
"in",
"self",
".",
"inputs",
"and",
"'sites'",
"in",
"self",
".",
"inputs",
":",
"return",
"False",
"elif",
"'site_model'",
"in",
"self",
".",
"inputs",
"and",
"self",
".",
"sites",
":... | The sites are overdetermined | [
"The",
"sites",
"are",
"overdetermined"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L733-L746 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.is_valid_complex_fault_mesh_spacing | def is_valid_complex_fault_mesh_spacing(self):
"""
The `complex_fault_mesh_spacing` parameter can be None only if
`rupture_mesh_spacing` is set. In that case it is identified with it.
"""
rms = getattr(self, 'rupture_mesh_spacing', None)
if rms and not getattr(self, 'comp... | python | def is_valid_complex_fault_mesh_spacing(self):
"""
The `complex_fault_mesh_spacing` parameter can be None only if
`rupture_mesh_spacing` is set. In that case it is identified with it.
"""
rms = getattr(self, 'rupture_mesh_spacing', None)
if rms and not getattr(self, 'comp... | [
"def",
"is_valid_complex_fault_mesh_spacing",
"(",
"self",
")",
":",
"rms",
"=",
"getattr",
"(",
"self",
",",
"'rupture_mesh_spacing'",
",",
"None",
")",
"if",
"rms",
"and",
"not",
"getattr",
"(",
"self",
",",
"'complex_fault_mesh_spacing'",
",",
"None",
")",
... | The `complex_fault_mesh_spacing` parameter can be None only if
`rupture_mesh_spacing` is set. In that case it is identified with it. | [
"The",
"complex_fault_mesh_spacing",
"parameter",
"can",
"be",
"None",
"only",
"if",
"rupture_mesh_spacing",
"is",
"set",
".",
"In",
"that",
"case",
"it",
"is",
"identified",
"with",
"it",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L748-L756 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.is_valid_optimize_same_id_sources | def is_valid_optimize_same_id_sources(self):
"""
The `optimize_same_id_sources` can be true only in the classical
calculators.
"""
if (self.optimize_same_id_sources and
'classical' in self.calculation_mode or
'disagg' in self.calculation_mode):
... | python | def is_valid_optimize_same_id_sources(self):
"""
The `optimize_same_id_sources` can be true only in the classical
calculators.
"""
if (self.optimize_same_id_sources and
'classical' in self.calculation_mode or
'disagg' in self.calculation_mode):
... | [
"def",
"is_valid_optimize_same_id_sources",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"optimize_same_id_sources",
"and",
"'classical'",
"in",
"self",
".",
"calculation_mode",
"or",
"'disagg'",
"in",
"self",
".",
"calculation_mode",
")",
":",
"return",
"True",... | The `optimize_same_id_sources` can be true only in the classical
calculators. | [
"The",
"optimize_same_id_sources",
"can",
"be",
"true",
"only",
"in",
"the",
"classical",
"calculators",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L758-L770 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.check_missing | def check_missing(self, param, action):
"""
Make sure the given parameter is missing in the job.ini file
"""
assert action in ('debug', 'info', 'warn', 'error'), action
if self.inputs.get(param):
msg = '%s_file in %s is ignored in %s' % (
param, self.i... | python | def check_missing(self, param, action):
"""
Make sure the given parameter is missing in the job.ini file
"""
assert action in ('debug', 'info', 'warn', 'error'), action
if self.inputs.get(param):
msg = '%s_file in %s is ignored in %s' % (
param, self.i... | [
"def",
"check_missing",
"(",
"self",
",",
"param",
",",
"action",
")",
":",
"assert",
"action",
"in",
"(",
"'debug'",
",",
"'info'",
",",
"'warn'",
",",
"'error'",
")",
",",
"action",
"if",
"self",
".",
"inputs",
".",
"get",
"(",
"param",
")",
":",
... | Make sure the given parameter is missing in the job.ini file | [
"Make",
"sure",
"the",
"given",
"parameter",
"is",
"missing",
"in",
"the",
"job",
".",
"ini",
"file"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L795-L806 |
gem/oq-engine | openquake/commonlib/oqvalidation.py | OqParam.hazard_precomputed | def hazard_precomputed(self):
"""
:returns: True if the hazard is precomputed
"""
if 'gmfs' in self.inputs or 'hazard_curves' in self.inputs:
return True
elif self.hazard_calculation_id:
parent = list(util.read(self.hazard_calculation_id))
retu... | python | def hazard_precomputed(self):
"""
:returns: True if the hazard is precomputed
"""
if 'gmfs' in self.inputs or 'hazard_curves' in self.inputs:
return True
elif self.hazard_calculation_id:
parent = list(util.read(self.hazard_calculation_id))
retu... | [
"def",
"hazard_precomputed",
"(",
"self",
")",
":",
"if",
"'gmfs'",
"in",
"self",
".",
"inputs",
"or",
"'hazard_curves'",
"in",
"self",
".",
"inputs",
":",
"return",
"True",
"elif",
"self",
".",
"hazard_calculation_id",
":",
"parent",
"=",
"list",
"(",
"ut... | :returns: True if the hazard is precomputed | [
":",
"returns",
":",
"True",
"if",
"the",
"hazard",
"is",
"precomputed"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L808-L816 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | get_set_num_ruptures | def get_set_num_ruptures(src):
"""
Extract the number of ruptures and set it
"""
if not src.num_ruptures:
t0 = time.time()
src.num_ruptures = src.count_ruptures()
dt = time.time() - t0
clsname = src.__class__.__name__
if dt > 10:
if 'Area' in clsname:
... | python | def get_set_num_ruptures(src):
"""
Extract the number of ruptures and set it
"""
if not src.num_ruptures:
t0 = time.time()
src.num_ruptures = src.count_ruptures()
dt = time.time() - t0
clsname = src.__class__.__name__
if dt > 10:
if 'Area' in clsname:
... | [
"def",
"get_set_num_ruptures",
"(",
"src",
")",
":",
"if",
"not",
"src",
".",
"num_ruptures",
":",
"t0",
"=",
"time",
".",
"time",
"(",
")",
"src",
".",
"num_ruptures",
"=",
"src",
".",
"count_ruptures",
"(",
")",
"dt",
"=",
"time",
".",
"time",
"(",... | Extract the number of ruptures and set it | [
"Extract",
"the",
"number",
"of",
"ruptures",
"and",
"set",
"it"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L238-L263 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | split_coords_2d | def split_coords_2d(seq):
"""
:param seq: a flat list with lons and lats
:returns: a validated list of pairs (lon, lat)
>>> split_coords_2d([1.1, 2.1, 2.2, 2.3])
[(1.1, 2.1), (2.2, 2.3)]
"""
lons, lats = [], []
for i, el in enumerate(seq):
if i % 2 == 0:
lons.append(... | python | def split_coords_2d(seq):
"""
:param seq: a flat list with lons and lats
:returns: a validated list of pairs (lon, lat)
>>> split_coords_2d([1.1, 2.1, 2.2, 2.3])
[(1.1, 2.1), (2.2, 2.3)]
"""
lons, lats = [], []
for i, el in enumerate(seq):
if i % 2 == 0:
lons.append(... | [
"def",
"split_coords_2d",
"(",
"seq",
")",
":",
"lons",
",",
"lats",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"i",
",",
"el",
"in",
"enumerate",
"(",
"seq",
")",
":",
"if",
"i",
"%",
"2",
"==",
"0",
":",
"lons",
".",
"append",
"(",
"valid",
".",
... | :param seq: a flat list with lons and lats
:returns: a validated list of pairs (lon, lat)
>>> split_coords_2d([1.1, 2.1, 2.2, 2.3])
[(1.1, 2.1), (2.2, 2.3)] | [
":",
"param",
"seq",
":",
"a",
"flat",
"list",
"with",
"lons",
"and",
"lats",
":",
"returns",
":",
"a",
"validated",
"list",
"of",
"pairs",
"(",
"lon",
"lat",
")"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L266-L280 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | split_coords_3d | def split_coords_3d(seq):
"""
:param seq: a flat list with lons, lats and depths
:returns: a validated list of (lon, lat, depths) triplets
>>> split_coords_3d([1.1, 2.1, 0.1, 2.3, 2.4, 0.1])
[(1.1, 2.1, 0.1), (2.3, 2.4, 0.1)]
"""
lons, lats, depths = [], [], []
for i, el in enumerate(se... | python | def split_coords_3d(seq):
"""
:param seq: a flat list with lons, lats and depths
:returns: a validated list of (lon, lat, depths) triplets
>>> split_coords_3d([1.1, 2.1, 0.1, 2.3, 2.4, 0.1])
[(1.1, 2.1, 0.1), (2.3, 2.4, 0.1)]
"""
lons, lats, depths = [], [], []
for i, el in enumerate(se... | [
"def",
"split_coords_3d",
"(",
"seq",
")",
":",
"lons",
",",
"lats",
",",
"depths",
"=",
"[",
"]",
",",
"[",
"]",
",",
"[",
"]",
"for",
"i",
",",
"el",
"in",
"enumerate",
"(",
"seq",
")",
":",
"if",
"i",
"%",
"3",
"==",
"0",
":",
"lons",
".... | :param seq: a flat list with lons, lats and depths
:returns: a validated list of (lon, lat, depths) triplets
>>> split_coords_3d([1.1, 2.1, 0.1, 2.3, 2.4, 0.1])
[(1.1, 2.1, 0.1), (2.3, 2.4, 0.1)] | [
":",
"param",
"seq",
":",
"a",
"flat",
"list",
"with",
"lons",
"lats",
"and",
"depths",
":",
"returns",
":",
"a",
"validated",
"list",
"of",
"(",
"lon",
"lat",
"depths",
")",
"triplets"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L283-L299 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | dists | def dists(node):
"""
:returns: hpdist, npdist and magScaleRel from the given pointSource node
"""
hd = tuple((node['probability'], node['depth'])
for node in node.hypoDepthDist)
npd = tuple(
((node['probability'], node['rake'], node['strike'], node['dip']))
for node in... | python | def dists(node):
"""
:returns: hpdist, npdist and magScaleRel from the given pointSource node
"""
hd = tuple((node['probability'], node['depth'])
for node in node.hypoDepthDist)
npd = tuple(
((node['probability'], node['rake'], node['strike'], node['dip']))
for node in... | [
"def",
"dists",
"(",
"node",
")",
":",
"hd",
"=",
"tuple",
"(",
"(",
"node",
"[",
"'probability'",
"]",
",",
"node",
"[",
"'depth'",
"]",
")",
"for",
"node",
"in",
"node",
".",
"hypoDepthDist",
")",
"npd",
"=",
"tuple",
"(",
"(",
"(",
"node",
"["... | :returns: hpdist, npdist and magScaleRel from the given pointSource node | [
":",
"returns",
":",
"hpdist",
"npdist",
"and",
"magScaleRel",
"from",
"the",
"given",
"pointSource",
"node"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L896-L905 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | mfds2multimfd | def mfds2multimfd(mfds):
"""
Convert a list of MFD nodes into a single MultiMFD node
"""
_, kind = mfds[0].tag.split('}')
node = Node('multiMFD', dict(kind=kind, size=len(mfds)))
lengths = None
for field in mfd.multi_mfd.ASSOC[kind][1:]:
alias = mfd.multi_mfd.ALIAS.get(field, field)
... | python | def mfds2multimfd(mfds):
"""
Convert a list of MFD nodes into a single MultiMFD node
"""
_, kind = mfds[0].tag.split('}')
node = Node('multiMFD', dict(kind=kind, size=len(mfds)))
lengths = None
for field in mfd.multi_mfd.ASSOC[kind][1:]:
alias = mfd.multi_mfd.ALIAS.get(field, field)
... | [
"def",
"mfds2multimfd",
"(",
"mfds",
")",
":",
"_",
",",
"kind",
"=",
"mfds",
"[",
"0",
"]",
".",
"tag",
".",
"split",
"(",
"'}'",
")",
"node",
"=",
"Node",
"(",
"'multiMFD'",
",",
"dict",
"(",
"kind",
"=",
"kind",
",",
"size",
"=",
"len",
"(",... | Convert a list of MFD nodes into a single MultiMFD node | [
"Convert",
"a",
"list",
"of",
"MFD",
"nodes",
"into",
"a",
"single",
"MultiMFD",
"node"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L918-L943 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | update_source_model | def update_source_model(sm_node, fname):
"""
:param sm_node: a sourceModel Node object containing sourceGroups
"""
i = 0
for group in sm_node:
if 'srcs_weights' in group.attrib:
raise InvalidFile('srcs_weights must be removed in %s' % fname)
if not group.tag.endswith('sou... | python | def update_source_model(sm_node, fname):
"""
:param sm_node: a sourceModel Node object containing sourceGroups
"""
i = 0
for group in sm_node:
if 'srcs_weights' in group.attrib:
raise InvalidFile('srcs_weights must be removed in %s' % fname)
if not group.tag.endswith('sou... | [
"def",
"update_source_model",
"(",
"sm_node",
",",
"fname",
")",
":",
"i",
"=",
"0",
"for",
"group",
"in",
"sm_node",
":",
"if",
"'srcs_weights'",
"in",
"group",
".",
"attrib",
":",
"raise",
"InvalidFile",
"(",
"'srcs_weights must be removed in %s'",
"%",
"fna... | :param sm_node: a sourceModel Node object containing sourceGroups | [
":",
"param",
"sm_node",
":",
"a",
"sourceModel",
"Node",
"object",
"containing",
"sourceGroups"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L988-L1012 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | to_python | def to_python(fname, converter):
"""
Convert a source model .hdf5 file into a :class:`SourceModel` object
"""
with hdf5.File(fname, 'r') as f:
source_model = f['/']
for sg in source_model:
for src in sg:
if hasattr(src, 'mfd'):
# multipoint source
... | python | def to_python(fname, converter):
"""
Convert a source model .hdf5 file into a :class:`SourceModel` object
"""
with hdf5.File(fname, 'r') as f:
source_model = f['/']
for sg in source_model:
for src in sg:
if hasattr(src, 'mfd'):
# multipoint source
... | [
"def",
"to_python",
"(",
"fname",
",",
"converter",
")",
":",
"with",
"hdf5",
".",
"File",
"(",
"fname",
",",
"'r'",
")",
"as",
"f",
":",
"source_model",
"=",
"f",
"[",
"'/'",
"]",
"for",
"sg",
"in",
"source_model",
":",
"for",
"src",
"in",
"sg",
... | Convert a source model .hdf5 file into a :class:`SourceModel` object | [
"Convert",
"a",
"source",
"model",
".",
"hdf5",
"file",
"into",
"a",
":",
"class",
":",
"SourceModel",
"object"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L1015-L1029 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | SourceGroup.collect | def collect(cls, sources):
"""
:param sources: dictionaries with a key 'tectonicRegion'
:returns: an ordered list of SourceGroup instances
"""
source_stats_dict = {}
for src in sources:
trt = src['tectonicRegion']
if trt not in source_stats_dict:
... | python | def collect(cls, sources):
"""
:param sources: dictionaries with a key 'tectonicRegion'
:returns: an ordered list of SourceGroup instances
"""
source_stats_dict = {}
for src in sources:
trt = src['tectonicRegion']
if trt not in source_stats_dict:
... | [
"def",
"collect",
"(",
"cls",
",",
"sources",
")",
":",
"source_stats_dict",
"=",
"{",
"}",
"for",
"src",
"in",
"sources",
":",
"trt",
"=",
"src",
"[",
"'tectonicRegion'",
"]",
"if",
"trt",
"not",
"in",
"source_stats_dict",
":",
"source_stats_dict",
"[",
... | :param sources: dictionaries with a key 'tectonicRegion'
:returns: an ordered list of SourceGroup instances | [
":",
"param",
"sources",
":",
"dictionaries",
"with",
"a",
"key",
"tectonicRegion",
":",
"returns",
":",
"an",
"ordered",
"list",
"of",
"SourceGroup",
"instances"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L80-L97 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | SourceGroup.update | def update(self, src):
"""
Update the attributes sources, min_mag, max_mag
according to the given source.
:param src:
an instance of :class:
`openquake.hazardlib.source.base.BaseSeismicSource`
"""
assert src.tectonic_region_type == self.trt, (
... | python | def update(self, src):
"""
Update the attributes sources, min_mag, max_mag
according to the given source.
:param src:
an instance of :class:
`openquake.hazardlib.source.base.BaseSeismicSource`
"""
assert src.tectonic_region_type == self.trt, (
... | [
"def",
"update",
"(",
"self",
",",
"src",
")",
":",
"assert",
"src",
".",
"tectonic_region_type",
"==",
"self",
".",
"trt",
",",
"(",
"src",
".",
"tectonic_region_type",
",",
"self",
".",
"trt",
")",
"if",
"not",
"src",
".",
"min_mag",
":",
"# if not s... | Update the attributes sources, min_mag, max_mag
according to the given source.
:param src:
an instance of :class:
`openquake.hazardlib.source.base.BaseSeismicSource` | [
"Update",
"the",
"attributes",
"sources",
"min_mag",
"max_mag",
"according",
"to",
"the",
"given",
"source",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L159-L187 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | RuptureConverter.convert_node | def convert_node(self, node):
"""
Convert the given rupture node into a hazardlib rupture, depending
on the node tag.
:param node: a node representing a rupture
"""
convert = getattr(self, 'convert_' + striptag(node.tag))
return convert(node) | python | def convert_node(self, node):
"""
Convert the given rupture node into a hazardlib rupture, depending
on the node tag.
:param node: a node representing a rupture
"""
convert = getattr(self, 'convert_' + striptag(node.tag))
return convert(node) | [
"def",
"convert_node",
"(",
"self",
",",
"node",
")",
":",
"convert",
"=",
"getattr",
"(",
"self",
",",
"'convert_'",
"+",
"striptag",
"(",
"node",
".",
"tag",
")",
")",
"return",
"convert",
"(",
"node",
")"
] | Convert the given rupture node into a hazardlib rupture, depending
on the node tag.
:param node: a node representing a rupture | [
"Convert",
"the",
"given",
"rupture",
"node",
"into",
"a",
"hazardlib",
"rupture",
"depending",
"on",
"the",
"node",
"tag",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L321-L329 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | RuptureConverter.geo_line | def geo_line(self, edge):
"""
Utility function to convert a node of kind edge
into a :class:`openquake.hazardlib.geo.Line` instance.
:param edge: a node describing an edge
"""
with context(self.fname, edge.LineString.posList) as plist:
coords = split_coords_2... | python | def geo_line(self, edge):
"""
Utility function to convert a node of kind edge
into a :class:`openquake.hazardlib.geo.Line` instance.
:param edge: a node describing an edge
"""
with context(self.fname, edge.LineString.posList) as plist:
coords = split_coords_2... | [
"def",
"geo_line",
"(",
"self",
",",
"edge",
")",
":",
"with",
"context",
"(",
"self",
".",
"fname",
",",
"edge",
".",
"LineString",
".",
"posList",
")",
"as",
"plist",
":",
"coords",
"=",
"split_coords_2d",
"(",
"~",
"plist",
")",
"return",
"geo",
"... | Utility function to convert a node of kind edge
into a :class:`openquake.hazardlib.geo.Line` instance.
:param edge: a node describing an edge | [
"Utility",
"function",
"to",
"convert",
"a",
"node",
"of",
"kind",
"edge",
"into",
"a",
":",
"class",
":",
"openquake",
".",
"hazardlib",
".",
"geo",
".",
"Line",
"instance",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L331-L340 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | RuptureConverter.geo_lines | def geo_lines(self, edges):
"""
Utility function to convert a list of edges into a list of
:class:`openquake.hazardlib.geo.Line` instances.
:param edge: a node describing an edge
"""
lines = []
for edge in edges:
with context(self.fname, edge):
... | python | def geo_lines(self, edges):
"""
Utility function to convert a list of edges into a list of
:class:`openquake.hazardlib.geo.Line` instances.
:param edge: a node describing an edge
"""
lines = []
for edge in edges:
with context(self.fname, edge):
... | [
"def",
"geo_lines",
"(",
"self",
",",
"edges",
")",
":",
"lines",
"=",
"[",
"]",
"for",
"edge",
"in",
"edges",
":",
"with",
"context",
"(",
"self",
".",
"fname",
",",
"edge",
")",
":",
"coords",
"=",
"split_coords_3d",
"(",
"~",
"edge",
".",
"LineS... | Utility function to convert a list of edges into a list of
:class:`openquake.hazardlib.geo.Line` instances.
:param edge: a node describing an edge | [
"Utility",
"function",
"to",
"convert",
"a",
"list",
"of",
"edges",
"into",
"a",
"list",
"of",
":",
"class",
":",
"openquake",
".",
"hazardlib",
".",
"geo",
".",
"Line",
"instances",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L342-L354 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | RuptureConverter.geo_planar | def geo_planar(self, surface):
"""
Utility to convert a PlanarSurface node with subnodes
topLeft, topRight, bottomLeft, bottomRight into a
:class:`openquake.hazardlib.geo.PlanarSurface` instance.
:param surface: PlanarSurface node
"""
with context(self.fname, sur... | python | def geo_planar(self, surface):
"""
Utility to convert a PlanarSurface node with subnodes
topLeft, topRight, bottomLeft, bottomRight into a
:class:`openquake.hazardlib.geo.PlanarSurface` instance.
:param surface: PlanarSurface node
"""
with context(self.fname, sur... | [
"def",
"geo_planar",
"(",
"self",
",",
"surface",
")",
":",
"with",
"context",
"(",
"self",
".",
"fname",
",",
"surface",
")",
":",
"tl",
"=",
"surface",
".",
"topLeft",
"top_left",
"=",
"geo",
".",
"Point",
"(",
"tl",
"[",
"'lon'",
"]",
",",
"tl",... | Utility to convert a PlanarSurface node with subnodes
topLeft, topRight, bottomLeft, bottomRight into a
:class:`openquake.hazardlib.geo.PlanarSurface` instance.
:param surface: PlanarSurface node | [
"Utility",
"to",
"convert",
"a",
"PlanarSurface",
"node",
"with",
"subnodes",
"topLeft",
"topRight",
"bottomLeft",
"bottomRight",
"into",
"a",
":",
"class",
":",
"openquake",
".",
"hazardlib",
".",
"geo",
".",
"PlanarSurface",
"instance",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L356-L374 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | RuptureConverter.convert_surfaces | def convert_surfaces(self, surface_nodes):
"""
Utility to convert a list of surface nodes into a single hazardlib
surface. There are four possibilities:
1. there is a single simpleFaultGeometry node; returns a
:class:`openquake.hazardlib.geo.simpleFaultSurface` instance
... | python | def convert_surfaces(self, surface_nodes):
"""
Utility to convert a list of surface nodes into a single hazardlib
surface. There are four possibilities:
1. there is a single simpleFaultGeometry node; returns a
:class:`openquake.hazardlib.geo.simpleFaultSurface` instance
... | [
"def",
"convert_surfaces",
"(",
"self",
",",
"surface_nodes",
")",
":",
"surface_node",
"=",
"surface_nodes",
"[",
"0",
"]",
"if",
"surface_node",
".",
"tag",
".",
"endswith",
"(",
"'simpleFaultGeometry'",
")",
":",
"surface",
"=",
"geo",
".",
"SimpleFaultSurf... | Utility to convert a list of surface nodes into a single hazardlib
surface. There are four possibilities:
1. there is a single simpleFaultGeometry node; returns a
:class:`openquake.hazardlib.geo.simpleFaultSurface` instance
2. there is a single complexFaultGeometry node; returns a
... | [
"Utility",
"to",
"convert",
"a",
"list",
"of",
"surface",
"nodes",
"into",
"a",
"single",
"hazardlib",
"surface",
".",
"There",
"are",
"four",
"possibilities",
":"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L376-L412 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | RuptureConverter.convert_simpleFaultRupture | def convert_simpleFaultRupture(self, node):
"""
Convert a simpleFaultRupture node.
:param node: the rupture node
"""
mag, rake, hypocenter = self.get_mag_rake_hypo(node)
with context(self.fname, node):
surfaces = [node.simpleFaultGeometry]
rupt = sour... | python | def convert_simpleFaultRupture(self, node):
"""
Convert a simpleFaultRupture node.
:param node: the rupture node
"""
mag, rake, hypocenter = self.get_mag_rake_hypo(node)
with context(self.fname, node):
surfaces = [node.simpleFaultGeometry]
rupt = sour... | [
"def",
"convert_simpleFaultRupture",
"(",
"self",
",",
"node",
")",
":",
"mag",
",",
"rake",
",",
"hypocenter",
"=",
"self",
".",
"get_mag_rake_hypo",
"(",
"node",
")",
"with",
"context",
"(",
"self",
".",
"fname",
",",
"node",
")",
":",
"surfaces",
"=",... | Convert a simpleFaultRupture node.
:param node: the rupture node | [
"Convert",
"a",
"simpleFaultRupture",
"node",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L414-L427 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | RuptureConverter.convert_multiPlanesRupture | def convert_multiPlanesRupture(self, node):
"""
Convert a multiPlanesRupture node.
:param node: the rupture node
"""
mag, rake, hypocenter = self.get_mag_rake_hypo(node)
with context(self.fname, node):
surfaces = list(node.getnodes('planarSurface'))
r... | python | def convert_multiPlanesRupture(self, node):
"""
Convert a multiPlanesRupture node.
:param node: the rupture node
"""
mag, rake, hypocenter = self.get_mag_rake_hypo(node)
with context(self.fname, node):
surfaces = list(node.getnodes('planarSurface'))
r... | [
"def",
"convert_multiPlanesRupture",
"(",
"self",
",",
"node",
")",
":",
"mag",
",",
"rake",
",",
"hypocenter",
"=",
"self",
".",
"get_mag_rake_hypo",
"(",
"node",
")",
"with",
"context",
"(",
"self",
".",
"fname",
",",
"node",
")",
":",
"surfaces",
"=",... | Convert a multiPlanesRupture node.
:param node: the rupture node | [
"Convert",
"a",
"multiPlanesRupture",
"node",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L460-L474 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | RuptureConverter.convert_ruptureCollection | def convert_ruptureCollection(self, node):
"""
:param node: a ruptureCollection node
:returns: a dictionary grp_id -> EBRuptures
"""
coll = {}
for grpnode in node:
grp_id = int(grpnode['id'])
coll[grp_id] = ebrs = []
for node in grpnode... | python | def convert_ruptureCollection(self, node):
"""
:param node: a ruptureCollection node
:returns: a dictionary grp_id -> EBRuptures
"""
coll = {}
for grpnode in node:
grp_id = int(grpnode['id'])
coll[grp_id] = ebrs = []
for node in grpnode... | [
"def",
"convert_ruptureCollection",
"(",
"self",
",",
"node",
")",
":",
"coll",
"=",
"{",
"}",
"for",
"grpnode",
"in",
"node",
":",
"grp_id",
"=",
"int",
"(",
"grpnode",
"[",
"'id'",
"]",
")",
"coll",
"[",
"grp_id",
"]",
"=",
"ebrs",
"=",
"[",
"]",... | :param node: a ruptureCollection node
:returns: a dictionary grp_id -> EBRuptures | [
":",
"param",
"node",
":",
"a",
"ruptureCollection",
"node",
":",
"returns",
":",
"a",
"dictionary",
"grp_id",
"-",
">",
"EBRuptures"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L492-L511 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | SourceConverter.get_tom | def get_tom(self, node):
"""
Convert the given node into a Temporal Occurrence Model object.
:param node: a node of kind poissonTOM or brownianTOM
:returns: a :class:`openquake.hazardlib.mfd.EvenlyDiscretizedMFD.` or
:class:`openquake.hazardlib.mfd.TruncatedGRMFD` inst... | python | def get_tom(self, node):
"""
Convert the given node into a Temporal Occurrence Model object.
:param node: a node of kind poissonTOM or brownianTOM
:returns: a :class:`openquake.hazardlib.mfd.EvenlyDiscretizedMFD.` or
:class:`openquake.hazardlib.mfd.TruncatedGRMFD` inst... | [
"def",
"get_tom",
"(",
"self",
",",
"node",
")",
":",
"if",
"'tom'",
"in",
"node",
".",
"attrib",
":",
"tom_cls",
"=",
"tom",
".",
"registry",
"[",
"node",
"[",
"'tom'",
"]",
"]",
"else",
":",
"tom_cls",
"=",
"tom",
".",
"registry",
"[",
"'PoissonT... | Convert the given node into a Temporal Occurrence Model object.
:param node: a node of kind poissonTOM or brownianTOM
:returns: a :class:`openquake.hazardlib.mfd.EvenlyDiscretizedMFD.` or
:class:`openquake.hazardlib.mfd.TruncatedGRMFD` instance | [
"Convert",
"the",
"given",
"node",
"into",
"a",
"Temporal",
"Occurrence",
"Model",
"object",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L533-L546 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | SourceConverter.convert_mfdist | def convert_mfdist(self, node):
"""
Convert the given node into a Magnitude-Frequency Distribution
object.
:param node: a node of kind incrementalMFD or truncGutenbergRichterMFD
:returns: a :class:`openquake.hazardlib.mfd.EvenlyDiscretizedMFD.` or
:class:`openq... | python | def convert_mfdist(self, node):
"""
Convert the given node into a Magnitude-Frequency Distribution
object.
:param node: a node of kind incrementalMFD or truncGutenbergRichterMFD
:returns: a :class:`openquake.hazardlib.mfd.EvenlyDiscretizedMFD.` or
:class:`openq... | [
"def",
"convert_mfdist",
"(",
"self",
",",
"node",
")",
":",
"with",
"context",
"(",
"self",
".",
"fname",
",",
"node",
")",
":",
"[",
"mfd_node",
"]",
"=",
"[",
"subnode",
"for",
"subnode",
"in",
"node",
"if",
"subnode",
".",
"tag",
".",
"endswith",... | Convert the given node into a Magnitude-Frequency Distribution
object.
:param node: a node of kind incrementalMFD or truncGutenbergRichterMFD
:returns: a :class:`openquake.hazardlib.mfd.EvenlyDiscretizedMFD.` or
:class:`openquake.hazardlib.mfd.TruncatedGRMFD` instance | [
"Convert",
"the",
"given",
"node",
"into",
"a",
"Magnitude",
"-",
"Frequency",
"Distribution",
"object",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L548-L595 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | SourceConverter.convert_npdist | def convert_npdist(self, node):
"""
Convert the given node into a Nodal Plane Distribution.
:param node: a nodalPlaneDist node
:returns: a :class:`openquake.hazardlib.geo.NodalPlane` instance
"""
with context(self.fname, node):
npdist = []
for np ... | python | def convert_npdist(self, node):
"""
Convert the given node into a Nodal Plane Distribution.
:param node: a nodalPlaneDist node
:returns: a :class:`openquake.hazardlib.geo.NodalPlane` instance
"""
with context(self.fname, node):
npdist = []
for np ... | [
"def",
"convert_npdist",
"(",
"self",
",",
"node",
")",
":",
"with",
"context",
"(",
"self",
".",
"fname",
",",
"node",
")",
":",
"npdist",
"=",
"[",
"]",
"for",
"np",
"in",
"node",
".",
"nodalPlaneDist",
":",
"prob",
",",
"strike",
",",
"dip",
","... | Convert the given node into a Nodal Plane Distribution.
:param node: a nodalPlaneDist node
:returns: a :class:`openquake.hazardlib.geo.NodalPlane` instance | [
"Convert",
"the",
"given",
"node",
"into",
"a",
"Nodal",
"Plane",
"Distribution",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L597-L612 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | SourceConverter.convert_hpdist | def convert_hpdist(self, node):
"""
Convert the given node into a probability mass function for the
hypo depth distribution.
:param node: a hypoDepthDist node
:returns: a :class:`openquake.hazardlib.pmf.PMF` instance
"""
with context(self.fname, node):
... | python | def convert_hpdist(self, node):
"""
Convert the given node into a probability mass function for the
hypo depth distribution.
:param node: a hypoDepthDist node
:returns: a :class:`openquake.hazardlib.pmf.PMF` instance
"""
with context(self.fname, node):
... | [
"def",
"convert_hpdist",
"(",
"self",
",",
"node",
")",
":",
"with",
"context",
"(",
"self",
".",
"fname",
",",
"node",
")",
":",
"hcdist",
"=",
"[",
"(",
"hd",
"[",
"'probability'",
"]",
",",
"hd",
"[",
"'depth'",
"]",
")",
"for",
"hd",
"in",
"n... | Convert the given node into a probability mass function for the
hypo depth distribution.
:param node: a hypoDepthDist node
:returns: a :class:`openquake.hazardlib.pmf.PMF` instance | [
"Convert",
"the",
"given",
"node",
"into",
"a",
"probability",
"mass",
"function",
"for",
"the",
"hypo",
"depth",
"distribution",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L614-L627 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | SourceConverter.convert_areaSource | def convert_areaSource(self, node):
"""
Convert the given node into an area source object.
:param node: a node with tag areaGeometry
:returns: a :class:`openquake.hazardlib.source.AreaSource` instance
"""
geom = node.areaGeometry
coords = split_coords_2d(~geom.Po... | python | def convert_areaSource(self, node):
"""
Convert the given node into an area source object.
:param node: a node with tag areaGeometry
:returns: a :class:`openquake.hazardlib.source.AreaSource` instance
"""
geom = node.areaGeometry
coords = split_coords_2d(~geom.Po... | [
"def",
"convert_areaSource",
"(",
"self",
",",
"node",
")",
":",
"geom",
"=",
"node",
".",
"areaGeometry",
"coords",
"=",
"split_coords_2d",
"(",
"~",
"geom",
".",
"Polygon",
".",
"exterior",
".",
"LinearRing",
".",
"posList",
")",
"polygon",
"=",
"geo",
... | Convert the given node into an area source object.
:param node: a node with tag areaGeometry
:returns: a :class:`openquake.hazardlib.source.AreaSource` instance | [
"Convert",
"the",
"given",
"node",
"into",
"an",
"area",
"source",
"object",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L629-L661 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | SourceConverter.convert_pointSource | def convert_pointSource(self, node):
"""
Convert the given node into a point source object.
:param node: a node with tag pointGeometry
:returns: a :class:`openquake.hazardlib.source.PointSource` instance
"""
geom = node.pointGeometry
lon_lat = ~geom.Point.pos
... | python | def convert_pointSource(self, node):
"""
Convert the given node into a point source object.
:param node: a node with tag pointGeometry
:returns: a :class:`openquake.hazardlib.source.PointSource` instance
"""
geom = node.pointGeometry
lon_lat = ~geom.Point.pos
... | [
"def",
"convert_pointSource",
"(",
"self",
",",
"node",
")",
":",
"geom",
"=",
"node",
".",
"pointGeometry",
"lon_lat",
"=",
"~",
"geom",
".",
"Point",
".",
"pos",
"msr",
"=",
"valid",
".",
"SCALEREL",
"[",
"~",
"node",
".",
"magScaleRel",
"]",
"(",
... | Convert the given node into a point source object.
:param node: a node with tag pointGeometry
:returns: a :class:`openquake.hazardlib.source.PointSource` instance | [
"Convert",
"the",
"given",
"node",
"into",
"a",
"point",
"source",
"object",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L663-L686 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | SourceConverter.convert_multiPointSource | def convert_multiPointSource(self, node):
"""
Convert the given node into a MultiPointSource object.
:param node: a node with tag multiPointGeometry
:returns: a :class:`openquake.hazardlib.source.MultiPointSource`
"""
geom = node.multiPointGeometry
lons, lats = z... | python | def convert_multiPointSource(self, node):
"""
Convert the given node into a MultiPointSource object.
:param node: a node with tag multiPointGeometry
:returns: a :class:`openquake.hazardlib.source.MultiPointSource`
"""
geom = node.multiPointGeometry
lons, lats = z... | [
"def",
"convert_multiPointSource",
"(",
"self",
",",
"node",
")",
":",
"geom",
"=",
"node",
".",
"multiPointGeometry",
"lons",
",",
"lats",
"=",
"zip",
"(",
"*",
"split_coords_2d",
"(",
"~",
"geom",
".",
"posList",
")",
")",
"msr",
"=",
"valid",
".",
"... | Convert the given node into a MultiPointSource object.
:param node: a node with tag multiPointGeometry
:returns: a :class:`openquake.hazardlib.source.MultiPointSource` | [
"Convert",
"the",
"given",
"node",
"into",
"a",
"MultiPointSource",
"object",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L688-L710 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | SourceConverter.convert_simpleFaultSource | def convert_simpleFaultSource(self, node):
"""
Convert the given node into a simple fault object.
:param node: a node with tag areaGeometry
:returns: a :class:`openquake.hazardlib.source.SimpleFaultSource`
instance
"""
geom = node.simpleFaultGeometry
... | python | def convert_simpleFaultSource(self, node):
"""
Convert the given node into a simple fault object.
:param node: a node with tag areaGeometry
:returns: a :class:`openquake.hazardlib.source.SimpleFaultSource`
instance
"""
geom = node.simpleFaultGeometry
... | [
"def",
"convert_simpleFaultSource",
"(",
"self",
",",
"node",
")",
":",
"geom",
"=",
"node",
".",
"simpleFaultGeometry",
"msr",
"=",
"valid",
".",
"SCALEREL",
"[",
"~",
"node",
".",
"magScaleRel",
"]",
"(",
")",
"fault_trace",
"=",
"self",
".",
"geo_line",... | Convert the given node into a simple fault object.
:param node: a node with tag areaGeometry
:returns: a :class:`openquake.hazardlib.source.SimpleFaultSource`
instance | [
"Convert",
"the",
"given",
"node",
"into",
"a",
"simple",
"fault",
"object",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L712-L749 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | SourceConverter.convert_complexFaultSource | def convert_complexFaultSource(self, node):
"""
Convert the given node into a complex fault object.
:param node: a node with tag areaGeometry
:returns: a :class:`openquake.hazardlib.source.ComplexFaultSource`
instance
"""
geom = node.complexFaultGeometr... | python | def convert_complexFaultSource(self, node):
"""
Convert the given node into a complex fault object.
:param node: a node with tag areaGeometry
:returns: a :class:`openquake.hazardlib.source.ComplexFaultSource`
instance
"""
geom = node.complexFaultGeometr... | [
"def",
"convert_complexFaultSource",
"(",
"self",
",",
"node",
")",
":",
"geom",
"=",
"node",
".",
"complexFaultGeometry",
"edges",
"=",
"self",
".",
"geo_lines",
"(",
"geom",
")",
"mfd",
"=",
"self",
".",
"convert_mfdist",
"(",
"node",
")",
"msr",
"=",
... | Convert the given node into a complex fault object.
:param node: a node with tag areaGeometry
:returns: a :class:`openquake.hazardlib.source.ComplexFaultSource`
instance | [
"Convert",
"the",
"given",
"node",
"into",
"a",
"complex",
"fault",
"object",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L751-L775 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | SourceConverter.convert_characteristicFaultSource | def convert_characteristicFaultSource(self, node):
"""
Convert the given node into a characteristic fault object.
:param node:
a node with tag areaGeometry
:returns:
a :class:`openquake.hazardlib.source.CharacteristicFaultSource`
instance
"""
... | python | def convert_characteristicFaultSource(self, node):
"""
Convert the given node into a characteristic fault object.
:param node:
a node with tag areaGeometry
:returns:
a :class:`openquake.hazardlib.source.CharacteristicFaultSource`
instance
"""
... | [
"def",
"convert_characteristicFaultSource",
"(",
"self",
",",
"node",
")",
":",
"char",
"=",
"source",
".",
"CharacteristicFaultSource",
"(",
"source_id",
"=",
"node",
"[",
"'id'",
"]",
",",
"name",
"=",
"node",
"[",
"'name'",
"]",
",",
"tectonic_region_type",... | Convert the given node into a characteristic fault object.
:param node:
a node with tag areaGeometry
:returns:
a :class:`openquake.hazardlib.source.CharacteristicFaultSource`
instance | [
"Convert",
"the",
"given",
"node",
"into",
"a",
"characteristic",
"fault",
"object",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L777-L795 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | SourceConverter.convert_nonParametricSeismicSource | def convert_nonParametricSeismicSource(self, node):
"""
Convert the given node into a non parametric source object.
:param node:
a node with tag areaGeometry
:returns:
a :class:`openquake.hazardlib.source.NonParametricSeismicSource`
instance
"... | python | def convert_nonParametricSeismicSource(self, node):
"""
Convert the given node into a non parametric source object.
:param node:
a node with tag areaGeometry
:returns:
a :class:`openquake.hazardlib.source.NonParametricSeismicSource`
instance
"... | [
"def",
"convert_nonParametricSeismicSource",
"(",
"self",
",",
"node",
")",
":",
"trt",
"=",
"node",
".",
"attrib",
".",
"get",
"(",
"'tectonicRegion'",
")",
"rup_pmf_data",
"=",
"[",
"]",
"rups_weights",
"=",
"None",
"if",
"'rup_weights'",
"in",
"node",
"."... | Convert the given node into a non parametric source object.
:param node:
a node with tag areaGeometry
:returns:
a :class:`openquake.hazardlib.source.NonParametricSeismicSource`
instance | [
"Convert",
"the",
"given",
"node",
"into",
"a",
"non",
"parametric",
"source",
"object",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L797-L822 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | SourceConverter.convert_sourceGroup | def convert_sourceGroup(self, node):
"""
Convert the given node into a SourceGroup object.
:param node:
a node with tag sourceGroup
:returns:
a :class:`SourceGroup` instance
"""
trt = node['tectonicRegion']
srcs_weights = node.attrib.get('... | python | def convert_sourceGroup(self, node):
"""
Convert the given node into a SourceGroup object.
:param node:
a node with tag sourceGroup
:returns:
a :class:`SourceGroup` instance
"""
trt = node['tectonicRegion']
srcs_weights = node.attrib.get('... | [
"def",
"convert_sourceGroup",
"(",
"self",
",",
"node",
")",
":",
"trt",
"=",
"node",
"[",
"'tectonicRegion'",
"]",
"srcs_weights",
"=",
"node",
".",
"attrib",
".",
"get",
"(",
"'srcs_weights'",
")",
"grp_attrs",
"=",
"{",
"k",
":",
"v",
"for",
"k",
",... | Convert the given node into a SourceGroup object.
:param node:
a node with tag sourceGroup
:returns:
a :class:`SourceGroup` instance | [
"Convert",
"the",
"given",
"node",
"into",
"a",
"SourceGroup",
"object",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L827-L891 |
gem/oq-engine | openquake/hmtk/faults/tectonic_regionalisation.py | _check_list_weights | def _check_list_weights(parameter, name):
'''
Checks that the weights in a list of tuples sums to 1.0
'''
if not isinstance(parameter, list):
raise ValueError('%s must be formatted with a list of tuples' % name)
weight = np.sum([val[1] for val in parameter])
if fabs(weight - 1.) > 1E-8:
... | python | def _check_list_weights(parameter, name):
'''
Checks that the weights in a list of tuples sums to 1.0
'''
if not isinstance(parameter, list):
raise ValueError('%s must be formatted with a list of tuples' % name)
weight = np.sum([val[1] for val in parameter])
if fabs(weight - 1.) > 1E-8:
... | [
"def",
"_check_list_weights",
"(",
"parameter",
",",
"name",
")",
":",
"if",
"not",
"isinstance",
"(",
"parameter",
",",
"list",
")",
":",
"raise",
"ValueError",
"(",
"'%s must be formatted with a list of tuples'",
"%",
"name",
")",
"weight",
"=",
"np",
".",
"... | Checks that the weights in a list of tuples sums to 1.0 | [
"Checks",
"that",
"the",
"weights",
"in",
"a",
"list",
"of",
"tuples",
"sums",
"to",
"1",
".",
"0"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/tectonic_regionalisation.py#L63-L72 |
gem/oq-engine | openquake/hmtk/faults/tectonic_regionalisation.py | TectonicRegionalisation.populate_regions | def populate_regions(self, tectonic_region_dict):
'''
Populates the tectonic region from the list of dictionaries, where each
region is a dictionary of with the following format::
region = {'Shear_Modulus': [(val1, weight1), (val2, weight2), ...],
'Displacement_Lengt... | python | def populate_regions(self, tectonic_region_dict):
'''
Populates the tectonic region from the list of dictionaries, where each
region is a dictionary of with the following format::
region = {'Shear_Modulus': [(val1, weight1), (val2, weight2), ...],
'Displacement_Lengt... | [
"def",
"populate_regions",
"(",
"self",
",",
"tectonic_region_dict",
")",
":",
"for",
"tect_reg",
"in",
"tectonic_region_dict",
":",
"if",
"'Shear_Modulus'",
"in",
"tect_reg",
".",
"keys",
"(",
")",
":",
"shear_modulus",
"=",
"tect_reg",
"[",
"'Shear_Modulus'",
... | Populates the tectonic region from the list of dictionaries, where each
region is a dictionary of with the following format::
region = {'Shear_Modulus': [(val1, weight1), (val2, weight2), ...],
'Displacement_Length_Ratio': [(val1, weight1), ...],
'Magnitude_Scalin... | [
"Populates",
"the",
"tectonic",
"region",
"from",
"the",
"list",
"of",
"dictionaries",
"where",
"each",
"region",
"is",
"a",
"dictionary",
"of",
"with",
"the",
"following",
"format",
"::"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/tectonic_regionalisation.py#L111-L140 |
gem/oq-engine | openquake/hmtk/faults/active_fault_model.py | mtkActiveFaultModel.build_fault_model | def build_fault_model(self, collapse=False, rendered_msr=WC1994(),
mfd_config=None):
'''
Constructs a full fault model with epistemic uncertainty by
enumerating all the possible recurrence models of each fault as
separate faults, with the recurrence rates multip... | python | def build_fault_model(self, collapse=False, rendered_msr=WC1994(),
mfd_config=None):
'''
Constructs a full fault model with epistemic uncertainty by
enumerating all the possible recurrence models of each fault as
separate faults, with the recurrence rates multip... | [
"def",
"build_fault_model",
"(",
"self",
",",
"collapse",
"=",
"False",
",",
"rendered_msr",
"=",
"WC1994",
"(",
")",
",",
"mfd_config",
"=",
"None",
")",
":",
"self",
".",
"source_model",
"=",
"mtkSourceModel",
"(",
"self",
".",
"id",
",",
"self",
".",
... | Constructs a full fault model with epistemic uncertainty by
enumerating all the possible recurrence models of each fault as
separate faults, with the recurrence rates multiplied by the
corresponding weights.
:param bool collapse:
Determines whether or not to collapse the bra... | [
"Constructs",
"a",
"full",
"fault",
"model",
"with",
"epistemic",
"uncertainty",
"by",
"enumerating",
"all",
"the",
"possible",
"recurrence",
"models",
"of",
"each",
"fault",
"as",
"separate",
"faults",
"with",
"the",
"recurrence",
"rates",
"multiplied",
"by",
"... | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/active_fault_model.py#L94-L125 |
gem/oq-engine | openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py | _read_date_from_string | def _read_date_from_string(str1):
"""
Reads the date from a string in the format YYYY/MM/DD and returns
:class: datetime.date
"""
full_date = [int(x) for x in str1.split('/')]
return datetime.date(full_date[0], full_date[1], full_date[2]) | python | def _read_date_from_string(str1):
"""
Reads the date from a string in the format YYYY/MM/DD and returns
:class: datetime.date
"""
full_date = [int(x) for x in str1.split('/')]
return datetime.date(full_date[0], full_date[1], full_date[2]) | [
"def",
"_read_date_from_string",
"(",
"str1",
")",
":",
"full_date",
"=",
"[",
"int",
"(",
"x",
")",
"for",
"x",
"in",
"str1",
".",
"split",
"(",
"'/'",
")",
"]",
"return",
"datetime",
".",
"date",
"(",
"full_date",
"[",
"0",
"]",
",",
"full_date",
... | Reads the date from a string in the format YYYY/MM/DD and returns
:class: datetime.date | [
"Reads",
"the",
"date",
"from",
"a",
"string",
"in",
"the",
"format",
"YYYY",
"/",
"MM",
"/",
"DD",
"and",
"returns",
":",
"class",
":",
"datetime",
".",
"date"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py#L63-L69 |
gem/oq-engine | openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py | _read_time_from_string | def _read_time_from_string(str1):
"""
Reads the time from a string in the format HH:MM:SS.S and returns
:class: datetime.time
"""
full_time = [float(x) for x in str1.split(':')]
hour = int(full_time[0])
minute = int(full_time[1])
if full_time[2] > 59.99:
minute += 1
secon... | python | def _read_time_from_string(str1):
"""
Reads the time from a string in the format HH:MM:SS.S and returns
:class: datetime.time
"""
full_time = [float(x) for x in str1.split(':')]
hour = int(full_time[0])
minute = int(full_time[1])
if full_time[2] > 59.99:
minute += 1
secon... | [
"def",
"_read_time_from_string",
"(",
"str1",
")",
":",
"full_time",
"=",
"[",
"float",
"(",
"x",
")",
"for",
"x",
"in",
"str1",
".",
"split",
"(",
"':'",
")",
"]",
"hour",
"=",
"int",
"(",
"full_time",
"[",
"0",
"]",
")",
"minute",
"=",
"int",
"... | Reads the time from a string in the format HH:MM:SS.S and returns
:class: datetime.time | [
"Reads",
"the",
"time",
"from",
"a",
"string",
"in",
"the",
"format",
"HH",
":",
"MM",
":",
"SS",
".",
"S",
"and",
"returns",
":",
"class",
":",
"datetime",
".",
"time"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py#L72-L86 |
gem/oq-engine | openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py | _read_moment_tensor_from_ndk_string | def _read_moment_tensor_from_ndk_string(ndk_string, system='USE'):
"""
Reads the moment tensor from the ndk_string representation
ndk_string = [Mrr, sigMrr, Mtt, sigMtt, Mpp, sigMpp, Mrt, sigMrt, Mrp,
sigMrp, Mtp, sigMtp]
Output tensors should be of format:
expected = [[Mtt, Mt... | python | def _read_moment_tensor_from_ndk_string(ndk_string, system='USE'):
"""
Reads the moment tensor from the ndk_string representation
ndk_string = [Mrr, sigMrr, Mtt, sigMtt, Mpp, sigMpp, Mrt, sigMrt, Mrp,
sigMrp, Mtp, sigMtp]
Output tensors should be of format:
expected = [[Mtt, Mt... | [
"def",
"_read_moment_tensor_from_ndk_string",
"(",
"ndk_string",
",",
"system",
"=",
"'USE'",
")",
":",
"exponent",
"=",
"float",
"(",
"ndk_string",
"[",
"0",
":",
"2",
"]",
")",
"-",
"7.",
"mkr",
"=",
"np",
".",
"array",
"(",
"[",
"2",
",",
"9",
","... | Reads the moment tensor from the ndk_string representation
ndk_string = [Mrr, sigMrr, Mtt, sigMtt, Mpp, sigMpp, Mrt, sigMrt, Mrp,
sigMrp, Mtp, sigMtp]
Output tensors should be of format:
expected = [[Mtt, Mtp, Mtr],
[Mtp, Mpp, Mpr],
[Mtr, Mpr, Mr... | [
"Reads",
"the",
"moment",
"tensor",
"from",
"the",
"ndk_string",
"representation",
"ndk_string",
"=",
"[",
"Mrr",
"sigMrr",
"Mtt",
"sigMtt",
"Mpp",
"sigMpp",
"Mrt",
"sigMrt",
"Mrp",
"sigMrp",
"Mtp",
"sigMtp",
"]",
"Output",
"tensors",
"should",
"be",
"of",
"... | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py#L89-L129 |
gem/oq-engine | openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py | ParseNDKtoGCMT.read_file | def read_file(self, start_year=None, end_year=None, use_centroid=None):
"""
Reads the file
"""
raw_data = getlines(self.filename)
num_lines = len(raw_data)
if ((float(num_lines) / 5.) - float(num_lines / 5)) > 1E-9:
raise IOError('GCMT represented by 5 lines -... | python | def read_file(self, start_year=None, end_year=None, use_centroid=None):
"""
Reads the file
"""
raw_data = getlines(self.filename)
num_lines = len(raw_data)
if ((float(num_lines) / 5.) - float(num_lines / 5)) > 1E-9:
raise IOError('GCMT represented by 5 lines -... | [
"def",
"read_file",
"(",
"self",
",",
"start_year",
"=",
"None",
",",
"end_year",
"=",
"None",
",",
"use_centroid",
"=",
"None",
")",
":",
"raw_data",
"=",
"getlines",
"(",
"self",
".",
"filename",
")",
"num_lines",
"=",
"len",
"(",
"raw_data",
")",
"i... | Reads the file | [
"Reads",
"the",
"file"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py#L145-L176 |
gem/oq-engine | openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py | ParseNDKtoGCMT.read_ndk_event | def read_ndk_event(self, raw_data, id0):
"""
Reads a 5-line batch of data into a set of GCMTs
"""
gcmt = GCMTEvent()
# Get hypocentre
ndkstring = raw_data[id0].rstrip('\n')
gcmt.hypocentre = self._read_hypocentre_from_ndk_string(ndkstring)
# GCMT metadata... | python | def read_ndk_event(self, raw_data, id0):
"""
Reads a 5-line batch of data into a set of GCMTs
"""
gcmt = GCMTEvent()
# Get hypocentre
ndkstring = raw_data[id0].rstrip('\n')
gcmt.hypocentre = self._read_hypocentre_from_ndk_string(ndkstring)
# GCMT metadata... | [
"def",
"read_ndk_event",
"(",
"self",
",",
"raw_data",
",",
"id0",
")",
":",
"gcmt",
"=",
"GCMTEvent",
"(",
")",
"# Get hypocentre",
"ndkstring",
"=",
"raw_data",
"[",
"id0",
"]",
".",
"rstrip",
"(",
"'\\n'",
")",
"gcmt",
".",
"hypocentre",
"=",
"self",
... | Reads a 5-line batch of data into a set of GCMTs | [
"Reads",
"a",
"5",
"-",
"line",
"batch",
"of",
"data",
"into",
"a",
"set",
"of",
"GCMTs"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py#L178-L214 |
gem/oq-engine | openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py | ParseNDKtoGCMT.to_hmtk | def to_hmtk(self, use_centroid=True):
'''
Convert the content of the GCMT catalogue to a HMTK
catalogue.
'''
self._preallocate_data_dict()
for iloc, gcmt in enumerate(self.catalogue.gcmts):
self.catalogue.data['eventID'][iloc] = iloc
if use_centro... | python | def to_hmtk(self, use_centroid=True):
'''
Convert the content of the GCMT catalogue to a HMTK
catalogue.
'''
self._preallocate_data_dict()
for iloc, gcmt in enumerate(self.catalogue.gcmts):
self.catalogue.data['eventID'][iloc] = iloc
if use_centro... | [
"def",
"to_hmtk",
"(",
"self",
",",
"use_centroid",
"=",
"True",
")",
":",
"self",
".",
"_preallocate_data_dict",
"(",
")",
"for",
"iloc",
",",
"gcmt",
"in",
"enumerate",
"(",
"self",
".",
"catalogue",
".",
"gcmts",
")",
":",
"self",
".",
"catalogue",
... | Convert the content of the GCMT catalogue to a HMTK
catalogue. | [
"Convert",
"the",
"content",
"of",
"the",
"GCMT",
"catalogue",
"to",
"a",
"HMTK",
"catalogue",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py#L216-L301 |
gem/oq-engine | openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py | ParseNDKtoGCMT._read_hypocentre_from_ndk_string | def _read_hypocentre_from_ndk_string(self, linestring):
"""
Reads the hypocentre data from the ndk string to return an
instance of the GCMTHypocentre class
"""
hypo = GCMTHypocentre()
hypo.source = linestring[0:4]
hypo.date = _read_date_from_string(linestring[5:15... | python | def _read_hypocentre_from_ndk_string(self, linestring):
"""
Reads the hypocentre data from the ndk string to return an
instance of the GCMTHypocentre class
"""
hypo = GCMTHypocentre()
hypo.source = linestring[0:4]
hypo.date = _read_date_from_string(linestring[5:15... | [
"def",
"_read_hypocentre_from_ndk_string",
"(",
"self",
",",
"linestring",
")",
":",
"hypo",
"=",
"GCMTHypocentre",
"(",
")",
"hypo",
".",
"source",
"=",
"linestring",
"[",
"0",
":",
"4",
"]",
"hypo",
".",
"date",
"=",
"_read_date_from_string",
"(",
"linestr... | Reads the hypocentre data from the ndk string to return an
instance of the GCMTHypocentre class | [
"Reads",
"the",
"hypocentre",
"data",
"from",
"the",
"ndk",
"string",
"to",
"return",
"an",
"instance",
"of",
"the",
"GCMTHypocentre",
"class"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py#L315-L333 |
gem/oq-engine | openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py | ParseNDKtoGCMT._get_metadata_from_ndk_string | def _get_metadata_from_ndk_string(self, gcmt, ndk_string):
"""
Reads the GCMT metadata from line 2 of the ndk batch
"""
gcmt.identifier = ndk_string[:16]
inversion_data = re.split('[A-Z:]+', ndk_string[17:61])
gcmt.metadata['BODY'] = [float(x) for x in inversion_data[1].s... | python | def _get_metadata_from_ndk_string(self, gcmt, ndk_string):
"""
Reads the GCMT metadata from line 2 of the ndk batch
"""
gcmt.identifier = ndk_string[:16]
inversion_data = re.split('[A-Z:]+', ndk_string[17:61])
gcmt.metadata['BODY'] = [float(x) for x in inversion_data[1].s... | [
"def",
"_get_metadata_from_ndk_string",
"(",
"self",
",",
"gcmt",
",",
"ndk_string",
")",
":",
"gcmt",
".",
"identifier",
"=",
"ndk_string",
"[",
":",
"16",
"]",
"inversion_data",
"=",
"re",
".",
"split",
"(",
"'[A-Z:]+'",
",",
"ndk_string",
"[",
"17",
":"... | Reads the GCMT metadata from line 2 of the ndk batch | [
"Reads",
"the",
"GCMT",
"metadata",
"from",
"line",
"2",
"of",
"the",
"ndk",
"batch"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py#L335-L349 |
gem/oq-engine | openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py | ParseNDKtoGCMT._read_centroid_from_ndk_string | def _read_centroid_from_ndk_string(self, ndk_string, hypocentre):
"""
Reads the centroid data from the ndk string to return an
instance of the GCMTCentroid class
:param str ndk_string:
String of data (line 3 of ndk format)
:param hypocentre:
Instance of th... | python | def _read_centroid_from_ndk_string(self, ndk_string, hypocentre):
"""
Reads the centroid data from the ndk string to return an
instance of the GCMTCentroid class
:param str ndk_string:
String of data (line 3 of ndk format)
:param hypocentre:
Instance of th... | [
"def",
"_read_centroid_from_ndk_string",
"(",
"self",
",",
"ndk_string",
",",
"hypocentre",
")",
":",
"centroid",
"=",
"GCMTCentroid",
"(",
"hypocentre",
".",
"date",
",",
"hypocentre",
".",
"time",
")",
"data",
"=",
"ndk_string",
"[",
":",
"58",
"]",
".",
... | Reads the centroid data from the ndk string to return an
instance of the GCMTCentroid class
:param str ndk_string:
String of data (line 3 of ndk format)
:param hypocentre:
Instance of the GCMTHypocentre class | [
"Reads",
"the",
"centroid",
"data",
"from",
"the",
"ndk",
"string",
"to",
"return",
"an",
"instance",
"of",
"the",
"GCMTCentroid",
"class",
":",
"param",
"str",
"ndk_string",
":",
"String",
"of",
"data",
"(",
"line",
"3",
"of",
"ndk",
"format",
")",
":",... | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py#L351-L378 |
gem/oq-engine | openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py | ParseNDKtoGCMT._get_moment_tensor_from_ndk_string | def _get_moment_tensor_from_ndk_string(self, ndk_string):
"""
Reads the moment tensor from the ndk_string and returns an instance of
the GCMTMomentTensor class.
By default the ndk format uses the Up, South, East (USE) reference
system.
"""
moment_tensor = GCMTMome... | python | def _get_moment_tensor_from_ndk_string(self, ndk_string):
"""
Reads the moment tensor from the ndk_string and returns an instance of
the GCMTMomentTensor class.
By default the ndk format uses the Up, South, East (USE) reference
system.
"""
moment_tensor = GCMTMome... | [
"def",
"_get_moment_tensor_from_ndk_string",
"(",
"self",
",",
"ndk_string",
")",
":",
"moment_tensor",
"=",
"GCMTMomentTensor",
"(",
"'USE'",
")",
"tensor_data",
"=",
"_read_moment_tensor_from_ndk_string",
"(",
"ndk_string",
",",
"'USE'",
")",
"moment_tensor",
".",
"... | Reads the moment tensor from the ndk_string and returns an instance of
the GCMTMomentTensor class.
By default the ndk format uses the Up, South, East (USE) reference
system. | [
"Reads",
"the",
"moment",
"tensor",
"from",
"the",
"ndk_string",
"and",
"returns",
"an",
"instance",
"of",
"the",
"GCMTMomentTensor",
"class",
".",
"By",
"default",
"the",
"ndk",
"format",
"uses",
"the",
"Up",
"South",
"East",
"(",
"USE",
")",
"reference",
... | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py#L380-L392 |
gem/oq-engine | openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py | ParseNDKtoGCMT._get_principal_axes_from_ndk_string | def _get_principal_axes_from_ndk_string(self, ndk_string, exponent):
"""
Gets the principal axes from the ndk string and returns an instance
of the GCMTPrincipalAxes class
"""
axes = GCMTPrincipalAxes()
# The principal axes is defined in characters 3:48 of the 5th line
... | python | def _get_principal_axes_from_ndk_string(self, ndk_string, exponent):
"""
Gets the principal axes from the ndk string and returns an instance
of the GCMTPrincipalAxes class
"""
axes = GCMTPrincipalAxes()
# The principal axes is defined in characters 3:48 of the 5th line
... | [
"def",
"_get_principal_axes_from_ndk_string",
"(",
"self",
",",
"ndk_string",
",",
"exponent",
")",
":",
"axes",
"=",
"GCMTPrincipalAxes",
"(",
")",
"# The principal axes is defined in characters 3:48 of the 5th line",
"exponent",
"=",
"10.",
"**",
"exponent",
"axes",
"."... | Gets the principal axes from the ndk string and returns an instance
of the GCMTPrincipalAxes class | [
"Gets",
"the",
"principal",
"axes",
"from",
"the",
"ndk",
"string",
"and",
"returns",
"an",
"instance",
"of",
"the",
"GCMTPrincipalAxes",
"class"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py#L394-L413 |
gem/oq-engine | openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py | ParseNDKtoGCMT._get_nodal_planes_from_ndk_string | def _get_nodal_planes_from_ndk_string(self, ndk_string):
"""
Reads the nodal plane information (represented by 5th line [57:] of the
tensor representation) and returns an instance of the GCMTNodalPlanes
class
"""
planes = GCMTNodalPlanes()
planes.nodal_plane_1 = {... | python | def _get_nodal_planes_from_ndk_string(self, ndk_string):
"""
Reads the nodal plane information (represented by 5th line [57:] of the
tensor representation) and returns an instance of the GCMTNodalPlanes
class
"""
planes = GCMTNodalPlanes()
planes.nodal_plane_1 = {... | [
"def",
"_get_nodal_planes_from_ndk_string",
"(",
"self",
",",
"ndk_string",
")",
":",
"planes",
"=",
"GCMTNodalPlanes",
"(",
")",
"planes",
".",
"nodal_plane_1",
"=",
"{",
"'strike'",
":",
"float",
"(",
"ndk_string",
"[",
"0",
":",
"3",
"]",
")",
",",
"'di... | Reads the nodal plane information (represented by 5th line [57:] of the
tensor representation) and returns an instance of the GCMTNodalPlanes
class | [
"Reads",
"the",
"nodal",
"plane",
"information",
"(",
"represented",
"by",
"5th",
"line",
"[",
"57",
":",
"]",
"of",
"the",
"tensor",
"representation",
")",
"and",
"returns",
"an",
"instance",
"of",
"the",
"GCMTNodalPlanes",
"class"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py#L415-L428 |
gem/oq-engine | openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py | ParseNDKtoGCMT._get_moment_from_ndk_string | def _get_moment_from_ndk_string(self, ndk_string, exponent):
"""
Returns the moment and the moment magnitude
"""
moment = float(ndk_string[49:56]) * (10. ** exponent)
version = ndk_string[:3]
magnitude = utils.moment_magnitude_scalar(moment)
return moment, version... | python | def _get_moment_from_ndk_string(self, ndk_string, exponent):
"""
Returns the moment and the moment magnitude
"""
moment = float(ndk_string[49:56]) * (10. ** exponent)
version = ndk_string[:3]
magnitude = utils.moment_magnitude_scalar(moment)
return moment, version... | [
"def",
"_get_moment_from_ndk_string",
"(",
"self",
",",
"ndk_string",
",",
"exponent",
")",
":",
"moment",
"=",
"float",
"(",
"ndk_string",
"[",
"49",
":",
"56",
"]",
")",
"*",
"(",
"10.",
"**",
"exponent",
")",
"version",
"=",
"ndk_string",
"[",
":",
... | Returns the moment and the moment magnitude | [
"Returns",
"the",
"moment",
"and",
"the",
"moment",
"magnitude"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py#L430-L437 |
gem/oq-engine | openquake/hmtk/sources/source_model.py | mtkSourceModel.serialise_to_nrml | def serialise_to_nrml(self, filename, use_defaults=False):
'''
Writes the source model to a nrml source model file given by the
filename
:param str filename:
Path to output file
:param bool use_defaults:
Boolean to indicate whether to use default values ... | python | def serialise_to_nrml(self, filename, use_defaults=False):
'''
Writes the source model to a nrml source model file given by the
filename
:param str filename:
Path to output file
:param bool use_defaults:
Boolean to indicate whether to use default values ... | [
"def",
"serialise_to_nrml",
"(",
"self",
",",
"filename",
",",
"use_defaults",
"=",
"False",
")",
":",
"source_model",
"=",
"self",
".",
"convert_to_oqhazardlib",
"(",
"PoissonTOM",
"(",
"1.0",
")",
",",
"2.0",
",",
"2.0",
",",
"10.0",
",",
"use_defaults",
... | Writes the source model to a nrml source model file given by the
filename
:param str filename:
Path to output file
:param bool use_defaults:
Boolean to indicate whether to use default values (True) or not.
If set to False, ValueErrors will be raised when an ... | [
"Writes",
"the",
"source",
"model",
"to",
"a",
"nrml",
"source",
"model",
"file",
"given",
"by",
"the",
"filename"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/sources/source_model.py#L95-L110 |
gem/oq-engine | openquake/hmtk/sources/source_model.py | mtkSourceModel.convert_to_oqhazardlib | def convert_to_oqhazardlib(
self, tom, simple_mesh_spacing=1.0,
complex_mesh_spacing=2.0, area_discretisation=10.0,
use_defaults=False):
"""
Converts the source model to an iterator of sources of :class:
openquake.hazardlib.source.base.BaseSeismicSource
... | python | def convert_to_oqhazardlib(
self, tom, simple_mesh_spacing=1.0,
complex_mesh_spacing=2.0, area_discretisation=10.0,
use_defaults=False):
"""
Converts the source model to an iterator of sources of :class:
openquake.hazardlib.source.base.BaseSeismicSource
... | [
"def",
"convert_to_oqhazardlib",
"(",
"self",
",",
"tom",
",",
"simple_mesh_spacing",
"=",
"1.0",
",",
"complex_mesh_spacing",
"=",
"2.0",
",",
"area_discretisation",
"=",
"10.0",
",",
"use_defaults",
"=",
"False",
")",
":",
"oq_source_model",
"=",
"[",
"]",
"... | Converts the source model to an iterator of sources of :class:
openquake.hazardlib.source.base.BaseSeismicSource | [
"Converts",
"the",
"source",
"model",
"to",
"an",
"iterator",
"of",
"sources",
"of",
":",
"class",
":",
"openquake",
".",
"hazardlib",
".",
"source",
".",
"base",
".",
"BaseSeismicSource"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/sources/source_model.py#L112-L145 |
gem/oq-engine | openquake/hmtk/seismicity/occurrence/utils.py | recurrence_table | def recurrence_table(mag, dmag, year, time_interval=None):
"""
Table of recurrence statistics for each magnitude
[Magnitude, Number of Observations, Cumulative Number
of Observations >= M, Number of Observations
(normalised to annual value), Cumulative Number of
Observations (normalised to annua... | python | def recurrence_table(mag, dmag, year, time_interval=None):
"""
Table of recurrence statistics for each magnitude
[Magnitude, Number of Observations, Cumulative Number
of Observations >= M, Number of Observations
(normalised to annual value), Cumulative Number of
Observations (normalised to annua... | [
"def",
"recurrence_table",
"(",
"mag",
",",
"dmag",
",",
"year",
",",
"time_interval",
"=",
"None",
")",
":",
"# Define magnitude vectors",
"if",
"time_interval",
"is",
"None",
":",
"num_year",
"=",
"np",
".",
"max",
"(",
"year",
")",
"-",
"np",
".",
"mi... | Table of recurrence statistics for each magnitude
[Magnitude, Number of Observations, Cumulative Number
of Observations >= M, Number of Observations
(normalised to annual value), Cumulative Number of
Observations (normalised to annual value)]
Counts number and cumulative number of occurrences of
... | [
"Table",
"of",
"recurrence",
"statistics",
"for",
"each",
"magnitude",
"[",
"Magnitude",
"Number",
"of",
"Observations",
"Cumulative",
"Number",
"of",
"Observations",
">",
"=",
"M",
"Number",
"of",
"Observations",
"(",
"normalised",
"to",
"annual",
"value",
")",... | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/occurrence/utils.py#L54-L97 |
gem/oq-engine | openquake/hmtk/seismicity/occurrence/utils.py | input_checks | def input_checks(catalogue, config, completeness):
""" Performs a basic set of input checks on the data
"""
if isinstance(completeness, np.ndarray):
# completeness table is a numpy array (i.e. [year, magnitude])
if np.shape(completeness)[1] != 2:
raise ValueError('Completeness T... | python | def input_checks(catalogue, config, completeness):
""" Performs a basic set of input checks on the data
"""
if isinstance(completeness, np.ndarray):
# completeness table is a numpy array (i.e. [year, magnitude])
if np.shape(completeness)[1] != 2:
raise ValueError('Completeness T... | [
"def",
"input_checks",
"(",
"catalogue",
",",
"config",
",",
"completeness",
")",
":",
"if",
"isinstance",
"(",
"completeness",
",",
"np",
".",
"ndarray",
")",
":",
"# completeness table is a numpy array (i.e. [year, magnitude])",
"if",
"np",
".",
"shape",
"(",
"c... | Performs a basic set of input checks on the data | [
"Performs",
"a",
"basic",
"set",
"of",
"input",
"checks",
"on",
"the",
"data"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/occurrence/utils.py#L100-L142 |
gem/oq-engine | openquake/hmtk/seismicity/occurrence/utils.py | generate_trunc_gr_magnitudes | def generate_trunc_gr_magnitudes(bval, mmin, mmax, nsamples):
'''
Generate a random list of magnitudes distributed according to a
truncated Gutenberg-Richter model
:param float bval:
b-value
:param float mmin:
Minimum Magnitude
:param float mmax:
Maximum Magnitude
:p... | python | def generate_trunc_gr_magnitudes(bval, mmin, mmax, nsamples):
'''
Generate a random list of magnitudes distributed according to a
truncated Gutenberg-Richter model
:param float bval:
b-value
:param float mmin:
Minimum Magnitude
:param float mmax:
Maximum Magnitude
:p... | [
"def",
"generate_trunc_gr_magnitudes",
"(",
"bval",
",",
"mmin",
",",
"mmax",
",",
"nsamples",
")",
":",
"sampler",
"=",
"np",
".",
"random",
".",
"uniform",
"(",
"0.",
",",
"1.",
",",
"nsamples",
")",
"beta",
"=",
"bval",
"*",
"np",
".",
"log",
"(",... | Generate a random list of magnitudes distributed according to a
truncated Gutenberg-Richter model
:param float bval:
b-value
:param float mmin:
Minimum Magnitude
:param float mmax:
Maximum Magnitude
:param int nsamples:
Number of samples
:returns:
Vector... | [
"Generate",
"a",
"random",
"list",
"of",
"magnitudes",
"distributed",
"according",
"to",
"a",
"truncated",
"Gutenberg",
"-",
"Richter",
"model"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/occurrence/utils.py#L145-L165 |
gem/oq-engine | openquake/hmtk/seismicity/occurrence/utils.py | generate_synthetic_magnitudes | def generate_synthetic_magnitudes(aval, bval, mmin, mmax, nyears):
'''
Generates a synthetic catalogue for a specified number of years, with
magnitudes distributed according to a truncated Gutenberg-Richter
distribution
:param float aval:
a-value
:param float bval:
b-value
:... | python | def generate_synthetic_magnitudes(aval, bval, mmin, mmax, nyears):
'''
Generates a synthetic catalogue for a specified number of years, with
magnitudes distributed according to a truncated Gutenberg-Richter
distribution
:param float aval:
a-value
:param float bval:
b-value
:... | [
"def",
"generate_synthetic_magnitudes",
"(",
"aval",
",",
"bval",
",",
"mmin",
",",
"mmax",
",",
"nyears",
")",
":",
"nsamples",
"=",
"int",
"(",
"np",
".",
"round",
"(",
"nyears",
"*",
"(",
"10.",
"**",
"(",
"aval",
"-",
"bval",
"*",
"mmin",
")",
... | Generates a synthetic catalogue for a specified number of years, with
magnitudes distributed according to a truncated Gutenberg-Richter
distribution
:param float aval:
a-value
:param float bval:
b-value
:param float mmin:
Minimum Magnitude
:param float mmax:
Maxi... | [
"Generates",
"a",
"synthetic",
"catalogue",
"for",
"a",
"specified",
"number",
"of",
"years",
"with",
"magnitudes",
"distributed",
"according",
"to",
"a",
"truncated",
"Gutenberg",
"-",
"Richter",
"distribution"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/occurrence/utils.py#L168-L191 |
gem/oq-engine | openquake/hmtk/seismicity/occurrence/utils.py | downsample_completeness_table | def downsample_completeness_table(comp_table, sample_width=0.1, mmax=None):
"""
Re-sample the completeness table to a specified sample_width
"""
new_comp_table = []
for i in range(comp_table.shape[0] - 1):
mvals = np.arange(comp_table[i, 1],
comp_table[i + 1, 1], d_... | python | def downsample_completeness_table(comp_table, sample_width=0.1, mmax=None):
"""
Re-sample the completeness table to a specified sample_width
"""
new_comp_table = []
for i in range(comp_table.shape[0] - 1):
mvals = np.arange(comp_table[i, 1],
comp_table[i + 1, 1], d_... | [
"def",
"downsample_completeness_table",
"(",
"comp_table",
",",
"sample_width",
"=",
"0.1",
",",
"mmax",
"=",
"None",
")",
":",
"new_comp_table",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"comp_table",
".",
"shape",
"[",
"0",
"]",
"-",
"1",
")",
"... | Re-sample the completeness table to a specified sample_width | [
"Re",
"-",
"sample",
"the",
"completeness",
"table",
"to",
"a",
"specified",
"sample_width"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/occurrence/utils.py#L194-L208 |
gem/oq-engine | openquake/hmtk/seismicity/occurrence/utils.py | get_completeness_counts | def get_completeness_counts(catalogue, completeness, d_m):
"""
Returns the number of earthquakes in a set of magnitude bins of specified
with, along with the corresponding completeness duration (in years) of the
bin
:param catalogue:
Earthquake catalogue as instance of
:class: openq... | python | def get_completeness_counts(catalogue, completeness, d_m):
"""
Returns the number of earthquakes in a set of magnitude bins of specified
with, along with the corresponding completeness duration (in years) of the
bin
:param catalogue:
Earthquake catalogue as instance of
:class: openq... | [
"def",
"get_completeness_counts",
"(",
"catalogue",
",",
"completeness",
",",
"d_m",
")",
":",
"mmax_obs",
"=",
"np",
".",
"max",
"(",
"catalogue",
".",
"data",
"[",
"\"magnitude\"",
"]",
")",
"# thw line below was added by Nick Ackerley but it breaks the tests",
"# c... | Returns the number of earthquakes in a set of magnitude bins of specified
with, along with the corresponding completeness duration (in years) of the
bin
:param catalogue:
Earthquake catalogue as instance of
:class: openquake.hmtk.seisimicity.catalogue.Catalogue
:param numpy.ndarray comp... | [
"Returns",
"the",
"number",
"of",
"earthquakes",
"in",
"a",
"set",
"of",
"magnitude",
"bins",
"of",
"specified",
"with",
"along",
"with",
"the",
"corresponding",
"completeness",
"duration",
"(",
"in",
"years",
")",
"of",
"the",
"bin"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/occurrence/utils.py#L211-L266 |
gem/oq-engine | openquake/commands/reset.py | reset | def reset(yes):
"""
Remove all the datastores and the database of the current user
"""
ok = yes or confirm('Do you really want to destroy all your data? (y/n) ')
if not ok:
return
dbpath = os.path.realpath(os.path.expanduser(config.dbserver.file))
# user must be able to access and ... | python | def reset(yes):
"""
Remove all the datastores and the database of the current user
"""
ok = yes or confirm('Do you really want to destroy all your data? (y/n) ')
if not ok:
return
dbpath = os.path.realpath(os.path.expanduser(config.dbserver.file))
# user must be able to access and ... | [
"def",
"reset",
"(",
"yes",
")",
":",
"ok",
"=",
"yes",
"or",
"confirm",
"(",
"'Do you really want to destroy all your data? (y/n) '",
")",
"if",
"not",
"ok",
":",
"return",
"dbpath",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"os",
".",
"path",
".",
... | Remove all the datastores and the database of the current user | [
"Remove",
"all",
"the",
"datastores",
"and",
"the",
"database",
"of",
"the",
"current",
"user"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/reset.py#L30-L59 |
gem/oq-engine | openquake/hazardlib/gsim/drouet_alpes_2015.py | DrouetAlpes2015Rjb._compute_mean | def _compute_mean(self, C, mag, r):
"""
Compute mean value according to equation 30, page 1021.
"""
mean = (C['c1'] +
self._compute_term1(C, mag) +
self._compute_term2(C, mag, r))
return mean | python | def _compute_mean(self, C, mag, r):
"""
Compute mean value according to equation 30, page 1021.
"""
mean = (C['c1'] +
self._compute_term1(C, mag) +
self._compute_term2(C, mag, r))
return mean | [
"def",
"_compute_mean",
"(",
"self",
",",
"C",
",",
"mag",
",",
"r",
")",
":",
"mean",
"=",
"(",
"C",
"[",
"'c1'",
"]",
"+",
"self",
".",
"_compute_term1",
"(",
"C",
",",
"mag",
")",
"+",
"self",
".",
"_compute_term2",
"(",
"C",
",",
"mag",
","... | Compute mean value according to equation 30, page 1021. | [
"Compute",
"mean",
"value",
"according",
"to",
"equation",
"30",
"page",
"1021",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/drouet_alpes_2015.py#L119-L126 |
gem/oq-engine | openquake/hazardlib/gsim/drouet_alpes_2015.py | DrouetAlpes2015Rjb._compute_term2 | def _compute_term2(self, C, mag, r):
"""
This computes the term f2 equation 8 Drouet & Cotton (2015)
"""
return (C['c4'] + C['c5'] * mag) * \
np.log(np.sqrt(r**2 + C['c6']**2)) + C['c7'] * r | python | def _compute_term2(self, C, mag, r):
"""
This computes the term f2 equation 8 Drouet & Cotton (2015)
"""
return (C['c4'] + C['c5'] * mag) * \
np.log(np.sqrt(r**2 + C['c6']**2)) + C['c7'] * r | [
"def",
"_compute_term2",
"(",
"self",
",",
"C",
",",
"mag",
",",
"r",
")",
":",
"return",
"(",
"C",
"[",
"'c4'",
"]",
"+",
"C",
"[",
"'c5'",
"]",
"*",
"mag",
")",
"*",
"np",
".",
"log",
"(",
"np",
".",
"sqrt",
"(",
"r",
"**",
"2",
"+",
"C... | This computes the term f2 equation 8 Drouet & Cotton (2015) | [
"This",
"computes",
"the",
"term",
"f2",
"equation",
"8",
"Drouet",
"&",
"Cotton",
"(",
"2015",
")"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/drouet_alpes_2015.py#L150-L155 |
gem/oq-engine | openquake/hazardlib/gsim/drouet_alpes_2015.py | DrouetAlpes2015Rrup.get_mean_and_stddevs | def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
"""
See :meth:`superclass method
<.base.GroundShakingIntensityModel.get_mean_and_stddevs>`
for spec of input and result values.
"""
assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
... | python | def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
"""
See :meth:`superclass method
<.base.GroundShakingIntensityModel.get_mean_and_stddevs>`
for spec of input and result values.
"""
assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
... | [
"def",
"get_mean_and_stddevs",
"(",
"self",
",",
"sites",
",",
"rup",
",",
"dists",
",",
"imt",
",",
"stddev_types",
")",
":",
"assert",
"all",
"(",
"stddev_type",
"in",
"self",
".",
"DEFINED_FOR_STANDARD_DEVIATION_TYPES",
"for",
"stddev_type",
"in",
"stddev_typ... | See :meth:`superclass method
<.base.GroundShakingIntensityModel.get_mean_and_stddevs>`
for spec of input and result values. | [
"See",
":",
"meth",
":",
"superclass",
"method",
"<",
".",
"base",
".",
"GroundShakingIntensityModel",
".",
"get_mean_and_stddevs",
">",
"for",
"spec",
"of",
"input",
"and",
"result",
"values",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/drouet_alpes_2015.py#L196-L215 |
gem/oq-engine | openquake/server/db/actions.py | set_status | def set_status(db, job_id, status):
"""
Set the status 'created', 'executing', 'complete', 'failed', 'aborted'
consistently with `is_running`.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_id: ID of the current job
:param status: status string
"""
assert status in ... | python | def set_status(db, job_id, status):
"""
Set the status 'created', 'executing', 'complete', 'failed', 'aborted'
consistently with `is_running`.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_id: ID of the current job
:param status: status string
"""
assert status in ... | [
"def",
"set_status",
"(",
"db",
",",
"job_id",
",",
"status",
")",
":",
"assert",
"status",
"in",
"(",
"'created'",
",",
"'submitted'",
",",
"'executing'",
",",
"'complete'",
",",
"'aborted'",
",",
"'failed'",
")",
",",
"status",
"if",
"status",
"in",
"(... | Set the status 'created', 'executing', 'complete', 'failed', 'aborted'
consistently with `is_running`.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_id: ID of the current job
:param status: status string | [
"Set",
"the",
"status",
"created",
"executing",
"complete",
"failed",
"aborted",
"consistently",
"with",
"is_running",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L62-L85 |
gem/oq-engine | openquake/server/db/actions.py | create_job | def create_job(db, datadir):
"""
Create job for the given user, return it.
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param datadir:
Data directory of the user who owns/started this job.
:returns:
the job ID
"""
calc_id = get_calc_id(db, datadir) + 1
... | python | def create_job(db, datadir):
"""
Create job for the given user, return it.
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param datadir:
Data directory of the user who owns/started this job.
:returns:
the job ID
"""
calc_id = get_calc_id(db, datadir) + 1
... | [
"def",
"create_job",
"(",
"db",
",",
"datadir",
")",
":",
"calc_id",
"=",
"get_calc_id",
"(",
"db",
",",
"datadir",
")",
"+",
"1",
"job",
"=",
"dict",
"(",
"id",
"=",
"calc_id",
",",
"is_running",
"=",
"1",
",",
"description",
"=",
"'just created'",
... | Create job for the given user, return it.
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param datadir:
Data directory of the user who owns/started this job.
:returns:
the job ID | [
"Create",
"job",
"for",
"the",
"given",
"user",
"return",
"it",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L88-L104 |
gem/oq-engine | openquake/server/db/actions.py | import_job | def import_job(db, calc_id, calc_mode, description, user_name, status,
hc_id, datadir):
"""
Insert a calculation inside the database, if calc_id is not taken
"""
job = dict(id=calc_id,
calculation_mode=calc_mode,
description=description,
user_n... | python | def import_job(db, calc_id, calc_mode, description, user_name, status,
hc_id, datadir):
"""
Insert a calculation inside the database, if calc_id is not taken
"""
job = dict(id=calc_id,
calculation_mode=calc_mode,
description=description,
user_n... | [
"def",
"import_job",
"(",
"db",
",",
"calc_id",
",",
"calc_mode",
",",
"description",
",",
"user_name",
",",
"status",
",",
"hc_id",
",",
"datadir",
")",
":",
"job",
"=",
"dict",
"(",
"id",
"=",
"calc_id",
",",
"calculation_mode",
"=",
"calc_mode",
",",
... | Insert a calculation inside the database, if calc_id is not taken | [
"Insert",
"a",
"calculation",
"inside",
"the",
"database",
"if",
"calc_id",
"is",
"not",
"taken"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L107-L120 |
gem/oq-engine | openquake/server/db/actions.py | get_job | def get_job(db, job_id, username=None):
"""
If job_id is negative, return the last calculation of the current
user, otherwise returns the job_id unchanged.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_id: a job ID (can be negative and can be nonexisting)
:param username: ... | python | def get_job(db, job_id, username=None):
"""
If job_id is negative, return the last calculation of the current
user, otherwise returns the job_id unchanged.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_id: a job ID (can be negative and can be nonexisting)
:param username: ... | [
"def",
"get_job",
"(",
"db",
",",
"job_id",
",",
"username",
"=",
"None",
")",
":",
"job_id",
"=",
"int",
"(",
"job_id",
")",
"if",
"job_id",
">",
"0",
":",
"dic",
"=",
"dict",
"(",
"id",
"=",
"job_id",
")",
"if",
"username",
":",
"dic",
"[",
"... | If job_id is negative, return the last calculation of the current
user, otherwise returns the job_id unchanged.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_id: a job ID (can be negative and can be nonexisting)
:param username: an user name (if None, ignore it)
:returns: a va... | [
"If",
"job_id",
"is",
"negative",
"return",
"the",
"last",
"calculation",
"of",
"the",
"current",
"user",
"otherwise",
"returns",
"the",
"job_id",
"unchanged",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L133-L163 |
gem/oq-engine | openquake/server/db/actions.py | get_calc_id | def get_calc_id(db, datadir, job_id=None):
"""
Return the latest calc_id by looking both at the datastore
and the database.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param datadir: the directory containing the datastores
:param job_id: a job ID; if None, returns the latest job I... | python | def get_calc_id(db, datadir, job_id=None):
"""
Return the latest calc_id by looking both at the datastore
and the database.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param datadir: the directory containing the datastores
:param job_id: a job ID; if None, returns the latest job I... | [
"def",
"get_calc_id",
"(",
"db",
",",
"datadir",
",",
"job_id",
"=",
"None",
")",
":",
"calcs",
"=",
"datastore",
".",
"get_calc_ids",
"(",
"datadir",
")",
"calc_id",
"=",
"0",
"if",
"not",
"calcs",
"else",
"calcs",
"[",
"-",
"1",
"]",
"if",
"job_id"... | Return the latest calc_id by looking both at the datastore
and the database.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param datadir: the directory containing the datastores
:param job_id: a job ID; if None, returns the latest job ID | [
"Return",
"the",
"latest",
"calc_id",
"by",
"looking",
"both",
"at",
"the",
"datastore",
"and",
"the",
"database",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L166-L183 |
gem/oq-engine | openquake/server/db/actions.py | list_calculations | def list_calculations(db, job_type, user_name):
"""
Yield a summary of past calculations.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_type: 'hazard' or 'risk'
:param user_name: an user name
"""
jobs = db('SELECT *, %s FROM job WHERE user_name=?x '
'AND ... | python | def list_calculations(db, job_type, user_name):
"""
Yield a summary of past calculations.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_type: 'hazard' or 'risk'
:param user_name: an user name
"""
jobs = db('SELECT *, %s FROM job WHERE user_name=?x '
'AND ... | [
"def",
"list_calculations",
"(",
"db",
",",
"job_type",
",",
"user_name",
")",
":",
"jobs",
"=",
"db",
"(",
"'SELECT *, %s FROM job WHERE user_name=?x '",
"'AND job_type=?x ORDER BY start_time'",
"%",
"JOB_TYPE",
",",
"user_name",
",",
"job_type",
")",
"out",
"=",
"... | Yield a summary of past calculations.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_type: 'hazard' or 'risk'
:param user_name: an user name | [
"Yield",
"a",
"summary",
"of",
"past",
"calculations",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L186-L208 |
gem/oq-engine | openquake/server/db/actions.py | list_outputs | def list_outputs(db, job_id, full=True):
"""
List the outputs for a given
:class:`~openquake.server.db.models.OqJob`.
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param job_id:
ID of a calculation.
:param bool full:
If True produce a full listing, otherwise ... | python | def list_outputs(db, job_id, full=True):
"""
List the outputs for a given
:class:`~openquake.server.db.models.OqJob`.
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param job_id:
ID of a calculation.
:param bool full:
If True produce a full listing, otherwise ... | [
"def",
"list_outputs",
"(",
"db",
",",
"job_id",
",",
"full",
"=",
"True",
")",
":",
"outputs",
"=",
"get_outputs",
"(",
"db",
",",
"job_id",
")",
"out",
"=",
"[",
"]",
"if",
"len",
"(",
"outputs",
")",
">",
"0",
":",
"truncated",
"=",
"False",
"... | List the outputs for a given
:class:`~openquake.server.db.models.OqJob`.
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param job_id:
ID of a calculation.
:param bool full:
If True produce a full listing, otherwise a short version | [
"List",
"the",
"outputs",
"for",
"a",
"given",
":",
"class",
":",
"~openquake",
".",
"server",
".",
"db",
".",
"models",
".",
"OqJob",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L211-L238 |
gem/oq-engine | openquake/server/db/actions.py | create_outputs | def create_outputs(db, job_id, keysize, ds_size):
"""
Build a correspondence between the outputs in the datastore and the
ones in the database. Also, update the datastore size in the job table.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_id: ID of the current job
:param ... | python | def create_outputs(db, job_id, keysize, ds_size):
"""
Build a correspondence between the outputs in the datastore and the
ones in the database. Also, update the datastore size in the job table.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_id: ID of the current job
:param ... | [
"def",
"create_outputs",
"(",
"db",
",",
"job_id",
",",
"keysize",
",",
"ds_size",
")",
":",
"rows",
"=",
"[",
"(",
"job_id",
",",
"DISPLAY_NAME",
".",
"get",
"(",
"key",
",",
"key",
")",
",",
"key",
",",
"size",
")",
"for",
"key",
",",
"size",
"... | Build a correspondence between the outputs in the datastore and the
ones in the database. Also, update the datastore size in the job table.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_id: ID of the current job
:param keysize: a list of pairs (key, size_mb)
:param ds_size: to... | [
"Build",
"a",
"correspondence",
"between",
"the",
"outputs",
"in",
"the",
"datastore",
"and",
"the",
"ones",
"in",
"the",
"database",
".",
"Also",
"update",
"the",
"datastore",
"size",
"in",
"the",
"job",
"table",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L299-L312 |
gem/oq-engine | openquake/server/db/actions.py | finish | def finish(db, job_id, status):
"""
Set the job columns `is_running`, `status`, and `stop_time`.
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param job_id:
ID of the current job
:param status:
a string such as 'successful' or 'failed'
"""
db('UPDATE job ... | python | def finish(db, job_id, status):
"""
Set the job columns `is_running`, `status`, and `stop_time`.
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param job_id:
ID of the current job
:param status:
a string such as 'successful' or 'failed'
"""
db('UPDATE job ... | [
"def",
"finish",
"(",
"db",
",",
"job_id",
",",
"status",
")",
":",
"db",
"(",
"'UPDATE job SET ?D WHERE id=?x'",
",",
"dict",
"(",
"is_running",
"=",
"False",
",",
"status",
"=",
"status",
",",
"stop_time",
"=",
"datetime",
".",
"utcnow",
"(",
")",
")",... | Set the job columns `is_running`, `status`, and `stop_time`.
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param job_id:
ID of the current job
:param status:
a string such as 'successful' or 'failed' | [
"Set",
"the",
"job",
"columns",
"is_running",
"status",
"and",
"stop_time",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L315-L328 |
gem/oq-engine | openquake/server/db/actions.py | del_calc | def del_calc(db, job_id, user):
"""
Delete a calculation and all associated outputs, if possible.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_id: job ID, can be an integer or a string
:param user: username
:returns: None if everything went fine or an error message
""... | python | def del_calc(db, job_id, user):
"""
Delete a calculation and all associated outputs, if possible.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_id: job ID, can be an integer or a string
:param user: username
:returns: None if everything went fine or an error message
""... | [
"def",
"del_calc",
"(",
"db",
",",
"job_id",
",",
"user",
")",
":",
"job_id",
"=",
"int",
"(",
"job_id",
")",
"dependent",
"=",
"db",
"(",
"'SELECT id FROM job WHERE hazard_calculation_id=?x'",
",",
"job_id",
")",
"if",
"dependent",
":",
"return",
"{",
"\"er... | Delete a calculation and all associated outputs, if possible.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_id: job ID, can be an integer or a string
:param user: username
:returns: None if everything went fine or an error message | [
"Delete",
"a",
"calculation",
"and",
"all",
"associated",
"outputs",
"if",
"possible",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L331-L367 |
gem/oq-engine | openquake/server/db/actions.py | log | def log(db, job_id, timestamp, level, process, message):
"""
Write a log record in the database.
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param job_id:
a job ID
:param timestamp:
timestamp to store in the log record
:param level:
logging level to... | python | def log(db, job_id, timestamp, level, process, message):
"""
Write a log record in the database.
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param job_id:
a job ID
:param timestamp:
timestamp to store in the log record
:param level:
logging level to... | [
"def",
"log",
"(",
"db",
",",
"job_id",
",",
"timestamp",
",",
"level",
",",
"process",
",",
"message",
")",
":",
"db",
"(",
"'INSERT INTO log (job_id, timestamp, level, process, message) '",
"'VALUES (?X)'",
",",
"(",
"job_id",
",",
"timestamp",
",",
"level",
"... | Write a log record in the database.
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param job_id:
a job ID
:param timestamp:
timestamp to store in the log record
:param level:
logging level to store in the log record
:param process:
process ID to st... | [
"Write",
"a",
"log",
"record",
"in",
"the",
"database",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L370-L388 |
gem/oq-engine | openquake/server/db/actions.py | get_log | def get_log(db, job_id):
"""
Extract the logs as a big string
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_id: a job ID
"""
logs = db('SELECT * FROM log WHERE job_id=?x ORDER BY id', job_id)
out = []
for log in logs:
time = str(log.timestamp)[:-4] # strip... | python | def get_log(db, job_id):
"""
Extract the logs as a big string
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_id: a job ID
"""
logs = db('SELECT * FROM log WHERE job_id=?x ORDER BY id', job_id)
out = []
for log in logs:
time = str(log.timestamp)[:-4] # strip... | [
"def",
"get_log",
"(",
"db",
",",
"job_id",
")",
":",
"logs",
"=",
"db",
"(",
"'SELECT * FROM log WHERE job_id=?x ORDER BY id'",
",",
"job_id",
")",
"out",
"=",
"[",
"]",
"for",
"log",
"in",
"logs",
":",
"time",
"=",
"str",
"(",
"log",
".",
"timestamp",
... | Extract the logs as a big string
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_id: a job ID | [
"Extract",
"the",
"logs",
"as",
"a",
"big",
"string"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L391-L403 |
gem/oq-engine | openquake/server/db/actions.py | get_output | def get_output(db, output_id):
"""
:param db: a :class:`openquake.server.dbapi.Db` instance
:param output_id: ID of an Output object
:returns: (ds_key, calc_id, dirname)
"""
out = db('SELECT output.*, ds_calc_dir FROM output, job '
'WHERE oq_job_id=job.id AND output.id=?x', output_i... | python | def get_output(db, output_id):
"""
:param db: a :class:`openquake.server.dbapi.Db` instance
:param output_id: ID of an Output object
:returns: (ds_key, calc_id, dirname)
"""
out = db('SELECT output.*, ds_calc_dir FROM output, job '
'WHERE oq_job_id=job.id AND output.id=?x', output_i... | [
"def",
"get_output",
"(",
"db",
",",
"output_id",
")",
":",
"out",
"=",
"db",
"(",
"'SELECT output.*, ds_calc_dir FROM output, job '",
"'WHERE oq_job_id=job.id AND output.id=?x'",
",",
"output_id",
",",
"one",
"=",
"True",
")",
"return",
"out",
".",
"ds_key",
",",
... | :param db: a :class:`openquake.server.dbapi.Db` instance
:param output_id: ID of an Output object
:returns: (ds_key, calc_id, dirname) | [
":",
"param",
"db",
":",
"a",
":",
"class",
":",
"openquake",
".",
"server",
".",
"dbapi",
".",
"Db",
"instance",
":",
"param",
"output_id",
":",
"ID",
"of",
"an",
"Output",
"object",
":",
"returns",
":",
"(",
"ds_key",
"calc_id",
"dirname",
")"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L406-L414 |
gem/oq-engine | openquake/server/db/actions.py | save_performance | def save_performance(db, job_id, records):
"""
Save in the database the performance information about the given job.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_id: a job ID
:param records: a list of performance records
"""
# NB: rec['counts'] is a numpy.uint64 which... | python | def save_performance(db, job_id, records):
"""
Save in the database the performance information about the given job.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_id: a job ID
:param records: a list of performance records
"""
# NB: rec['counts'] is a numpy.uint64 which... | [
"def",
"save_performance",
"(",
"db",
",",
"job_id",
",",
"records",
")",
":",
"# NB: rec['counts'] is a numpy.uint64 which is not automatically converted",
"# into an int in Ubuntu 12.04, so we convert it manually below",
"rows",
"=",
"[",
"(",
"job_id",
",",
"rec",
"[",
"'o... | Save in the database the performance information about the given job.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_id: a job ID
:param records: a list of performance records | [
"Save",
"in",
"the",
"database",
"the",
"performance",
"information",
"about",
"the",
"given",
"job",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L417-L430 |
gem/oq-engine | openquake/server/db/actions.py | calc_info | def calc_info(db, calc_id):
"""
:param db: a :class:`openquake.server.dbapi.Db` instance
:param calc_id: calculation ID
:returns: dictionary of info about the given calculation
"""
job = db('SELECT * FROM job WHERE id=?x', calc_id, one=True)
response_data = {}
response_data['user_name'] ... | python | def calc_info(db, calc_id):
"""
:param db: a :class:`openquake.server.dbapi.Db` instance
:param calc_id: calculation ID
:returns: dictionary of info about the given calculation
"""
job = db('SELECT * FROM job WHERE id=?x', calc_id, one=True)
response_data = {}
response_data['user_name'] ... | [
"def",
"calc_info",
"(",
"db",
",",
"calc_id",
")",
":",
"job",
"=",
"db",
"(",
"'SELECT * FROM job WHERE id=?x'",
",",
"calc_id",
",",
"one",
"=",
"True",
")",
"response_data",
"=",
"{",
"}",
"response_data",
"[",
"'user_name'",
"]",
"=",
"job",
".",
"u... | :param db: a :class:`openquake.server.dbapi.Db` instance
:param calc_id: calculation ID
:returns: dictionary of info about the given calculation | [
":",
"param",
"db",
":",
"a",
":",
"class",
":",
"openquake",
".",
"server",
".",
"dbapi",
".",
"Db",
"instance",
":",
"param",
"calc_id",
":",
"calculation",
"ID",
":",
"returns",
":",
"dictionary",
"of",
"info",
"about",
"the",
"given",
"calculation"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L492-L505 |
gem/oq-engine | openquake/server/db/actions.py | get_calcs | def get_calcs(db, request_get_dict, allowed_users, user_acl_on=False, id=None):
"""
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param request_get_dict:
a dictionary
:param allowed_users:
a list of users
:param user_acl_on:
if True, returns only the calcu... | python | def get_calcs(db, request_get_dict, allowed_users, user_acl_on=False, id=None):
"""
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param request_get_dict:
a dictionary
:param allowed_users:
a list of users
:param user_acl_on:
if True, returns only the calcu... | [
"def",
"get_calcs",
"(",
"db",
",",
"request_get_dict",
",",
"allowed_users",
",",
"user_acl_on",
"=",
"False",
",",
"id",
"=",
"None",
")",
":",
"# helper to get job+calculation data from the oq-engine database",
"filterdict",
"=",
"{",
"}",
"if",
"id",
"is",
"no... | :param db:
a :class:`openquake.server.dbapi.Db` instance
:param request_get_dict:
a dictionary
:param allowed_users:
a list of users
:param user_acl_on:
if True, returns only the calculations owned by the user or the group
:param id:
if given, extract only the spe... | [
":",
"param",
"db",
":",
"a",
":",
"class",
":",
"openquake",
".",
"server",
".",
"dbapi",
".",
"Db",
"instance",
":",
"param",
"request_get_dict",
":",
"a",
"dictionary",
":",
"param",
"allowed_users",
":",
"a",
"list",
"of",
"users",
":",
"param",
"u... | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L508-L563 |
gem/oq-engine | openquake/server/db/actions.py | get_log_slice | def get_log_slice(db, job_id, start, stop):
"""
Get a slice of the calculation log as a JSON list of rows
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param job_id:
a job ID
:param start:
start of the slice
:param stop:
end of the slice (the last ele... | python | def get_log_slice(db, job_id, start, stop):
"""
Get a slice of the calculation log as a JSON list of rows
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param job_id:
a job ID
:param start:
start of the slice
:param stop:
end of the slice (the last ele... | [
"def",
"get_log_slice",
"(",
"db",
",",
"job_id",
",",
"start",
",",
"stop",
")",
":",
"start",
"=",
"int",
"(",
"start",
")",
"stop",
"=",
"int",
"(",
"stop",
")",
"limit",
"=",
"-",
"1",
"if",
"stop",
"==",
"0",
"else",
"stop",
"-",
"start",
... | Get a slice of the calculation log as a JSON list of rows
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param job_id:
a job ID
:param start:
start of the slice
:param stop:
end of the slice (the last element is excluded) | [
"Get",
"a",
"slice",
"of",
"the",
"calculation",
"log",
"as",
"a",
"JSON",
"list",
"of",
"rows"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L588-L610 |
gem/oq-engine | openquake/server/db/actions.py | get_traceback | def get_traceback(db, job_id):
"""
Return the traceback of the given calculation as a list of lines.
The list is empty if the calculation was successful.
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param job_id:
a job ID
"""
# strange: understand why the filter... | python | def get_traceback(db, job_id):
"""
Return the traceback of the given calculation as a list of lines.
The list is empty if the calculation was successful.
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param job_id:
a job ID
"""
# strange: understand why the filter... | [
"def",
"get_traceback",
"(",
"db",
",",
"job_id",
")",
":",
"# strange: understand why the filter returns two lines or zero lines",
"log",
"=",
"db",
"(",
"\"SELECT * FROM log WHERE job_id=?x AND level='CRITICAL'\"",
",",
"job_id",
")",
"if",
"not",
"log",
":",
"return",
... | Return the traceback of the given calculation as a list of lines.
The list is empty if the calculation was successful.
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param job_id:
a job ID | [
"Return",
"the",
"traceback",
"of",
"the",
"given",
"calculation",
"as",
"a",
"list",
"of",
"lines",
".",
"The",
"list",
"is",
"empty",
"if",
"the",
"calculation",
"was",
"successful",
"."
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L626-L642 |
gem/oq-engine | openquake/server/db/actions.py | get_result | def get_result(db, result_id):
"""
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param result_id:
a result ID
:returns: (job_id, job_status, datadir, datastore_key)
"""
job = db('SELECT job.*, ds_key FROM job, output WHERE '
'oq_job_id=job.id AND output.i... | python | def get_result(db, result_id):
"""
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param result_id:
a result ID
:returns: (job_id, job_status, datadir, datastore_key)
"""
job = db('SELECT job.*, ds_key FROM job, output WHERE '
'oq_job_id=job.id AND output.i... | [
"def",
"get_result",
"(",
"db",
",",
"result_id",
")",
":",
"job",
"=",
"db",
"(",
"'SELECT job.*, ds_key FROM job, output WHERE '",
"'oq_job_id=job.id AND output.id=?x'",
",",
"result_id",
",",
"one",
"=",
"True",
")",
"return",
"(",
"job",
".",
"id",
",",
"job... | :param db:
a :class:`openquake.server.dbapi.Db` instance
:param result_id:
a result ID
:returns: (job_id, job_status, datadir, datastore_key) | [
":",
"param",
"db",
":",
"a",
":",
"class",
":",
"openquake",
".",
"server",
".",
"dbapi",
".",
"Db",
"instance",
":",
"param",
"result_id",
":",
"a",
"result",
"ID",
":",
"returns",
":",
"(",
"job_id",
"job_status",
"datadir",
"datastore_key",
")"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L645-L656 |
gem/oq-engine | openquake/server/db/actions.py | get_results | def get_results(db, job_id):
"""
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param job_id:
a job ID
:returns: (datadir, datastore_keys)
"""
ds_calc_dir = db('SELECT ds_calc_dir FROM job WHERE id=?x', job_id,
scalar=True)
datadir = os.path.di... | python | def get_results(db, job_id):
"""
:param db:
a :class:`openquake.server.dbapi.Db` instance
:param job_id:
a job ID
:returns: (datadir, datastore_keys)
"""
ds_calc_dir = db('SELECT ds_calc_dir FROM job WHERE id=?x', job_id,
scalar=True)
datadir = os.path.di... | [
"def",
"get_results",
"(",
"db",
",",
"job_id",
")",
":",
"ds_calc_dir",
"=",
"db",
"(",
"'SELECT ds_calc_dir FROM job WHERE id=?x'",
",",
"job_id",
",",
"scalar",
"=",
"True",
")",
"datadir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"ds_calc_dir",
")",
... | :param db:
a :class:`openquake.server.dbapi.Db` instance
:param job_id:
a job ID
:returns: (datadir, datastore_keys) | [
":",
"param",
"db",
":",
"a",
":",
"class",
":",
"openquake",
".",
"server",
".",
"dbapi",
".",
"Db",
"instance",
":",
"param",
"job_id",
":",
"a",
"job",
"ID",
":",
"returns",
":",
"(",
"datadir",
"datastore_keys",
")"
] | train | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L659-L670 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.