id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
300 | gem/oq-engine | openquake/baselib/parallel.py | Result.get | def get(self):
"""
Returns the underlying value or raise the underlying exception
"""
val = self.pik.unpickle()
if self.tb_str:
etype = val.__class__
msg = '\n%s%s: %s' % (self.tb_str, etype.__name__, val)
if issubclass(etype, KeyError):
... | python | def get(self):
"""
Returns the underlying value or raise the underlying exception
"""
val = self.pik.unpickle()
if self.tb_str:
etype = val.__class__
msg = '\n%s%s: %s' % (self.tb_str, etype.__name__, val)
if issubclass(etype, KeyError):
... | [
"def",
"get",
"(",
"self",
")",
":",
"val",
"=",
"self",
".",
"pik",
".",
"unpickle",
"(",
")",
"if",
"self",
".",
"tb_str",
":",
"etype",
"=",
"val",
".",
"__class__",
"msg",
"=",
"'\\n%s%s: %s'",
"%",
"(",
"self",
".",
"tb_str",
",",
"etype",
"... | Returns the underlying value or raise the underlying exception | [
"Returns",
"the",
"underlying",
"value",
"or",
"raise",
"the",
"underlying",
"exception"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/parallel.py#L337-L349 |
301 | gem/oq-engine | openquake/baselib/parallel.py | IterResult.sum | def sum(cls, iresults):
"""
Sum the data transfer information of a set of results
"""
res = object.__new__(cls)
res.received = []
res.sent = 0
for iresult in iresults:
res.received.extend(iresult.received)
res.sent += iresult.sent
... | python | def sum(cls, iresults):
"""
Sum the data transfer information of a set of results
"""
res = object.__new__(cls)
res.received = []
res.sent = 0
for iresult in iresults:
res.received.extend(iresult.received)
res.sent += iresult.sent
... | [
"def",
"sum",
"(",
"cls",
",",
"iresults",
")",
":",
"res",
"=",
"object",
".",
"__new__",
"(",
"cls",
")",
"res",
".",
"received",
"=",
"[",
"]",
"res",
".",
"sent",
"=",
"0",
"for",
"iresult",
"in",
"iresults",
":",
"res",
".",
"received",
".",... | Sum the data transfer information of a set of results | [
"Sum",
"the",
"data",
"transfer",
"information",
"of",
"a",
"set",
"of",
"results"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/parallel.py#L532-L547 |
302 | gem/oq-engine | openquake/baselib/parallel.py | Starmap.log_percent | def log_percent(self):
"""
Log the progress of the computation in percentage
"""
done = self.total - self.todo
percent = int(float(done) / self.total * 100)
if not hasattr(self, 'prev_percent'): # first time
self.prev_percent = 0
self.progress('Se... | python | def log_percent(self):
"""
Log the progress of the computation in percentage
"""
done = self.total - self.todo
percent = int(float(done) / self.total * 100)
if not hasattr(self, 'prev_percent'): # first time
self.prev_percent = 0
self.progress('Se... | [
"def",
"log_percent",
"(",
"self",
")",
":",
"done",
"=",
"self",
".",
"total",
"-",
"self",
".",
"todo",
"percent",
"=",
"int",
"(",
"float",
"(",
"done",
")",
"/",
"self",
".",
"total",
"*",
"100",
")",
"if",
"not",
"hasattr",
"(",
"self",
",",... | Log the progress of the computation in percentage | [
"Log",
"the",
"progress",
"of",
"the",
"computation",
"in",
"percentage"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/parallel.py#L691-L705 |
303 | gem/oq-engine | openquake/baselib/parallel.py | Starmap.submit | def submit(self, *args, func=None, monitor=None):
"""
Submit the given arguments to the underlying task
"""
monitor = monitor or self.monitor
func = func or self.task_func
if not hasattr(self, 'socket'): # first time
self.__class__.running_tasks = self.tasks
... | python | def submit(self, *args, func=None, monitor=None):
"""
Submit the given arguments to the underlying task
"""
monitor = monitor or self.monitor
func = func or self.task_func
if not hasattr(self, 'socket'): # first time
self.__class__.running_tasks = self.tasks
... | [
"def",
"submit",
"(",
"self",
",",
"*",
"args",
",",
"func",
"=",
"None",
",",
"monitor",
"=",
"None",
")",
":",
"monitor",
"=",
"monitor",
"or",
"self",
".",
"monitor",
"func",
"=",
"func",
"or",
"self",
".",
"task_func",
"if",
"not",
"hasattr",
"... | Submit the given arguments to the underlying task | [
"Submit",
"the",
"given",
"arguments",
"to",
"the",
"underlying",
"task"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/parallel.py#L707-L724 |
304 | gem/oq-engine | openquake/baselib/parallel.py | Starmap.reduce | def reduce(self, agg=operator.add, acc=None):
"""
Submit all tasks and reduce the results
"""
return self.submit_all().reduce(agg, acc) | python | def reduce(self, agg=operator.add, acc=None):
"""
Submit all tasks and reduce the results
"""
return self.submit_all().reduce(agg, acc) | [
"def",
"reduce",
"(",
"self",
",",
"agg",
"=",
"operator",
".",
"add",
",",
"acc",
"=",
"None",
")",
":",
"return",
"self",
".",
"submit_all",
"(",
")",
".",
"reduce",
"(",
"agg",
",",
"acc",
")"
] | Submit all tasks and reduce the results | [
"Submit",
"all",
"tasks",
"and",
"reduce",
"the",
"results"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/parallel.py#L748-L752 |
305 | gem/oq-engine | openquake/hazardlib/probability_map.py | ProbabilityCurve.convert | def convert(self, imtls, idx=0):
"""
Convert a probability curve into a record of dtype `imtls.dt`.
:param imtls: DictArray instance
:param idx: extract the data corresponding to the given inner index
"""
curve = numpy.zeros(1, imtls.dt)
for imt in imtls:
... | python | def convert(self, imtls, idx=0):
"""
Convert a probability curve into a record of dtype `imtls.dt`.
:param imtls: DictArray instance
:param idx: extract the data corresponding to the given inner index
"""
curve = numpy.zeros(1, imtls.dt)
for imt in imtls:
... | [
"def",
"convert",
"(",
"self",
",",
"imtls",
",",
"idx",
"=",
"0",
")",
":",
"curve",
"=",
"numpy",
".",
"zeros",
"(",
"1",
",",
"imtls",
".",
"dt",
")",
"for",
"imt",
"in",
"imtls",
":",
"curve",
"[",
"imt",
"]",
"=",
"self",
".",
"array",
"... | Convert a probability curve into a record of dtype `imtls.dt`.
:param imtls: DictArray instance
:param idx: extract the data corresponding to the given inner index | [
"Convert",
"a",
"probability",
"curve",
"into",
"a",
"record",
"of",
"dtype",
"imtls",
".",
"dt",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/probability_map.py#L96-L106 |
306 | gem/oq-engine | openquake/hazardlib/probability_map.py | ProbabilityMap.nbytes | def nbytes(self):
"""The size of the underlying array"""
try:
N, L, I = get_shape([self])
except AllEmptyProbabilityMaps:
return 0
return BYTES_PER_FLOAT * N * L * I | python | def nbytes(self):
"""The size of the underlying array"""
try:
N, L, I = get_shape([self])
except AllEmptyProbabilityMaps:
return 0
return BYTES_PER_FLOAT * N * L * I | [
"def",
"nbytes",
"(",
"self",
")",
":",
"try",
":",
"N",
",",
"L",
",",
"I",
"=",
"get_shape",
"(",
"[",
"self",
"]",
")",
"except",
"AllEmptyProbabilityMaps",
":",
"return",
"0",
"return",
"BYTES_PER_FLOAT",
"*",
"N",
"*",
"L",
"*",
"I"
] | The size of the underlying array | [
"The",
"size",
"of",
"the",
"underlying",
"array"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/probability_map.py#L194-L200 |
307 | gem/oq-engine | openquake/hazardlib/probability_map.py | ProbabilityMap.convert | def convert(self, imtls, nsites, idx=0):
"""
Convert a probability map into a composite array of length `nsites`
and dtype `imtls.dt`.
:param imtls:
DictArray instance
:param nsites:
the total number of sites
:param idx:
index on the z... | python | def convert(self, imtls, nsites, idx=0):
"""
Convert a probability map into a composite array of length `nsites`
and dtype `imtls.dt`.
:param imtls:
DictArray instance
:param nsites:
the total number of sites
:param idx:
index on the z... | [
"def",
"convert",
"(",
"self",
",",
"imtls",
",",
"nsites",
",",
"idx",
"=",
"0",
")",
":",
"curves",
"=",
"numpy",
".",
"zeros",
"(",
"nsites",
",",
"imtls",
".",
"dt",
")",
"for",
"imt",
"in",
"curves",
".",
"dtype",
".",
"names",
":",
"curves_... | Convert a probability map into a composite array of length `nsites`
and dtype `imtls.dt`.
:param imtls:
DictArray instance
:param nsites:
the total number of sites
:param idx:
index on the z-axis (default 0) | [
"Convert",
"a",
"probability",
"map",
"into",
"a",
"composite",
"array",
"of",
"length",
"nsites",
"and",
"dtype",
"imtls",
".",
"dt",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/probability_map.py#L203-L220 |
308 | gem/oq-engine | openquake/hazardlib/probability_map.py | ProbabilityMap.filter | def filter(self, sids):
"""
Extracs a submap of self for the given sids.
"""
dic = self.__class__(self.shape_y, self.shape_z)
for sid in sids:
try:
dic[sid] = self[sid]
except KeyError:
pass
return dic | python | def filter(self, sids):
"""
Extracs a submap of self for the given sids.
"""
dic = self.__class__(self.shape_y, self.shape_z)
for sid in sids:
try:
dic[sid] = self[sid]
except KeyError:
pass
return dic | [
"def",
"filter",
"(",
"self",
",",
"sids",
")",
":",
"dic",
"=",
"self",
".",
"__class__",
"(",
"self",
".",
"shape_y",
",",
"self",
".",
"shape_z",
")",
"for",
"sid",
"in",
"sids",
":",
"try",
":",
"dic",
"[",
"sid",
"]",
"=",
"self",
"[",
"si... | Extracs a submap of self for the given sids. | [
"Extracs",
"a",
"submap",
"of",
"self",
"for",
"the",
"given",
"sids",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/probability_map.py#L247-L257 |
309 | gem/oq-engine | openquake/hazardlib/probability_map.py | ProbabilityMap.extract | def extract(self, inner_idx):
"""
Extracts a component of the underlying ProbabilityCurves,
specified by the index `inner_idx`.
"""
out = self.__class__(self.shape_y, 1)
for sid in self:
curve = self[sid]
array = curve.array[:, inner_idx].reshape(-... | python | def extract(self, inner_idx):
"""
Extracts a component of the underlying ProbabilityCurves,
specified by the index `inner_idx`.
"""
out = self.__class__(self.shape_y, 1)
for sid in self:
curve = self[sid]
array = curve.array[:, inner_idx].reshape(-... | [
"def",
"extract",
"(",
"self",
",",
"inner_idx",
")",
":",
"out",
"=",
"self",
".",
"__class__",
"(",
"self",
".",
"shape_y",
",",
"1",
")",
"for",
"sid",
"in",
"self",
":",
"curve",
"=",
"self",
"[",
"sid",
"]",
"array",
"=",
"curve",
".",
"arra... | Extracts a component of the underlying ProbabilityCurves,
specified by the index `inner_idx`. | [
"Extracts",
"a",
"component",
"of",
"the",
"underlying",
"ProbabilityCurves",
"specified",
"by",
"the",
"index",
"inner_idx",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/probability_map.py#L259-L269 |
310 | gem/oq-engine | openquake/commands/compare.py | compare | def compare(what, imt, calc_ids, files, samplesites=100, rtol=.1, atol=1E-4):
"""
Compare the hazard curves or maps of two or more calculations
"""
sids, imtls, poes, arrays = getdata(what, calc_ids, samplesites)
try:
levels = imtls[imt]
except KeyError:
sys.exit(
'%s... | python | def compare(what, imt, calc_ids, files, samplesites=100, rtol=.1, atol=1E-4):
"""
Compare the hazard curves or maps of two or more calculations
"""
sids, imtls, poes, arrays = getdata(what, calc_ids, samplesites)
try:
levels = imtls[imt]
except KeyError:
sys.exit(
'%s... | [
"def",
"compare",
"(",
"what",
",",
"imt",
",",
"calc_ids",
",",
"files",
",",
"samplesites",
"=",
"100",
",",
"rtol",
"=",
".1",
",",
"atol",
"=",
"1E-4",
")",
":",
"sids",
",",
"imtls",
",",
"poes",
",",
"arrays",
"=",
"getdata",
"(",
"what",
"... | Compare the hazard curves or maps of two or more calculations | [
"Compare",
"the",
"hazard",
"curves",
"or",
"maps",
"of",
"two",
"or",
"more",
"calculations"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/compare.py#L69-L107 |
311 | gem/oq-engine | openquake/hmtk/plotting/seismicity/catalogue_plots.py | build_filename | def build_filename(filename, filetype='png', resolution=300):
"""
Uses the input properties to create the string of the filename
:param str filename:
Name of the file
:param str filetype:
Type of file
:param int resolution:
DPI resolution of the output figure
"""
fil... | python | def build_filename(filename, filetype='png', resolution=300):
"""
Uses the input properties to create the string of the filename
:param str filename:
Name of the file
:param str filetype:
Type of file
:param int resolution:
DPI resolution of the output figure
"""
fil... | [
"def",
"build_filename",
"(",
"filename",
",",
"filetype",
"=",
"'png'",
",",
"resolution",
"=",
"300",
")",
":",
"filevals",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"if",
"filevals",
"[",
"1",
"]",
":",
"filetype",
"=",
"fileval... | Uses the input properties to create the string of the filename
:param str filename:
Name of the file
:param str filetype:
Type of file
:param int resolution:
DPI resolution of the output figure | [
"Uses",
"the",
"input",
"properties",
"to",
"create",
"the",
"string",
"of",
"the",
"filename"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/catalogue_plots.py#L61-L81 |
312 | gem/oq-engine | openquake/hmtk/plotting/seismicity/catalogue_plots.py | _get_catalogue_bin_limits | def _get_catalogue_bin_limits(catalogue, dmag):
"""
Returns the magnitude bins corresponing to the catalogue
"""
mag_bins = np.arange(
float(np.floor(np.min(catalogue.data['magnitude']))) - dmag,
float(np.ceil(np.max(catalogue.data['magnitude']))) + dmag,
dmag)
counter = np.h... | python | def _get_catalogue_bin_limits(catalogue, dmag):
"""
Returns the magnitude bins corresponing to the catalogue
"""
mag_bins = np.arange(
float(np.floor(np.min(catalogue.data['magnitude']))) - dmag,
float(np.ceil(np.max(catalogue.data['magnitude']))) + dmag,
dmag)
counter = np.h... | [
"def",
"_get_catalogue_bin_limits",
"(",
"catalogue",
",",
"dmag",
")",
":",
"mag_bins",
"=",
"np",
".",
"arange",
"(",
"float",
"(",
"np",
".",
"floor",
"(",
"np",
".",
"min",
"(",
"catalogue",
".",
"data",
"[",
"'magnitude'",
"]",
")",
")",
")",
"-... | Returns the magnitude bins corresponing to the catalogue | [
"Returns",
"the",
"magnitude",
"bins",
"corresponing",
"to",
"the",
"catalogue"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/catalogue_plots.py#L103-L114 |
313 | gem/oq-engine | openquake/hmtk/plotting/seismicity/catalogue_plots.py | plot_depth_histogram | def plot_depth_histogram(
catalogue, bin_width,
normalisation=False, bootstrap=None, filename=None,
figure_size=(8, 6), filetype='png', dpi=300, ax=None):
"""
Creates a histogram of the depths in the catalogue
:param catalogue:
Earthquake catalogue as instance of :class:
... | python | def plot_depth_histogram(
catalogue, bin_width,
normalisation=False, bootstrap=None, filename=None,
figure_size=(8, 6), filetype='png', dpi=300, ax=None):
"""
Creates a histogram of the depths in the catalogue
:param catalogue:
Earthquake catalogue as instance of :class:
... | [
"def",
"plot_depth_histogram",
"(",
"catalogue",
",",
"bin_width",
",",
"normalisation",
"=",
"False",
",",
"bootstrap",
"=",
"None",
",",
"filename",
"=",
"None",
",",
"figure_size",
"=",
"(",
"8",
",",
"6",
")",
",",
"filetype",
"=",
"'png'",
",",
"dpi... | Creates a histogram of the depths in the catalogue
:param catalogue:
Earthquake catalogue as instance of :class:
openquake.hmtk.seismicity.catalogue.Catalogue
:param float bin_width:
Width of the histogram for the depth bins
:param bool normalisation:
Normalise the histogram... | [
"Creates",
"a",
"histogram",
"of",
"the",
"depths",
"in",
"the",
"catalogue"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/catalogue_plots.py#L117-L158 |
314 | gem/oq-engine | openquake/hmtk/plotting/seismicity/catalogue_plots.py | plot_magnitude_depth_density | def plot_magnitude_depth_density(
catalogue, mag_int, depth_int,
logscale=False, normalisation=False, bootstrap=None, filename=None,
figure_size=(8, 6), filetype='png', dpi=300, ax=None):
"""
Creates a density plot of the magnitude and depth distribution
:param catalogue:
Ea... | python | def plot_magnitude_depth_density(
catalogue, mag_int, depth_int,
logscale=False, normalisation=False, bootstrap=None, filename=None,
figure_size=(8, 6), filetype='png', dpi=300, ax=None):
"""
Creates a density plot of the magnitude and depth distribution
:param catalogue:
Ea... | [
"def",
"plot_magnitude_depth_density",
"(",
"catalogue",
",",
"mag_int",
",",
"depth_int",
",",
"logscale",
"=",
"False",
",",
"normalisation",
"=",
"False",
",",
"bootstrap",
"=",
"None",
",",
"filename",
"=",
"None",
",",
"figure_size",
"=",
"(",
"8",
",",... | Creates a density plot of the magnitude and depth distribution
:param catalogue:
Earthquake catalogue as instance of :class:
openquake.hmtk.seismicity.catalogue.Catalogue
:param float mag_int:
Width of the histogram for the magnitude bins
:param float depth_int:
Width of the... | [
"Creates",
"a",
"density",
"plot",
"of",
"the",
"magnitude",
"and",
"depth",
"distribution"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/catalogue_plots.py#L161-L218 |
315 | gem/oq-engine | openquake/hmtk/plotting/seismicity/catalogue_plots.py | plot_magnitude_time_scatter | def plot_magnitude_time_scatter(
catalogue, plot_error=False, fmt_string='o', filename=None,
figure_size=(8, 6), filetype='png', dpi=300, ax=None):
"""
Creates a simple scatter plot of magnitude with time
:param catalogue:
Earthquake catalogue as instance of :class:
openquak... | python | def plot_magnitude_time_scatter(
catalogue, plot_error=False, fmt_string='o', filename=None,
figure_size=(8, 6), filetype='png', dpi=300, ax=None):
"""
Creates a simple scatter plot of magnitude with time
:param catalogue:
Earthquake catalogue as instance of :class:
openquak... | [
"def",
"plot_magnitude_time_scatter",
"(",
"catalogue",
",",
"plot_error",
"=",
"False",
",",
"fmt_string",
"=",
"'o'",
",",
"filename",
"=",
"None",
",",
"figure_size",
"=",
"(",
"8",
",",
"6",
")",
",",
"filetype",
"=",
"'png'",
",",
"dpi",
"=",
"300",... | Creates a simple scatter plot of magnitude with time
:param catalogue:
Earthquake catalogue as instance of :class:
openquake.hmtk.seismicity.catalogue.Catalogue
:param bool plot_error:
Choose to plot error bars (True) or not (False)
:param str fmt_string:
Symbology of plot | [
"Creates",
"a",
"simple",
"scatter",
"plot",
"of",
"magnitude",
"with",
"time"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/catalogue_plots.py#L221-L258 |
316 | gem/oq-engine | openquake/hmtk/plotting/seismicity/catalogue_plots.py | plot_magnitude_time_density | def plot_magnitude_time_density(
catalogue, mag_int, time_int, completeness=None,
normalisation=False, logscale=True, bootstrap=None, xlim=[], ylim=[],
filename=None, figure_size=(8, 6), filetype='png', dpi=300, ax=None):
"""
Creates a plot of magnitude-time density
:param catalogue... | python | def plot_magnitude_time_density(
catalogue, mag_int, time_int, completeness=None,
normalisation=False, logscale=True, bootstrap=None, xlim=[], ylim=[],
filename=None, figure_size=(8, 6), filetype='png', dpi=300, ax=None):
"""
Creates a plot of magnitude-time density
:param catalogue... | [
"def",
"plot_magnitude_time_density",
"(",
"catalogue",
",",
"mag_int",
",",
"time_int",
",",
"completeness",
"=",
"None",
",",
"normalisation",
"=",
"False",
",",
"logscale",
"=",
"True",
",",
"bootstrap",
"=",
"None",
",",
"xlim",
"=",
"[",
"]",
",",
"yl... | Creates a plot of magnitude-time density
:param catalogue:
Earthquake catalogue as instance of :class:
openquake.hmtk.seismicity.catalogue.Catalogue
:param float mag_int:
Width of the histogram for the magnitude bins
:param float time_int:
Width of the histogram for the time... | [
"Creates",
"a",
"plot",
"of",
"magnitude",
"-",
"time",
"density"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/catalogue_plots.py#L261-L342 |
317 | gem/oq-engine | openquake/hmtk/plotting/seismicity/catalogue_plots.py | _plot_completeness | def _plot_completeness(ax, comw, start_time, end_time):
'''
Adds completeness intervals to a plot
'''
comw = np.array(comw)
comp = np.column_stack([np.hstack([end_time, comw[:, 0], start_time]),
np.hstack([comw[0, 1], comw[:, 1], comw[-1, 1]])])
ax.step(comp[:-1, 0], ... | python | def _plot_completeness(ax, comw, start_time, end_time):
'''
Adds completeness intervals to a plot
'''
comw = np.array(comw)
comp = np.column_stack([np.hstack([end_time, comw[:, 0], start_time]),
np.hstack([comw[0, 1], comw[:, 1], comw[-1, 1]])])
ax.step(comp[:-1, 0], ... | [
"def",
"_plot_completeness",
"(",
"ax",
",",
"comw",
",",
"start_time",
",",
"end_time",
")",
":",
"comw",
"=",
"np",
".",
"array",
"(",
"comw",
")",
"comp",
"=",
"np",
".",
"column_stack",
"(",
"[",
"np",
".",
"hstack",
"(",
"[",
"end_time",
",",
... | Adds completeness intervals to a plot | [
"Adds",
"completeness",
"intervals",
"to",
"a",
"plot"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/catalogue_plots.py#L345-L353 |
318 | gem/oq-engine | openquake/hmtk/plotting/seismicity/catalogue_plots.py | get_completeness_adjusted_table | def get_completeness_adjusted_table(catalogue, completeness, dmag,
offset=1.0E-5, end_year=None, plot=False,
figure_size=(8, 6), filename=None,
filetype='png', dpi=300, ax=None):
"""
Counts the number of ... | python | def get_completeness_adjusted_table(catalogue, completeness, dmag,
offset=1.0E-5, end_year=None, plot=False,
figure_size=(8, 6), filename=None,
filetype='png', dpi=300, ax=None):
"""
Counts the number of ... | [
"def",
"get_completeness_adjusted_table",
"(",
"catalogue",
",",
"completeness",
",",
"dmag",
",",
"offset",
"=",
"1.0E-5",
",",
"end_year",
"=",
"None",
",",
"plot",
"=",
"False",
",",
"figure_size",
"=",
"(",
"8",
",",
"6",
")",
",",
"filename",
"=",
"... | Counts the number of earthquakes in each magnitude bin and normalises
the rate to annual rates, taking into account the completeness | [
"Counts",
"the",
"number",
"of",
"earthquakes",
"in",
"each",
"magnitude",
"bin",
"and",
"normalises",
"the",
"rate",
"to",
"annual",
"rates",
"taking",
"into",
"account",
"the",
"completeness"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/catalogue_plots.py#L356-L417 |
319 | gem/oq-engine | openquake/hmtk/plotting/seismicity/catalogue_plots.py | plot_observed_recurrence | def plot_observed_recurrence(
catalogue, completeness, dmag, end_year=None, filename=None,
figure_size=(8, 6), filetype='png', dpi=300, ax=None):
"""
Plots the observed recurrence taking into account the completeness
"""
# Get completeness adjusted recurrence table
if isinstance(comp... | python | def plot_observed_recurrence(
catalogue, completeness, dmag, end_year=None, filename=None,
figure_size=(8, 6), filetype='png', dpi=300, ax=None):
"""
Plots the observed recurrence taking into account the completeness
"""
# Get completeness adjusted recurrence table
if isinstance(comp... | [
"def",
"plot_observed_recurrence",
"(",
"catalogue",
",",
"completeness",
",",
"dmag",
",",
"end_year",
"=",
"None",
",",
"filename",
"=",
"None",
",",
"figure_size",
"=",
"(",
"8",
",",
"6",
")",
",",
"filetype",
"=",
"'png'",
",",
"dpi",
"=",
"300",
... | Plots the observed recurrence taking into account the completeness | [
"Plots",
"the",
"observed",
"recurrence",
"taking",
"into",
"account",
"the",
"completeness"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/catalogue_plots.py#L420-L452 |
320 | gem/oq-engine | openquake/hmtk/strain/geodetic_strain.py | GeodeticStrain.get_number_observations | def get_number_observations(self):
'''
Returns the number of observations in the data file
'''
if isinstance(self.data, dict) and ('exx' in self.data.keys()):
return len(self.data['exx'])
else:
return 0 | python | def get_number_observations(self):
'''
Returns the number of observations in the data file
'''
if isinstance(self.data, dict) and ('exx' in self.data.keys()):
return len(self.data['exx'])
else:
return 0 | [
"def",
"get_number_observations",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"data",
",",
"dict",
")",
"and",
"(",
"'exx'",
"in",
"self",
".",
"data",
".",
"keys",
"(",
")",
")",
":",
"return",
"len",
"(",
"self",
".",
"data",
"["... | Returns the number of observations in the data file | [
"Returns",
"the",
"number",
"of",
"observations",
"in",
"the",
"data",
"file"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/strain/geodetic_strain.py#L137-L144 |
321 | gem/oq-engine | openquake/commands/plot_lc.py | plot_lc | def plot_lc(calc_id, aid=None):
"""
Plot loss curves given a calculation id and an asset ordinal.
"""
# read the hazard data
dstore = util.read(calc_id)
dset = dstore['agg_curves-rlzs']
if aid is None: # plot the global curves
plt = make_figure(dset.attrs['return_periods'], dset.val... | python | def plot_lc(calc_id, aid=None):
"""
Plot loss curves given a calculation id and an asset ordinal.
"""
# read the hazard data
dstore = util.read(calc_id)
dset = dstore['agg_curves-rlzs']
if aid is None: # plot the global curves
plt = make_figure(dset.attrs['return_periods'], dset.val... | [
"def",
"plot_lc",
"(",
"calc_id",
",",
"aid",
"=",
"None",
")",
":",
"# read the hazard data",
"dstore",
"=",
"util",
".",
"read",
"(",
"calc_id",
")",
"dset",
"=",
"dstore",
"[",
"'agg_curves-rlzs'",
"]",
"if",
"aid",
"is",
"None",
":",
"# plot the global... | Plot loss curves given a calculation id and an asset ordinal. | [
"Plot",
"loss",
"curves",
"given",
"a",
"calculation",
"id",
"and",
"an",
"asset",
"ordinal",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/plot_lc.py#L41-L52 |
322 | gem/oq-engine | openquake/hazardlib/gsim/nshmp_2014.py | get_weighted_poes | def get_weighted_poes(gsim, sctx, rctx, dctx, imt, imls, truncation_level,
weighting=DEFAULT_WEIGHTING):
"""
This function implements the NGA West 2 GMPE epistemic uncertainty
adjustment factor without re-calculating the actual GMPE each time.
:param gsim:
Instance of the ... | python | def get_weighted_poes(gsim, sctx, rctx, dctx, imt, imls, truncation_level,
weighting=DEFAULT_WEIGHTING):
"""
This function implements the NGA West 2 GMPE epistemic uncertainty
adjustment factor without re-calculating the actual GMPE each time.
:param gsim:
Instance of the ... | [
"def",
"get_weighted_poes",
"(",
"gsim",
",",
"sctx",
",",
"rctx",
",",
"dctx",
",",
"imt",
",",
"imls",
",",
"truncation_level",
",",
"weighting",
"=",
"DEFAULT_WEIGHTING",
")",
":",
"if",
"truncation_level",
"is",
"not",
"None",
"and",
"truncation_level",
... | This function implements the NGA West 2 GMPE epistemic uncertainty
adjustment factor without re-calculating the actual GMPE each time.
:param gsim:
Instance of the GMPE
:param list weighting:
Weightings as a list of tuples of (weight, number standard deviations
of the epistemic unce... | [
"This",
"function",
"implements",
"the",
"NGA",
"West",
"2",
"GMPE",
"epistemic",
"uncertainty",
"adjustment",
"factor",
"without",
"re",
"-",
"calculating",
"the",
"actual",
"GMPE",
"each",
"time",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/nshmp_2014.py#L102-L146 |
323 | gem/oq-engine | openquake/commonlib/shapefileparser.py | register_fields | def register_fields(w):
"""
Register shapefile fields.
"""
PARAMS_LIST = [BASE_PARAMS, GEOMETRY_PARAMS, MFD_PARAMS]
for PARAMS in PARAMS_LIST:
for _, param, dtype in PARAMS:
w.field(param, fieldType=dtype, size=FIELD_SIZE)
PARAMS_LIST = [
RATE_PARAMS, STRIKE_PARAMS, ... | python | def register_fields(w):
"""
Register shapefile fields.
"""
PARAMS_LIST = [BASE_PARAMS, GEOMETRY_PARAMS, MFD_PARAMS]
for PARAMS in PARAMS_LIST:
for _, param, dtype in PARAMS:
w.field(param, fieldType=dtype, size=FIELD_SIZE)
PARAMS_LIST = [
RATE_PARAMS, STRIKE_PARAMS, ... | [
"def",
"register_fields",
"(",
"w",
")",
":",
"PARAMS_LIST",
"=",
"[",
"BASE_PARAMS",
",",
"GEOMETRY_PARAMS",
",",
"MFD_PARAMS",
"]",
"for",
"PARAMS",
"in",
"PARAMS_LIST",
":",
"for",
"_",
",",
"param",
",",
"dtype",
"in",
"PARAMS",
":",
"w",
".",
"field... | Register shapefile fields. | [
"Register",
"shapefile",
"fields",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L86-L103 |
324 | gem/oq-engine | openquake/commonlib/shapefileparser.py | extract_source_params | def extract_source_params(src):
"""
Extract params from source object.
"""
tags = get_taglist(src)
data = []
for key, param, vtype in BASE_PARAMS:
if key in src.attrib:
if vtype == "c":
data.append((param, src.attrib[key]))
elif vtype == "f":
... | python | def extract_source_params(src):
"""
Extract params from source object.
"""
tags = get_taglist(src)
data = []
for key, param, vtype in BASE_PARAMS:
if key in src.attrib:
if vtype == "c":
data.append((param, src.attrib[key]))
elif vtype == "f":
... | [
"def",
"extract_source_params",
"(",
"src",
")",
":",
"tags",
"=",
"get_taglist",
"(",
"src",
")",
"data",
"=",
"[",
"]",
"for",
"key",
",",
"param",
",",
"vtype",
"in",
"BASE_PARAMS",
":",
"if",
"key",
"in",
"src",
".",
"attrib",
":",
"if",
"vtype",... | Extract params from source object. | [
"Extract",
"params",
"from",
"source",
"object",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L120-L143 |
325 | gem/oq-engine | openquake/commonlib/shapefileparser.py | parse_complex_fault_geometry | def parse_complex_fault_geometry(node):
"""
Parses a complex fault geometry node returning both the attributes and
parameters in a dictionary
"""
assert "complexFaultGeometry" in node.tag
# Get general attributes
geometry = {"intermediateEdges": []}
for subnode in node:
crds = su... | python | def parse_complex_fault_geometry(node):
"""
Parses a complex fault geometry node returning both the attributes and
parameters in a dictionary
"""
assert "complexFaultGeometry" in node.tag
# Get general attributes
geometry = {"intermediateEdges": []}
for subnode in node:
crds = su... | [
"def",
"parse_complex_fault_geometry",
"(",
"node",
")",
":",
"assert",
"\"complexFaultGeometry\"",
"in",
"node",
".",
"tag",
"# Get general attributes",
"geometry",
"=",
"{",
"\"intermediateEdges\"",
":",
"[",
"]",
"}",
"for",
"subnode",
"in",
"node",
":",
"crds"... | Parses a complex fault geometry node returning both the attributes and
parameters in a dictionary | [
"Parses",
"a",
"complex",
"fault",
"geometry",
"node",
"returning",
"both",
"the",
"attributes",
"and",
"parameters",
"in",
"a",
"dictionary"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L201-L231 |
326 | gem/oq-engine | openquake/commonlib/shapefileparser.py | parse_planar_fault_geometry | def parse_planar_fault_geometry(node):
"""
Parses a planar fault geometry node returning both the attributes and
parameters in a dictionary
"""
assert "planarSurface" in node.tag
geometry = {"strike": node.attrib["strike"],
"dip": node.attrib["dip"]}
upper_depth = numpy.inf
... | python | def parse_planar_fault_geometry(node):
"""
Parses a planar fault geometry node returning both the attributes and
parameters in a dictionary
"""
assert "planarSurface" in node.tag
geometry = {"strike": node.attrib["strike"],
"dip": node.attrib["dip"]}
upper_depth = numpy.inf
... | [
"def",
"parse_planar_fault_geometry",
"(",
"node",
")",
":",
"assert",
"\"planarSurface\"",
"in",
"node",
".",
"tag",
"geometry",
"=",
"{",
"\"strike\"",
":",
"node",
".",
"attrib",
"[",
"\"strike\"",
"]",
",",
"\"dip\"",
":",
"node",
".",
"attrib",
"[",
"... | Parses a planar fault geometry node returning both the attributes and
parameters in a dictionary | [
"Parses",
"a",
"planar",
"fault",
"geometry",
"node",
"returning",
"both",
"the",
"attributes",
"and",
"parameters",
"in",
"a",
"dictionary"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L234-L256 |
327 | gem/oq-engine | openquake/commonlib/shapefileparser.py | extract_mfd_params | def extract_mfd_params(src):
"""
Extracts the MFD parameters from an object
"""
tags = get_taglist(src)
if "incrementalMFD" in tags:
mfd_node = src.nodes[tags.index("incrementalMFD")]
elif "truncGutenbergRichterMFD" in tags:
mfd_node = src.nodes[tags.index("truncGutenbergRichterM... | python | def extract_mfd_params(src):
"""
Extracts the MFD parameters from an object
"""
tags = get_taglist(src)
if "incrementalMFD" in tags:
mfd_node = src.nodes[tags.index("incrementalMFD")]
elif "truncGutenbergRichterMFD" in tags:
mfd_node = src.nodes[tags.index("truncGutenbergRichterM... | [
"def",
"extract_mfd_params",
"(",
"src",
")",
":",
"tags",
"=",
"get_taglist",
"(",
"src",
")",
"if",
"\"incrementalMFD\"",
"in",
"tags",
":",
"mfd_node",
"=",
"src",
".",
"nodes",
"[",
"tags",
".",
"index",
"(",
"\"incrementalMFD\"",
")",
"]",
"elif",
"... | Extracts the MFD parameters from an object | [
"Extracts",
"the",
"MFD",
"parameters",
"from",
"an",
"object"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L322-L359 |
328 | gem/oq-engine | openquake/commonlib/shapefileparser.py | extract_source_hypocentral_depths | def extract_source_hypocentral_depths(src):
"""
Extract source hypocentral depths.
"""
if "pointSource" not in src.tag and "areaSource" not in src.tag:
hds = dict([(key, None) for key, _ in HDEPTH_PARAMS])
hdsw = dict([(key, None) for key, _ in HDW_PARAMS])
return hds, hdsw
... | python | def extract_source_hypocentral_depths(src):
"""
Extract source hypocentral depths.
"""
if "pointSource" not in src.tag and "areaSource" not in src.tag:
hds = dict([(key, None) for key, _ in HDEPTH_PARAMS])
hdsw = dict([(key, None) for key, _ in HDW_PARAMS])
return hds, hdsw
... | [
"def",
"extract_source_hypocentral_depths",
"(",
"src",
")",
":",
"if",
"\"pointSource\"",
"not",
"in",
"src",
".",
"tag",
"and",
"\"areaSource\"",
"not",
"in",
"src",
".",
"tag",
":",
"hds",
"=",
"dict",
"(",
"[",
"(",
"key",
",",
"None",
")",
"for",
... | Extract source hypocentral depths. | [
"Extract",
"source",
"hypocentral",
"depths",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L397-L425 |
329 | gem/oq-engine | openquake/commonlib/shapefileparser.py | extract_source_planes_strikes_dips | def extract_source_planes_strikes_dips(src):
"""
Extract strike and dip angles for source defined by multiple planes.
"""
if "characteristicFaultSource" not in src.tag:
strikes = dict([(key, None) for key, _ in PLANES_STRIKES_PARAM])
dips = dict([(key, None) for key, _ in PLANES_DIPS_PAR... | python | def extract_source_planes_strikes_dips(src):
"""
Extract strike and dip angles for source defined by multiple planes.
"""
if "characteristicFaultSource" not in src.tag:
strikes = dict([(key, None) for key, _ in PLANES_STRIKES_PARAM])
dips = dict([(key, None) for key, _ in PLANES_DIPS_PAR... | [
"def",
"extract_source_planes_strikes_dips",
"(",
"src",
")",
":",
"if",
"\"characteristicFaultSource\"",
"not",
"in",
"src",
".",
"tag",
":",
"strikes",
"=",
"dict",
"(",
"[",
"(",
"key",
",",
"None",
")",
"for",
"key",
",",
"_",
"in",
"PLANES_STRIKES_PARAM... | Extract strike and dip angles for source defined by multiple planes. | [
"Extract",
"strike",
"and",
"dip",
"angles",
"for",
"source",
"defined",
"by",
"multiple",
"planes",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L428-L456 |
330 | gem/oq-engine | openquake/commonlib/shapefileparser.py | set_params | def set_params(w, src):
"""
Set source parameters.
"""
params = extract_source_params(src)
# this is done because for characteristic sources geometry is in
# 'surface' attribute
params.update(extract_geometry_params(src))
mfd_pars, rate_pars = extract_mfd_params(src)
params.update(m... | python | def set_params(w, src):
"""
Set source parameters.
"""
params = extract_source_params(src)
# this is done because for characteristic sources geometry is in
# 'surface' attribute
params.update(extract_geometry_params(src))
mfd_pars, rate_pars = extract_mfd_params(src)
params.update(m... | [
"def",
"set_params",
"(",
"w",
",",
"src",
")",
":",
"params",
"=",
"extract_source_params",
"(",
"src",
")",
"# this is done because for characteristic sources geometry is in",
"# 'surface' attribute",
"params",
".",
"update",
"(",
"extract_geometry_params",
"(",
"src",
... | Set source parameters. | [
"Set",
"source",
"parameters",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L459-L486 |
331 | gem/oq-engine | openquake/commonlib/shapefileparser.py | set_area_geometry | def set_area_geometry(w, src):
"""
Set area polygon as shapefile geometry
"""
assert "areaSource" in src.tag
geometry_node = src.nodes[get_taglist(src).index("areaGeometry")]
area_attrs = parse_area_geometry(geometry_node)
w.poly(parts=[area_attrs["polygon"].tolist()]) | python | def set_area_geometry(w, src):
"""
Set area polygon as shapefile geometry
"""
assert "areaSource" in src.tag
geometry_node = src.nodes[get_taglist(src).index("areaGeometry")]
area_attrs = parse_area_geometry(geometry_node)
w.poly(parts=[area_attrs["polygon"].tolist()]) | [
"def",
"set_area_geometry",
"(",
"w",
",",
"src",
")",
":",
"assert",
"\"areaSource\"",
"in",
"src",
".",
"tag",
"geometry_node",
"=",
"src",
".",
"nodes",
"[",
"get_taglist",
"(",
"src",
")",
".",
"index",
"(",
"\"areaGeometry\"",
")",
"]",
"area_attrs",
... | Set area polygon as shapefile geometry | [
"Set",
"area",
"polygon",
"as",
"shapefile",
"geometry"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L489-L496 |
332 | gem/oq-engine | openquake/commonlib/shapefileparser.py | set_point_geometry | def set_point_geometry(w, src):
"""
Set point location as shapefile geometry.
"""
assert "pointSource" in src.tag
geometry_node = src.nodes[get_taglist(src).index("pointGeometry")]
point_attrs = parse_point_geometry(geometry_node)
w.point(point_attrs["point"][0], point_attrs["point"][1]) | python | def set_point_geometry(w, src):
"""
Set point location as shapefile geometry.
"""
assert "pointSource" in src.tag
geometry_node = src.nodes[get_taglist(src).index("pointGeometry")]
point_attrs = parse_point_geometry(geometry_node)
w.point(point_attrs["point"][0], point_attrs["point"][1]) | [
"def",
"set_point_geometry",
"(",
"w",
",",
"src",
")",
":",
"assert",
"\"pointSource\"",
"in",
"src",
".",
"tag",
"geometry_node",
"=",
"src",
".",
"nodes",
"[",
"get_taglist",
"(",
"src",
")",
".",
"index",
"(",
"\"pointGeometry\"",
")",
"]",
"point_attr... | Set point location as shapefile geometry. | [
"Set",
"point",
"location",
"as",
"shapefile",
"geometry",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L499-L506 |
333 | gem/oq-engine | openquake/commonlib/shapefileparser.py | set_simple_fault_geometry | def set_simple_fault_geometry(w, src):
"""
Set simple fault trace coordinates as shapefile geometry.
:parameter w:
Writer
:parameter src:
source
"""
assert "simpleFaultSource" in src.tag
geometry_node = src.nodes[get_taglist(src).index("simpleFaultGeometry")]
fault_attrs... | python | def set_simple_fault_geometry(w, src):
"""
Set simple fault trace coordinates as shapefile geometry.
:parameter w:
Writer
:parameter src:
source
"""
assert "simpleFaultSource" in src.tag
geometry_node = src.nodes[get_taglist(src).index("simpleFaultGeometry")]
fault_attrs... | [
"def",
"set_simple_fault_geometry",
"(",
"w",
",",
"src",
")",
":",
"assert",
"\"simpleFaultSource\"",
"in",
"src",
".",
"tag",
"geometry_node",
"=",
"src",
".",
"nodes",
"[",
"get_taglist",
"(",
"src",
")",
".",
"index",
"(",
"\"simpleFaultGeometry\"",
")",
... | Set simple fault trace coordinates as shapefile geometry.
:parameter w:
Writer
:parameter src:
source | [
"Set",
"simple",
"fault",
"trace",
"coordinates",
"as",
"shapefile",
"geometry",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L509-L521 |
334 | gem/oq-engine | openquake/commonlib/shapefileparser.py | set_simple_fault_geometry_3D | def set_simple_fault_geometry_3D(w, src):
"""
Builds a 3D polygon from a node instance
"""
assert "simpleFaultSource" in src.tag
geometry_node = src.nodes[get_taglist(src).index("simpleFaultGeometry")]
fault_attrs = parse_simple_fault_geometry(geometry_node)
build_polygon_from_fault_attrs(w,... | python | def set_simple_fault_geometry_3D(w, src):
"""
Builds a 3D polygon from a node instance
"""
assert "simpleFaultSource" in src.tag
geometry_node = src.nodes[get_taglist(src).index("simpleFaultGeometry")]
fault_attrs = parse_simple_fault_geometry(geometry_node)
build_polygon_from_fault_attrs(w,... | [
"def",
"set_simple_fault_geometry_3D",
"(",
"w",
",",
"src",
")",
":",
"assert",
"\"simpleFaultSource\"",
"in",
"src",
".",
"tag",
"geometry_node",
"=",
"src",
".",
"nodes",
"[",
"get_taglist",
"(",
"src",
")",
".",
"index",
"(",
"\"simpleFaultGeometry\"",
")"... | Builds a 3D polygon from a node instance | [
"Builds",
"a",
"3D",
"polygon",
"from",
"a",
"node",
"instance"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L543-L550 |
335 | gem/oq-engine | openquake/commonlib/shapefileparser.py | SourceModel.appraise_source_model | def appraise_source_model(self):
"""
Identify parameters defined in NRML source model file, so that
shapefile contains only source model specific fields.
"""
for src in self.sources:
# source params
src_taglist = get_taglist(src)
if "areaSource... | python | def appraise_source_model(self):
"""
Identify parameters defined in NRML source model file, so that
shapefile contains only source model specific fields.
"""
for src in self.sources:
# source params
src_taglist = get_taglist(src)
if "areaSource... | [
"def",
"appraise_source_model",
"(",
"self",
")",
":",
"for",
"src",
"in",
"self",
".",
"sources",
":",
"# source params",
"src_taglist",
"=",
"get_taglist",
"(",
"src",
")",
"if",
"\"areaSource\"",
"in",
"src",
".",
"tag",
":",
"self",
".",
"has_area_source... | Identify parameters defined in NRML source model file, so that
shapefile contains only source model specific fields. | [
"Identify",
"parameters",
"defined",
"in",
"NRML",
"source",
"model",
"file",
"so",
"that",
"shapefile",
"contains",
"only",
"source",
"model",
"specific",
"fields",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L826-L884 |
336 | gem/oq-engine | openquake/commonlib/shapefileparser.py | SourceModelParser.write | def write(self, destination, source_model, name=None):
"""
Exports to NRML
"""
if os.path.exists(destination):
os.remove(destination)
self.destination = destination
if name:
source_model.name = name
output_source_model = Node("sourceModel",... | python | def write(self, destination, source_model, name=None):
"""
Exports to NRML
"""
if os.path.exists(destination):
os.remove(destination)
self.destination = destination
if name:
source_model.name = name
output_source_model = Node("sourceModel",... | [
"def",
"write",
"(",
"self",
",",
"destination",
",",
"source_model",
",",
"name",
"=",
"None",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"destination",
")",
":",
"os",
".",
"remove",
"(",
"destination",
")",
"self",
".",
"destination",
... | Exports to NRML | [
"Exports",
"to",
"NRML"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L937-L956 |
337 | gem/oq-engine | openquake/commonlib/shapefileparser.py | ShapefileParser.filter_params | def filter_params(self, src_mod):
"""
Remove params uneeded by source_model
"""
# point and area related params
STRIKE_PARAMS[src_mod.num_np:] = []
DIP_PARAMS[src_mod.num_np:] = []
RAKE_PARAMS[src_mod.num_np:] = []
NPW_PARAMS[src_mod.num_np:] = []
... | python | def filter_params(self, src_mod):
"""
Remove params uneeded by source_model
"""
# point and area related params
STRIKE_PARAMS[src_mod.num_np:] = []
DIP_PARAMS[src_mod.num_np:] = []
RAKE_PARAMS[src_mod.num_np:] = []
NPW_PARAMS[src_mod.num_np:] = []
... | [
"def",
"filter_params",
"(",
"self",
",",
"src_mod",
")",
":",
"# point and area related params",
"STRIKE_PARAMS",
"[",
"src_mod",
".",
"num_np",
":",
"]",
"=",
"[",
"]",
"DIP_PARAMS",
"[",
"src_mod",
".",
"num_np",
":",
"]",
"=",
"[",
"]",
"RAKE_PARAMS",
... | Remove params uneeded by source_model | [
"Remove",
"params",
"uneeded",
"by",
"source_model"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L960-L992 |
338 | gem/oq-engine | openquake/baselib/node.py | tostring | def tostring(node, indent=4, nsmap=None):
"""
Convert a node into an XML string by using the StreamingXMLWriter.
This is useful for testing purposes.
:param node: a node object (typically an ElementTree object)
:param indent: the indentation to use in the XML (default 4 spaces)
"""
out = io... | python | def tostring(node, indent=4, nsmap=None):
"""
Convert a node into an XML string by using the StreamingXMLWriter.
This is useful for testing purposes.
:param node: a node object (typically an ElementTree object)
:param indent: the indentation to use in the XML (default 4 spaces)
"""
out = io... | [
"def",
"tostring",
"(",
"node",
",",
"indent",
"=",
"4",
",",
"nsmap",
"=",
"None",
")",
":",
"out",
"=",
"io",
".",
"BytesIO",
"(",
")",
"writer",
"=",
"StreamingXMLWriter",
"(",
"out",
",",
"indent",
",",
"nsmap",
"=",
"nsmap",
")",
"writer",
"."... | Convert a node into an XML string by using the StreamingXMLWriter.
This is useful for testing purposes.
:param node: a node object (typically an ElementTree object)
:param indent: the indentation to use in the XML (default 4 spaces) | [
"Convert",
"a",
"node",
"into",
"an",
"XML",
"string",
"by",
"using",
"the",
"StreamingXMLWriter",
".",
"This",
"is",
"useful",
"for",
"testing",
"purposes",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L216-L227 |
339 | gem/oq-engine | openquake/baselib/node.py | parse | def parse(source, remove_comments=True, **kw):
"""Thin wrapper around ElementTree.parse"""
return ElementTree.parse(source, SourceLineParser(), **kw) | python | def parse(source, remove_comments=True, **kw):
"""Thin wrapper around ElementTree.parse"""
return ElementTree.parse(source, SourceLineParser(), **kw) | [
"def",
"parse",
"(",
"source",
",",
"remove_comments",
"=",
"True",
",",
"*",
"*",
"kw",
")",
":",
"return",
"ElementTree",
".",
"parse",
"(",
"source",
",",
"SourceLineParser",
"(",
")",
",",
"*",
"*",
"kw",
")"
] | Thin wrapper around ElementTree.parse | [
"Thin",
"wrapper",
"around",
"ElementTree",
".",
"parse"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L350-L352 |
340 | gem/oq-engine | openquake/baselib/node.py | iterparse | def iterparse(source, events=('end',), remove_comments=True, **kw):
"""Thin wrapper around ElementTree.iterparse"""
return ElementTree.iterparse(source, events, SourceLineParser(), **kw) | python | def iterparse(source, events=('end',), remove_comments=True, **kw):
"""Thin wrapper around ElementTree.iterparse"""
return ElementTree.iterparse(source, events, SourceLineParser(), **kw) | [
"def",
"iterparse",
"(",
"source",
",",
"events",
"=",
"(",
"'end'",
",",
")",
",",
"remove_comments",
"=",
"True",
",",
"*",
"*",
"kw",
")",
":",
"return",
"ElementTree",
".",
"iterparse",
"(",
"source",
",",
"events",
",",
"SourceLineParser",
"(",
")... | Thin wrapper around ElementTree.iterparse | [
"Thin",
"wrapper",
"around",
"ElementTree",
".",
"iterparse"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L355-L357 |
341 | gem/oq-engine | openquake/baselib/node.py | _displayattrs | def _displayattrs(attrib, expandattrs):
"""
Helper function to display the attributes of a Node object in lexicographic
order.
:param attrib: dictionary with the attributes
:param expandattrs: if True also displays the value of the attributes
"""
if not attrib:
return ''
if expa... | python | def _displayattrs(attrib, expandattrs):
"""
Helper function to display the attributes of a Node object in lexicographic
order.
:param attrib: dictionary with the attributes
:param expandattrs: if True also displays the value of the attributes
"""
if not attrib:
return ''
if expa... | [
"def",
"_displayattrs",
"(",
"attrib",
",",
"expandattrs",
")",
":",
"if",
"not",
"attrib",
":",
"return",
"''",
"if",
"expandattrs",
":",
"alist",
"=",
"[",
"'%s=%r'",
"%",
"item",
"for",
"item",
"in",
"sorted",
"(",
"attrib",
".",
"items",
"(",
")",
... | Helper function to display the attributes of a Node object in lexicographic
order.
:param attrib: dictionary with the attributes
:param expandattrs: if True also displays the value of the attributes | [
"Helper",
"function",
"to",
"display",
"the",
"attributes",
"of",
"a",
"Node",
"object",
"in",
"lexicographic",
"order",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L363-L377 |
342 | gem/oq-engine | openquake/baselib/node.py | _display | def _display(node, indent, expandattrs, expandvals, output):
"""Core function to display a Node object"""
attrs = _displayattrs(node.attrib, expandattrs)
if node.text is None or not expandvals:
val = ''
elif isinstance(node.text, str):
val = ' %s' % repr(node.text.strip())
else:
... | python | def _display(node, indent, expandattrs, expandvals, output):
"""Core function to display a Node object"""
attrs = _displayattrs(node.attrib, expandattrs)
if node.text is None or not expandvals:
val = ''
elif isinstance(node.text, str):
val = ' %s' % repr(node.text.strip())
else:
... | [
"def",
"_display",
"(",
"node",
",",
"indent",
",",
"expandattrs",
",",
"expandvals",
",",
"output",
")",
":",
"attrs",
"=",
"_displayattrs",
"(",
"node",
".",
"attrib",
",",
"expandattrs",
")",
"if",
"node",
".",
"text",
"is",
"None",
"or",
"not",
"ex... | Core function to display a Node object | [
"Core",
"function",
"to",
"display",
"a",
"Node",
"object"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L380-L391 |
343 | gem/oq-engine | openquake/baselib/node.py | to_literal | def to_literal(self):
"""
Convert the node into a literal Python object
"""
if not self.nodes:
return (self.tag, self.attrib, self.text, [])
else:
return (self.tag, self.attrib, self.text,
list(map(to_literal, self.nodes))) | python | def to_literal(self):
"""
Convert the node into a literal Python object
"""
if not self.nodes:
return (self.tag, self.attrib, self.text, [])
else:
return (self.tag, self.attrib, self.text,
list(map(to_literal, self.nodes))) | [
"def",
"to_literal",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"nodes",
":",
"return",
"(",
"self",
".",
"tag",
",",
"self",
".",
"attrib",
",",
"self",
".",
"text",
",",
"[",
"]",
")",
"else",
":",
"return",
"(",
"self",
".",
"tag",
","... | Convert the node into a literal Python object | [
"Convert",
"the",
"node",
"into",
"a",
"literal",
"Python",
"object"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L574-L582 |
344 | gem/oq-engine | openquake/baselib/node.py | pprint | def pprint(self, stream=None, indent=1, width=80, depth=None):
"""
Pretty print the underlying literal Python object
"""
pp.pprint(to_literal(self), stream, indent, width, depth) | python | def pprint(self, stream=None, indent=1, width=80, depth=None):
"""
Pretty print the underlying literal Python object
"""
pp.pprint(to_literal(self), stream, indent, width, depth) | [
"def",
"pprint",
"(",
"self",
",",
"stream",
"=",
"None",
",",
"indent",
"=",
"1",
",",
"width",
"=",
"80",
",",
"depth",
"=",
"None",
")",
":",
"pp",
".",
"pprint",
"(",
"to_literal",
"(",
"self",
")",
",",
"stream",
",",
"indent",
",",
"width",... | Pretty print the underlying literal Python object | [
"Pretty",
"print",
"the",
"underlying",
"literal",
"Python",
"object"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L585-L589 |
345 | gem/oq-engine | openquake/baselib/node.py | read_nodes | def read_nodes(fname, filter_elem, nodefactory=Node, remove_comments=True):
"""
Convert an XML file into a lazy iterator over Node objects
satifying the given specification, i.e. a function element -> boolean.
:param fname: file name of file object
:param filter_elem: element specification
In ... | python | def read_nodes(fname, filter_elem, nodefactory=Node, remove_comments=True):
"""
Convert an XML file into a lazy iterator over Node objects
satifying the given specification, i.e. a function element -> boolean.
:param fname: file name of file object
:param filter_elem: element specification
In ... | [
"def",
"read_nodes",
"(",
"fname",
",",
"filter_elem",
",",
"nodefactory",
"=",
"Node",
",",
"remove_comments",
"=",
"True",
")",
":",
"try",
":",
"for",
"_",
",",
"el",
"in",
"iterparse",
"(",
"fname",
",",
"remove_comments",
"=",
"remove_comments",
")",
... | Convert an XML file into a lazy iterator over Node objects
satifying the given specification, i.e. a function element -> boolean.
:param fname: file name of file object
:param filter_elem: element specification
In case of errors, add the file name to the error message. | [
"Convert",
"an",
"XML",
"file",
"into",
"a",
"lazy",
"iterator",
"over",
"Node",
"objects",
"satifying",
"the",
"given",
"specification",
"i",
".",
"e",
".",
"a",
"function",
"element",
"-",
">",
"boolean",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L666-L686 |
346 | gem/oq-engine | openquake/baselib/node.py | node_from_xml | def node_from_xml(xmlfile, nodefactory=Node):
"""
Convert a .xml file into a Node object.
:param xmlfile: a file name or file object open for reading
"""
root = parse(xmlfile).getroot()
return node_from_elem(root, nodefactory) | python | def node_from_xml(xmlfile, nodefactory=Node):
"""
Convert a .xml file into a Node object.
:param xmlfile: a file name or file object open for reading
"""
root = parse(xmlfile).getroot()
return node_from_elem(root, nodefactory) | [
"def",
"node_from_xml",
"(",
"xmlfile",
",",
"nodefactory",
"=",
"Node",
")",
":",
"root",
"=",
"parse",
"(",
"xmlfile",
")",
".",
"getroot",
"(",
")",
"return",
"node_from_elem",
"(",
"root",
",",
"nodefactory",
")"
] | Convert a .xml file into a Node object.
:param xmlfile: a file name or file object open for reading | [
"Convert",
"a",
".",
"xml",
"file",
"into",
"a",
"Node",
"object",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L689-L696 |
347 | gem/oq-engine | openquake/baselib/node.py | node_from_ini | def node_from_ini(ini_file, nodefactory=Node, root_name='ini'):
"""
Convert a .ini file into a Node object.
:param ini_file: a filename or a file like object in read mode
"""
fileobj = open(ini_file) if isinstance(ini_file, str) else ini_file
cfp = configparser.RawConfigParser()
cfp.read_fi... | python | def node_from_ini(ini_file, nodefactory=Node, root_name='ini'):
"""
Convert a .ini file into a Node object.
:param ini_file: a filename or a file like object in read mode
"""
fileobj = open(ini_file) if isinstance(ini_file, str) else ini_file
cfp = configparser.RawConfigParser()
cfp.read_fi... | [
"def",
"node_from_ini",
"(",
"ini_file",
",",
"nodefactory",
"=",
"Node",
",",
"root_name",
"=",
"'ini'",
")",
":",
"fileobj",
"=",
"open",
"(",
"ini_file",
")",
"if",
"isinstance",
"(",
"ini_file",
",",
"str",
")",
"else",
"ini_file",
"cfp",
"=",
"confi... | Convert a .ini file into a Node object.
:param ini_file: a filename or a file like object in read mode | [
"Convert",
"a",
".",
"ini",
"file",
"into",
"a",
"Node",
"object",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L719-L733 |
348 | gem/oq-engine | openquake/baselib/node.py | node_to_ini | def node_to_ini(node, output=sys.stdout):
"""
Convert a Node object with the right structure into a .ini file.
:params node: a Node object
:params output: a file-like object opened in write mode
"""
for subnode in node:
output.write(u'\n[%s]\n' % subnode.tag)
for name, value in ... | python | def node_to_ini(node, output=sys.stdout):
"""
Convert a Node object with the right structure into a .ini file.
:params node: a Node object
:params output: a file-like object opened in write mode
"""
for subnode in node:
output.write(u'\n[%s]\n' % subnode.tag)
for name, value in ... | [
"def",
"node_to_ini",
"(",
"node",
",",
"output",
"=",
"sys",
".",
"stdout",
")",
":",
"for",
"subnode",
"in",
"node",
":",
"output",
".",
"write",
"(",
"u'\\n[%s]\\n'",
"%",
"subnode",
".",
"tag",
")",
"for",
"name",
",",
"value",
"in",
"sorted",
"(... | Convert a Node object with the right structure into a .ini file.
:params node: a Node object
:params output: a file-like object opened in write mode | [
"Convert",
"a",
"Node",
"object",
"with",
"the",
"right",
"structure",
"into",
"a",
".",
"ini",
"file",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L736-L747 |
349 | gem/oq-engine | openquake/baselib/node.py | node_copy | def node_copy(node, nodefactory=Node):
"""Make a deep copy of the node"""
return nodefactory(node.tag, node.attrib.copy(), node.text,
[node_copy(n, nodefactory) for n in node]) | python | def node_copy(node, nodefactory=Node):
"""Make a deep copy of the node"""
return nodefactory(node.tag, node.attrib.copy(), node.text,
[node_copy(n, nodefactory) for n in node]) | [
"def",
"node_copy",
"(",
"node",
",",
"nodefactory",
"=",
"Node",
")",
":",
"return",
"nodefactory",
"(",
"node",
".",
"tag",
",",
"node",
".",
"attrib",
".",
"copy",
"(",
")",
",",
"node",
".",
"text",
",",
"[",
"node_copy",
"(",
"n",
",",
"nodefa... | Make a deep copy of the node | [
"Make",
"a",
"deep",
"copy",
"of",
"the",
"node"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L750-L753 |
350 | gem/oq-engine | openquake/baselib/node.py | context | def context(fname, node):
"""
Context manager managing exceptions and adding line number of the
current node and name of the current file to the error message.
:param fname: the current file being processed
:param node: the current node being processed
"""
try:
yield node
except... | python | def context(fname, node):
"""
Context manager managing exceptions and adding line number of the
current node and name of the current file to the error message.
:param fname: the current file being processed
:param node: the current node being processed
"""
try:
yield node
except... | [
"def",
"context",
"(",
"fname",
",",
"node",
")",
":",
"try",
":",
"yield",
"node",
"except",
"Exception",
":",
"etype",
",",
"exc",
",",
"tb",
"=",
"sys",
".",
"exc_info",
"(",
")",
"msg",
"=",
"'node %s: %s, line %s of %s'",
"%",
"(",
"striptag",
"("... | Context manager managing exceptions and adding line number of the
current node and name of the current file to the error message.
:param fname: the current file being processed
:param node: the current node being processed | [
"Context",
"manager",
"managing",
"exceptions",
"and",
"adding",
"line",
"number",
"of",
"the",
"current",
"node",
"and",
"name",
"of",
"the",
"current",
"file",
"to",
"the",
"error",
"message",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L757-L771 |
351 | gem/oq-engine | openquake/baselib/node.py | StreamingXMLWriter.shorten | def shorten(self, tag):
"""
Get the short representation of a fully qualified tag
:param str tag: a (fully qualified or not) XML tag
"""
if tag.startswith('{'):
ns, _tag = tag.rsplit('}')
tag = self.nsmap.get(ns[1:], '') + _tag
return tag | python | def shorten(self, tag):
"""
Get the short representation of a fully qualified tag
:param str tag: a (fully qualified or not) XML tag
"""
if tag.startswith('{'):
ns, _tag = tag.rsplit('}')
tag = self.nsmap.get(ns[1:], '') + _tag
return tag | [
"def",
"shorten",
"(",
"self",
",",
"tag",
")",
":",
"if",
"tag",
".",
"startswith",
"(",
"'{'",
")",
":",
"ns",
",",
"_tag",
"=",
"tag",
".",
"rsplit",
"(",
"'}'",
")",
"tag",
"=",
"self",
".",
"nsmap",
".",
"get",
"(",
"ns",
"[",
"1",
":",
... | Get the short representation of a fully qualified tag
:param str tag: a (fully qualified or not) XML tag | [
"Get",
"the",
"short",
"representation",
"of",
"a",
"fully",
"qualified",
"tag"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L254-L263 |
352 | gem/oq-engine | openquake/baselib/node.py | StreamingXMLWriter._write | def _write(self, text):
"""Write text by respecting the current indentlevel"""
spaces = ' ' * (self.indent * self.indentlevel)
t = spaces + text.strip() + '\n'
if hasattr(t, 'encode'):
t = t.encode(self.encoding, 'xmlcharrefreplace')
self.stream.write(t) | python | def _write(self, text):
"""Write text by respecting the current indentlevel"""
spaces = ' ' * (self.indent * self.indentlevel)
t = spaces + text.strip() + '\n'
if hasattr(t, 'encode'):
t = t.encode(self.encoding, 'xmlcharrefreplace')
self.stream.write(t) | [
"def",
"_write",
"(",
"self",
",",
"text",
")",
":",
"spaces",
"=",
"' '",
"*",
"(",
"self",
".",
"indent",
"*",
"self",
".",
"indentlevel",
")",
"t",
"=",
"spaces",
"+",
"text",
".",
"strip",
"(",
")",
"+",
"'\\n'",
"if",
"hasattr",
"(",
"t",
... | Write text by respecting the current indentlevel | [
"Write",
"text",
"by",
"respecting",
"the",
"current",
"indentlevel"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L265-L271 |
353 | gem/oq-engine | openquake/baselib/node.py | StreamingXMLWriter.start_tag | def start_tag(self, name, attrs=None):
"""Open an XML tag"""
if not attrs:
self._write('<%s>' % name)
else:
self._write('<' + name)
for (name, value) in sorted(attrs.items()):
self._write(
' %s=%s' % (name, quoteattr(scienti... | python | def start_tag(self, name, attrs=None):
"""Open an XML tag"""
if not attrs:
self._write('<%s>' % name)
else:
self._write('<' + name)
for (name, value) in sorted(attrs.items()):
self._write(
' %s=%s' % (name, quoteattr(scienti... | [
"def",
"start_tag",
"(",
"self",
",",
"name",
",",
"attrs",
"=",
"None",
")",
":",
"if",
"not",
"attrs",
":",
"self",
".",
"_write",
"(",
"'<%s>'",
"%",
"name",
")",
"else",
":",
"self",
".",
"_write",
"(",
"'<'",
"+",
"name",
")",
"for",
"(",
... | Open an XML tag | [
"Open",
"an",
"XML",
"tag"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L279-L289 |
354 | gem/oq-engine | openquake/baselib/node.py | Node.getnodes | def getnodes(self, name):
"Return the direct subnodes with name 'name'"
for node in self.nodes:
if striptag(node.tag) == name:
yield node | python | def getnodes(self, name):
"Return the direct subnodes with name 'name'"
for node in self.nodes:
if striptag(node.tag) == name:
yield node | [
"def",
"getnodes",
"(",
"self",
",",
"name",
")",
":",
"for",
"node",
"in",
"self",
".",
"nodes",
":",
"if",
"striptag",
"(",
"node",
".",
"tag",
")",
"==",
"name",
":",
"yield",
"node"
] | Return the direct subnodes with name 'name | [
"Return",
"the",
"direct",
"subnodes",
"with",
"name",
"name"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L458-L462 |
355 | gem/oq-engine | openquake/baselib/node.py | Node.append | def append(self, node):
"Append a new subnode"
if not isinstance(node, self.__class__):
raise TypeError('Expected Node instance, got %r' % node)
self.nodes.append(node) | python | def append(self, node):
"Append a new subnode"
if not isinstance(node, self.__class__):
raise TypeError('Expected Node instance, got %r' % node)
self.nodes.append(node) | [
"def",
"append",
"(",
"self",
",",
"node",
")",
":",
"if",
"not",
"isinstance",
"(",
"node",
",",
"self",
".",
"__class__",
")",
":",
"raise",
"TypeError",
"(",
"'Expected Node instance, got %r'",
"%",
"node",
")",
"self",
".",
"nodes",
".",
"append",
"(... | Append a new subnode | [
"Append",
"a",
"new",
"subnode"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L464-L468 |
356 | gem/oq-engine | openquake/baselib/node.py | ValidatingXmlParser.parse_bytes | def parse_bytes(self, bytestr, isfinal=True):
"""
Parse a byte string. If the string is very large, split it in chuncks
and parse each chunk with isfinal=False, then parse an empty chunk
with isfinal=True.
"""
with self._context():
self.filename = None
... | python | def parse_bytes(self, bytestr, isfinal=True):
"""
Parse a byte string. If the string is very large, split it in chuncks
and parse each chunk with isfinal=False, then parse an empty chunk
with isfinal=True.
"""
with self._context():
self.filename = None
... | [
"def",
"parse_bytes",
"(",
"self",
",",
"bytestr",
",",
"isfinal",
"=",
"True",
")",
":",
"with",
"self",
".",
"_context",
"(",
")",
":",
"self",
".",
"filename",
"=",
"None",
"self",
".",
"p",
".",
"Parse",
"(",
"bytestr",
",",
"isfinal",
")",
"re... | Parse a byte string. If the string is very large, split it in chuncks
and parse each chunk with isfinal=False, then parse an empty chunk
with isfinal=True. | [
"Parse",
"a",
"byte",
"string",
".",
"If",
"the",
"string",
"is",
"very",
"large",
"split",
"it",
"in",
"chuncks",
"and",
"parse",
"each",
"chunk",
"with",
"isfinal",
"=",
"False",
"then",
"parse",
"an",
"empty",
"chunk",
"with",
"isfinal",
"=",
"True",
... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L815-L824 |
357 | gem/oq-engine | openquake/baselib/node.py | ValidatingXmlParser.parse_file | def parse_file(self, file_or_fname):
"""
Parse a file or a filename
"""
with self._context():
if hasattr(file_or_fname, 'read'):
self.filename = getattr(
file_or_fname, 'name', file_or_fname.__class__.__name__)
self.p.ParseF... | python | def parse_file(self, file_or_fname):
"""
Parse a file or a filename
"""
with self._context():
if hasattr(file_or_fname, 'read'):
self.filename = getattr(
file_or_fname, 'name', file_or_fname.__class__.__name__)
self.p.ParseF... | [
"def",
"parse_file",
"(",
"self",
",",
"file_or_fname",
")",
":",
"with",
"self",
".",
"_context",
"(",
")",
":",
"if",
"hasattr",
"(",
"file_or_fname",
",",
"'read'",
")",
":",
"self",
".",
"filename",
"=",
"getattr",
"(",
"file_or_fname",
",",
"'name'"... | Parse a file or a filename | [
"Parse",
"a",
"file",
"or",
"a",
"filename"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L826-L839 |
358 | gem/oq-engine | openquake/hmtk/plotting/seismicity/completeness/cumulative_rate_analysis.py | SimpleCumulativeRate._get_magnitudes_from_spacing | def _get_magnitudes_from_spacing(self, magnitudes, delta_m):
'''If a single magnitude spacing is input then create the bins
:param numpy.ndarray magnitudes:
Vector of earthquake magnitudes
:param float delta_m:
Magnitude bin width
:returns: Vector of magnitude ... | python | def _get_magnitudes_from_spacing(self, magnitudes, delta_m):
'''If a single magnitude spacing is input then create the bins
:param numpy.ndarray magnitudes:
Vector of earthquake magnitudes
:param float delta_m:
Magnitude bin width
:returns: Vector of magnitude ... | [
"def",
"_get_magnitudes_from_spacing",
"(",
"self",
",",
"magnitudes",
",",
"delta_m",
")",
":",
"min_mag",
"=",
"np",
".",
"min",
"(",
"magnitudes",
")",
"max_mag",
"=",
"np",
".",
"max",
"(",
"magnitudes",
")",
"if",
"(",
"max_mag",
"-",
"min_mag",
")"... | If a single magnitude spacing is input then create the bins
:param numpy.ndarray magnitudes:
Vector of earthquake magnitudes
:param float delta_m:
Magnitude bin width
:returns: Vector of magnitude bin edges (numpy.ndarray) | [
"If",
"a",
"single",
"magnitude",
"spacing",
"is",
"input",
"then",
"create",
"the",
"bins"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/completeness/cumulative_rate_analysis.py#L132-L152 |
359 | gem/oq-engine | openquake/hmtk/seismicity/catalogue.py | _merge_data | def _merge_data(dat1, dat2):
"""
Merge two data dictionaries containing catalogue data
:parameter dictionary dat1:
Catalogue data dictionary
:parameter dictionary dat2:
Catalogue data dictionary
:returns:
A catalogue data dictionary containing the information originally
... | python | def _merge_data(dat1, dat2):
"""
Merge two data dictionaries containing catalogue data
:parameter dictionary dat1:
Catalogue data dictionary
:parameter dictionary dat2:
Catalogue data dictionary
:returns:
A catalogue data dictionary containing the information originally
... | [
"def",
"_merge_data",
"(",
"dat1",
",",
"dat2",
")",
":",
"cnt",
"=",
"0",
"for",
"key",
"in",
"dat1",
":",
"flg1",
"=",
"len",
"(",
"dat1",
"[",
"key",
"]",
")",
">",
"0",
"flg2",
"=",
"len",
"(",
"dat2",
"[",
"key",
"]",
")",
">",
"0",
"i... | Merge two data dictionaries containing catalogue data
:parameter dictionary dat1:
Catalogue data dictionary
:parameter dictionary dat2:
Catalogue data dictionary
:returns:
A catalogue data dictionary containing the information originally
included in dat1 and dat2 | [
"Merge",
"two",
"data",
"dictionaries",
"containing",
"catalogue",
"data"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/catalogue.py#L566-L600 |
360 | gem/oq-engine | openquake/hmtk/seismicity/catalogue.py | Catalogue._get_row_str | def _get_row_str(self, i):
"""
Returns a string representation of the key information in a row
"""
row_data = ["{:s}".format(self.data['eventID'][i]),
"{:g}".format(self.data['year'][i]),
"{:g}".format(self.data['month'][i]),
"{... | python | def _get_row_str(self, i):
"""
Returns a string representation of the key information in a row
"""
row_data = ["{:s}".format(self.data['eventID'][i]),
"{:g}".format(self.data['year'][i]),
"{:g}".format(self.data['month'][i]),
"{... | [
"def",
"_get_row_str",
"(",
"self",
",",
"i",
")",
":",
"row_data",
"=",
"[",
"\"{:s}\"",
".",
"format",
"(",
"self",
".",
"data",
"[",
"'eventID'",
"]",
"[",
"i",
"]",
")",
",",
"\"{:g}\"",
".",
"format",
"(",
"self",
".",
"data",
"[",
"'year'",
... | Returns a string representation of the key information in a row | [
"Returns",
"a",
"string",
"representation",
"of",
"the",
"key",
"information",
"in",
"a",
"row"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/catalogue.py#L138-L153 |
361 | gem/oq-engine | openquake/hmtk/seismicity/catalogue.py | Catalogue.load_to_array | def load_to_array(self, keys):
"""
This loads the data contained in the catalogue into a numpy array. The
method works only for float data
:param keys:
A list of keys to be uploaded into the array
:type list:
"""
# Preallocate the numpy array
... | python | def load_to_array(self, keys):
"""
This loads the data contained in the catalogue into a numpy array. The
method works only for float data
:param keys:
A list of keys to be uploaded into the array
:type list:
"""
# Preallocate the numpy array
... | [
"def",
"load_to_array",
"(",
"self",
",",
"keys",
")",
":",
"# Preallocate the numpy array",
"data",
"=",
"np",
".",
"empty",
"(",
"(",
"len",
"(",
"self",
".",
"data",
"[",
"keys",
"[",
"0",
"]",
"]",
")",
",",
"len",
"(",
"keys",
")",
")",
")",
... | This loads the data contained in the catalogue into a numpy array. The
method works only for float data
:param keys:
A list of keys to be uploaded into the array
:type list: | [
"This",
"loads",
"the",
"data",
"contained",
"in",
"the",
"catalogue",
"into",
"a",
"numpy",
"array",
".",
"The",
"method",
"works",
"only",
"for",
"float",
"data"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/catalogue.py#L223-L237 |
362 | gem/oq-engine | openquake/hmtk/seismicity/catalogue.py | Catalogue.load_from_array | def load_from_array(self, keys, data_array):
"""
This loads the data contained in an array into the catalogue object
:param keys:
A list of keys explaining the content of the columns in the array
:type list:
"""
if len(keys) != np.shape(data_array)[1]:
... | python | def load_from_array(self, keys, data_array):
"""
This loads the data contained in an array into the catalogue object
:param keys:
A list of keys explaining the content of the columns in the array
:type list:
"""
if len(keys) != np.shape(data_array)[1]:
... | [
"def",
"load_from_array",
"(",
"self",
",",
"keys",
",",
"data_array",
")",
":",
"if",
"len",
"(",
"keys",
")",
"!=",
"np",
".",
"shape",
"(",
"data_array",
")",
"[",
"1",
"]",
":",
"raise",
"ValueError",
"(",
"'Key list does not match shape of array!'",
"... | This loads the data contained in an array into the catalogue object
:param keys:
A list of keys explaining the content of the columns in the array
:type list: | [
"This",
"loads",
"the",
"data",
"contained",
"in",
"an",
"array",
"into",
"the",
"catalogue",
"object"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/catalogue.py#L239-L259 |
363 | gem/oq-engine | openquake/hmtk/seismicity/catalogue.py | Catalogue.catalogue_mt_filter | def catalogue_mt_filter(self, mt_table, flag=None):
"""
Filter the catalogue using a magnitude-time table. The table has
two columns and n-rows.
:param nump.ndarray mt_table:
Magnitude time table with n-rows where column 1 is year and column
2 is magnitude
... | python | def catalogue_mt_filter(self, mt_table, flag=None):
"""
Filter the catalogue using a magnitude-time table. The table has
two columns and n-rows.
:param nump.ndarray mt_table:
Magnitude time table with n-rows where column 1 is year and column
2 is magnitude
... | [
"def",
"catalogue_mt_filter",
"(",
"self",
",",
"mt_table",
",",
"flag",
"=",
"None",
")",
":",
"if",
"flag",
"is",
"None",
":",
"# No flag defined, therefore all events are initially valid",
"flag",
"=",
"np",
".",
"ones",
"(",
"self",
".",
"get_number_events",
... | Filter the catalogue using a magnitude-time table. The table has
two columns and n-rows.
:param nump.ndarray mt_table:
Magnitude time table with n-rows where column 1 is year and column
2 is magnitude | [
"Filter",
"the",
"catalogue",
"using",
"a",
"magnitude",
"-",
"time",
"table",
".",
"The",
"table",
"has",
"two",
"columns",
"and",
"n",
"-",
"rows",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/catalogue.py#L282-L302 |
364 | gem/oq-engine | openquake/hmtk/seismicity/catalogue.py | Catalogue.get_bounding_box | def get_bounding_box(self):
"""
Returns the bounding box of the catalogue
:returns: (West, East, South, North)
"""
return (np.min(self.data["longitude"]),
np.max(self.data["longitude"]),
np.min(self.data["latitude"]),
np.max(self.d... | python | def get_bounding_box(self):
"""
Returns the bounding box of the catalogue
:returns: (West, East, South, North)
"""
return (np.min(self.data["longitude"]),
np.max(self.data["longitude"]),
np.min(self.data["latitude"]),
np.max(self.d... | [
"def",
"get_bounding_box",
"(",
"self",
")",
":",
"return",
"(",
"np",
".",
"min",
"(",
"self",
".",
"data",
"[",
"\"longitude\"",
"]",
")",
",",
"np",
".",
"max",
"(",
"self",
".",
"data",
"[",
"\"longitude\"",
"]",
")",
",",
"np",
".",
"min",
"... | Returns the bounding box of the catalogue
:returns: (West, East, South, North) | [
"Returns",
"the",
"bounding",
"box",
"of",
"the",
"catalogue"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/catalogue.py#L304-L313 |
365 | gem/oq-engine | openquake/hmtk/seismicity/catalogue.py | Catalogue.get_decimal_time | def get_decimal_time(self):
'''
Returns the time of the catalogue as a decimal
'''
return decimal_time(self.data['year'],
self.data['month'],
self.data['day'],
self.data['hour'],
... | python | def get_decimal_time(self):
'''
Returns the time of the catalogue as a decimal
'''
return decimal_time(self.data['year'],
self.data['month'],
self.data['day'],
self.data['hour'],
... | [
"def",
"get_decimal_time",
"(",
"self",
")",
":",
"return",
"decimal_time",
"(",
"self",
".",
"data",
"[",
"'year'",
"]",
",",
"self",
".",
"data",
"[",
"'month'",
"]",
",",
"self",
".",
"data",
"[",
"'day'",
"]",
",",
"self",
".",
"data",
"[",
"'h... | Returns the time of the catalogue as a decimal | [
"Returns",
"the",
"time",
"of",
"the",
"catalogue",
"as",
"a",
"decimal"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/catalogue.py#L326-L335 |
366 | gem/oq-engine | openquake/hmtk/seismicity/catalogue.py | Catalogue.sort_catalogue_chronologically | def sort_catalogue_chronologically(self):
'''
Sorts the catalogue into chronological order
'''
dec_time = self.get_decimal_time()
idx = np.argsort(dec_time)
if np.all((idx[1:] - idx[:-1]) > 0.):
# Catalogue was already in chronological order
return... | python | def sort_catalogue_chronologically(self):
'''
Sorts the catalogue into chronological order
'''
dec_time = self.get_decimal_time()
idx = np.argsort(dec_time)
if np.all((idx[1:] - idx[:-1]) > 0.):
# Catalogue was already in chronological order
return... | [
"def",
"sort_catalogue_chronologically",
"(",
"self",
")",
":",
"dec_time",
"=",
"self",
".",
"get_decimal_time",
"(",
")",
"idx",
"=",
"np",
".",
"argsort",
"(",
"dec_time",
")",
"if",
"np",
".",
"all",
"(",
"(",
"idx",
"[",
"1",
":",
"]",
"-",
"idx... | Sorts the catalogue into chronological order | [
"Sorts",
"the",
"catalogue",
"into",
"chronological",
"order"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/catalogue.py#L353-L362 |
367 | gem/oq-engine | openquake/hmtk/seismicity/catalogue.py | Catalogue.purge_catalogue | def purge_catalogue(self, flag_vector):
'''
Purges present catalogue with invalid events defined by flag_vector
:param numpy.ndarray flag_vector:
Boolean vector showing if events are selected (True) or not (False)
'''
id0 = np.where(flag_vector)[0]
self.sele... | python | def purge_catalogue(self, flag_vector):
'''
Purges present catalogue with invalid events defined by flag_vector
:param numpy.ndarray flag_vector:
Boolean vector showing if events are selected (True) or not (False)
'''
id0 = np.where(flag_vector)[0]
self.sele... | [
"def",
"purge_catalogue",
"(",
"self",
",",
"flag_vector",
")",
":",
"id0",
"=",
"np",
".",
"where",
"(",
"flag_vector",
")",
"[",
"0",
"]",
"self",
".",
"select_catalogue_events",
"(",
"id0",
")",
"self",
".",
"get_number_events",
"(",
")"
] | Purges present catalogue with invalid events defined by flag_vector
:param numpy.ndarray flag_vector:
Boolean vector showing if events are selected (True) or not (False) | [
"Purges",
"present",
"catalogue",
"with",
"invalid",
"events",
"defined",
"by",
"flag_vector"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/catalogue.py#L364-L374 |
368 | gem/oq-engine | openquake/hmtk/seismicity/catalogue.py | Catalogue.select_catalogue_events | def select_catalogue_events(self, id0):
'''
Orders the events in the catalogue according to an indexing vector.
:param np.ndarray id0:
Pointer array indicating the locations of selected events
'''
for key in self.data:
if isinstance(
s... | python | def select_catalogue_events(self, id0):
'''
Orders the events in the catalogue according to an indexing vector.
:param np.ndarray id0:
Pointer array indicating the locations of selected events
'''
for key in self.data:
if isinstance(
s... | [
"def",
"select_catalogue_events",
"(",
"self",
",",
"id0",
")",
":",
"for",
"key",
"in",
"self",
".",
"data",
":",
"if",
"isinstance",
"(",
"self",
".",
"data",
"[",
"key",
"]",
",",
"np",
".",
"ndarray",
")",
"and",
"len",
"(",
"self",
".",
"data"... | Orders the events in the catalogue according to an indexing vector.
:param np.ndarray id0:
Pointer array indicating the locations of selected events | [
"Orders",
"the",
"events",
"in",
"the",
"catalogue",
"according",
"to",
"an",
"indexing",
"vector",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/catalogue.py#L376-L393 |
369 | gem/oq-engine | openquake/hmtk/seismicity/catalogue.py | Catalogue.get_depth_distribution | def get_depth_distribution(self, depth_bins, normalisation=False,
bootstrap=None):
'''
Gets the depth distribution of the earthquake catalogue to return a
single histogram. Depths may be normalised. If uncertainties are found
in the catalogue the distrbutio... | python | def get_depth_distribution(self, depth_bins, normalisation=False,
bootstrap=None):
'''
Gets the depth distribution of the earthquake catalogue to return a
single histogram. Depths may be normalised. If uncertainties are found
in the catalogue the distrbutio... | [
"def",
"get_depth_distribution",
"(",
"self",
",",
"depth_bins",
",",
"normalisation",
"=",
"False",
",",
"bootstrap",
"=",
"None",
")",
":",
"if",
"len",
"(",
"self",
".",
"data",
"[",
"'depth'",
"]",
")",
"==",
"0",
":",
"# If depth information is missing"... | Gets the depth distribution of the earthquake catalogue to return a
single histogram. Depths may be normalised. If uncertainties are found
in the catalogue the distrbution may be bootstrap sampled
:param numpy.ndarray depth_bins:
getBin edges for the depths
:param bool nor... | [
"Gets",
"the",
"depth",
"distribution",
"of",
"the",
"earthquake",
"catalogue",
"to",
"return",
"a",
"single",
"histogram",
".",
"Depths",
"may",
"be",
"normalised",
".",
"If",
"uncertainties",
"are",
"found",
"in",
"the",
"catalogue",
"the",
"distrbution",
"m... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/catalogue.py#L395-L429 |
370 | gem/oq-engine | openquake/hmtk/seismicity/catalogue.py | Catalogue.get_depth_pmf | def get_depth_pmf(self, depth_bins, default_depth=5.0, bootstrap=None):
"""
Returns the depth distribution of the catalogue as a probability mass
function
"""
if len(self.data['depth']) == 0:
# If depth information is missing
return PMF([(1.0, default_dept... | python | def get_depth_pmf(self, depth_bins, default_depth=5.0, bootstrap=None):
"""
Returns the depth distribution of the catalogue as a probability mass
function
"""
if len(self.data['depth']) == 0:
# If depth information is missing
return PMF([(1.0, default_dept... | [
"def",
"get_depth_pmf",
"(",
"self",
",",
"depth_bins",
",",
"default_depth",
"=",
"5.0",
",",
"bootstrap",
"=",
"None",
")",
":",
"if",
"len",
"(",
"self",
".",
"data",
"[",
"'depth'",
"]",
")",
"==",
"0",
":",
"# If depth information is missing",
"return... | Returns the depth distribution of the catalogue as a probability mass
function | [
"Returns",
"the",
"depth",
"distribution",
"of",
"the",
"catalogue",
"as",
"a",
"probability",
"mass",
"function"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/catalogue.py#L431-L454 |
371 | gem/oq-engine | openquake/hmtk/seismicity/catalogue.py | Catalogue.get_magnitude_depth_distribution | def get_magnitude_depth_distribution(self, magnitude_bins, depth_bins,
normalisation=False, bootstrap=None):
'''
Returns a 2-D magnitude-depth histogram for the catalogue
:param numpy.ndarray magnitude_bins:
Bin edges for the magnitudes
... | python | def get_magnitude_depth_distribution(self, magnitude_bins, depth_bins,
normalisation=False, bootstrap=None):
'''
Returns a 2-D magnitude-depth histogram for the catalogue
:param numpy.ndarray magnitude_bins:
Bin edges for the magnitudes
... | [
"def",
"get_magnitude_depth_distribution",
"(",
"self",
",",
"magnitude_bins",
",",
"depth_bins",
",",
"normalisation",
"=",
"False",
",",
"bootstrap",
"=",
"None",
")",
":",
"if",
"len",
"(",
"self",
".",
"data",
"[",
"'depth'",
"]",
")",
"==",
"0",
":",
... | Returns a 2-D magnitude-depth histogram for the catalogue
:param numpy.ndarray magnitude_bins:
Bin edges for the magnitudes
:param numpy.ndarray depth_bins:
Bin edges for the depths
:param bool normalisation:
Choose to normalise the results such that the t... | [
"Returns",
"a",
"2",
"-",
"D",
"magnitude",
"-",
"depth",
"histogram",
"for",
"the",
"catalogue"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/catalogue.py#L456-L497 |
372 | gem/oq-engine | openquake/hmtk/seismicity/catalogue.py | Catalogue.get_magnitude_time_distribution | def get_magnitude_time_distribution(self, magnitude_bins, time_bins,
normalisation=False, bootstrap=None):
'''
Returns a 2-D histogram indicating the number of earthquakes in a
set of time-magnitude bins. Time is in decimal years!
:param numpy.nda... | python | def get_magnitude_time_distribution(self, magnitude_bins, time_bins,
normalisation=False, bootstrap=None):
'''
Returns a 2-D histogram indicating the number of earthquakes in a
set of time-magnitude bins. Time is in decimal years!
:param numpy.nda... | [
"def",
"get_magnitude_time_distribution",
"(",
"self",
",",
"magnitude_bins",
",",
"time_bins",
",",
"normalisation",
"=",
"False",
",",
"bootstrap",
"=",
"None",
")",
":",
"return",
"bootstrap_histogram_2D",
"(",
"self",
".",
"get_decimal_time",
"(",
")",
",",
... | Returns a 2-D histogram indicating the number of earthquakes in a
set of time-magnitude bins. Time is in decimal years!
:param numpy.ndarray magnitude_bins:
Bin edges for the magnitudes
:param numpy.ndarray time_bins:
Bin edges for the times
:param bool normal... | [
"Returns",
"a",
"2",
"-",
"D",
"histogram",
"indicating",
"the",
"number",
"of",
"earthquakes",
"in",
"a",
"set",
"of",
"time",
"-",
"magnitude",
"bins",
".",
"Time",
"is",
"in",
"decimal",
"years!"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/catalogue.py#L499-L529 |
373 | gem/oq-engine | openquake/hmtk/seismicity/catalogue.py | Catalogue.concatenate | def concatenate(self, catalogue):
"""
This method attaches one catalogue to the current one
:parameter catalogue:
An instance of :class:`htmk.seismicity.catalogue.Catalogue`
"""
atts = getattr(self, 'data')
attn = getattr(catalogue, 'data')
data = _m... | python | def concatenate(self, catalogue):
"""
This method attaches one catalogue to the current one
:parameter catalogue:
An instance of :class:`htmk.seismicity.catalogue.Catalogue`
"""
atts = getattr(self, 'data')
attn = getattr(catalogue, 'data')
data = _m... | [
"def",
"concatenate",
"(",
"self",
",",
"catalogue",
")",
":",
"atts",
"=",
"getattr",
"(",
"self",
",",
"'data'",
")",
"attn",
"=",
"getattr",
"(",
"catalogue",
",",
"'data'",
")",
"data",
"=",
"_merge_data",
"(",
"atts",
",",
"attn",
")",
"if",
"da... | This method attaches one catalogue to the current one
:parameter catalogue:
An instance of :class:`htmk.seismicity.catalogue.Catalogue` | [
"This",
"method",
"attaches",
"one",
"catalogue",
"to",
"the",
"current",
"one"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/catalogue.py#L531-L563 |
374 | gem/oq-engine | openquake/engine/engine.py | expose_outputs | def expose_outputs(dstore, owner=getpass.getuser(), status='complete'):
"""
Build a correspondence between the outputs in the datastore and the
ones in the database.
:param dstore: datastore
"""
oq = dstore['oqparam']
exportable = set(ekey[0] for ekey in export.export)
calcmode = oq.cal... | python | def expose_outputs(dstore, owner=getpass.getuser(), status='complete'):
"""
Build a correspondence between the outputs in the datastore and the
ones in the database.
:param dstore: datastore
"""
oq = dstore['oqparam']
exportable = set(ekey[0] for ekey in export.export)
calcmode = oq.cal... | [
"def",
"expose_outputs",
"(",
"dstore",
",",
"owner",
"=",
"getpass",
".",
"getuser",
"(",
")",
",",
"status",
"=",
"'complete'",
")",
":",
"oq",
"=",
"dstore",
"[",
"'oqparam'",
"]",
"exportable",
"=",
"set",
"(",
"ekey",
"[",
"0",
"]",
"for",
"ekey... | Build a correspondence between the outputs in the datastore and the
ones in the database.
:param dstore: datastore | [
"Build",
"a",
"correspondence",
"between",
"the",
"outputs",
"in",
"the",
"datastore",
"and",
"the",
"ones",
"in",
"the",
"database",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/engine/engine.py#L119-L175 |
375 | gem/oq-engine | openquake/engine/engine.py | raiseMasterKilled | def raiseMasterKilled(signum, _stack):
"""
When a SIGTERM is received, raise the MasterKilled
exception with an appropriate error message.
:param int signum: the number of the received signal
:param _stack: the current frame object, ignored
"""
# Disable further CTRL-C to allow tasks revoca... | python | def raiseMasterKilled(signum, _stack):
"""
When a SIGTERM is received, raise the MasterKilled
exception with an appropriate error message.
:param int signum: the number of the received signal
:param _stack: the current frame object, ignored
"""
# Disable further CTRL-C to allow tasks revoca... | [
"def",
"raiseMasterKilled",
"(",
"signum",
",",
"_stack",
")",
":",
"# Disable further CTRL-C to allow tasks revocation when Celery is used",
"if",
"OQ_DISTRIBUTE",
".",
"startswith",
"(",
"'celery'",
")",
":",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGINT",
",... | When a SIGTERM is received, raise the MasterKilled
exception with an appropriate error message.
:param int signum: the number of the received signal
:param _stack: the current frame object, ignored | [
"When",
"a",
"SIGTERM",
"is",
"received",
"raise",
"the",
"MasterKilled",
"exception",
"with",
"an",
"appropriate",
"error",
"message",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/engine/engine.py#L186-L212 |
376 | gem/oq-engine | openquake/engine/engine.py | job_from_file | def job_from_file(job_ini, job_id, username, **kw):
"""
Create a full job profile from a job config file.
:param job_ini:
Path to a job.ini file
:param job_id:
ID of the created job
:param username:
The user who will own this job profile and all results
:param kw:
... | python | def job_from_file(job_ini, job_id, username, **kw):
"""
Create a full job profile from a job config file.
:param job_ini:
Path to a job.ini file
:param job_id:
ID of the created job
:param username:
The user who will own this job profile and all results
:param kw:
... | [
"def",
"job_from_file",
"(",
"job_ini",
",",
"job_id",
",",
"username",
",",
"*",
"*",
"kw",
")",
":",
"hc_id",
"=",
"kw",
".",
"get",
"(",
"'hazard_calculation_id'",
")",
"try",
":",
"oq",
"=",
"readinput",
".",
"get_oqparam",
"(",
"job_ini",
",",
"hc... | Create a full job profile from a job config file.
:param job_ini:
Path to a job.ini file
:param job_id:
ID of the created job
:param username:
The user who will own this job profile and all results
:param kw:
Extra parameters including `calculation_mode` and `exposure_f... | [
"Create",
"a",
"full",
"job",
"profile",
"from",
"a",
"job",
"config",
"file",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/engine/engine.py#L230-L266 |
377 | gem/oq-engine | openquake/engine/engine.py | check_obsolete_version | def check_obsolete_version(calculation_mode='WebUI'):
"""
Check if there is a newer version of the engine.
:param calculation_mode:
- the calculation mode when called from the engine
- an empty string when called from the WebUI
:returns:
- a message if the running version of t... | python | def check_obsolete_version(calculation_mode='WebUI'):
"""
Check if there is a newer version of the engine.
:param calculation_mode:
- the calculation mode when called from the engine
- an empty string when called from the WebUI
:returns:
- a message if the running version of t... | [
"def",
"check_obsolete_version",
"(",
"calculation_mode",
"=",
"'WebUI'",
")",
":",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"'JENKINS_URL'",
")",
"or",
"os",
".",
"environ",
".",
"get",
"(",
"'TRAVIS'",
")",
":",
"# avoid flooding our API server with reques... | Check if there is a newer version of the engine.
:param calculation_mode:
- the calculation mode when called from the engine
- an empty string when called from the WebUI
:returns:
- a message if the running version of the engine is obsolete
- the empty string if the engine is ... | [
"Check",
"if",
"there",
"is",
"a",
"newer",
"version",
"of",
"the",
"engine",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/engine/engine.py#L384-L416 |
378 | gem/oq-engine | openquake/baselib/python3compat.py | encode | def encode(val):
"""
Encode a string assuming the encoding is UTF-8.
:param: a unicode or bytes object
:returns: bytes
"""
if isinstance(val, (list, tuple)): # encode a list or tuple of strings
return [encode(v) for v in val]
elif isinstance(val, str):
return val.encode('ut... | python | def encode(val):
"""
Encode a string assuming the encoding is UTF-8.
:param: a unicode or bytes object
:returns: bytes
"""
if isinstance(val, (list, tuple)): # encode a list or tuple of strings
return [encode(v) for v in val]
elif isinstance(val, str):
return val.encode('ut... | [
"def",
"encode",
"(",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"# encode a list or tuple of strings",
"return",
"[",
"encode",
"(",
"v",
")",
"for",
"v",
"in",
"val",
"]",
"elif",
"isinstance",
"("... | Encode a string assuming the encoding is UTF-8.
:param: a unicode or bytes object
:returns: bytes | [
"Encode",
"a",
"string",
"assuming",
"the",
"encoding",
"is",
"UTF",
"-",
"8",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/python3compat.py#L28-L41 |
379 | gem/oq-engine | openquake/baselib/python3compat.py | raise_ | def raise_(tp, value=None, tb=None):
"""
A function that matches the Python 2.x ``raise`` statement. This
allows re-raising exceptions with the cls value and traceback on
Python 2 and 3.
"""
if value is not None and isinstance(tp, Exception):
raise TypeError("instance exception may not h... | python | def raise_(tp, value=None, tb=None):
"""
A function that matches the Python 2.x ``raise`` statement. This
allows re-raising exceptions with the cls value and traceback on
Python 2 and 3.
"""
if value is not None and isinstance(tp, Exception):
raise TypeError("instance exception may not h... | [
"def",
"raise_",
"(",
"tp",
",",
"value",
"=",
"None",
",",
"tb",
"=",
"None",
")",
":",
"if",
"value",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"tp",
",",
"Exception",
")",
":",
"raise",
"TypeError",
"(",
"\"instance exception may not have a separat... | A function that matches the Python 2.x ``raise`` statement. This
allows re-raising exceptions with the cls value and traceback on
Python 2 and 3. | [
"A",
"function",
"that",
"matches",
"the",
"Python",
"2",
".",
"x",
"raise",
"statement",
".",
"This",
"allows",
"re",
"-",
"raising",
"exceptions",
"with",
"the",
"cls",
"value",
"and",
"traceback",
"on",
"Python",
"2",
"and",
"3",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/python3compat.py#L70-L84 |
380 | gem/oq-engine | openquake/commands/plot_pyro.py | plot_pyro | def plot_pyro(calc_id=-1):
"""
Plot the pyroclastic cloud and the assets
"""
# NB: matplotlib is imported inside since it is a costly import
import matplotlib.pyplot as p
dstore = util.read(calc_id)
sitecol = dstore['sitecol']
asset_risk = dstore['asset_risk'].value
pyro, = numpy.whe... | python | def plot_pyro(calc_id=-1):
"""
Plot the pyroclastic cloud and the assets
"""
# NB: matplotlib is imported inside since it is a costly import
import matplotlib.pyplot as p
dstore = util.read(calc_id)
sitecol = dstore['sitecol']
asset_risk = dstore['asset_risk'].value
pyro, = numpy.whe... | [
"def",
"plot_pyro",
"(",
"calc_id",
"=",
"-",
"1",
")",
":",
"# NB: matplotlib is imported inside since it is a costly import",
"import",
"matplotlib",
".",
"pyplot",
"as",
"p",
"dstore",
"=",
"util",
".",
"read",
"(",
"calc_id",
")",
"sitecol",
"=",
"dstore",
"... | Plot the pyroclastic cloud and the assets | [
"Plot",
"the",
"pyroclastic",
"cloud",
"and",
"the",
"assets"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/plot_pyro.py#L24-L42 |
381 | gem/oq-engine | openquake/hazardlib/geo/polygon.py | get_resampled_coordinates | def get_resampled_coordinates(lons, lats):
"""
Resample polygon line segments and return the coordinates of the new
vertices. This limits distortions when projecting a polygon onto a
spherical surface.
Parameters define longitudes and latitudes of a point collection in the
form of lists or nump... | python | def get_resampled_coordinates(lons, lats):
"""
Resample polygon line segments and return the coordinates of the new
vertices. This limits distortions when projecting a polygon onto a
spherical surface.
Parameters define longitudes and latitudes of a point collection in the
form of lists or nump... | [
"def",
"get_resampled_coordinates",
"(",
"lons",
",",
"lats",
")",
":",
"num_coords",
"=",
"len",
"(",
"lons",
")",
"assert",
"num_coords",
"==",
"len",
"(",
"lats",
")",
"lons1",
"=",
"numpy",
".",
"array",
"(",
"lons",
")",
"lats1",
"=",
"numpy",
"."... | Resample polygon line segments and return the coordinates of the new
vertices. This limits distortions when projecting a polygon onto a
spherical surface.
Parameters define longitudes and latitudes of a point collection in the
form of lists or numpy arrays.
:return:
A tuple of two numpy ar... | [
"Resample",
"polygon",
"line",
"segments",
"and",
"return",
"the",
"coordinates",
"of",
"the",
"new",
"vertices",
".",
"This",
"limits",
"distortions",
"when",
"projecting",
"a",
"polygon",
"onto",
"a",
"spherical",
"surface",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/polygon.py#L249-L291 |
382 | gem/oq-engine | openquake/hazardlib/geo/surface/gridded.py | GriddedSurface.get_middle_point | def get_middle_point(self):
"""
Compute coordinates of surface middle point.
The actual definition of ``middle point`` depends on the type of
surface geometry.
:return:
instance of :class:`openquake.hazardlib.geo.point.Point`
representing surface middle ... | python | def get_middle_point(self):
"""
Compute coordinates of surface middle point.
The actual definition of ``middle point`` depends on the type of
surface geometry.
:return:
instance of :class:`openquake.hazardlib.geo.point.Point`
representing surface middle ... | [
"def",
"get_middle_point",
"(",
"self",
")",
":",
"lons",
"=",
"self",
".",
"mesh",
".",
"lons",
".",
"squeeze",
"(",
")",
"lats",
"=",
"self",
".",
"mesh",
".",
"lats",
".",
"squeeze",
"(",
")",
"depths",
"=",
"self",
".",
"mesh",
".",
"depths",
... | Compute coordinates of surface middle point.
The actual definition of ``middle point`` depends on the type of
surface geometry.
:return:
instance of :class:`openquake.hazardlib.geo.point.Point`
representing surface middle point. | [
"Compute",
"coordinates",
"of",
"surface",
"middle",
"point",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/gridded.py#L164-L181 |
383 | gem/oq-engine | openquake/hazardlib/mfd/base.py | BaseMFD.modify | def modify(self, modification, parameters):
"""
Apply a single modification to an MFD parameters.
Reflects the modification method and calls it passing ``parameters``
as keyword arguments. See also :attr:`MODIFICATIONS`.
Modifications can be applied one on top of another. The l... | python | def modify(self, modification, parameters):
"""
Apply a single modification to an MFD parameters.
Reflects the modification method and calls it passing ``parameters``
as keyword arguments. See also :attr:`MODIFICATIONS`.
Modifications can be applied one on top of another. The l... | [
"def",
"modify",
"(",
"self",
",",
"modification",
",",
"parameters",
")",
":",
"if",
"modification",
"not",
"in",
"self",
".",
"MODIFICATIONS",
":",
"raise",
"ValueError",
"(",
"'Modification %s is not supported by %s'",
"%",
"(",
"modification",
",",
"type",
"... | Apply a single modification to an MFD parameters.
Reflects the modification method and calls it passing ``parameters``
as keyword arguments. See also :attr:`MODIFICATIONS`.
Modifications can be applied one on top of another. The logic
of stacking modifications is up to a specific MFD i... | [
"Apply",
"a",
"single",
"modification",
"to",
"an",
"MFD",
"parameters",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/mfd/base.py#L34-L56 |
384 | gem/oq-engine | openquake/hazardlib/gsim/travasarou_2003.py | TravasarouEtAl2003._get_stddevs | def _get_stddevs(self, rup, arias, stddev_types, sites):
"""
Return standard deviations as defined in table 1, p. 200.
"""
stddevs = []
# Magnitude dependent inter-event term (Eq. 13)
if rup.mag < 4.7:
tau = 0.611
elif rup.mag > 7.6:
tau = ... | python | def _get_stddevs(self, rup, arias, stddev_types, sites):
"""
Return standard deviations as defined in table 1, p. 200.
"""
stddevs = []
# Magnitude dependent inter-event term (Eq. 13)
if rup.mag < 4.7:
tau = 0.611
elif rup.mag > 7.6:
tau = ... | [
"def",
"_get_stddevs",
"(",
"self",
",",
"rup",
",",
"arias",
",",
"stddev_types",
",",
"sites",
")",
":",
"stddevs",
"=",
"[",
"]",
"# Magnitude dependent inter-event term (Eq. 13)",
"if",
"rup",
".",
"mag",
"<",
"4.7",
":",
"tau",
"=",
"0.611",
"elif",
"... | Return standard deviations as defined in table 1, p. 200. | [
"Return",
"standard",
"deviations",
"as",
"defined",
"in",
"table",
"1",
"p",
".",
"200",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/travasarou_2003.py#L95-L128 |
385 | gem/oq-engine | openquake/hazardlib/gsim/travasarou_2003.py | TravasarouEtAl2003._get_intra_event_sigmas | def _get_intra_event_sigmas(self, sites):
"""
The intra-event term nonlinear and dependent on both the site class
and the expected ground motion. In this case the sigma coefficients
are determined from the site class as described below Eq. 14
"""
sigma1 = 1.18 * np.ones_l... | python | def _get_intra_event_sigmas(self, sites):
"""
The intra-event term nonlinear and dependent on both the site class
and the expected ground motion. In this case the sigma coefficients
are determined from the site class as described below Eq. 14
"""
sigma1 = 1.18 * np.ones_l... | [
"def",
"_get_intra_event_sigmas",
"(",
"self",
",",
"sites",
")",
":",
"sigma1",
"=",
"1.18",
"*",
"np",
".",
"ones_like",
"(",
"sites",
".",
"vs30",
")",
"sigma2",
"=",
"0.94",
"*",
"np",
".",
"ones_like",
"(",
"sites",
".",
"vs30",
")",
"idx1",
"="... | The intra-event term nonlinear and dependent on both the site class
and the expected ground motion. In this case the sigma coefficients
are determined from the site class as described below Eq. 14 | [
"The",
"intra",
"-",
"event",
"term",
"nonlinear",
"and",
"dependent",
"on",
"both",
"the",
"site",
"class",
"and",
"the",
"expected",
"ground",
"motion",
".",
"In",
"this",
"case",
"the",
"sigma",
"coefficients",
"are",
"determined",
"from",
"the",
"site",
... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/travasarou_2003.py#L130-L145 |
386 | gem/oq-engine | openquake/hazardlib/gsim/boore_2014.py | BooreEtAl2014._get_pga_on_rock | def _get_pga_on_rock(self, C, rup, dists):
"""
Returns the median PGA on rock, which is a sum of the
magnitude and distance scaling
"""
return np.exp(self._get_magnitude_scaling_term(C, rup) +
self._get_path_scaling(C, dists, rup.mag)) | python | def _get_pga_on_rock(self, C, rup, dists):
"""
Returns the median PGA on rock, which is a sum of the
magnitude and distance scaling
"""
return np.exp(self._get_magnitude_scaling_term(C, rup) +
self._get_path_scaling(C, dists, rup.mag)) | [
"def",
"_get_pga_on_rock",
"(",
"self",
",",
"C",
",",
"rup",
",",
"dists",
")",
":",
"return",
"np",
".",
"exp",
"(",
"self",
".",
"_get_magnitude_scaling_term",
"(",
"C",
",",
"rup",
")",
"+",
"self",
".",
"_get_path_scaling",
"(",
"C",
",",
"dists",... | Returns the median PGA on rock, which is a sum of the
magnitude and distance scaling | [
"Returns",
"the",
"median",
"PGA",
"on",
"rock",
"which",
"is",
"a",
"sum",
"of",
"the",
"magnitude",
"and",
"distance",
"scaling"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/boore_2014.py#L103-L109 |
387 | gem/oq-engine | openquake/hazardlib/mfd/multi_mfd.py | MultiMFD.modify | def modify(self, modification, parameters):
"""
Apply a modification to the underlying point sources, with the
same parameters for all sources
"""
for src in self:
src.modify(modification, parameters) | python | def modify(self, modification, parameters):
"""
Apply a modification to the underlying point sources, with the
same parameters for all sources
"""
for src in self:
src.modify(modification, parameters) | [
"def",
"modify",
"(",
"self",
",",
"modification",
",",
"parameters",
")",
":",
"for",
"src",
"in",
"self",
":",
"src",
".",
"modify",
"(",
"modification",
",",
"parameters",
")"
] | Apply a modification to the underlying point sources, with the
same parameters for all sources | [
"Apply",
"a",
"modification",
"to",
"the",
"underlying",
"point",
"sources",
"with",
"the",
"same",
"parameters",
"for",
"all",
"sources"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/mfd/multi_mfd.py#L143-L149 |
388 | gem/oq-engine | openquake/hazardlib/gsim/geomatrix_1993.py | Geomatrix1993SSlabNSHMP2008._compute_mean | def _compute_mean(self, C, mag, ztor, rrup):
"""
Compute mean value as in ``subroutine getGeom`` in ``hazgridXnga2.f``
"""
gc0 = 0.2418
ci = 0.3846
gch = 0.00607
g4 = 1.7818
ge = 0.554
gm = 1.414
mean = (
gc0 + ci + ztor * gch ... | python | def _compute_mean(self, C, mag, ztor, rrup):
"""
Compute mean value as in ``subroutine getGeom`` in ``hazgridXnga2.f``
"""
gc0 = 0.2418
ci = 0.3846
gch = 0.00607
g4 = 1.7818
ge = 0.554
gm = 1.414
mean = (
gc0 + ci + ztor * gch ... | [
"def",
"_compute_mean",
"(",
"self",
",",
"C",
",",
"mag",
",",
"ztor",
",",
"rrup",
")",
":",
"gc0",
"=",
"0.2418",
"ci",
"=",
"0.3846",
"gch",
"=",
"0.00607",
"g4",
"=",
"1.7818",
"ge",
"=",
"0.554",
"gm",
"=",
"1.414",
"mean",
"=",
"(",
"gc0",... | Compute mean value as in ``subroutine getGeom`` in ``hazgridXnga2.f`` | [
"Compute",
"mean",
"value",
"as",
"in",
"subroutine",
"getGeom",
"in",
"hazgridXnga2",
".",
"f"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/geomatrix_1993.py#L92-L109 |
389 | gem/oq-engine | openquake/commands/abort.py | abort | def abort(job_id):
"""
Abort the given job
"""
job = logs.dbcmd('get_job', job_id) # job_id can be negative
if job is None:
print('There is no job %d' % job_id)
return
elif job.status not in ('executing', 'running'):
print('Job %d is %s' % (job.id, job.status))
r... | python | def abort(job_id):
"""
Abort the given job
"""
job = logs.dbcmd('get_job', job_id) # job_id can be negative
if job is None:
print('There is no job %d' % job_id)
return
elif job.status not in ('executing', 'running'):
print('Job %d is %s' % (job.id, job.status))
r... | [
"def",
"abort",
"(",
"job_id",
")",
":",
"job",
"=",
"logs",
".",
"dbcmd",
"(",
"'get_job'",
",",
"job_id",
")",
"# job_id can be negative",
"if",
"job",
"is",
"None",
":",
"print",
"(",
"'There is no job %d'",
"%",
"job_id",
")",
"return",
"elif",
"job",
... | Abort the given job | [
"Abort",
"the",
"given",
"job"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/abort.py#L27-L53 |
390 | gem/oq-engine | openquake/baselib/sap.py | compose | def compose(scripts, name='main', description=None, prog=None,
version=None):
"""
Collects together different scripts and builds a single
script dispatching to the subparsers depending on
the first argument, i.e. the name of the subparser to invoke.
:param scripts: a list of script inst... | python | def compose(scripts, name='main', description=None, prog=None,
version=None):
"""
Collects together different scripts and builds a single
script dispatching to the subparsers depending on
the first argument, i.e. the name of the subparser to invoke.
:param scripts: a list of script inst... | [
"def",
"compose",
"(",
"scripts",
",",
"name",
"=",
"'main'",
",",
"description",
"=",
"None",
",",
"prog",
"=",
"None",
",",
"version",
"=",
"None",
")",
":",
"assert",
"len",
"(",
"scripts",
")",
">=",
"1",
",",
"scripts",
"parentparser",
"=",
"arg... | Collects together different scripts and builds a single
script dispatching to the subparsers depending on
the first argument, i.e. the name of the subparser to invoke.
:param scripts: a list of script instances
:param name: the name of the composed parser
:param description: description of the comp... | [
"Collects",
"together",
"different",
"scripts",
"and",
"builds",
"a",
"single",
"script",
"dispatching",
"to",
"the",
"subparsers",
"depending",
"on",
"the",
"first",
"argument",
"i",
".",
"e",
".",
"the",
"name",
"of",
"the",
"subparser",
"to",
"invoke",
".... | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/sap.py#L205-L253 |
391 | gem/oq-engine | openquake/baselib/sap.py | Script._add | def _add(self, name, *args, **kw):
"""
Add an argument to the underlying parser and grow the list
.all_arguments and the set .names
"""
argname = list(self.argdict)[self._argno]
if argname != name:
raise NameError(
'Setting argument %s, but it ... | python | def _add(self, name, *args, **kw):
"""
Add an argument to the underlying parser and grow the list
.all_arguments and the set .names
"""
argname = list(self.argdict)[self._argno]
if argname != name:
raise NameError(
'Setting argument %s, but it ... | [
"def",
"_add",
"(",
"self",
",",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"argname",
"=",
"list",
"(",
"self",
".",
"argdict",
")",
"[",
"self",
".",
"_argno",
"]",
"if",
"argname",
"!=",
"name",
":",
"raise",
"NameError",
"(",
... | Add an argument to the underlying parser and grow the list
.all_arguments and the set .names | [
"Add",
"an",
"argument",
"to",
"the",
"underlying",
"parser",
"and",
"grow",
"the",
"list",
".",
"all_arguments",
"and",
"the",
"set",
".",
"names"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/sap.py#L116-L128 |
392 | gem/oq-engine | openquake/baselib/sap.py | Script.arg | def arg(self, name, help, type=None, choices=None, metavar=None,
nargs=None):
"""Describe a positional argument"""
kw = dict(help=help, type=type, choices=choices, metavar=metavar,
nargs=nargs)
default = self.argdict[name]
if default is not NODEFAULT:
... | python | def arg(self, name, help, type=None, choices=None, metavar=None,
nargs=None):
"""Describe a positional argument"""
kw = dict(help=help, type=type, choices=choices, metavar=metavar,
nargs=nargs)
default = self.argdict[name]
if default is not NODEFAULT:
... | [
"def",
"arg",
"(",
"self",
",",
"name",
",",
"help",
",",
"type",
"=",
"None",
",",
"choices",
"=",
"None",
",",
"metavar",
"=",
"None",
",",
"nargs",
"=",
"None",
")",
":",
"kw",
"=",
"dict",
"(",
"help",
"=",
"help",
",",
"type",
"=",
"type",... | Describe a positional argument | [
"Describe",
"a",
"positional",
"argument"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/sap.py#L130-L140 |
393 | gem/oq-engine | openquake/baselib/sap.py | Script.opt | def opt(self, name, help, abbrev=None,
type=None, choices=None, metavar=None, nargs=None):
"""Describe an option"""
kw = dict(help=help, type=type, choices=choices, metavar=metavar,
nargs=nargs)
default = self.argdict[name]
if default is not NODEFAULT:
... | python | def opt(self, name, help, abbrev=None,
type=None, choices=None, metavar=None, nargs=None):
"""Describe an option"""
kw = dict(help=help, type=type, choices=choices, metavar=metavar,
nargs=nargs)
default = self.argdict[name]
if default is not NODEFAULT:
... | [
"def",
"opt",
"(",
"self",
",",
"name",
",",
"help",
",",
"abbrev",
"=",
"None",
",",
"type",
"=",
"None",
",",
"choices",
"=",
"None",
",",
"metavar",
"=",
"None",
",",
"nargs",
"=",
"None",
")",
":",
"kw",
"=",
"dict",
"(",
"help",
"=",
"help... | Describe an option | [
"Describe",
"an",
"option"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/sap.py#L142-L158 |
394 | gem/oq-engine | openquake/baselib/sap.py | Script.flg | def flg(self, name, help, abbrev=None):
"""Describe a flag"""
abbrev = abbrev or '-' + name[0]
longname = '--' + name.replace('_', '-')
self._add(name, abbrev, longname, action='store_true', help=help) | python | def flg(self, name, help, abbrev=None):
"""Describe a flag"""
abbrev = abbrev or '-' + name[0]
longname = '--' + name.replace('_', '-')
self._add(name, abbrev, longname, action='store_true', help=help) | [
"def",
"flg",
"(",
"self",
",",
"name",
",",
"help",
",",
"abbrev",
"=",
"None",
")",
":",
"abbrev",
"=",
"abbrev",
"or",
"'-'",
"+",
"name",
"[",
"0",
"]",
"longname",
"=",
"'--'",
"+",
"name",
".",
"replace",
"(",
"'_'",
",",
"'-'",
")",
"sel... | Describe a flag | [
"Describe",
"a",
"flag"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/sap.py#L160-L164 |
395 | gem/oq-engine | openquake/baselib/sap.py | Script.check_arguments | def check_arguments(self):
"""Make sure all arguments have a specification"""
for name, default in self.argdict.items():
if name not in self.names and default is NODEFAULT:
raise NameError('Missing argparse specification for %r' % name) | python | def check_arguments(self):
"""Make sure all arguments have a specification"""
for name, default in self.argdict.items():
if name not in self.names and default is NODEFAULT:
raise NameError('Missing argparse specification for %r' % name) | [
"def",
"check_arguments",
"(",
"self",
")",
":",
"for",
"name",
",",
"default",
"in",
"self",
".",
"argdict",
".",
"items",
"(",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"names",
"and",
"default",
"is",
"NODEFAULT",
":",
"raise",
"NameError",
... | Make sure all arguments have a specification | [
"Make",
"sure",
"all",
"arguments",
"have",
"a",
"specification"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/sap.py#L166-L170 |
396 | gem/oq-engine | openquake/baselib/sap.py | Script.callfunc | def callfunc(self, argv=None):
"""
Parse the argv list and extract a dictionary of arguments which
is then passed to the function underlying the script.
"""
if not self.checked:
self.check_arguments()
self.checked = True
namespace = self.parentpar... | python | def callfunc(self, argv=None):
"""
Parse the argv list and extract a dictionary of arguments which
is then passed to the function underlying the script.
"""
if not self.checked:
self.check_arguments()
self.checked = True
namespace = self.parentpar... | [
"def",
"callfunc",
"(",
"self",
",",
"argv",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"checked",
":",
"self",
".",
"check_arguments",
"(",
")",
"self",
".",
"checked",
"=",
"True",
"namespace",
"=",
"self",
".",
"parentparser",
".",
"parse_args... | Parse the argv list and extract a dictionary of arguments which
is then passed to the function underlying the script. | [
"Parse",
"the",
"argv",
"list",
"and",
"extract",
"a",
"dictionary",
"of",
"arguments",
"which",
"is",
"then",
"passed",
"to",
"the",
"function",
"underlying",
"the",
"script",
"."
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/sap.py#L172-L181 |
397 | gem/oq-engine | openquake/hmtk/faults/mfd/anderson_luco_arbitrary.py | Type1RecurrenceModel.incremental_value | def incremental_value(self, slip_moment, mmax, mag_value, bbar, dbar):
"""
Returns the incremental rate of earthquakes with M = mag_value
"""
delta_m = mmax - mag_value
dirac_term = np.zeros_like(mag_value)
dirac_term[np.fabs(delta_m) < 1.0E-12] = 1.0
a_1 = self._... | python | def incremental_value(self, slip_moment, mmax, mag_value, bbar, dbar):
"""
Returns the incremental rate of earthquakes with M = mag_value
"""
delta_m = mmax - mag_value
dirac_term = np.zeros_like(mag_value)
dirac_term[np.fabs(delta_m) < 1.0E-12] = 1.0
a_1 = self._... | [
"def",
"incremental_value",
"(",
"self",
",",
"slip_moment",
",",
"mmax",
",",
"mag_value",
",",
"bbar",
",",
"dbar",
")",
":",
"delta_m",
"=",
"mmax",
"-",
"mag_value",
"dirac_term",
"=",
"np",
".",
"zeros_like",
"(",
"mag_value",
")",
"dirac_term",
"[",
... | Returns the incremental rate of earthquakes with M = mag_value | [
"Returns",
"the",
"incremental",
"rate",
"of",
"earthquakes",
"with",
"M",
"=",
"mag_value"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/mfd/anderson_luco_arbitrary.py#L128-L137 |
398 | gem/oq-engine | openquake/hmtk/faults/mfd/anderson_luco_arbitrary.py | Type2RecurrenceModel._get_a2 | def _get_a2(bbar, dbar, slip_moment, mmax):
"""
Returns the A2 value defined in II.4 of Table 2
"""
return ((dbar - bbar) / bbar) * (slip_moment / _scale_moment(mmax)) | python | def _get_a2(bbar, dbar, slip_moment, mmax):
"""
Returns the A2 value defined in II.4 of Table 2
"""
return ((dbar - bbar) / bbar) * (slip_moment / _scale_moment(mmax)) | [
"def",
"_get_a2",
"(",
"bbar",
",",
"dbar",
",",
"slip_moment",
",",
"mmax",
")",
":",
"return",
"(",
"(",
"dbar",
"-",
"bbar",
")",
"/",
"bbar",
")",
"*",
"(",
"slip_moment",
"/",
"_scale_moment",
"(",
"mmax",
")",
")"
] | Returns the A2 value defined in II.4 of Table 2 | [
"Returns",
"the",
"A2",
"value",
"defined",
"in",
"II",
".",
"4",
"of",
"Table",
"2"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/mfd/anderson_luco_arbitrary.py#L166-L170 |
399 | gem/oq-engine | openquake/hmtk/faults/mfd/anderson_luco_arbitrary.py | Type3RecurrenceModel.incremental_value | def incremental_value(self, slip_moment, mmax, mag_value, bbar, dbar):
"""
Returns the incremental rate with Mmax = Mag_value
"""
delta_m = mmax - mag_value
a_3 = self._get_a3(bbar, dbar, slip_moment, mmax)
return a_3 * bbar * (np.exp(bbar * delta_m) - 1.0) * (delta_m > 0... | python | def incremental_value(self, slip_moment, mmax, mag_value, bbar, dbar):
"""
Returns the incremental rate with Mmax = Mag_value
"""
delta_m = mmax - mag_value
a_3 = self._get_a3(bbar, dbar, slip_moment, mmax)
return a_3 * bbar * (np.exp(bbar * delta_m) - 1.0) * (delta_m > 0... | [
"def",
"incremental_value",
"(",
"self",
",",
"slip_moment",
",",
"mmax",
",",
"mag_value",
",",
"bbar",
",",
"dbar",
")",
":",
"delta_m",
"=",
"mmax",
"-",
"mag_value",
"a_3",
"=",
"self",
".",
"_get_a3",
"(",
"bbar",
",",
"dbar",
",",
"slip_moment",
... | Returns the incremental rate with Mmax = Mag_value | [
"Returns",
"the",
"incremental",
"rate",
"with",
"Mmax",
"=",
"Mag_value"
] | 8294553a0b8aba33fd96437a35065d03547d0040 | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/mfd/anderson_luco_arbitrary.py#L215-L221 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.