repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
gem/oq-engine
openquake/calculators/views.py
view_extreme_groups
def view_extreme_groups(token, dstore): """ Show the source groups contributing the most to the highest IML """ data = dstore['disagg_by_grp'].value data.sort(order='extreme_poe') return rst_table(data[::-1])
python
def view_extreme_groups(token, dstore): """ Show the source groups contributing the most to the highest IML """ data = dstore['disagg_by_grp'].value data.sort(order='extreme_poe') return rst_table(data[::-1])
[ "def", "view_extreme_groups", "(", "token", ",", "dstore", ")", ":", "data", "=", "dstore", "[", "'disagg_by_grp'", "]", ".", "value", "data", ".", "sort", "(", "order", "=", "'extreme_poe'", ")", "return", "rst_table", "(", "data", "[", ":", ":", "-", ...
Show the source groups contributing the most to the highest IML
[ "Show", "the", "source", "groups", "contributing", "the", "most", "to", "the", "highest", "IML" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/views.py#L868-L874
train
gem/oq-engine
openquake/commonlib/oqzip.py
zip_all
def zip_all(directory): """ Zip source models and exposures recursively """ zips = [] for cwd, dirs, files in os.walk(directory): if 'ssmLT.xml' in files: zips.append(zip_source_model(os.path.join(cwd, 'ssmLT.xml'))) for f in files: if f.endswith('.xml') and '...
python
def zip_all(directory): """ Zip source models and exposures recursively """ zips = [] for cwd, dirs, files in os.walk(directory): if 'ssmLT.xml' in files: zips.append(zip_source_model(os.path.join(cwd, 'ssmLT.xml'))) for f in files: if f.endswith('.xml') and '...
[ "def", "zip_all", "(", "directory", ")", ":", "zips", "=", "[", "]", "for", "cwd", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "directory", ")", ":", "if", "'ssmLT.xml'", "in", "files", ":", "zips", ".", "append", "(", "zip_source_model"...
Zip source models and exposures recursively
[ "Zip", "source", "models", "and", "exposures", "recursively" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqzip.py#L27-L39
train
gem/oq-engine
openquake/commonlib/oqzip.py
zip_source_model
def zip_source_model(ssmLT, archive_zip='', log=logging.info): """ Zip the source model files starting from the smmLT.xml file """ basedir = os.path.dirname(ssmLT) if os.path.basename(ssmLT) != 'ssmLT.xml': orig = ssmLT ssmLT = os.path.join(basedir, 'ssmLT.xml') with open(ssm...
python
def zip_source_model(ssmLT, archive_zip='', log=logging.info): """ Zip the source model files starting from the smmLT.xml file """ basedir = os.path.dirname(ssmLT) if os.path.basename(ssmLT) != 'ssmLT.xml': orig = ssmLT ssmLT = os.path.join(basedir, 'ssmLT.xml') with open(ssm...
[ "def", "zip_source_model", "(", "ssmLT", ",", "archive_zip", "=", "''", ",", "log", "=", "logging", ".", "info", ")", ":", "basedir", "=", "os", ".", "path", ".", "dirname", "(", "ssmLT", ")", "if", "os", ".", "path", ".", "basename", "(", "ssmLT", ...
Zip the source model files starting from the smmLT.xml file
[ "Zip", "the", "source", "model", "files", "starting", "from", "the", "smmLT", ".", "xml", "file" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqzip.py#L42-L64
train
gem/oq-engine
openquake/commonlib/oqzip.py
zip_job
def zip_job(job_ini, archive_zip='', risk_ini='', oq=None, log=logging.info): """ Zip the given job.ini file into the given archive, together with all related files. """ if not os.path.exists(job_ini): sys.exit('%s does not exist' % job_ini) archive_zip = archive_zip or 'job.zip' if ...
python
def zip_job(job_ini, archive_zip='', risk_ini='', oq=None, log=logging.info): """ Zip the given job.ini file into the given archive, together with all related files. """ if not os.path.exists(job_ini): sys.exit('%s does not exist' % job_ini) archive_zip = archive_zip or 'job.zip' if ...
[ "def", "zip_job", "(", "job_ini", ",", "archive_zip", "=", "''", ",", "risk_ini", "=", "''", ",", "oq", "=", "None", ",", "log", "=", "logging", ".", "info", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "job_ini", ")", ":", "sys"...
Zip the given job.ini file into the given archive, together with all related files.
[ "Zip", "the", "given", "job", ".", "ini", "file", "into", "the", "given", "archive", "together", "with", "all", "related", "files", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqzip.py#L80-L103
train
gem/oq-engine
openquake/calculators/reportwriter.py
build_report
def build_report(job_ini, output_dir=None): """ Write a `report.csv` file with information about the calculation without running it :param job_ini: full pathname of the job.ini file :param output_dir: the directory where the report is written (default the input directory) """ ...
python
def build_report(job_ini, output_dir=None): """ Write a `report.csv` file with information about the calculation without running it :param job_ini: full pathname of the job.ini file :param output_dir: the directory where the report is written (default the input directory) """ ...
[ "def", "build_report", "(", "job_ini", ",", "output_dir", "=", "None", ")", ":", "calc_id", "=", "logs", ".", "init", "(", ")", "oq", "=", "readinput", ".", "get_oqparam", "(", "job_ini", ")", "if", "oq", ".", "calculation_mode", "==", "'classical'", ":"...
Write a `report.csv` file with information about the calculation without running it :param job_ini: full pathname of the job.ini file :param output_dir: the directory where the report is written (default the input directory)
[ "Write", "a", "report", ".", "csv", "file", "with", "information", "about", "the", "calculation", "without", "running", "it" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/reportwriter.py#L125-L159
train
gem/oq-engine
openquake/calculators/reportwriter.py
ReportWriter.add
def add(self, name, obj=None): """Add the view named `name` to the report text""" if obj: text = '\n::\n\n' + indent(str(obj)) else: text = views.view(name, self.dstore) if text: title = self.title[name] line = '-' * len(title) ...
python
def add(self, name, obj=None): """Add the view named `name` to the report text""" if obj: text = '\n::\n\n' + indent(str(obj)) else: text = views.view(name, self.dstore) if text: title = self.title[name] line = '-' * len(title) ...
[ "def", "add", "(", "self", ",", "name", ",", "obj", "=", "None", ")", ":", "if", "obj", ":", "text", "=", "'\\n::\\n\\n'", "+", "indent", "(", "str", "(", "obj", ")", ")", "else", ":", "text", "=", "views", ".", "view", "(", "name", ",", "self"...
Add the view named `name` to the report text
[ "Add", "the", "view", "named", "name", "to", "the", "report", "text" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/reportwriter.py#L74-L83
train
gem/oq-engine
openquake/calculators/reportwriter.py
ReportWriter.make_report
def make_report(self): """Build the report and return a restructed text string""" oq, ds = self.oq, self.dstore for name in ('params', 'inputs'): self.add(name) if 'csm_info' in ds: self.add('csm_info') if ds['csm_info'].source_models[0].name != 'scena...
python
def make_report(self): """Build the report and return a restructed text string""" oq, ds = self.oq, self.dstore for name in ('params', 'inputs'): self.add(name) if 'csm_info' in ds: self.add('csm_info') if ds['csm_info'].source_models[0].name != 'scena...
[ "def", "make_report", "(", "self", ")", ":", "oq", ",", "ds", "=", "self", ".", "oq", ",", "self", ".", "dstore", "for", "name", "in", "(", "'params'", ",", "'inputs'", ")", ":", "self", ".", "add", "(", "name", ")", "if", "'csm_info'", "in", "ds...
Build the report and return a restructed text string
[ "Build", "the", "report", "and", "return", "a", "restructed", "text", "string" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/reportwriter.py#L85-L117
train
gem/oq-engine
openquake/calculators/reportwriter.py
ReportWriter.save
def save(self, fname): """Save the report""" with open(fname, 'wb') as f: f.write(encode(self.text))
python
def save(self, fname): """Save the report""" with open(fname, 'wb') as f: f.write(encode(self.text))
[ "def", "save", "(", "self", ",", "fname", ")", ":", "with", "open", "(", "fname", ",", "'wb'", ")", "as", "f", ":", "f", ".", "write", "(", "encode", "(", "self", ".", "text", ")", ")" ]
Save the report
[ "Save", "the", "report" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/reportwriter.py#L119-L122
train
gem/oq-engine
openquake/hazardlib/gsim/frankel_1996.py
FrankelEtAl1996MblgAB1987NSHMP2008._compute_mean
def _compute_mean(self, imt, mag, rhypo): """ Compute mean value from lookup table. Lookup table defines log10(IMT) (in g) for combinations of Mw and log10(rhypo) values. ``mag`` is therefore converted from Mblg to Mw using Atkinson and Boore 1987 conversion equation. Mean value...
python
def _compute_mean(self, imt, mag, rhypo): """ Compute mean value from lookup table. Lookup table defines log10(IMT) (in g) for combinations of Mw and log10(rhypo) values. ``mag`` is therefore converted from Mblg to Mw using Atkinson and Boore 1987 conversion equation. Mean value...
[ "def", "_compute_mean", "(", "self", ",", "imt", ",", "mag", ",", "rhypo", ")", ":", "mag", "=", "np", ".", "zeros_like", "(", "rhypo", ")", "+", "self", ".", "_convert_magnitude", "(", "mag", ")", "rhypo", "[", "rhypo", "<", "10", "]", "=", "10", ...
Compute mean value from lookup table. Lookup table defines log10(IMT) (in g) for combinations of Mw and log10(rhypo) values. ``mag`` is therefore converted from Mblg to Mw using Atkinson and Boore 1987 conversion equation. Mean value is finally converted from base 10 to base e.
[ "Compute", "mean", "value", "from", "lookup", "table", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/frankel_1996.py#L129-L152
train
gem/oq-engine
openquake/hmtk/plotting/seismicity/occurrence/recurrence_plot.py
_get_recurrence_model
def _get_recurrence_model(input_model): """ Returns the annual and cumulative recurrence rates predicted by the recurrence model """ if not isinstance(input_model, (TruncatedGRMFD, EvenlyDiscretizedMFD, YoungsCoppersmith1985MFD)...
python
def _get_recurrence_model(input_model): """ Returns the annual and cumulative recurrence rates predicted by the recurrence model """ if not isinstance(input_model, (TruncatedGRMFD, EvenlyDiscretizedMFD, YoungsCoppersmith1985MFD)...
[ "def", "_get_recurrence_model", "(", "input_model", ")", ":", "if", "not", "isinstance", "(", "input_model", ",", "(", "TruncatedGRMFD", ",", "EvenlyDiscretizedMFD", ",", "YoungsCoppersmith1985MFD", ")", ")", ":", "raise", "ValueError", "(", "'Recurrence model not rec...
Returns the annual and cumulative recurrence rates predicted by the recurrence model
[ "Returns", "the", "annual", "and", "cumulative", "recurrence", "rates", "predicted", "by", "the", "recurrence", "model" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/occurrence/recurrence_plot.py#L62-L77
train
gem/oq-engine
openquake/hmtk/plotting/seismicity/occurrence/recurrence_plot.py
_check_completeness_table
def _check_completeness_table(completeness, catalogue): """ Generates the completeness table according to different instances """ if isinstance(completeness, np.ndarray) and np.shape(completeness)[1] == 2: return completeness elif isinstance(completeness, float): return np.array([[fl...
python
def _check_completeness_table(completeness, catalogue): """ Generates the completeness table according to different instances """ if isinstance(completeness, np.ndarray) and np.shape(completeness)[1] == 2: return completeness elif isinstance(completeness, float): return np.array([[fl...
[ "def", "_check_completeness_table", "(", "completeness", ",", "catalogue", ")", ":", "if", "isinstance", "(", "completeness", ",", "np", ".", "ndarray", ")", "and", "np", ".", "shape", "(", "completeness", ")", "[", "1", "]", "==", "2", ":", "return", "c...
Generates the completeness table according to different instances
[ "Generates", "the", "completeness", "table", "according", "to", "different", "instances" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/occurrence/recurrence_plot.py#L80-L93
train
gem/oq-engine
openquake/hmtk/plotting/seismicity/occurrence/recurrence_plot.py
plot_recurrence_model
def plot_recurrence_model( input_model, catalogue, completeness, dmag=0.1, filename=None, figure_size=(8, 6), filetype='png', dpi=300, ax=None): """ Plot a calculated recurrence model over an observed catalogue, adjusted for time-varying completeness """ annual_rates, cumulative_rate...
python
def plot_recurrence_model( input_model, catalogue, completeness, dmag=0.1, filename=None, figure_size=(8, 6), filetype='png', dpi=300, ax=None): """ Plot a calculated recurrence model over an observed catalogue, adjusted for time-varying completeness """ annual_rates, cumulative_rate...
[ "def", "plot_recurrence_model", "(", "input_model", ",", "catalogue", ",", "completeness", ",", "dmag", "=", "0.1", ",", "filename", "=", "None", ",", "figure_size", "=", "(", "8", ",", "6", ")", ",", "filetype", "=", "'png'", ",", "dpi", "=", "300", "...
Plot a calculated recurrence model over an observed catalogue, adjusted for time-varying completeness
[ "Plot", "a", "calculated", "recurrence", "model", "over", "an", "observed", "catalogue", "adjusted", "for", "time", "-", "varying", "completeness" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/occurrence/recurrence_plot.py#L96-L132
train
gem/oq-engine
openquake/hmtk/plotting/seismicity/occurrence/recurrence_plot.py
plot_trunc_gr_model
def plot_trunc_gr_model( aval, bval, min_mag, max_mag, dmag, catalogue=None, completeness=None, filename=None, figure_size=(8, 6), filetype='png', dpi=300, ax=None): """ Plots a Gutenberg-Richter model """ input_model = TruncatedGRMFD(min_mag, max_mag, dmag, aval, bval) if no...
python
def plot_trunc_gr_model( aval, bval, min_mag, max_mag, dmag, catalogue=None, completeness=None, filename=None, figure_size=(8, 6), filetype='png', dpi=300, ax=None): """ Plots a Gutenberg-Richter model """ input_model = TruncatedGRMFD(min_mag, max_mag, dmag, aval, bval) if no...
[ "def", "plot_trunc_gr_model", "(", "aval", ",", "bval", ",", "min_mag", ",", "max_mag", ",", "dmag", ",", "catalogue", "=", "None", ",", "completeness", "=", "None", ",", "filename", "=", "None", ",", "figure_size", "=", "(", "8", ",", "6", ")", ",", ...
Plots a Gutenberg-Richter model
[ "Plots", "a", "Gutenberg", "-", "Richter", "model" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/occurrence/recurrence_plot.py#L135-L163
train
gem/oq-engine
openquake/hazardlib/nrml.py
read
def read(source, chatty=True, stop=None): """ Convert a NRML file into a validated Node object. Keeps the entire tree in memory. :param source: a file name or file object open for reading """ vparser = ValidatingXmlParser(validators, stop) nrml = vparser.parse_file(source) if st...
python
def read(source, chatty=True, stop=None): """ Convert a NRML file into a validated Node object. Keeps the entire tree in memory. :param source: a file name or file object open for reading """ vparser = ValidatingXmlParser(validators, stop) nrml = vparser.parse_file(source) if st...
[ "def", "read", "(", "source", ",", "chatty", "=", "True", ",", "stop", "=", "None", ")", ":", "vparser", "=", "ValidatingXmlParser", "(", "validators", ",", "stop", ")", "nrml", "=", "vparser", ".", "parse_file", "(", "source", ")", "if", "striptag", "...
Convert a NRML file into a validated Node object. Keeps the entire tree in memory. :param source: a file name or file object open for reading
[ "Convert", "a", "NRML", "file", "into", "a", "validated", "Node", "object", ".", "Keeps", "the", "entire", "tree", "in", "memory", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/nrml.py#L329-L349
train
gem/oq-engine
openquake/hazardlib/nrml.py
write
def write(nodes, output=sys.stdout, fmt='%.7E', gml=True, xmlns=None): """ Convert nodes into a NRML file. output must be a file object open in write mode. If you want to perform a consistency check, open it in read-write mode, then it will be read after creation and validated. :params nodes: a...
python
def write(nodes, output=sys.stdout, fmt='%.7E', gml=True, xmlns=None): """ Convert nodes into a NRML file. output must be a file object open in write mode. If you want to perform a consistency check, open it in read-write mode, then it will be read after creation and validated. :params nodes: a...
[ "def", "write", "(", "nodes", ",", "output", "=", "sys", ".", "stdout", ",", "fmt", "=", "'%.7E'", ",", "gml", "=", "True", ",", "xmlns", "=", "None", ")", ":", "root", "=", "Node", "(", "'nrml'", ",", "nodes", "=", "nodes", ")", "namespaces", "=...
Convert nodes into a NRML file. output must be a file object open in write mode. If you want to perform a consistency check, open it in read-write mode, then it will be read after creation and validated. :params nodes: an iterable over Node objects :params output: a file-like object in write or rea...
[ "Convert", "nodes", "into", "a", "NRML", "file", ".", "output", "must", "be", "a", "file", "object", "open", "in", "write", "mode", ".", "If", "you", "want", "to", "perform", "a", "consistency", "check", "open", "it", "in", "read", "-", "write", "mode"...
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/nrml.py#L352-L373
train
gem/oq-engine
openquake/hazardlib/nrml.py
to_string
def to_string(node): """ Convert a node into a string in NRML format """ with io.BytesIO() as f: write([node], f) return f.getvalue().decode('utf-8')
python
def to_string(node): """ Convert a node into a string in NRML format """ with io.BytesIO() as f: write([node], f) return f.getvalue().decode('utf-8')
[ "def", "to_string", "(", "node", ")", ":", "with", "io", ".", "BytesIO", "(", ")", "as", "f", ":", "write", "(", "[", "node", "]", ",", "f", ")", "return", "f", ".", "getvalue", "(", ")", ".", "decode", "(", "'utf-8'", ")" ]
Convert a node into a string in NRML format
[ "Convert", "a", "node", "into", "a", "string", "in", "NRML", "format" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/nrml.py#L376-L382
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2014.py
CampbellBozorgnia2014.get_mean_values
def get_mean_values(self, C, sites, rup, dists, a1100): """ Returns the mean values for a specific IMT """ if isinstance(a1100, np.ndarray): # Site model defined temp_vs30 = sites.vs30 temp_z2pt5 = sites.z2pt5 else: # Default site a...
python
def get_mean_values(self, C, sites, rup, dists, a1100): """ Returns the mean values for a specific IMT """ if isinstance(a1100, np.ndarray): # Site model defined temp_vs30 = sites.vs30 temp_z2pt5 = sites.z2pt5 else: # Default site a...
[ "def", "get_mean_values", "(", "self", ",", "C", ",", "sites", ",", "rup", ",", "dists", ",", "a1100", ")", ":", "if", "isinstance", "(", "a1100", ",", "np", ".", "ndarray", ")", ":", "temp_vs30", "=", "sites", ".", "vs30", "temp_z2pt5", "=", "sites"...
Returns the mean values for a specific IMT
[ "Returns", "the", "mean", "values", "for", "a", "specific", "IMT" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L122-L144
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2014.py
CampbellBozorgnia2014._get_magnitude_term
def _get_magnitude_term(self, C, mag): """ Returns the magnitude scaling term defined in equation 2 """ f_mag = C["c0"] + C["c1"] * mag if (mag > 4.5) and (mag <= 5.5): return f_mag + (C["c2"] * (mag - 4.5)) elif (mag > 5.5) and (mag <= 6.5): retur...
python
def _get_magnitude_term(self, C, mag): """ Returns the magnitude scaling term defined in equation 2 """ f_mag = C["c0"] + C["c1"] * mag if (mag > 4.5) and (mag <= 5.5): return f_mag + (C["c2"] * (mag - 4.5)) elif (mag > 5.5) and (mag <= 6.5): retur...
[ "def", "_get_magnitude_term", "(", "self", ",", "C", ",", "mag", ")", ":", "f_mag", "=", "C", "[", "\"c0\"", "]", "+", "C", "[", "\"c1\"", "]", "*", "mag", "if", "(", "mag", ">", "4.5", ")", "and", "(", "mag", "<=", "5.5", ")", ":", "return", ...
Returns the magnitude scaling term defined in equation 2
[ "Returns", "the", "magnitude", "scaling", "term", "defined", "in", "equation", "2" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L146-L159
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2014.py
CampbellBozorgnia2014._get_geometric_attenuation_term
def _get_geometric_attenuation_term(self, C, mag, rrup): """ Returns the geometric attenuation term defined in equation 3 """ return (C["c5"] + C["c6"] * mag) * np.log(np.sqrt((rrup ** 2.) + (C["c7"] ** 2.)))
python
def _get_geometric_attenuation_term(self, C, mag, rrup): """ Returns the geometric attenuation term defined in equation 3 """ return (C["c5"] + C["c6"] * mag) * np.log(np.sqrt((rrup ** 2.) + (C["c7"] ** 2.)))
[ "def", "_get_geometric_attenuation_term", "(", "self", ",", "C", ",", "mag", ",", "rrup", ")", ":", "return", "(", "C", "[", "\"c5\"", "]", "+", "C", "[", "\"c6\"", "]", "*", "mag", ")", "*", "np", ".", "log", "(", "np", ".", "sqrt", "(", "(", ...
Returns the geometric attenuation term defined in equation 3
[ "Returns", "the", "geometric", "attenuation", "term", "defined", "in", "equation", "3" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L161-L166
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2014.py
CampbellBozorgnia2014._get_style_of_faulting_term
def _get_style_of_faulting_term(self, C, rup): """ Returns the style-of-faulting scaling term defined in equations 4 to 6 """ if (rup.rake > 30.0) and (rup.rake < 150.): frv = 1.0 fnm = 0.0 elif (rup.rake > -150.0) and (rup.rake < -30.0): fnm =...
python
def _get_style_of_faulting_term(self, C, rup): """ Returns the style-of-faulting scaling term defined in equations 4 to 6 """ if (rup.rake > 30.0) and (rup.rake < 150.): frv = 1.0 fnm = 0.0 elif (rup.rake > -150.0) and (rup.rake < -30.0): fnm =...
[ "def", "_get_style_of_faulting_term", "(", "self", ",", "C", ",", "rup", ")", ":", "if", "(", "rup", ".", "rake", ">", "30.0", ")", "and", "(", "rup", ".", "rake", "<", "150.", ")", ":", "frv", "=", "1.0", "fnm", "=", "0.0", "elif", "(", "rup", ...
Returns the style-of-faulting scaling term defined in equations 4 to 6
[ "Returns", "the", "style", "-", "of", "-", "faulting", "scaling", "term", "defined", "in", "equations", "4", "to", "6" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L168-L189
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2014.py
CampbellBozorgnia2014._get_hanging_wall_term
def _get_hanging_wall_term(self, C, rup, dists): """ Returns the hanging wall scaling term defined in equations 7 to 16 """ return (C["c10"] * self._get_hanging_wall_coeffs_rx(C, rup, dists.rx) * self._get_hanging_wall_coeffs_rrup(dists) * ...
python
def _get_hanging_wall_term(self, C, rup, dists): """ Returns the hanging wall scaling term defined in equations 7 to 16 """ return (C["c10"] * self._get_hanging_wall_coeffs_rx(C, rup, dists.rx) * self._get_hanging_wall_coeffs_rrup(dists) * ...
[ "def", "_get_hanging_wall_term", "(", "self", ",", "C", ",", "rup", ",", "dists", ")", ":", "return", "(", "C", "[", "\"c10\"", "]", "*", "self", ".", "_get_hanging_wall_coeffs_rx", "(", "C", ",", "rup", ",", "dists", ".", "rx", ")", "*", "self", "."...
Returns the hanging wall scaling term defined in equations 7 to 16
[ "Returns", "the", "hanging", "wall", "scaling", "term", "defined", "in", "equations", "7", "to", "16" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L191-L200
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2014.py
CampbellBozorgnia2014._get_hanging_wall_coeffs_rx
def _get_hanging_wall_coeffs_rx(self, C, rup, r_x): """ Returns the hanging wall r-x caling term defined in equation 7 to 12 """ # Define coefficients R1 and R2 r_1 = rup.width * cos(radians(rup.dip)) r_2 = 62.0 * rup.mag - 350.0 fhngrx = np.zeros(len(r_x)) ...
python
def _get_hanging_wall_coeffs_rx(self, C, rup, r_x): """ Returns the hanging wall r-x caling term defined in equation 7 to 12 """ # Define coefficients R1 and R2 r_1 = rup.width * cos(radians(rup.dip)) r_2 = 62.0 * rup.mag - 350.0 fhngrx = np.zeros(len(r_x)) ...
[ "def", "_get_hanging_wall_coeffs_rx", "(", "self", ",", "C", ",", "rup", ",", "r_x", ")", ":", "r_1", "=", "rup", ".", "width", "*", "cos", "(", "radians", "(", "rup", ".", "dip", ")", ")", "r_2", "=", "62.0", "*", "rup", ".", "mag", "-", "350.0"...
Returns the hanging wall r-x caling term defined in equation 7 to 12
[ "Returns", "the", "hanging", "wall", "r", "-", "x", "caling", "term", "defined", "in", "equation", "7", "to", "12" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L202-L218
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2014.py
CampbellBozorgnia2014._get_f1rx
def _get_f1rx(self, C, r_x, r_1): """ Defines the f1 scaling coefficient defined in equation 9 """ rxr1 = r_x / r_1 return C["h1"] + (C["h2"] * rxr1) + (C["h3"] * (rxr1 ** 2.))
python
def _get_f1rx(self, C, r_x, r_1): """ Defines the f1 scaling coefficient defined in equation 9 """ rxr1 = r_x / r_1 return C["h1"] + (C["h2"] * rxr1) + (C["h3"] * (rxr1 ** 2.))
[ "def", "_get_f1rx", "(", "self", ",", "C", ",", "r_x", ",", "r_1", ")", ":", "rxr1", "=", "r_x", "/", "r_1", "return", "C", "[", "\"h1\"", "]", "+", "(", "C", "[", "\"h2\"", "]", "*", "rxr1", ")", "+", "(", "C", "[", "\"h3\"", "]", "*", "("...
Defines the f1 scaling coefficient defined in equation 9
[ "Defines", "the", "f1", "scaling", "coefficient", "defined", "in", "equation", "9" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L220-L225
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2014.py
CampbellBozorgnia2014._get_f2rx
def _get_f2rx(self, C, r_x, r_1, r_2): """ Defines the f2 scaling coefficient defined in equation 10 """ drx = (r_x - r_1) / (r_2 - r_1) return self.CONSTS["h4"] + (C["h5"] * drx) + (C["h6"] * (drx ** 2.))
python
def _get_f2rx(self, C, r_x, r_1, r_2): """ Defines the f2 scaling coefficient defined in equation 10 """ drx = (r_x - r_1) / (r_2 - r_1) return self.CONSTS["h4"] + (C["h5"] * drx) + (C["h6"] * (drx ** 2.))
[ "def", "_get_f2rx", "(", "self", ",", "C", ",", "r_x", ",", "r_1", ",", "r_2", ")", ":", "drx", "=", "(", "r_x", "-", "r_1", ")", "/", "(", "r_2", "-", "r_1", ")", "return", "self", ".", "CONSTS", "[", "\"h4\"", "]", "+", "(", "C", "[", "\"...
Defines the f2 scaling coefficient defined in equation 10
[ "Defines", "the", "f2", "scaling", "coefficient", "defined", "in", "equation", "10" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L227-L232
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2014.py
CampbellBozorgnia2014._get_hanging_wall_coeffs_rrup
def _get_hanging_wall_coeffs_rrup(self, dists): """ Returns the hanging wall rrup term defined in equation 13 """ fhngrrup = np.ones(len(dists.rrup)) idx = dists.rrup > 0.0 fhngrrup[idx] = (dists.rrup[idx] - dists.rjb[idx]) / dists.rrup[idx] return fhngrrup
python
def _get_hanging_wall_coeffs_rrup(self, dists): """ Returns the hanging wall rrup term defined in equation 13 """ fhngrrup = np.ones(len(dists.rrup)) idx = dists.rrup > 0.0 fhngrrup[idx] = (dists.rrup[idx] - dists.rjb[idx]) / dists.rrup[idx] return fhngrrup
[ "def", "_get_hanging_wall_coeffs_rrup", "(", "self", ",", "dists", ")", ":", "fhngrrup", "=", "np", ".", "ones", "(", "len", "(", "dists", ".", "rrup", ")", ")", "idx", "=", "dists", ".", "rrup", ">", "0.0", "fhngrrup", "[", "idx", "]", "=", "(", "...
Returns the hanging wall rrup term defined in equation 13
[ "Returns", "the", "hanging", "wall", "rrup", "term", "defined", "in", "equation", "13" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L234-L241
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2014.py
CampbellBozorgnia2014._get_hanging_wall_coeffs_mag
def _get_hanging_wall_coeffs_mag(self, C, mag): """ Returns the hanging wall magnitude term defined in equation 14 """ if mag < 5.5: return 0.0 elif mag > 6.5: return 1.0 + C["a2"] * (mag - 6.5) else: return (mag - 5.5) * (1.0 + C["a2"]...
python
def _get_hanging_wall_coeffs_mag(self, C, mag): """ Returns the hanging wall magnitude term defined in equation 14 """ if mag < 5.5: return 0.0 elif mag > 6.5: return 1.0 + C["a2"] * (mag - 6.5) else: return (mag - 5.5) * (1.0 + C["a2"]...
[ "def", "_get_hanging_wall_coeffs_mag", "(", "self", ",", "C", ",", "mag", ")", ":", "if", "mag", "<", "5.5", ":", "return", "0.0", "elif", "mag", ">", "6.5", ":", "return", "1.0", "+", "C", "[", "\"a2\"", "]", "*", "(", "mag", "-", "6.5", ")", "e...
Returns the hanging wall magnitude term defined in equation 14
[ "Returns", "the", "hanging", "wall", "magnitude", "term", "defined", "in", "equation", "14" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L243-L252
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2014.py
CampbellBozorgnia2014._get_hypocentral_depth_term
def _get_hypocentral_depth_term(self, C, rup): """ Returns the hypocentral depth scaling term defined in equations 21 - 23 """ if rup.hypo_depth <= 7.0: fhyp_h = 0.0 elif rup.hypo_depth > 20.0: fhyp_h = 13.0 else: fhyp_h = rup.hypo_dept...
python
def _get_hypocentral_depth_term(self, C, rup): """ Returns the hypocentral depth scaling term defined in equations 21 - 23 """ if rup.hypo_depth <= 7.0: fhyp_h = 0.0 elif rup.hypo_depth > 20.0: fhyp_h = 13.0 else: fhyp_h = rup.hypo_dept...
[ "def", "_get_hypocentral_depth_term", "(", "self", ",", "C", ",", "rup", ")", ":", "if", "rup", ".", "hypo_depth", "<=", "7.0", ":", "fhyp_h", "=", "0.0", "elif", "rup", ".", "hypo_depth", ">", "20.0", ":", "fhyp_h", "=", "13.0", "else", ":", "fhyp_h",...
Returns the hypocentral depth scaling term defined in equations 21 - 23
[ "Returns", "the", "hypocentral", "depth", "scaling", "term", "defined", "in", "equations", "21", "-", "23" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L269-L286
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2014.py
CampbellBozorgnia2014._get_fault_dip_term
def _get_fault_dip_term(self, C, rup): """ Returns the fault dip term, defined in equation 24 """ if rup.mag < 4.5: return C["c19"] * rup.dip elif rup.mag > 5.5: return 0.0 else: return C["c19"] * (5.5 - rup.mag) * rup.dip
python
def _get_fault_dip_term(self, C, rup): """ Returns the fault dip term, defined in equation 24 """ if rup.mag < 4.5: return C["c19"] * rup.dip elif rup.mag > 5.5: return 0.0 else: return C["c19"] * (5.5 - rup.mag) * rup.dip
[ "def", "_get_fault_dip_term", "(", "self", ",", "C", ",", "rup", ")", ":", "if", "rup", ".", "mag", "<", "4.5", ":", "return", "C", "[", "\"c19\"", "]", "*", "rup", ".", "dip", "elif", "rup", ".", "mag", ">", "5.5", ":", "return", "0.0", "else", ...
Returns the fault dip term, defined in equation 24
[ "Returns", "the", "fault", "dip", "term", "defined", "in", "equation", "24" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L288-L297
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2014.py
CampbellBozorgnia2014._get_anelastic_attenuation_term
def _get_anelastic_attenuation_term(self, C, rrup): """ Returns the anelastic attenuation term defined in equation 25 """ f_atn = np.zeros(len(rrup)) idx = rrup >= 80.0 f_atn[idx] = (C["c20"] + C["Dc20"]) * (rrup[idx] - 80.0) return f_atn
python
def _get_anelastic_attenuation_term(self, C, rrup): """ Returns the anelastic attenuation term defined in equation 25 """ f_atn = np.zeros(len(rrup)) idx = rrup >= 80.0 f_atn[idx] = (C["c20"] + C["Dc20"]) * (rrup[idx] - 80.0) return f_atn
[ "def", "_get_anelastic_attenuation_term", "(", "self", ",", "C", ",", "rrup", ")", ":", "f_atn", "=", "np", ".", "zeros", "(", "len", "(", "rrup", ")", ")", "idx", "=", "rrup", ">=", "80.0", "f_atn", "[", "idx", "]", "=", "(", "C", "[", "\"c20\"", ...
Returns the anelastic attenuation term defined in equation 25
[ "Returns", "the", "anelastic", "attenuation", "term", "defined", "in", "equation", "25" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L299-L306
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2014.py
CampbellBozorgnia2014._get_basin_response_term
def _get_basin_response_term(self, C, z2pt5): """ Returns the basin response term defined in equation 20 """ f_sed = np.zeros(len(z2pt5)) idx = z2pt5 < 1.0 f_sed[idx] = (C["c14"] + C["c15"] * float(self.CONSTS["SJ"])) *\ (z2pt5[idx] - 1.0) idx = z2pt5 ...
python
def _get_basin_response_term(self, C, z2pt5): """ Returns the basin response term defined in equation 20 """ f_sed = np.zeros(len(z2pt5)) idx = z2pt5 < 1.0 f_sed[idx] = (C["c14"] + C["c15"] * float(self.CONSTS["SJ"])) *\ (z2pt5[idx] - 1.0) idx = z2pt5 ...
[ "def", "_get_basin_response_term", "(", "self", ",", "C", ",", "z2pt5", ")", ":", "f_sed", "=", "np", ".", "zeros", "(", "len", "(", "z2pt5", ")", ")", "idx", "=", "z2pt5", "<", "1.0", "f_sed", "[", "idx", "]", "=", "(", "C", "[", "\"c14\"", "]",...
Returns the basin response term defined in equation 20
[ "Returns", "the", "basin", "response", "term", "defined", "in", "equation", "20" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L321-L332
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2014.py
CampbellBozorgnia2014._get_shallow_site_response_term
def _get_shallow_site_response_term(self, C, vs30, pga_rock): """ Returns the shallow site response term defined in equations 17, 18 and 19 """ vs_mod = vs30 / C["k1"] # Get linear global site response term f_site_g = C["c11"] * np.log(vs_mod) idx = vs30 >...
python
def _get_shallow_site_response_term(self, C, vs30, pga_rock): """ Returns the shallow site response term defined in equations 17, 18 and 19 """ vs_mod = vs30 / C["k1"] # Get linear global site response term f_site_g = C["c11"] * np.log(vs_mod) idx = vs30 >...
[ "def", "_get_shallow_site_response_term", "(", "self", ",", "C", ",", "vs30", ",", "pga_rock", ")", ":", "vs_mod", "=", "vs30", "/", "C", "[", "\"k1\"", "]", "f_site_g", "=", "C", "[", "\"c11\"", "]", "*", "np", ".", "log", "(", "vs_mod", ")", "idx",...
Returns the shallow site response term defined in equations 17, 18 and 19
[ "Returns", "the", "shallow", "site", "response", "term", "defined", "in", "equations", "17", "18", "and", "19" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L334-L369
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2014.py
CampbellBozorgnia2014._get_stddevs
def _get_stddevs(self, C, C_PGA, rup, sites, pga1100, stddev_types): """ Returns the inter- and intra-event and total standard deviations """ # Get stddevs for PGA on basement rock tau_lnpga_b, phi_lnpga_b = self._get_stddevs_pga(C_PGA, rup) num_sites = len(sites.vs30) ...
python
def _get_stddevs(self, C, C_PGA, rup, sites, pga1100, stddev_types): """ Returns the inter- and intra-event and total standard deviations """ # Get stddevs for PGA on basement rock tau_lnpga_b, phi_lnpga_b = self._get_stddevs_pga(C_PGA, rup) num_sites = len(sites.vs30) ...
[ "def", "_get_stddevs", "(", "self", ",", "C", ",", "C_PGA", ",", "rup", ",", "sites", ",", "pga1100", ",", "stddev_types", ")", ":", "tau_lnpga_b", ",", "phi_lnpga_b", "=", "self", ".", "_get_stddevs_pga", "(", "C_PGA", ",", "rup", ")", "num_sites", "=",...
Returns the inter- and intra-event and total standard deviations
[ "Returns", "the", "inter", "-", "and", "intra", "-", "event", "and", "total", "standard", "deviations" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L371-L407
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2014.py
CampbellBozorgnia2014._get_stddevs_pga
def _get_stddevs_pga(self, C, rup): """ Returns the inter- and intra-event coefficients for PGA """ tau_lnpga_b = self._get_taulny(C, rup.mag) phi_lnpga_b = np.sqrt(self._get_philny(C, rup.mag) ** 2. - self.CONSTS["philnAF"] ** 2.) return tau...
python
def _get_stddevs_pga(self, C, rup): """ Returns the inter- and intra-event coefficients for PGA """ tau_lnpga_b = self._get_taulny(C, rup.mag) phi_lnpga_b = np.sqrt(self._get_philny(C, rup.mag) ** 2. - self.CONSTS["philnAF"] ** 2.) return tau...
[ "def", "_get_stddevs_pga", "(", "self", ",", "C", ",", "rup", ")", ":", "tau_lnpga_b", "=", "self", ".", "_get_taulny", "(", "C", ",", "rup", ".", "mag", ")", "phi_lnpga_b", "=", "np", ".", "sqrt", "(", "self", ".", "_get_philny", "(", "C", ",", "r...
Returns the inter- and intra-event coefficients for PGA
[ "Returns", "the", "inter", "-", "and", "intra", "-", "event", "coefficients", "for", "PGA" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L409-L416
train
gem/oq-engine
openquake/hazardlib/gsim/campbell_bozorgnia_2014.py
CampbellBozorgnia2014._get_alpha
def _get_alpha(self, C, vs30, pga_rock): """ Returns the alpha, the linearised functional relationship between the site amplification and the PGA on rock. Equation 31. """ alpha = np.zeros(len(pga_rock)) idx = vs30 < C["k1"] if np.any(idx): af1 = pga_r...
python
def _get_alpha(self, C, vs30, pga_rock): """ Returns the alpha, the linearised functional relationship between the site amplification and the PGA on rock. Equation 31. """ alpha = np.zeros(len(pga_rock)) idx = vs30 < C["k1"] if np.any(idx): af1 = pga_r...
[ "def", "_get_alpha", "(", "self", ",", "C", ",", "vs30", ",", "pga_rock", ")", ":", "alpha", "=", "np", ".", "zeros", "(", "len", "(", "pga_rock", ")", ")", "idx", "=", "vs30", "<", "C", "[", "\"k1\"", "]", "if", "np", ".", "any", "(", "idx", ...
Returns the alpha, the linearised functional relationship between the site amplification and the PGA on rock. Equation 31.
[ "Returns", "the", "alpha", "the", "linearised", "functional", "relationship", "between", "the", "site", "amplification", "and", "the", "PGA", "on", "rock", ".", "Equation", "31", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/campbell_bozorgnia_2014.py#L442-L454
train
gem/oq-engine
openquake/hmtk/seismicity/utils.py
decimal_time
def decimal_time(year, month, day, hour, minute, second): """ Returns the full time as a decimal value :param year: Year of events (integer numpy.ndarray) :param month: Month of events (integer numpy.ndarray) :param day: Days of event (integer numpy.ndarray) :param hour:...
python
def decimal_time(year, month, day, hour, minute, second): """ Returns the full time as a decimal value :param year: Year of events (integer numpy.ndarray) :param month: Month of events (integer numpy.ndarray) :param day: Days of event (integer numpy.ndarray) :param hour:...
[ "def", "decimal_time", "(", "year", ",", "month", ",", "day", ",", "hour", ",", "minute", ",", "second", ")", ":", "tmo", "=", "np", ".", "ones_like", "(", "year", ",", "dtype", "=", "int", ")", "tda", "=", "np", ".", "ones_like", "(", "year", ",...
Returns the full time as a decimal value :param year: Year of events (integer numpy.ndarray) :param month: Month of events (integer numpy.ndarray) :param day: Days of event (integer numpy.ndarray) :param hour: Hour of event (integer numpy.ndarray) :param minute: ...
[ "Returns", "the", "full", "time", "as", "a", "decimal", "value" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/utils.py#L137-L197
train
gem/oq-engine
openquake/hmtk/seismicity/utils.py
haversine
def haversine(lon1, lat1, lon2, lat2, radians=False, earth_rad=6371.227): """ Allows to calculate geographical distance using the haversine formula. :param lon1: longitude of the first set of locations :type lon1: numpy.ndarray :param lat1: latitude of the frist set of locations :type lat1:...
python
def haversine(lon1, lat1, lon2, lat2, radians=False, earth_rad=6371.227): """ Allows to calculate geographical distance using the haversine formula. :param lon1: longitude of the first set of locations :type lon1: numpy.ndarray :param lat1: latitude of the frist set of locations :type lat1:...
[ "def", "haversine", "(", "lon1", ",", "lat1", ",", "lon2", ",", "lat2", ",", "radians", "=", "False", ",", "earth_rad", "=", "6371.227", ")", ":", "if", "not", "radians", ":", "cfact", "=", "np", ".", "pi", "/", "180.", "lon1", "=", "cfact", "*", ...
Allows to calculate geographical distance using the haversine formula. :param lon1: longitude of the first set of locations :type lon1: numpy.ndarray :param lat1: latitude of the frist set of locations :type lat1: numpy.ndarray :param lon2: longitude of the second set of locations :type lon...
[ "Allows", "to", "calculate", "geographical", "distance", "using", "the", "haversine", "formula", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/utils.py#L200-L252
train
gem/oq-engine
openquake/hmtk/seismicity/utils.py
greg2julian
def greg2julian(year, month, day, hour, minute, second): """ Function to convert a date from Gregorian to Julian format :param year: Year of events (integer numpy.ndarray) :param month: Month of events (integer numpy.ndarray) :param day: Days of event (integer numpy.ndarray)...
python
def greg2julian(year, month, day, hour, minute, second): """ Function to convert a date from Gregorian to Julian format :param year: Year of events (integer numpy.ndarray) :param month: Month of events (integer numpy.ndarray) :param day: Days of event (integer numpy.ndarray)...
[ "def", "greg2julian", "(", "year", ",", "month", ",", "day", ",", "hour", ",", "minute", ",", "second", ")", ":", "year", "=", "year", ".", "astype", "(", "float", ")", "month", "=", "month", ".", "astype", "(", "float", ")", "day", "=", "day", "...
Function to convert a date from Gregorian to Julian format :param year: Year of events (integer numpy.ndarray) :param month: Month of events (integer numpy.ndarray) :param day: Days of event (integer numpy.ndarray) :param hour: Hour of event (integer numpy.ndarray) :...
[ "Function", "to", "convert", "a", "date", "from", "Gregorian", "to", "Julian", "format" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/utils.py#L255-L289
train
gem/oq-engine
openquake/hmtk/seismicity/utils.py
sample_truncated_gaussian_vector
def sample_truncated_gaussian_vector(data, uncertainties, bounds=None): ''' Samples a Gaussian distribution subject to boundaries on the data :param numpy.ndarray data: Vector of N data values :param numpy.ndarray uncertainties: Vector of N data uncertainties :param int number_boots...
python
def sample_truncated_gaussian_vector(data, uncertainties, bounds=None): ''' Samples a Gaussian distribution subject to boundaries on the data :param numpy.ndarray data: Vector of N data values :param numpy.ndarray uncertainties: Vector of N data uncertainties :param int number_boots...
[ "def", "sample_truncated_gaussian_vector", "(", "data", ",", "uncertainties", ",", "bounds", "=", "None", ")", ":", "nvals", "=", "len", "(", "data", ")", "if", "bounds", ":", "if", "bounds", "[", "0", "]", "is", "not", "None", ":", "lower_bound", "=", ...
Samples a Gaussian distribution subject to boundaries on the data :param numpy.ndarray data: Vector of N data values :param numpy.ndarray uncertainties: Vector of N data uncertainties :param int number_bootstraps: Number of bootstrap samples :param tuple bounds: (Lower, ...
[ "Samples", "a", "Gaussian", "distribution", "subject", "to", "boundaries", "on", "the", "data" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/utils.py#L333-L363
train
gem/oq-engine
openquake/hmtk/seismicity/utils.py
hmtk_histogram_2D
def hmtk_histogram_2D(xvalues, yvalues, bins, x_offset=1.0E-10, y_offset=1.0E-10): """ See the explanation for the 1D case - now applied to 2D. :param numpy.ndarray xvalues: Values of x-data :param numpy.ndarray yvalues: Values of y-data :param tuple bins: ...
python
def hmtk_histogram_2D(xvalues, yvalues, bins, x_offset=1.0E-10, y_offset=1.0E-10): """ See the explanation for the 1D case - now applied to 2D. :param numpy.ndarray xvalues: Values of x-data :param numpy.ndarray yvalues: Values of y-data :param tuple bins: ...
[ "def", "hmtk_histogram_2D", "(", "xvalues", ",", "yvalues", ",", "bins", ",", "x_offset", "=", "1.0E-10", ",", "y_offset", "=", "1.0E-10", ")", ":", "xbins", ",", "ybins", "=", "(", "bins", "[", "0", "]", "-", "x_offset", ",", "bins", "[", "1", "]", ...
See the explanation for the 1D case - now applied to 2D. :param numpy.ndarray xvalues: Values of x-data :param numpy.ndarray yvalues: Values of y-data :param tuple bins: Tuple containing bin intervals for x-data and y-data (as numpy arrays) :param float x_offset: Small a...
[ "See", "the", "explanation", "for", "the", "1D", "case", "-", "now", "applied", "to", "2D", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/utils.py#L404-L432
train
gem/oq-engine
openquake/hmtk/seismicity/utils.py
bootstrap_histogram_1D
def bootstrap_histogram_1D( values, intervals, uncertainties=None, normalisation=False, number_bootstraps=None, boundaries=None): ''' Bootstrap samples a set of vectors :param numpy.ndarray values: The data values :param numpy.ndarray intervals: The bin edges :param ...
python
def bootstrap_histogram_1D( values, intervals, uncertainties=None, normalisation=False, number_bootstraps=None, boundaries=None): ''' Bootstrap samples a set of vectors :param numpy.ndarray values: The data values :param numpy.ndarray intervals: The bin edges :param ...
[ "def", "bootstrap_histogram_1D", "(", "values", ",", "intervals", ",", "uncertainties", "=", "None", ",", "normalisation", "=", "False", ",", "number_bootstraps", "=", "None", ",", "boundaries", "=", "None", ")", ":", "if", "not", "number_bootstraps", "or", "n...
Bootstrap samples a set of vectors :param numpy.ndarray values: The data values :param numpy.ndarray intervals: The bin edges :param numpy.ndarray uncertainties: The standard deviations of each observation :param bool normalisation: If True then returns the histogram as ...
[ "Bootstrap", "samples", "a", "set", "of", "vectors" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/utils.py#L435-L483
train
gem/oq-engine
openquake/hmtk/seismicity/utils.py
bootstrap_histogram_2D
def bootstrap_histogram_2D( xvalues, yvalues, xbins, ybins, boundaries=[None, None], xsigma=None, ysigma=None, normalisation=False, number_bootstraps=None): ''' Calculates a 2D histogram of data, allowing for normalisation and bootstrap sampling :param numpy.ndarray xvalues: ...
python
def bootstrap_histogram_2D( xvalues, yvalues, xbins, ybins, boundaries=[None, None], xsigma=None, ysigma=None, normalisation=False, number_bootstraps=None): ''' Calculates a 2D histogram of data, allowing for normalisation and bootstrap sampling :param numpy.ndarray xvalues: ...
[ "def", "bootstrap_histogram_2D", "(", "xvalues", ",", "yvalues", ",", "xbins", ",", "ybins", ",", "boundaries", "=", "[", "None", ",", "None", "]", ",", "xsigma", "=", "None", ",", "ysigma", "=", "None", ",", "normalisation", "=", "False", ",", "number_b...
Calculates a 2D histogram of data, allowing for normalisation and bootstrap sampling :param numpy.ndarray xvalues: Data values of the first variable :param numpy.ndarray yvalues: Data values of the second variable :param numpy.ndarray xbins: Bin edges for the first variable ...
[ "Calculates", "a", "2D", "histogram", "of", "data", "allowing", "for", "normalisation", "and", "bootstrap", "sampling" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/utils.py#L486-L558
train
gem/oq-engine
openquake/hmtk/seismicity/utils.py
area_of_polygon
def area_of_polygon(polygon): """ Returns the area of an OpenQuake polygon in square kilometres """ lon0 = np.mean(polygon.lons) lat0 = np.mean(polygon.lats) # Transform to lamber equal area projection x, y = lonlat_to_laea(polygon.lons, polygon.lats, lon0, lat0) # Build shapely polygons...
python
def area_of_polygon(polygon): """ Returns the area of an OpenQuake polygon in square kilometres """ lon0 = np.mean(polygon.lons) lat0 = np.mean(polygon.lats) # Transform to lamber equal area projection x, y = lonlat_to_laea(polygon.lons, polygon.lats, lon0, lat0) # Build shapely polygons...
[ "def", "area_of_polygon", "(", "polygon", ")", ":", "lon0", "=", "np", ".", "mean", "(", "polygon", ".", "lons", ")", "lat0", "=", "np", ".", "mean", "(", "polygon", ".", "lats", ")", "x", ",", "y", "=", "lonlat_to_laea", "(", "polygon", ".", "lons...
Returns the area of an OpenQuake polygon in square kilometres
[ "Returns", "the", "area", "of", "an", "OpenQuake", "polygon", "in", "square", "kilometres" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/utils.py#L628-L638
train
gem/oq-engine
openquake/commonlib/oqvalidation.py
OqParam.lti
def lti(self): """ Dictionary extended_loss_type -> extended_loss_type index """ return {lt: i for i, (lt, dt) in enumerate(self.loss_dt_list())}
python
def lti(self): """ Dictionary extended_loss_type -> extended_loss_type index """ return {lt: i for i, (lt, dt) in enumerate(self.loss_dt_list())}
[ "def", "lti", "(", "self", ")", ":", "return", "{", "lt", ":", "i", "for", "i", ",", "(", "lt", ",", "dt", ")", "in", "enumerate", "(", "self", ".", "loss_dt_list", "(", ")", ")", "}" ]
Dictionary extended_loss_type -> extended_loss_type index
[ "Dictionary", "extended_loss_type", "-", ">", "extended_loss_type", "index" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L468-L472
train
gem/oq-engine
openquake/commonlib/oqvalidation.py
OqParam.loss_maps_dt
def loss_maps_dt(self, dtype=F32): """ Return a composite data type for loss maps """ ltypes = self.loss_dt(dtype).names lst = [('poe-%s' % poe, dtype) for poe in self.conditional_loss_poes] return numpy.dtype([(lt, lst) for lt in ltypes])
python
def loss_maps_dt(self, dtype=F32): """ Return a composite data type for loss maps """ ltypes = self.loss_dt(dtype).names lst = [('poe-%s' % poe, dtype) for poe in self.conditional_loss_poes] return numpy.dtype([(lt, lst) for lt in ltypes])
[ "def", "loss_maps_dt", "(", "self", ",", "dtype", "=", "F32", ")", ":", "ltypes", "=", "self", ".", "loss_dt", "(", "dtype", ")", ".", "names", "lst", "=", "[", "(", "'poe-%s'", "%", "poe", ",", "dtype", ")", "for", "poe", "in", "self", ".", "con...
Return a composite data type for loss maps
[ "Return", "a", "composite", "data", "type", "for", "loss", "maps" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L488-L494
train
gem/oq-engine
openquake/commonlib/oqvalidation.py
OqParam.gmf_data_dt
def gmf_data_dt(self): """ Return a composite data type for the GMFs """ return numpy.dtype( [('rlzi', U16), ('sid', U32), ('eid', U64), ('gmv', (F32, (len(self.imtls),)))])
python
def gmf_data_dt(self): """ Return a composite data type for the GMFs """ return numpy.dtype( [('rlzi', U16), ('sid', U32), ('eid', U64), ('gmv', (F32, (len(self.imtls),)))])
[ "def", "gmf_data_dt", "(", "self", ")", ":", "return", "numpy", ".", "dtype", "(", "[", "(", "'rlzi'", ",", "U16", ")", ",", "(", "'sid'", ",", "U32", ")", ",", "(", "'eid'", ",", "U64", ")", ",", "(", "'gmv'", ",", "(", "F32", ",", "(", "len...
Return a composite data type for the GMFs
[ "Return", "a", "composite", "data", "type", "for", "the", "GMFs" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L496-L502
train
gem/oq-engine
openquake/commonlib/oqvalidation.py
OqParam.no_imls
def no_imls(self): """ Return True if there are no intensity measure levels """ return all(numpy.isnan(ls).any() for ls in self.imtls.values())
python
def no_imls(self): """ Return True if there are no intensity measure levels """ return all(numpy.isnan(ls).any() for ls in self.imtls.values())
[ "def", "no_imls", "(", "self", ")", ":", "return", "all", "(", "numpy", ".", "isnan", "(", "ls", ")", ".", "any", "(", ")", "for", "ls", "in", "self", ".", "imtls", ".", "values", "(", ")", ")" ]
Return True if there are no intensity measure levels
[ "Return", "True", "if", "there", "are", "no", "intensity", "measure", "levels" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L504-L508
train
gem/oq-engine
openquake/commonlib/oqvalidation.py
OqParam.get_kinds
def get_kinds(self, kind, R): """ Yield 'rlz-000', 'rlz-001', ...', 'mean', 'quantile-0.1', ... """ stats = self.hazard_stats() if kind == 'stats': yield from stats return elif kind == 'rlzs': for r in range(R): yield 'r...
python
def get_kinds(self, kind, R): """ Yield 'rlz-000', 'rlz-001', ...', 'mean', 'quantile-0.1', ... """ stats = self.hazard_stats() if kind == 'stats': yield from stats return elif kind == 'rlzs': for r in range(R): yield 'r...
[ "def", "get_kinds", "(", "self", ",", "kind", ",", "R", ")", ":", "stats", "=", "self", ".", "hazard_stats", "(", ")", "if", "kind", "==", "'stats'", ":", "yield", "from", "stats", "return", "elif", "kind", "==", "'rlzs'", ":", "for", "r", "in", "r...
Yield 'rlz-000', 'rlz-001', ...', 'mean', 'quantile-0.1', ...
[ "Yield", "rlz", "-", "000", "rlz", "-", "001", "...", "mean", "quantile", "-", "0", ".", "1", "..." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L523-L542
train
gem/oq-engine
openquake/commonlib/oqvalidation.py
OqParam.hazard_stats
def hazard_stats(self): """ Return a list of item with the statistical functions defined for the hazard calculation """ names = [] # name of statistical functions funcs = [] # statistical functions of kind func(values, weights) if self.mean_hazard_curves: ...
python
def hazard_stats(self): """ Return a list of item with the statistical functions defined for the hazard calculation """ names = [] # name of statistical functions funcs = [] # statistical functions of kind func(values, weights) if self.mean_hazard_curves: ...
[ "def", "hazard_stats", "(", "self", ")", ":", "names", "=", "[", "]", "funcs", "=", "[", "]", "if", "self", ".", "mean_hazard_curves", ":", "names", ".", "append", "(", "'mean'", ")", "funcs", ".", "append", "(", "stats", ".", "mean_curve", ")", "if"...
Return a list of item with the statistical functions defined for the hazard calculation
[ "Return", "a", "list", "of", "item", "with", "the", "statistical", "functions", "defined", "for", "the", "hazard", "calculation" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L544-L563
train
gem/oq-engine
openquake/commonlib/oqvalidation.py
OqParam.is_valid_geometry
def is_valid_geometry(self): """ It is possible to infer the geometry only if exactly one of sites, sites_csv, hazard_curves_csv, gmfs_csv, region is set. You did set more than one, or nothing. """ has_sites = (self.sites is not None or 'sites' in self.inputs ...
python
def is_valid_geometry(self): """ It is possible to infer the geometry only if exactly one of sites, sites_csv, hazard_curves_csv, gmfs_csv, region is set. You did set more than one, or nothing. """ has_sites = (self.sites is not None or 'sites' in self.inputs ...
[ "def", "is_valid_geometry", "(", "self", ")", ":", "has_sites", "=", "(", "self", ".", "sites", "is", "not", "None", "or", "'sites'", "in", "self", ".", "inputs", "or", "'site_model'", "in", "self", ".", "inputs", ")", "if", "not", "has_sites", "and", ...
It is possible to infer the geometry only if exactly one of sites, sites_csv, hazard_curves_csv, gmfs_csv, region is set. You did set more than one, or nothing.
[ "It", "is", "possible", "to", "infer", "the", "geometry", "only", "if", "exactly", "one", "of", "sites", "sites_csv", "hazard_curves_csv", "gmfs_csv", "region", "is", "set", ".", "You", "did", "set", "more", "than", "one", "or", "nothing", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L595-L622
train
gem/oq-engine
openquake/commonlib/oqvalidation.py
OqParam.is_valid_intensity_measure_types
def is_valid_intensity_measure_types(self): """ If the IMTs and levels are extracted from the risk models, they must not be set directly. Moreover, if `intensity_measure_types_and_levels` is set directly, `intensity_measure_types` must not be set. """ if self.grou...
python
def is_valid_intensity_measure_types(self): """ If the IMTs and levels are extracted from the risk models, they must not be set directly. Moreover, if `intensity_measure_types_and_levels` is set directly, `intensity_measure_types` must not be set. """ if self.grou...
[ "def", "is_valid_intensity_measure_types", "(", "self", ")", ":", "if", "self", ".", "ground_motion_correlation_model", ":", "for", "imt", "in", "self", ".", "imtls", ":", "if", "not", "(", "imt", ".", "startswith", "(", "'SA'", ")", "or", "imt", "==", "'P...
If the IMTs and levels are extracted from the risk models, they must not be set directly. Moreover, if `intensity_measure_types_and_levels` is set directly, `intensity_measure_types` must not be set.
[ "If", "the", "IMTs", "and", "levels", "are", "extracted", "from", "the", "risk", "models", "they", "must", "not", "be", "set", "directly", ".", "Moreover", "if", "intensity_measure_types_and_levels", "is", "set", "directly", "intensity_measure_types", "must", "not...
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L660-L679
train
gem/oq-engine
openquake/commonlib/oqvalidation.py
OqParam.is_valid_intensity_measure_levels
def is_valid_intensity_measure_levels(self): """ In order to compute hazard curves, `intensity_measure_types_and_levels` must be set or extracted from the risk models. """ invalid = self.no_imls() and not self.risk_files and ( self.hazard_curves_from_gmfs or self.calc...
python
def is_valid_intensity_measure_levels(self): """ In order to compute hazard curves, `intensity_measure_types_and_levels` must be set or extracted from the risk models. """ invalid = self.no_imls() and not self.risk_files and ( self.hazard_curves_from_gmfs or self.calc...
[ "def", "is_valid_intensity_measure_levels", "(", "self", ")", ":", "invalid", "=", "self", ".", "no_imls", "(", ")", "and", "not", "self", ".", "risk_files", "and", "(", "self", ".", "hazard_curves_from_gmfs", "or", "self", ".", "calculation_mode", "in", "(", ...
In order to compute hazard curves, `intensity_measure_types_and_levels` must be set or extracted from the risk models.
[ "In", "order", "to", "compute", "hazard", "curves", "intensity_measure_types_and_levels", "must", "be", "set", "or", "extracted", "from", "the", "risk", "models", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L681-L689
train
gem/oq-engine
openquake/commonlib/oqvalidation.py
OqParam.is_valid_sites
def is_valid_sites(self): """ The sites are overdetermined """ if 'site_model' in self.inputs and 'sites' in self.inputs: return False elif 'site_model' in self.inputs and self.sites: return False elif 'sites' in self.inputs and self.sites: ...
python
def is_valid_sites(self): """ The sites are overdetermined """ if 'site_model' in self.inputs and 'sites' in self.inputs: return False elif 'site_model' in self.inputs and self.sites: return False elif 'sites' in self.inputs and self.sites: ...
[ "def", "is_valid_sites", "(", "self", ")", ":", "if", "'site_model'", "in", "self", ".", "inputs", "and", "'sites'", "in", "self", ".", "inputs", ":", "return", "False", "elif", "'site_model'", "in", "self", ".", "inputs", "and", "self", ".", "sites", ":...
The sites are overdetermined
[ "The", "sites", "are", "overdetermined" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L733-L746
train
gem/oq-engine
openquake/commonlib/oqvalidation.py
OqParam.is_valid_complex_fault_mesh_spacing
def is_valid_complex_fault_mesh_spacing(self): """ The `complex_fault_mesh_spacing` parameter can be None only if `rupture_mesh_spacing` is set. In that case it is identified with it. """ rms = getattr(self, 'rupture_mesh_spacing', None) if rms and not getattr(self, 'comp...
python
def is_valid_complex_fault_mesh_spacing(self): """ The `complex_fault_mesh_spacing` parameter can be None only if `rupture_mesh_spacing` is set. In that case it is identified with it. """ rms = getattr(self, 'rupture_mesh_spacing', None) if rms and not getattr(self, 'comp...
[ "def", "is_valid_complex_fault_mesh_spacing", "(", "self", ")", ":", "rms", "=", "getattr", "(", "self", ",", "'rupture_mesh_spacing'", ",", "None", ")", "if", "rms", "and", "not", "getattr", "(", "self", ",", "'complex_fault_mesh_spacing'", ",", "None", ")", ...
The `complex_fault_mesh_spacing` parameter can be None only if `rupture_mesh_spacing` is set. In that case it is identified with it.
[ "The", "complex_fault_mesh_spacing", "parameter", "can", "be", "None", "only", "if", "rupture_mesh_spacing", "is", "set", ".", "In", "that", "case", "it", "is", "identified", "with", "it", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L748-L756
train
gem/oq-engine
openquake/commonlib/oqvalidation.py
OqParam.is_valid_optimize_same_id_sources
def is_valid_optimize_same_id_sources(self): """ The `optimize_same_id_sources` can be true only in the classical calculators. """ if (self.optimize_same_id_sources and 'classical' in self.calculation_mode or 'disagg' in self.calculation_mode): ...
python
def is_valid_optimize_same_id_sources(self): """ The `optimize_same_id_sources` can be true only in the classical calculators. """ if (self.optimize_same_id_sources and 'classical' in self.calculation_mode or 'disagg' in self.calculation_mode): ...
[ "def", "is_valid_optimize_same_id_sources", "(", "self", ")", ":", "if", "(", "self", ".", "optimize_same_id_sources", "and", "'classical'", "in", "self", ".", "calculation_mode", "or", "'disagg'", "in", "self", ".", "calculation_mode", ")", ":", "return", "True",...
The `optimize_same_id_sources` can be true only in the classical calculators.
[ "The", "optimize_same_id_sources", "can", "be", "true", "only", "in", "the", "classical", "calculators", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L758-L770
train
gem/oq-engine
openquake/commonlib/oqvalidation.py
OqParam.check_missing
def check_missing(self, param, action): """ Make sure the given parameter is missing in the job.ini file """ assert action in ('debug', 'info', 'warn', 'error'), action if self.inputs.get(param): msg = '%s_file in %s is ignored in %s' % ( param, self.i...
python
def check_missing(self, param, action): """ Make sure the given parameter is missing in the job.ini file """ assert action in ('debug', 'info', 'warn', 'error'), action if self.inputs.get(param): msg = '%s_file in %s is ignored in %s' % ( param, self.i...
[ "def", "check_missing", "(", "self", ",", "param", ",", "action", ")", ":", "assert", "action", "in", "(", "'debug'", ",", "'info'", ",", "'warn'", ",", "'error'", ")", ",", "action", "if", "self", ".", "inputs", ".", "get", "(", "param", ")", ":", ...
Make sure the given parameter is missing in the job.ini file
[ "Make", "sure", "the", "given", "parameter", "is", "missing", "in", "the", "job", ".", "ini", "file" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L795-L806
train
gem/oq-engine
openquake/hazardlib/sourceconverter.py
get_set_num_ruptures
def get_set_num_ruptures(src): """ Extract the number of ruptures and set it """ if not src.num_ruptures: t0 = time.time() src.num_ruptures = src.count_ruptures() dt = time.time() - t0 clsname = src.__class__.__name__ if dt > 10: if 'Area' in clsname: ...
python
def get_set_num_ruptures(src): """ Extract the number of ruptures and set it """ if not src.num_ruptures: t0 = time.time() src.num_ruptures = src.count_ruptures() dt = time.time() - t0 clsname = src.__class__.__name__ if dt > 10: if 'Area' in clsname: ...
[ "def", "get_set_num_ruptures", "(", "src", ")", ":", "if", "not", "src", ".", "num_ruptures", ":", "t0", "=", "time", ".", "time", "(", ")", "src", ".", "num_ruptures", "=", "src", ".", "count_ruptures", "(", ")", "dt", "=", "time", ".", "time", "(",...
Extract the number of ruptures and set it
[ "Extract", "the", "number", "of", "ruptures", "and", "set", "it" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L238-L263
train
gem/oq-engine
openquake/hazardlib/sourceconverter.py
mfds2multimfd
def mfds2multimfd(mfds): """ Convert a list of MFD nodes into a single MultiMFD node """ _, kind = mfds[0].tag.split('}') node = Node('multiMFD', dict(kind=kind, size=len(mfds))) lengths = None for field in mfd.multi_mfd.ASSOC[kind][1:]: alias = mfd.multi_mfd.ALIAS.get(field, field) ...
python
def mfds2multimfd(mfds): """ Convert a list of MFD nodes into a single MultiMFD node """ _, kind = mfds[0].tag.split('}') node = Node('multiMFD', dict(kind=kind, size=len(mfds))) lengths = None for field in mfd.multi_mfd.ASSOC[kind][1:]: alias = mfd.multi_mfd.ALIAS.get(field, field) ...
[ "def", "mfds2multimfd", "(", "mfds", ")", ":", "_", ",", "kind", "=", "mfds", "[", "0", "]", ".", "tag", ".", "split", "(", "'}'", ")", "node", "=", "Node", "(", "'multiMFD'", ",", "dict", "(", "kind", "=", "kind", ",", "size", "=", "len", "(",...
Convert a list of MFD nodes into a single MultiMFD node
[ "Convert", "a", "list", "of", "MFD", "nodes", "into", "a", "single", "MultiMFD", "node" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L918-L943
train
gem/oq-engine
openquake/hazardlib/sourceconverter.py
SourceGroup.update
def update(self, src): """ Update the attributes sources, min_mag, max_mag according to the given source. :param src: an instance of :class: `openquake.hazardlib.source.base.BaseSeismicSource` """ assert src.tectonic_region_type == self.trt, ( ...
python
def update(self, src): """ Update the attributes sources, min_mag, max_mag according to the given source. :param src: an instance of :class: `openquake.hazardlib.source.base.BaseSeismicSource` """ assert src.tectonic_region_type == self.trt, ( ...
[ "def", "update", "(", "self", ",", "src", ")", ":", "assert", "src", ".", "tectonic_region_type", "==", "self", ".", "trt", ",", "(", "src", ".", "tectonic_region_type", ",", "self", ".", "trt", ")", "if", "not", "src", ".", "min_mag", ":", "src", "....
Update the attributes sources, min_mag, max_mag according to the given source. :param src: an instance of :class: `openquake.hazardlib.source.base.BaseSeismicSource`
[ "Update", "the", "attributes", "sources", "min_mag", "max_mag", "according", "to", "the", "given", "source", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L159-L187
train
gem/oq-engine
openquake/hazardlib/sourceconverter.py
RuptureConverter.convert_node
def convert_node(self, node): """ Convert the given rupture node into a hazardlib rupture, depending on the node tag. :param node: a node representing a rupture """ convert = getattr(self, 'convert_' + striptag(node.tag)) return convert(node)
python
def convert_node(self, node): """ Convert the given rupture node into a hazardlib rupture, depending on the node tag. :param node: a node representing a rupture """ convert = getattr(self, 'convert_' + striptag(node.tag)) return convert(node)
[ "def", "convert_node", "(", "self", ",", "node", ")", ":", "convert", "=", "getattr", "(", "self", ",", "'convert_'", "+", "striptag", "(", "node", ".", "tag", ")", ")", "return", "convert", "(", "node", ")" ]
Convert the given rupture node into a hazardlib rupture, depending on the node tag. :param node: a node representing a rupture
[ "Convert", "the", "given", "rupture", "node", "into", "a", "hazardlib", "rupture", "depending", "on", "the", "node", "tag", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L321-L329
train
gem/oq-engine
openquake/hazardlib/sourceconverter.py
RuptureConverter.convert_simpleFaultRupture
def convert_simpleFaultRupture(self, node): """ Convert a simpleFaultRupture node. :param node: the rupture node """ mag, rake, hypocenter = self.get_mag_rake_hypo(node) with context(self.fname, node): surfaces = [node.simpleFaultGeometry] rupt = sour...
python
def convert_simpleFaultRupture(self, node): """ Convert a simpleFaultRupture node. :param node: the rupture node """ mag, rake, hypocenter = self.get_mag_rake_hypo(node) with context(self.fname, node): surfaces = [node.simpleFaultGeometry] rupt = sour...
[ "def", "convert_simpleFaultRupture", "(", "self", ",", "node", ")", ":", "mag", ",", "rake", ",", "hypocenter", "=", "self", ".", "get_mag_rake_hypo", "(", "node", ")", "with", "context", "(", "self", ".", "fname", ",", "node", ")", ":", "surfaces", "=",...
Convert a simpleFaultRupture node. :param node: the rupture node
[ "Convert", "a", "simpleFaultRupture", "node", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L414-L427
train
gem/oq-engine
openquake/hazardlib/sourceconverter.py
RuptureConverter.convert_multiPlanesRupture
def convert_multiPlanesRupture(self, node): """ Convert a multiPlanesRupture node. :param node: the rupture node """ mag, rake, hypocenter = self.get_mag_rake_hypo(node) with context(self.fname, node): surfaces = list(node.getnodes('planarSurface')) r...
python
def convert_multiPlanesRupture(self, node): """ Convert a multiPlanesRupture node. :param node: the rupture node """ mag, rake, hypocenter = self.get_mag_rake_hypo(node) with context(self.fname, node): surfaces = list(node.getnodes('planarSurface')) r...
[ "def", "convert_multiPlanesRupture", "(", "self", ",", "node", ")", ":", "mag", ",", "rake", ",", "hypocenter", "=", "self", ".", "get_mag_rake_hypo", "(", "node", ")", "with", "context", "(", "self", ".", "fname", ",", "node", ")", ":", "surfaces", "=",...
Convert a multiPlanesRupture node. :param node: the rupture node
[ "Convert", "a", "multiPlanesRupture", "node", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L460-L474
train
gem/oq-engine
openquake/hazardlib/sourceconverter.py
SourceConverter.get_tom
def get_tom(self, node): """ Convert the given node into a Temporal Occurrence Model object. :param node: a node of kind poissonTOM or brownianTOM :returns: a :class:`openquake.hazardlib.mfd.EvenlyDiscretizedMFD.` or :class:`openquake.hazardlib.mfd.TruncatedGRMFD` inst...
python
def get_tom(self, node): """ Convert the given node into a Temporal Occurrence Model object. :param node: a node of kind poissonTOM or brownianTOM :returns: a :class:`openquake.hazardlib.mfd.EvenlyDiscretizedMFD.` or :class:`openquake.hazardlib.mfd.TruncatedGRMFD` inst...
[ "def", "get_tom", "(", "self", ",", "node", ")", ":", "if", "'tom'", "in", "node", ".", "attrib", ":", "tom_cls", "=", "tom", ".", "registry", "[", "node", "[", "'tom'", "]", "]", "else", ":", "tom_cls", "=", "tom", ".", "registry", "[", "'PoissonT...
Convert the given node into a Temporal Occurrence Model object. :param node: a node of kind poissonTOM or brownianTOM :returns: a :class:`openquake.hazardlib.mfd.EvenlyDiscretizedMFD.` or :class:`openquake.hazardlib.mfd.TruncatedGRMFD` instance
[ "Convert", "the", "given", "node", "into", "a", "Temporal", "Occurrence", "Model", "object", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L533-L546
train
gem/oq-engine
openquake/hazardlib/sourceconverter.py
SourceConverter.convert_mfdist
def convert_mfdist(self, node): """ Convert the given node into a Magnitude-Frequency Distribution object. :param node: a node of kind incrementalMFD or truncGutenbergRichterMFD :returns: a :class:`openquake.hazardlib.mfd.EvenlyDiscretizedMFD.` or :class:`openq...
python
def convert_mfdist(self, node): """ Convert the given node into a Magnitude-Frequency Distribution object. :param node: a node of kind incrementalMFD or truncGutenbergRichterMFD :returns: a :class:`openquake.hazardlib.mfd.EvenlyDiscretizedMFD.` or :class:`openq...
[ "def", "convert_mfdist", "(", "self", ",", "node", ")", ":", "with", "context", "(", "self", ".", "fname", ",", "node", ")", ":", "[", "mfd_node", "]", "=", "[", "subnode", "for", "subnode", "in", "node", "if", "subnode", ".", "tag", ".", "endswith",...
Convert the given node into a Magnitude-Frequency Distribution object. :param node: a node of kind incrementalMFD or truncGutenbergRichterMFD :returns: a :class:`openquake.hazardlib.mfd.EvenlyDiscretizedMFD.` or :class:`openquake.hazardlib.mfd.TruncatedGRMFD` instance
[ "Convert", "the", "given", "node", "into", "a", "Magnitude", "-", "Frequency", "Distribution", "object", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L548-L595
train
gem/oq-engine
openquake/hazardlib/sourceconverter.py
SourceConverter.convert_npdist
def convert_npdist(self, node): """ Convert the given node into a Nodal Plane Distribution. :param node: a nodalPlaneDist node :returns: a :class:`openquake.hazardlib.geo.NodalPlane` instance """ with context(self.fname, node): npdist = [] for np ...
python
def convert_npdist(self, node): """ Convert the given node into a Nodal Plane Distribution. :param node: a nodalPlaneDist node :returns: a :class:`openquake.hazardlib.geo.NodalPlane` instance """ with context(self.fname, node): npdist = [] for np ...
[ "def", "convert_npdist", "(", "self", ",", "node", ")", ":", "with", "context", "(", "self", ".", "fname", ",", "node", ")", ":", "npdist", "=", "[", "]", "for", "np", "in", "node", ".", "nodalPlaneDist", ":", "prob", ",", "strike", ",", "dip", ","...
Convert the given node into a Nodal Plane Distribution. :param node: a nodalPlaneDist node :returns: a :class:`openquake.hazardlib.geo.NodalPlane` instance
[ "Convert", "the", "given", "node", "into", "a", "Nodal", "Plane", "Distribution", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L597-L612
train
gem/oq-engine
openquake/hazardlib/sourceconverter.py
SourceConverter.convert_hpdist
def convert_hpdist(self, node): """ Convert the given node into a probability mass function for the hypo depth distribution. :param node: a hypoDepthDist node :returns: a :class:`openquake.hazardlib.pmf.PMF` instance """ with context(self.fname, node): ...
python
def convert_hpdist(self, node): """ Convert the given node into a probability mass function for the hypo depth distribution. :param node: a hypoDepthDist node :returns: a :class:`openquake.hazardlib.pmf.PMF` instance """ with context(self.fname, node): ...
[ "def", "convert_hpdist", "(", "self", ",", "node", ")", ":", "with", "context", "(", "self", ".", "fname", ",", "node", ")", ":", "hcdist", "=", "[", "(", "hd", "[", "'probability'", "]", ",", "hd", "[", "'depth'", "]", ")", "for", "hd", "in", "n...
Convert the given node into a probability mass function for the hypo depth distribution. :param node: a hypoDepthDist node :returns: a :class:`openquake.hazardlib.pmf.PMF` instance
[ "Convert", "the", "given", "node", "into", "a", "probability", "mass", "function", "for", "the", "hypo", "depth", "distribution", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L614-L627
train
gem/oq-engine
openquake/hazardlib/sourceconverter.py
SourceConverter.convert_areaSource
def convert_areaSource(self, node): """ Convert the given node into an area source object. :param node: a node with tag areaGeometry :returns: a :class:`openquake.hazardlib.source.AreaSource` instance """ geom = node.areaGeometry coords = split_coords_2d(~geom.Po...
python
def convert_areaSource(self, node): """ Convert the given node into an area source object. :param node: a node with tag areaGeometry :returns: a :class:`openquake.hazardlib.source.AreaSource` instance """ geom = node.areaGeometry coords = split_coords_2d(~geom.Po...
[ "def", "convert_areaSource", "(", "self", ",", "node", ")", ":", "geom", "=", "node", ".", "areaGeometry", "coords", "=", "split_coords_2d", "(", "~", "geom", ".", "Polygon", ".", "exterior", ".", "LinearRing", ".", "posList", ")", "polygon", "=", "geo", ...
Convert the given node into an area source object. :param node: a node with tag areaGeometry :returns: a :class:`openquake.hazardlib.source.AreaSource` instance
[ "Convert", "the", "given", "node", "into", "an", "area", "source", "object", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L629-L661
train
gem/oq-engine
openquake/hazardlib/sourceconverter.py
SourceConverter.convert_pointSource
def convert_pointSource(self, node): """ Convert the given node into a point source object. :param node: a node with tag pointGeometry :returns: a :class:`openquake.hazardlib.source.PointSource` instance """ geom = node.pointGeometry lon_lat = ~geom.Point.pos ...
python
def convert_pointSource(self, node): """ Convert the given node into a point source object. :param node: a node with tag pointGeometry :returns: a :class:`openquake.hazardlib.source.PointSource` instance """ geom = node.pointGeometry lon_lat = ~geom.Point.pos ...
[ "def", "convert_pointSource", "(", "self", ",", "node", ")", ":", "geom", "=", "node", ".", "pointGeometry", "lon_lat", "=", "~", "geom", ".", "Point", ".", "pos", "msr", "=", "valid", ".", "SCALEREL", "[", "~", "node", ".", "magScaleRel", "]", "(", ...
Convert the given node into a point source object. :param node: a node with tag pointGeometry :returns: a :class:`openquake.hazardlib.source.PointSource` instance
[ "Convert", "the", "given", "node", "into", "a", "point", "source", "object", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L663-L686
train
gem/oq-engine
openquake/hazardlib/sourceconverter.py
SourceConverter.convert_multiPointSource
def convert_multiPointSource(self, node): """ Convert the given node into a MultiPointSource object. :param node: a node with tag multiPointGeometry :returns: a :class:`openquake.hazardlib.source.MultiPointSource` """ geom = node.multiPointGeometry lons, lats = z...
python
def convert_multiPointSource(self, node): """ Convert the given node into a MultiPointSource object. :param node: a node with tag multiPointGeometry :returns: a :class:`openquake.hazardlib.source.MultiPointSource` """ geom = node.multiPointGeometry lons, lats = z...
[ "def", "convert_multiPointSource", "(", "self", ",", "node", ")", ":", "geom", "=", "node", ".", "multiPointGeometry", "lons", ",", "lats", "=", "zip", "(", "*", "split_coords_2d", "(", "~", "geom", ".", "posList", ")", ")", "msr", "=", "valid", ".", "...
Convert the given node into a MultiPointSource object. :param node: a node with tag multiPointGeometry :returns: a :class:`openquake.hazardlib.source.MultiPointSource`
[ "Convert", "the", "given", "node", "into", "a", "MultiPointSource", "object", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L688-L710
train
gem/oq-engine
openquake/hazardlib/sourceconverter.py
SourceConverter.convert_simpleFaultSource
def convert_simpleFaultSource(self, node): """ Convert the given node into a simple fault object. :param node: a node with tag areaGeometry :returns: a :class:`openquake.hazardlib.source.SimpleFaultSource` instance """ geom = node.simpleFaultGeometry ...
python
def convert_simpleFaultSource(self, node): """ Convert the given node into a simple fault object. :param node: a node with tag areaGeometry :returns: a :class:`openquake.hazardlib.source.SimpleFaultSource` instance """ geom = node.simpleFaultGeometry ...
[ "def", "convert_simpleFaultSource", "(", "self", ",", "node", ")", ":", "geom", "=", "node", ".", "simpleFaultGeometry", "msr", "=", "valid", ".", "SCALEREL", "[", "~", "node", ".", "magScaleRel", "]", "(", ")", "fault_trace", "=", "self", ".", "geo_line",...
Convert the given node into a simple fault object. :param node: a node with tag areaGeometry :returns: a :class:`openquake.hazardlib.source.SimpleFaultSource` instance
[ "Convert", "the", "given", "node", "into", "a", "simple", "fault", "object", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L712-L749
train
gem/oq-engine
openquake/hazardlib/sourceconverter.py
SourceConverter.convert_complexFaultSource
def convert_complexFaultSource(self, node): """ Convert the given node into a complex fault object. :param node: a node with tag areaGeometry :returns: a :class:`openquake.hazardlib.source.ComplexFaultSource` instance """ geom = node.complexFaultGeometr...
python
def convert_complexFaultSource(self, node): """ Convert the given node into a complex fault object. :param node: a node with tag areaGeometry :returns: a :class:`openquake.hazardlib.source.ComplexFaultSource` instance """ geom = node.complexFaultGeometr...
[ "def", "convert_complexFaultSource", "(", "self", ",", "node", ")", ":", "geom", "=", "node", ".", "complexFaultGeometry", "edges", "=", "self", ".", "geo_lines", "(", "geom", ")", "mfd", "=", "self", ".", "convert_mfdist", "(", "node", ")", "msr", "=", ...
Convert the given node into a complex fault object. :param node: a node with tag areaGeometry :returns: a :class:`openquake.hazardlib.source.ComplexFaultSource` instance
[ "Convert", "the", "given", "node", "into", "a", "complex", "fault", "object", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L751-L775
train
gem/oq-engine
openquake/hazardlib/sourceconverter.py
SourceConverter.convert_characteristicFaultSource
def convert_characteristicFaultSource(self, node): """ Convert the given node into a characteristic fault object. :param node: a node with tag areaGeometry :returns: a :class:`openquake.hazardlib.source.CharacteristicFaultSource` instance """ ...
python
def convert_characteristicFaultSource(self, node): """ Convert the given node into a characteristic fault object. :param node: a node with tag areaGeometry :returns: a :class:`openquake.hazardlib.source.CharacteristicFaultSource` instance """ ...
[ "def", "convert_characteristicFaultSource", "(", "self", ",", "node", ")", ":", "char", "=", "source", ".", "CharacteristicFaultSource", "(", "source_id", "=", "node", "[", "'id'", "]", ",", "name", "=", "node", "[", "'name'", "]", ",", "tectonic_region_type",...
Convert the given node into a characteristic fault object. :param node: a node with tag areaGeometry :returns: a :class:`openquake.hazardlib.source.CharacteristicFaultSource` instance
[ "Convert", "the", "given", "node", "into", "a", "characteristic", "fault", "object", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L777-L795
train
gem/oq-engine
openquake/hazardlib/sourceconverter.py
SourceConverter.convert_nonParametricSeismicSource
def convert_nonParametricSeismicSource(self, node): """ Convert the given node into a non parametric source object. :param node: a node with tag areaGeometry :returns: a :class:`openquake.hazardlib.source.NonParametricSeismicSource` instance "...
python
def convert_nonParametricSeismicSource(self, node): """ Convert the given node into a non parametric source object. :param node: a node with tag areaGeometry :returns: a :class:`openquake.hazardlib.source.NonParametricSeismicSource` instance "...
[ "def", "convert_nonParametricSeismicSource", "(", "self", ",", "node", ")", ":", "trt", "=", "node", ".", "attrib", ".", "get", "(", "'tectonicRegion'", ")", "rup_pmf_data", "=", "[", "]", "rups_weights", "=", "None", "if", "'rup_weights'", "in", "node", "."...
Convert the given node into a non parametric source object. :param node: a node with tag areaGeometry :returns: a :class:`openquake.hazardlib.source.NonParametricSeismicSource` instance
[ "Convert", "the", "given", "node", "into", "a", "non", "parametric", "source", "object", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L797-L822
train
gem/oq-engine
openquake/hazardlib/sourceconverter.py
SourceConverter.convert_sourceGroup
def convert_sourceGroup(self, node): """ Convert the given node into a SourceGroup object. :param node: a node with tag sourceGroup :returns: a :class:`SourceGroup` instance """ trt = node['tectonicRegion'] srcs_weights = node.attrib.get('...
python
def convert_sourceGroup(self, node): """ Convert the given node into a SourceGroup object. :param node: a node with tag sourceGroup :returns: a :class:`SourceGroup` instance """ trt = node['tectonicRegion'] srcs_weights = node.attrib.get('...
[ "def", "convert_sourceGroup", "(", "self", ",", "node", ")", ":", "trt", "=", "node", "[", "'tectonicRegion'", "]", "srcs_weights", "=", "node", ".", "attrib", ".", "get", "(", "'srcs_weights'", ")", "grp_attrs", "=", "{", "k", ":", "v", "for", "k", ",...
Convert the given node into a SourceGroup object. :param node: a node with tag sourceGroup :returns: a :class:`SourceGroup` instance
[ "Convert", "the", "given", "node", "into", "a", "SourceGroup", "object", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L827-L891
train
gem/oq-engine
openquake/hmtk/faults/tectonic_regionalisation.py
_check_list_weights
def _check_list_weights(parameter, name): ''' Checks that the weights in a list of tuples sums to 1.0 ''' if not isinstance(parameter, list): raise ValueError('%s must be formatted with a list of tuples' % name) weight = np.sum([val[1] for val in parameter]) if fabs(weight - 1.) > 1E-8: ...
python
def _check_list_weights(parameter, name): ''' Checks that the weights in a list of tuples sums to 1.0 ''' if not isinstance(parameter, list): raise ValueError('%s must be formatted with a list of tuples' % name) weight = np.sum([val[1] for val in parameter]) if fabs(weight - 1.) > 1E-8: ...
[ "def", "_check_list_weights", "(", "parameter", ",", "name", ")", ":", "if", "not", "isinstance", "(", "parameter", ",", "list", ")", ":", "raise", "ValueError", "(", "'%s must be formatted with a list of tuples'", "%", "name", ")", "weight", "=", "np", ".", "...
Checks that the weights in a list of tuples sums to 1.0
[ "Checks", "that", "the", "weights", "in", "a", "list", "of", "tuples", "sums", "to", "1", ".", "0" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/tectonic_regionalisation.py#L63-L72
train
gem/oq-engine
openquake/hmtk/faults/active_fault_model.py
mtkActiveFaultModel.build_fault_model
def build_fault_model(self, collapse=False, rendered_msr=WC1994(), mfd_config=None): ''' Constructs a full fault model with epistemic uncertainty by enumerating all the possible recurrence models of each fault as separate faults, with the recurrence rates multip...
python
def build_fault_model(self, collapse=False, rendered_msr=WC1994(), mfd_config=None): ''' Constructs a full fault model with epistemic uncertainty by enumerating all the possible recurrence models of each fault as separate faults, with the recurrence rates multip...
[ "def", "build_fault_model", "(", "self", ",", "collapse", "=", "False", ",", "rendered_msr", "=", "WC1994", "(", ")", ",", "mfd_config", "=", "None", ")", ":", "self", ".", "source_model", "=", "mtkSourceModel", "(", "self", ".", "id", ",", "self", ".", ...
Constructs a full fault model with epistemic uncertainty by enumerating all the possible recurrence models of each fault as separate faults, with the recurrence rates multiplied by the corresponding weights. :param bool collapse: Determines whether or not to collapse the bra...
[ "Constructs", "a", "full", "fault", "model", "with", "epistemic", "uncertainty", "by", "enumerating", "all", "the", "possible", "recurrence", "models", "of", "each", "fault", "as", "separate", "faults", "with", "the", "recurrence", "rates", "multiplied", "by", "...
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/active_fault_model.py#L94-L125
train
gem/oq-engine
openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py
ParseNDKtoGCMT.read_file
def read_file(self, start_year=None, end_year=None, use_centroid=None): """ Reads the file """ raw_data = getlines(self.filename) num_lines = len(raw_data) if ((float(num_lines) / 5.) - float(num_lines / 5)) > 1E-9: raise IOError('GCMT represented by 5 lines -...
python
def read_file(self, start_year=None, end_year=None, use_centroid=None): """ Reads the file """ raw_data = getlines(self.filename) num_lines = len(raw_data) if ((float(num_lines) / 5.) - float(num_lines / 5)) > 1E-9: raise IOError('GCMT represented by 5 lines -...
[ "def", "read_file", "(", "self", ",", "start_year", "=", "None", ",", "end_year", "=", "None", ",", "use_centroid", "=", "None", ")", ":", "raw_data", "=", "getlines", "(", "self", ".", "filename", ")", "num_lines", "=", "len", "(", "raw_data", ")", "i...
Reads the file
[ "Reads", "the", "file" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py#L145-L176
train
gem/oq-engine
openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py
ParseNDKtoGCMT.read_ndk_event
def read_ndk_event(self, raw_data, id0): """ Reads a 5-line batch of data into a set of GCMTs """ gcmt = GCMTEvent() # Get hypocentre ndkstring = raw_data[id0].rstrip('\n') gcmt.hypocentre = self._read_hypocentre_from_ndk_string(ndkstring) # GCMT metadata...
python
def read_ndk_event(self, raw_data, id0): """ Reads a 5-line batch of data into a set of GCMTs """ gcmt = GCMTEvent() # Get hypocentre ndkstring = raw_data[id0].rstrip('\n') gcmt.hypocentre = self._read_hypocentre_from_ndk_string(ndkstring) # GCMT metadata...
[ "def", "read_ndk_event", "(", "self", ",", "raw_data", ",", "id0", ")", ":", "gcmt", "=", "GCMTEvent", "(", ")", "ndkstring", "=", "raw_data", "[", "id0", "]", ".", "rstrip", "(", "'\\n'", ")", "gcmt", ".", "hypocentre", "=", "self", ".", "_read_hypoce...
Reads a 5-line batch of data into a set of GCMTs
[ "Reads", "a", "5", "-", "line", "batch", "of", "data", "into", "a", "set", "of", "GCMTs" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py#L178-L214
train
gem/oq-engine
openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py
ParseNDKtoGCMT._read_hypocentre_from_ndk_string
def _read_hypocentre_from_ndk_string(self, linestring): """ Reads the hypocentre data from the ndk string to return an instance of the GCMTHypocentre class """ hypo = GCMTHypocentre() hypo.source = linestring[0:4] hypo.date = _read_date_from_string(linestring[5:15...
python
def _read_hypocentre_from_ndk_string(self, linestring): """ Reads the hypocentre data from the ndk string to return an instance of the GCMTHypocentre class """ hypo = GCMTHypocentre() hypo.source = linestring[0:4] hypo.date = _read_date_from_string(linestring[5:15...
[ "def", "_read_hypocentre_from_ndk_string", "(", "self", ",", "linestring", ")", ":", "hypo", "=", "GCMTHypocentre", "(", ")", "hypo", ".", "source", "=", "linestring", "[", "0", ":", "4", "]", "hypo", ".", "date", "=", "_read_date_from_string", "(", "linestr...
Reads the hypocentre data from the ndk string to return an instance of the GCMTHypocentre class
[ "Reads", "the", "hypocentre", "data", "from", "the", "ndk", "string", "to", "return", "an", "instance", "of", "the", "GCMTHypocentre", "class" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py#L315-L333
train
gem/oq-engine
openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py
ParseNDKtoGCMT._get_metadata_from_ndk_string
def _get_metadata_from_ndk_string(self, gcmt, ndk_string): """ Reads the GCMT metadata from line 2 of the ndk batch """ gcmt.identifier = ndk_string[:16] inversion_data = re.split('[A-Z:]+', ndk_string[17:61]) gcmt.metadata['BODY'] = [float(x) for x in inversion_data[1].s...
python
def _get_metadata_from_ndk_string(self, gcmt, ndk_string): """ Reads the GCMT metadata from line 2 of the ndk batch """ gcmt.identifier = ndk_string[:16] inversion_data = re.split('[A-Z:]+', ndk_string[17:61]) gcmt.metadata['BODY'] = [float(x) for x in inversion_data[1].s...
[ "def", "_get_metadata_from_ndk_string", "(", "self", ",", "gcmt", ",", "ndk_string", ")", ":", "gcmt", ".", "identifier", "=", "ndk_string", "[", ":", "16", "]", "inversion_data", "=", "re", ".", "split", "(", "'[A-Z:]+'", ",", "ndk_string", "[", "17", ":"...
Reads the GCMT metadata from line 2 of the ndk batch
[ "Reads", "the", "GCMT", "metadata", "from", "line", "2", "of", "the", "ndk", "batch" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py#L335-L349
train
gem/oq-engine
openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py
ParseNDKtoGCMT._get_principal_axes_from_ndk_string
def _get_principal_axes_from_ndk_string(self, ndk_string, exponent): """ Gets the principal axes from the ndk string and returns an instance of the GCMTPrincipalAxes class """ axes = GCMTPrincipalAxes() # The principal axes is defined in characters 3:48 of the 5th line ...
python
def _get_principal_axes_from_ndk_string(self, ndk_string, exponent): """ Gets the principal axes from the ndk string and returns an instance of the GCMTPrincipalAxes class """ axes = GCMTPrincipalAxes() # The principal axes is defined in characters 3:48 of the 5th line ...
[ "def", "_get_principal_axes_from_ndk_string", "(", "self", ",", "ndk_string", ",", "exponent", ")", ":", "axes", "=", "GCMTPrincipalAxes", "(", ")", "exponent", "=", "10.", "**", "exponent", "axes", ".", "t_axis", "=", "{", "'eigenvalue'", ":", "exponent", "*"...
Gets the principal axes from the ndk string and returns an instance of the GCMTPrincipalAxes class
[ "Gets", "the", "principal", "axes", "from", "the", "ndk", "string", "and", "returns", "an", "instance", "of", "the", "GCMTPrincipalAxes", "class" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py#L394-L413
train
gem/oq-engine
openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py
ParseNDKtoGCMT._get_moment_from_ndk_string
def _get_moment_from_ndk_string(self, ndk_string, exponent): """ Returns the moment and the moment magnitude """ moment = float(ndk_string[49:56]) * (10. ** exponent) version = ndk_string[:3] magnitude = utils.moment_magnitude_scalar(moment) return moment, version...
python
def _get_moment_from_ndk_string(self, ndk_string, exponent): """ Returns the moment and the moment magnitude """ moment = float(ndk_string[49:56]) * (10. ** exponent) version = ndk_string[:3] magnitude = utils.moment_magnitude_scalar(moment) return moment, version...
[ "def", "_get_moment_from_ndk_string", "(", "self", ",", "ndk_string", ",", "exponent", ")", ":", "moment", "=", "float", "(", "ndk_string", "[", "49", ":", "56", "]", ")", "*", "(", "10.", "**", "exponent", ")", "version", "=", "ndk_string", "[", ":", ...
Returns the moment and the moment magnitude
[ "Returns", "the", "moment", "and", "the", "moment", "magnitude" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/catalogue/gcmt_ndk_parser.py#L430-L437
train
gem/oq-engine
openquake/hmtk/sources/source_model.py
mtkSourceModel.serialise_to_nrml
def serialise_to_nrml(self, filename, use_defaults=False): ''' Writes the source model to a nrml source model file given by the filename :param str filename: Path to output file :param bool use_defaults: Boolean to indicate whether to use default values ...
python
def serialise_to_nrml(self, filename, use_defaults=False): ''' Writes the source model to a nrml source model file given by the filename :param str filename: Path to output file :param bool use_defaults: Boolean to indicate whether to use default values ...
[ "def", "serialise_to_nrml", "(", "self", ",", "filename", ",", "use_defaults", "=", "False", ")", ":", "source_model", "=", "self", ".", "convert_to_oqhazardlib", "(", "PoissonTOM", "(", "1.0", ")", ",", "2.0", ",", "2.0", ",", "10.0", ",", "use_defaults", ...
Writes the source model to a nrml source model file given by the filename :param str filename: Path to output file :param bool use_defaults: Boolean to indicate whether to use default values (True) or not. If set to False, ValueErrors will be raised when an ...
[ "Writes", "the", "source", "model", "to", "a", "nrml", "source", "model", "file", "given", "by", "the", "filename" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/sources/source_model.py#L95-L110
train
gem/oq-engine
openquake/hmtk/seismicity/occurrence/utils.py
input_checks
def input_checks(catalogue, config, completeness): """ Performs a basic set of input checks on the data """ if isinstance(completeness, np.ndarray): # completeness table is a numpy array (i.e. [year, magnitude]) if np.shape(completeness)[1] != 2: raise ValueError('Completeness T...
python
def input_checks(catalogue, config, completeness): """ Performs a basic set of input checks on the data """ if isinstance(completeness, np.ndarray): # completeness table is a numpy array (i.e. [year, magnitude]) if np.shape(completeness)[1] != 2: raise ValueError('Completeness T...
[ "def", "input_checks", "(", "catalogue", ",", "config", ",", "completeness", ")", ":", "if", "isinstance", "(", "completeness", ",", "np", ".", "ndarray", ")", ":", "if", "np", ".", "shape", "(", "completeness", ")", "[", "1", "]", "!=", "2", ":", "r...
Performs a basic set of input checks on the data
[ "Performs", "a", "basic", "set", "of", "input", "checks", "on", "the", "data" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/occurrence/utils.py#L100-L142
train
gem/oq-engine
openquake/hmtk/seismicity/occurrence/utils.py
generate_trunc_gr_magnitudes
def generate_trunc_gr_magnitudes(bval, mmin, mmax, nsamples): ''' Generate a random list of magnitudes distributed according to a truncated Gutenberg-Richter model :param float bval: b-value :param float mmin: Minimum Magnitude :param float mmax: Maximum Magnitude :p...
python
def generate_trunc_gr_magnitudes(bval, mmin, mmax, nsamples): ''' Generate a random list of magnitudes distributed according to a truncated Gutenberg-Richter model :param float bval: b-value :param float mmin: Minimum Magnitude :param float mmax: Maximum Magnitude :p...
[ "def", "generate_trunc_gr_magnitudes", "(", "bval", ",", "mmin", ",", "mmax", ",", "nsamples", ")", ":", "sampler", "=", "np", ".", "random", ".", "uniform", "(", "0.", ",", "1.", ",", "nsamples", ")", "beta", "=", "bval", "*", "np", ".", "log", "(",...
Generate a random list of magnitudes distributed according to a truncated Gutenberg-Richter model :param float bval: b-value :param float mmin: Minimum Magnitude :param float mmax: Maximum Magnitude :param int nsamples: Number of samples :returns: Vector...
[ "Generate", "a", "random", "list", "of", "magnitudes", "distributed", "according", "to", "a", "truncated", "Gutenberg", "-", "Richter", "model" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/occurrence/utils.py#L145-L165
train
gem/oq-engine
openquake/hmtk/seismicity/occurrence/utils.py
generate_synthetic_magnitudes
def generate_synthetic_magnitudes(aval, bval, mmin, mmax, nyears): ''' Generates a synthetic catalogue for a specified number of years, with magnitudes distributed according to a truncated Gutenberg-Richter distribution :param float aval: a-value :param float bval: b-value :...
python
def generate_synthetic_magnitudes(aval, bval, mmin, mmax, nyears): ''' Generates a synthetic catalogue for a specified number of years, with magnitudes distributed according to a truncated Gutenberg-Richter distribution :param float aval: a-value :param float bval: b-value :...
[ "def", "generate_synthetic_magnitudes", "(", "aval", ",", "bval", ",", "mmin", ",", "mmax", ",", "nyears", ")", ":", "nsamples", "=", "int", "(", "np", ".", "round", "(", "nyears", "*", "(", "10.", "**", "(", "aval", "-", "bval", "*", "mmin", ")", ...
Generates a synthetic catalogue for a specified number of years, with magnitudes distributed according to a truncated Gutenberg-Richter distribution :param float aval: a-value :param float bval: b-value :param float mmin: Minimum Magnitude :param float mmax: Maxi...
[ "Generates", "a", "synthetic", "catalogue", "for", "a", "specified", "number", "of", "years", "with", "magnitudes", "distributed", "according", "to", "a", "truncated", "Gutenberg", "-", "Richter", "distribution" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/occurrence/utils.py#L168-L191
train
gem/oq-engine
openquake/hmtk/seismicity/occurrence/utils.py
downsample_completeness_table
def downsample_completeness_table(comp_table, sample_width=0.1, mmax=None): """ Re-sample the completeness table to a specified sample_width """ new_comp_table = [] for i in range(comp_table.shape[0] - 1): mvals = np.arange(comp_table[i, 1], comp_table[i + 1, 1], d_...
python
def downsample_completeness_table(comp_table, sample_width=0.1, mmax=None): """ Re-sample the completeness table to a specified sample_width """ new_comp_table = [] for i in range(comp_table.shape[0] - 1): mvals = np.arange(comp_table[i, 1], comp_table[i + 1, 1], d_...
[ "def", "downsample_completeness_table", "(", "comp_table", ",", "sample_width", "=", "0.1", ",", "mmax", "=", "None", ")", ":", "new_comp_table", "=", "[", "]", "for", "i", "in", "range", "(", "comp_table", ".", "shape", "[", "0", "]", "-", "1", ")", "...
Re-sample the completeness table to a specified sample_width
[ "Re", "-", "sample", "the", "completeness", "table", "to", "a", "specified", "sample_width" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/occurrence/utils.py#L194-L208
train
gem/oq-engine
openquake/commands/reset.py
reset
def reset(yes): """ Remove all the datastores and the database of the current user """ ok = yes or confirm('Do you really want to destroy all your data? (y/n) ') if not ok: return dbpath = os.path.realpath(os.path.expanduser(config.dbserver.file)) # user must be able to access and ...
python
def reset(yes): """ Remove all the datastores and the database of the current user """ ok = yes or confirm('Do you really want to destroy all your data? (y/n) ') if not ok: return dbpath = os.path.realpath(os.path.expanduser(config.dbserver.file)) # user must be able to access and ...
[ "def", "reset", "(", "yes", ")", ":", "ok", "=", "yes", "or", "confirm", "(", "'Do you really want to destroy all your data? (y/n) '", ")", "if", "not", "ok", ":", "return", "dbpath", "=", "os", ".", "path", ".", "realpath", "(", "os", ".", "path", ".", ...
Remove all the datastores and the database of the current user
[ "Remove", "all", "the", "datastores", "and", "the", "database", "of", "the", "current", "user" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/reset.py#L30-L59
train
gem/oq-engine
openquake/server/db/actions.py
set_status
def set_status(db, job_id, status): """ Set the status 'created', 'executing', 'complete', 'failed', 'aborted' consistently with `is_running`. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: ID of the current job :param status: status string """ assert status in ...
python
def set_status(db, job_id, status): """ Set the status 'created', 'executing', 'complete', 'failed', 'aborted' consistently with `is_running`. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: ID of the current job :param status: status string """ assert status in ...
[ "def", "set_status", "(", "db", ",", "job_id", ",", "status", ")", ":", "assert", "status", "in", "(", "'created'", ",", "'submitted'", ",", "'executing'", ",", "'complete'", ",", "'aborted'", ",", "'failed'", ")", ",", "status", "if", "status", "in", "(...
Set the status 'created', 'executing', 'complete', 'failed', 'aborted' consistently with `is_running`. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: ID of the current job :param status: status string
[ "Set", "the", "status", "created", "executing", "complete", "failed", "aborted", "consistently", "with", "is_running", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L62-L85
train
gem/oq-engine
openquake/server/db/actions.py
create_job
def create_job(db, datadir): """ Create job for the given user, return it. :param db: a :class:`openquake.server.dbapi.Db` instance :param datadir: Data directory of the user who owns/started this job. :returns: the job ID """ calc_id = get_calc_id(db, datadir) + 1 ...
python
def create_job(db, datadir): """ Create job for the given user, return it. :param db: a :class:`openquake.server.dbapi.Db` instance :param datadir: Data directory of the user who owns/started this job. :returns: the job ID """ calc_id = get_calc_id(db, datadir) + 1 ...
[ "def", "create_job", "(", "db", ",", "datadir", ")", ":", "calc_id", "=", "get_calc_id", "(", "db", ",", "datadir", ")", "+", "1", "job", "=", "dict", "(", "id", "=", "calc_id", ",", "is_running", "=", "1", ",", "description", "=", "'just created'", ...
Create job for the given user, return it. :param db: a :class:`openquake.server.dbapi.Db` instance :param datadir: Data directory of the user who owns/started this job. :returns: the job ID
[ "Create", "job", "for", "the", "given", "user", "return", "it", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L88-L104
train
gem/oq-engine
openquake/server/db/actions.py
import_job
def import_job(db, calc_id, calc_mode, description, user_name, status, hc_id, datadir): """ Insert a calculation inside the database, if calc_id is not taken """ job = dict(id=calc_id, calculation_mode=calc_mode, description=description, user_n...
python
def import_job(db, calc_id, calc_mode, description, user_name, status, hc_id, datadir): """ Insert a calculation inside the database, if calc_id is not taken """ job = dict(id=calc_id, calculation_mode=calc_mode, description=description, user_n...
[ "def", "import_job", "(", "db", ",", "calc_id", ",", "calc_mode", ",", "description", ",", "user_name", ",", "status", ",", "hc_id", ",", "datadir", ")", ":", "job", "=", "dict", "(", "id", "=", "calc_id", ",", "calculation_mode", "=", "calc_mode", ",", ...
Insert a calculation inside the database, if calc_id is not taken
[ "Insert", "a", "calculation", "inside", "the", "database", "if", "calc_id", "is", "not", "taken" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L107-L120
train
gem/oq-engine
openquake/server/db/actions.py
get_job
def get_job(db, job_id, username=None): """ If job_id is negative, return the last calculation of the current user, otherwise returns the job_id unchanged. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: a job ID (can be negative and can be nonexisting) :param username: ...
python
def get_job(db, job_id, username=None): """ If job_id is negative, return the last calculation of the current user, otherwise returns the job_id unchanged. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: a job ID (can be negative and can be nonexisting) :param username: ...
[ "def", "get_job", "(", "db", ",", "job_id", ",", "username", "=", "None", ")", ":", "job_id", "=", "int", "(", "job_id", ")", "if", "job_id", ">", "0", ":", "dic", "=", "dict", "(", "id", "=", "job_id", ")", "if", "username", ":", "dic", "[", "...
If job_id is negative, return the last calculation of the current user, otherwise returns the job_id unchanged. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: a job ID (can be negative and can be nonexisting) :param username: an user name (if None, ignore it) :returns: a va...
[ "If", "job_id", "is", "negative", "return", "the", "last", "calculation", "of", "the", "current", "user", "otherwise", "returns", "the", "job_id", "unchanged", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L133-L163
train
gem/oq-engine
openquake/server/db/actions.py
get_calc_id
def get_calc_id(db, datadir, job_id=None): """ Return the latest calc_id by looking both at the datastore and the database. :param db: a :class:`openquake.server.dbapi.Db` instance :param datadir: the directory containing the datastores :param job_id: a job ID; if None, returns the latest job I...
python
def get_calc_id(db, datadir, job_id=None): """ Return the latest calc_id by looking both at the datastore and the database. :param db: a :class:`openquake.server.dbapi.Db` instance :param datadir: the directory containing the datastores :param job_id: a job ID; if None, returns the latest job I...
[ "def", "get_calc_id", "(", "db", ",", "datadir", ",", "job_id", "=", "None", ")", ":", "calcs", "=", "datastore", ".", "get_calc_ids", "(", "datadir", ")", "calc_id", "=", "0", "if", "not", "calcs", "else", "calcs", "[", "-", "1", "]", "if", "job_id"...
Return the latest calc_id by looking both at the datastore and the database. :param db: a :class:`openquake.server.dbapi.Db` instance :param datadir: the directory containing the datastores :param job_id: a job ID; if None, returns the latest job ID
[ "Return", "the", "latest", "calc_id", "by", "looking", "both", "at", "the", "datastore", "and", "the", "database", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L166-L183
train
gem/oq-engine
openquake/server/db/actions.py
list_calculations
def list_calculations(db, job_type, user_name): """ Yield a summary of past calculations. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_type: 'hazard' or 'risk' :param user_name: an user name """ jobs = db('SELECT *, %s FROM job WHERE user_name=?x ' 'AND ...
python
def list_calculations(db, job_type, user_name): """ Yield a summary of past calculations. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_type: 'hazard' or 'risk' :param user_name: an user name """ jobs = db('SELECT *, %s FROM job WHERE user_name=?x ' 'AND ...
[ "def", "list_calculations", "(", "db", ",", "job_type", ",", "user_name", ")", ":", "jobs", "=", "db", "(", "'SELECT *, %s FROM job WHERE user_name=?x '", "'AND job_type=?x ORDER BY start_time'", "%", "JOB_TYPE", ",", "user_name", ",", "job_type", ")", "out", "=", "...
Yield a summary of past calculations. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_type: 'hazard' or 'risk' :param user_name: an user name
[ "Yield", "a", "summary", "of", "past", "calculations", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L186-L208
train
gem/oq-engine
openquake/server/db/actions.py
create_outputs
def create_outputs(db, job_id, keysize, ds_size): """ Build a correspondence between the outputs in the datastore and the ones in the database. Also, update the datastore size in the job table. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: ID of the current job :param ...
python
def create_outputs(db, job_id, keysize, ds_size): """ Build a correspondence between the outputs in the datastore and the ones in the database. Also, update the datastore size in the job table. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: ID of the current job :param ...
[ "def", "create_outputs", "(", "db", ",", "job_id", ",", "keysize", ",", "ds_size", ")", ":", "rows", "=", "[", "(", "job_id", ",", "DISPLAY_NAME", ".", "get", "(", "key", ",", "key", ")", ",", "key", ",", "size", ")", "for", "key", ",", "size", "...
Build a correspondence between the outputs in the datastore and the ones in the database. Also, update the datastore size in the job table. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: ID of the current job :param keysize: a list of pairs (key, size_mb) :param ds_size: to...
[ "Build", "a", "correspondence", "between", "the", "outputs", "in", "the", "datastore", "and", "the", "ones", "in", "the", "database", ".", "Also", "update", "the", "datastore", "size", "in", "the", "job", "table", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L299-L312
train
gem/oq-engine
openquake/server/db/actions.py
finish
def finish(db, job_id, status): """ Set the job columns `is_running`, `status`, and `stop_time`. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: ID of the current job :param status: a string such as 'successful' or 'failed' """ db('UPDATE job ...
python
def finish(db, job_id, status): """ Set the job columns `is_running`, `status`, and `stop_time`. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: ID of the current job :param status: a string such as 'successful' or 'failed' """ db('UPDATE job ...
[ "def", "finish", "(", "db", ",", "job_id", ",", "status", ")", ":", "db", "(", "'UPDATE job SET ?D WHERE id=?x'", ",", "dict", "(", "is_running", "=", "False", ",", "status", "=", "status", ",", "stop_time", "=", "datetime", ".", "utcnow", "(", ")", ")",...
Set the job columns `is_running`, `status`, and `stop_time`. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: ID of the current job :param status: a string such as 'successful' or 'failed'
[ "Set", "the", "job", "columns", "is_running", "status", "and", "stop_time", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L315-L328
train
gem/oq-engine
openquake/server/db/actions.py
del_calc
def del_calc(db, job_id, user): """ Delete a calculation and all associated outputs, if possible. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: job ID, can be an integer or a string :param user: username :returns: None if everything went fine or an error message ""...
python
def del_calc(db, job_id, user): """ Delete a calculation and all associated outputs, if possible. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: job ID, can be an integer or a string :param user: username :returns: None if everything went fine or an error message ""...
[ "def", "del_calc", "(", "db", ",", "job_id", ",", "user", ")", ":", "job_id", "=", "int", "(", "job_id", ")", "dependent", "=", "db", "(", "'SELECT id FROM job WHERE hazard_calculation_id=?x'", ",", "job_id", ")", "if", "dependent", ":", "return", "{", "\"er...
Delete a calculation and all associated outputs, if possible. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: job ID, can be an integer or a string :param user: username :returns: None if everything went fine or an error message
[ "Delete", "a", "calculation", "and", "all", "associated", "outputs", "if", "possible", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L331-L367
train
gem/oq-engine
openquake/server/db/actions.py
log
def log(db, job_id, timestamp, level, process, message): """ Write a log record in the database. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: a job ID :param timestamp: timestamp to store in the log record :param level: logging level to...
python
def log(db, job_id, timestamp, level, process, message): """ Write a log record in the database. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: a job ID :param timestamp: timestamp to store in the log record :param level: logging level to...
[ "def", "log", "(", "db", ",", "job_id", ",", "timestamp", ",", "level", ",", "process", ",", "message", ")", ":", "db", "(", "'INSERT INTO log (job_id, timestamp, level, process, message) '", "'VALUES (?X)'", ",", "(", "job_id", ",", "timestamp", ",", "level", "...
Write a log record in the database. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: a job ID :param timestamp: timestamp to store in the log record :param level: logging level to store in the log record :param process: process ID to st...
[ "Write", "a", "log", "record", "in", "the", "database", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L370-L388
train
gem/oq-engine
openquake/server/db/actions.py
get_log
def get_log(db, job_id): """ Extract the logs as a big string :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: a job ID """ logs = db('SELECT * FROM log WHERE job_id=?x ORDER BY id', job_id) out = [] for log in logs: time = str(log.timestamp)[:-4] # strip...
python
def get_log(db, job_id): """ Extract the logs as a big string :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: a job ID """ logs = db('SELECT * FROM log WHERE job_id=?x ORDER BY id', job_id) out = [] for log in logs: time = str(log.timestamp)[:-4] # strip...
[ "def", "get_log", "(", "db", ",", "job_id", ")", ":", "logs", "=", "db", "(", "'SELECT * FROM log WHERE job_id=?x ORDER BY id'", ",", "job_id", ")", "out", "=", "[", "]", "for", "log", "in", "logs", ":", "time", "=", "str", "(", "log", ".", "timestamp", ...
Extract the logs as a big string :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: a job ID
[ "Extract", "the", "logs", "as", "a", "big", "string" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L391-L403
train
gem/oq-engine
openquake/server/db/actions.py
save_performance
def save_performance(db, job_id, records): """ Save in the database the performance information about the given job. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: a job ID :param records: a list of performance records """ # NB: rec['counts'] is a numpy.uint64 which...
python
def save_performance(db, job_id, records): """ Save in the database the performance information about the given job. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: a job ID :param records: a list of performance records """ # NB: rec['counts'] is a numpy.uint64 which...
[ "def", "save_performance", "(", "db", ",", "job_id", ",", "records", ")", ":", "rows", "=", "[", "(", "job_id", ",", "rec", "[", "'operation'", "]", ",", "rec", "[", "'time_sec'", "]", ",", "rec", "[", "'memory_mb'", "]", ",", "int", "(", "rec", "[...
Save in the database the performance information about the given job. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: a job ID :param records: a list of performance records
[ "Save", "in", "the", "database", "the", "performance", "information", "about", "the", "given", "job", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L417-L430
train
gem/oq-engine
openquake/server/db/actions.py
get_traceback
def get_traceback(db, job_id): """ Return the traceback of the given calculation as a list of lines. The list is empty if the calculation was successful. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: a job ID """ # strange: understand why the filter...
python
def get_traceback(db, job_id): """ Return the traceback of the given calculation as a list of lines. The list is empty if the calculation was successful. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: a job ID """ # strange: understand why the filter...
[ "def", "get_traceback", "(", "db", ",", "job_id", ")", ":", "log", "=", "db", "(", "\"SELECT * FROM log WHERE job_id=?x AND level='CRITICAL'\"", ",", "job_id", ")", "if", "not", "log", ":", "return", "[", "]", "response_data", "=", "log", "[", "-", "1", "]",...
Return the traceback of the given calculation as a list of lines. The list is empty if the calculation was successful. :param db: a :class:`openquake.server.dbapi.Db` instance :param job_id: a job ID
[ "Return", "the", "traceback", "of", "the", "given", "calculation", "as", "a", "list", "of", "lines", ".", "The", "list", "is", "empty", "if", "the", "calculation", "was", "successful", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L626-L642
train