repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
gem/oq-engine
openquake/hmtk/seismicity/gcmt_catalogue.py
GCMTCatalogue.select_catalogue_events
def select_catalogue_events(self, id0): ''' Orders the events in the catalogue according to an indexing vector :param np.ndarray id0: Pointer array indicating the locations of selected events ''' for key in self.data.keys(): if isinstance( ...
python
def select_catalogue_events(self, id0): ''' Orders the events in the catalogue according to an indexing vector :param np.ndarray id0: Pointer array indicating the locations of selected events ''' for key in self.data.keys(): if isinstance( ...
[ "def", "select_catalogue_events", "(", "self", ",", "id0", ")", ":", "for", "key", "in", "self", ".", "data", ".", "keys", "(", ")", ":", "if", "isinstance", "(", "self", ".", "data", "[", "key", "]", ",", "np", ".", "ndarray", ")", "and", "len", ...
Orders the events in the catalogue according to an indexing vector :param np.ndarray id0: Pointer array indicating the locations of selected events
[ "Orders", "the", "events", "in", "the", "catalogue", "according", "to", "an", "indexing", "vector" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/gcmt_catalogue.py#L424-L445
gem/oq-engine
openquake/hmtk/seismicity/gcmt_catalogue.py
GCMTCatalogue.gcmt_to_simple_array
def gcmt_to_simple_array(self, centroid_location=True): """ Converts the GCMT catalogue to a simple array of [ID, year, month, day, hour, minute, second, long., lat., depth, Mw, strike1, dip1, rake1, strike2, dip2, rake2, b-plunge, b-azimuth, b-eigenvalue, p-plunge, p-azimuth, p-...
python
def gcmt_to_simple_array(self, centroid_location=True): """ Converts the GCMT catalogue to a simple array of [ID, year, month, day, hour, minute, second, long., lat., depth, Mw, strike1, dip1, rake1, strike2, dip2, rake2, b-plunge, b-azimuth, b-eigenvalue, p-plunge, p-azimuth, p-...
[ "def", "gcmt_to_simple_array", "(", "self", ",", "centroid_location", "=", "True", ")", ":", "catalogue", "=", "np", ".", "zeros", "(", "[", "self", ".", "get_number_tensors", "(", ")", ",", "29", "]", ",", "dtype", "=", "float", ")", "for", "iloc", ",...
Converts the GCMT catalogue to a simple array of [ID, year, month, day, hour, minute, second, long., lat., depth, Mw, strike1, dip1, rake1, strike2, dip2, rake2, b-plunge, b-azimuth, b-eigenvalue, p-plunge, p-azimuth, p-eigenvalue, t-plunge, t-azimuth, t-eigenvalue, moment, f_clvd, erel]
[ "Converts", "the", "GCMT", "catalogue", "to", "a", "simple", "array", "of", "[", "ID", "year", "month", "day", "hour", "minute", "second", "long", ".", "lat", ".", "depth", "Mw", "strike1", "dip1", "rake1", "strike2", "dip2", "rake2", "b", "-", "plunge",...
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/gcmt_catalogue.py#L447-L503
gem/oq-engine
openquake/hazardlib/gsim/akkar_cagnan_2010.py
AkkarCagnan2010.get_mean_and_stddevs
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types): """ See :meth:`superclass method <.base.GroundShakingIntensityModel.get_mean_and_stddevs>` for spec of input and result values. """ # extracting dictionary of coefficients (for soil amplification) ...
python
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types): """ See :meth:`superclass method <.base.GroundShakingIntensityModel.get_mean_and_stddevs>` for spec of input and result values. """ # extracting dictionary of coefficients (for soil amplification) ...
[ "def", "get_mean_and_stddevs", "(", "self", ",", "sites", ",", "rup", ",", "dists", ",", "imt", ",", "stddev_types", ")", ":", "# extracting dictionary of coefficients (for soil amplification)", "# specific to required intensity measure type", "C_SR", "=", "self", ".", "C...
See :meth:`superclass method <.base.GroundShakingIntensityModel.get_mean_and_stddevs>` for spec of input and result values.
[ "See", ":", "meth", ":", "superclass", "method", "<", ".", "base", ".", "GroundShakingIntensityModel", ".", "get_mean_and_stddevs", ">", "for", "spec", "of", "input", "and", "result", "values", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/akkar_cagnan_2010.py#L83-L119
gem/oq-engine
openquake/hazardlib/gsim/akkar_cagnan_2010.py
AkkarCagnan2010._compute_linear_magnitude_term
def _compute_linear_magnitude_term(self, C, mag): """ Compute and return second term in equations (1a) and (1b), pages 2981 and 2982, respectively. """ if mag <= self.c1: # this is the second term in eq. (1a), p. 2981 return C['a2'] * (mag - self.c1) ...
python
def _compute_linear_magnitude_term(self, C, mag): """ Compute and return second term in equations (1a) and (1b), pages 2981 and 2982, respectively. """ if mag <= self.c1: # this is the second term in eq. (1a), p. 2981 return C['a2'] * (mag - self.c1) ...
[ "def", "_compute_linear_magnitude_term", "(", "self", ",", "C", ",", "mag", ")", ":", "if", "mag", "<=", "self", ".", "c1", ":", "# this is the second term in eq. (1a), p. 2981", "return", "C", "[", "'a2'", "]", "*", "(", "mag", "-", "self", ".", "c1", ")"...
Compute and return second term in equations (1a) and (1b), pages 2981 and 2982, respectively.
[ "Compute", "and", "return", "second", "term", "in", "equations", "(", "1a", ")", "and", "(", "1b", ")", "pages", "2981", "and", "2982", "respectively", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/akkar_cagnan_2010.py#L137-L147
gem/oq-engine
openquake/commands/from_shapefile.py
from_shapefile
def from_shapefile(output, input_shp_files, validate): """ Convert multiple ESRI Shapefile(s) into a single NRML source model file. """ input_parser = shapefileparser.ShapefileParser() source_model = input_parser.read(input_shp_files[0], validate) for f in input_shp_files[1:]: source_mod...
python
def from_shapefile(output, input_shp_files, validate): """ Convert multiple ESRI Shapefile(s) into a single NRML source model file. """ input_parser = shapefileparser.ShapefileParser() source_model = input_parser.read(input_shp_files[0], validate) for f in input_shp_files[1:]: source_mod...
[ "def", "from_shapefile", "(", "output", ",", "input_shp_files", ",", "validate", ")", ":", "input_parser", "=", "shapefileparser", ".", "ShapefileParser", "(", ")", "source_model", "=", "input_parser", ".", "read", "(", "input_shp_files", "[", "0", "]", ",", "...
Convert multiple ESRI Shapefile(s) into a single NRML source model file.
[ "Convert", "multiple", "ESRI", "Shapefile", "(", "s", ")", "into", "a", "single", "NRML", "source", "model", "file", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/from_shapefile.py#L24-L34
gem/oq-engine
openquake/hazardlib/gsim/akkar_bommer_2010.py
AkkarBommer2010._compute_magnitude
def _compute_magnitude(self, rup, C): """ Compute the first term of the equation described on p. 199: ``b1 + b2 * M + b3 * M**2`` """ return C['b1'] + (C['b2'] * rup.mag) + (C['b3'] * (rup.mag ** 2))
python
def _compute_magnitude(self, rup, C): """ Compute the first term of the equation described on p. 199: ``b1 + b2 * M + b3 * M**2`` """ return C['b1'] + (C['b2'] * rup.mag) + (C['b3'] * (rup.mag ** 2))
[ "def", "_compute_magnitude", "(", "self", ",", "rup", ",", "C", ")", ":", "return", "C", "[", "'b1'", "]", "+", "(", "C", "[", "'b2'", "]", "*", "rup", ".", "mag", ")", "+", "(", "C", "[", "'b3'", "]", "*", "(", "rup", ".", "mag", "**", "2"...
Compute the first term of the equation described on p. 199: ``b1 + b2 * M + b3 * M**2``
[ "Compute", "the", "first", "term", "of", "the", "equation", "described", "on", "p", ".", "199", ":" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/akkar_bommer_2010.py#L145-L151
gem/oq-engine
openquake/hazardlib/gsim/akkar_bommer_2010.py
AkkarBommer2010._compute_distance
def _compute_distance(self, rup, dists, imt, C): """ Compute the second term of the equation described on p. 199: ``(b4 + b5 * M) * log(sqrt(Rjb ** 2 + b6 ** 2))`` """ return (((C['b4'] + C['b5'] * rup.mag) * np.log10((np.sqrt(dists.rjb ** 2.0 + C['b6'] ** 2.0))...
python
def _compute_distance(self, rup, dists, imt, C): """ Compute the second term of the equation described on p. 199: ``(b4 + b5 * M) * log(sqrt(Rjb ** 2 + b6 ** 2))`` """ return (((C['b4'] + C['b5'] * rup.mag) * np.log10((np.sqrt(dists.rjb ** 2.0 + C['b6'] ** 2.0))...
[ "def", "_compute_distance", "(", "self", ",", "rup", ",", "dists", ",", "imt", ",", "C", ")", ":", "return", "(", "(", "(", "C", "[", "'b4'", "]", "+", "C", "[", "'b5'", "]", "*", "rup", ".", "mag", ")", "*", "np", ".", "log10", "(", "(", "...
Compute the second term of the equation described on p. 199: ``(b4 + b5 * M) * log(sqrt(Rjb ** 2 + b6 ** 2))``
[ "Compute", "the", "second", "term", "of", "the", "equation", "described", "on", "p", ".", "199", ":" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/akkar_bommer_2010.py#L153-L160
gem/oq-engine
openquake/hazardlib/gsim/akkar_bommer_2010.py
AkkarBommer2010._get_site_amplification
def _get_site_amplification(self, sites, imt, C): """ Compute the third term of the equation described on p. 199: ``b7 * Ss + b8 * Sa`` """ Ss, Sa = self._get_site_type_dummy_variables(sites) return (C['b7'] * Ss) + (C['b8'] * Sa)
python
def _get_site_amplification(self, sites, imt, C): """ Compute the third term of the equation described on p. 199: ``b7 * Ss + b8 * Sa`` """ Ss, Sa = self._get_site_type_dummy_variables(sites) return (C['b7'] * Ss) + (C['b8'] * Sa)
[ "def", "_get_site_amplification", "(", "self", ",", "sites", ",", "imt", ",", "C", ")", ":", "Ss", ",", "Sa", "=", "self", ".", "_get_site_type_dummy_variables", "(", "sites", ")", "return", "(", "C", "[", "'b7'", "]", "*", "Ss", ")", "+", "(", "C", ...
Compute the third term of the equation described on p. 199: ``b7 * Ss + b8 * Sa``
[ "Compute", "the", "third", "term", "of", "the", "equation", "described", "on", "p", ".", "199", ":" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/akkar_bommer_2010.py#L162-L169
gem/oq-engine
openquake/hazardlib/gsim/akkar_bommer_2010.py
AkkarBommer2010._get_site_type_dummy_variables
def _get_site_type_dummy_variables(self, sites): """ Get site type dummy variables, ``Ss`` (for soft and stiff soil sites) and ``Sa`` (for rock sites). """ Ss = np.zeros((len(sites.vs30),)) Sa = np.zeros((len(sites.vs30),)) # Soft soil; Vs30 < 360 m/s. Page 199. ...
python
def _get_site_type_dummy_variables(self, sites): """ Get site type dummy variables, ``Ss`` (for soft and stiff soil sites) and ``Sa`` (for rock sites). """ Ss = np.zeros((len(sites.vs30),)) Sa = np.zeros((len(sites.vs30),)) # Soft soil; Vs30 < 360 m/s. Page 199. ...
[ "def", "_get_site_type_dummy_variables", "(", "self", ",", "sites", ")", ":", "Ss", "=", "np", ".", "zeros", "(", "(", "len", "(", "sites", ".", "vs30", ")", ",", ")", ")", "Sa", "=", "np", ".", "zeros", "(", "(", "len", "(", "sites", ".", "vs30"...
Get site type dummy variables, ``Ss`` (for soft and stiff soil sites) and ``Sa`` (for rock sites).
[ "Get", "site", "type", "dummy", "variables", "Ss", "(", "for", "soft", "and", "stiff", "soil", "sites", ")", "and", "Sa", "(", "for", "rock", "sites", ")", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/akkar_bommer_2010.py#L171-L184
gem/oq-engine
openquake/hazardlib/gsim/akkar_bommer_2010.py
AkkarBommer2010._get_mechanism
def _get_mechanism(self, sites, rup, imt, C): """ Compute the fourth term of the equation described on p. 199: ``b9 * Fn + b10 * Fr`` """ Fn, Fr = self._get_fault_type_dummy_variables(sites, rup, imt) return (C['b9'] * Fn) + (C['b10'] * Fr)
python
def _get_mechanism(self, sites, rup, imt, C): """ Compute the fourth term of the equation described on p. 199: ``b9 * Fn + b10 * Fr`` """ Fn, Fr = self._get_fault_type_dummy_variables(sites, rup, imt) return (C['b9'] * Fn) + (C['b10'] * Fr)
[ "def", "_get_mechanism", "(", "self", ",", "sites", ",", "rup", ",", "imt", ",", "C", ")", ":", "Fn", ",", "Fr", "=", "self", ".", "_get_fault_type_dummy_variables", "(", "sites", ",", "rup", ",", "imt", ")", "return", "(", "C", "[", "'b9'", "]", "...
Compute the fourth term of the equation described on p. 199: ``b9 * Fn + b10 * Fr``
[ "Compute", "the", "fourth", "term", "of", "the", "equation", "described", "on", "p", ".", "199", ":" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/akkar_bommer_2010.py#L186-L193
gem/oq-engine
openquake/hazardlib/gsim/akkar_bommer_2010.py
AkkarBommer2010._get_fault_type_dummy_variables
def _get_fault_type_dummy_variables(self, sites, rup, imt): """ Same classification of SadighEtAl1997. Akkar and Bommer 2010 is based on Akkar and Bommer 2007b; read Strong-Motion Dataset and Record Processing on p. 514 (Akkar and Bommer 2007b). """ Fn, Fr = 0, 0 ...
python
def _get_fault_type_dummy_variables(self, sites, rup, imt): """ Same classification of SadighEtAl1997. Akkar and Bommer 2010 is based on Akkar and Bommer 2007b; read Strong-Motion Dataset and Record Processing on p. 514 (Akkar and Bommer 2007b). """ Fn, Fr = 0, 0 ...
[ "def", "_get_fault_type_dummy_variables", "(", "self", ",", "sites", ",", "rup", ",", "imt", ")", ":", "Fn", ",", "Fr", "=", "0", ",", "0", "if", "rup", ".", "rake", ">=", "-", "135", "and", "rup", ".", "rake", "<=", "-", "45", ":", "# normal", "...
Same classification of SadighEtAl1997. Akkar and Bommer 2010 is based on Akkar and Bommer 2007b; read Strong-Motion Dataset and Record Processing on p. 514 (Akkar and Bommer 2007b).
[ "Same", "classification", "of", "SadighEtAl1997", ".", "Akkar", "and", "Bommer", "2010", "is", "based", "on", "Akkar", "and", "Bommer", "2007b", ";", "read", "Strong", "-", "Motion", "Dataset", "and", "Record", "Processing", "on", "p", ".", "514", "(", "Ak...
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/akkar_bommer_2010.py#L195-L209
gem/oq-engine
openquake/hazardlib/gsim/akkar_bommer_2010.py
AkkarBommer2010SWISS01.get_mean_and_stddevs
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types): """ See :meth:`superclass method <.base.GroundShakingIntensityModel.get_mean_and_stddevs>` for spec of input and result values. """ sites.vs30 = 600 * np.ones(len(sites.vs30)) mean, stddevs = ...
python
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types): """ See :meth:`superclass method <.base.GroundShakingIntensityModel.get_mean_and_stddevs>` for spec of input and result values. """ sites.vs30 = 600 * np.ones(len(sites.vs30)) mean, stddevs = ...
[ "def", "get_mean_and_stddevs", "(", "self", ",", "sites", ",", "rup", ",", "dists", ",", "imt", ",", "stddev_types", ")", ":", "sites", ".", "vs30", "=", "600", "*", "np", ".", "ones", "(", "len", "(", "sites", ".", "vs30", ")", ")", "mean", ",", ...
See :meth:`superclass method <.base.GroundShakingIntensityModel.get_mean_and_stddevs>` for spec of input and result values.
[ "See", ":", "meth", ":", "superclass", "method", "<", ".", "base", ".", "GroundShakingIntensityModel", ".", "get_mean_and_stddevs", ">", "for", "spec", "of", "input", "and", "result", "values", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/akkar_bommer_2010.py#L317-L336
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface.mesh
def mesh(self): """ :returns: mesh corresponding to the whole multi surface """ meshes = [surface.mesh for surface in self.surfaces] lons = numpy.concatenate([m.lons for m in meshes]) lats = numpy.concatenate([m.lats for m in meshes]) depths = numpy.concatenate([m...
python
def mesh(self): """ :returns: mesh corresponding to the whole multi surface """ meshes = [surface.mesh for surface in self.surfaces] lons = numpy.concatenate([m.lons for m in meshes]) lats = numpy.concatenate([m.lats for m in meshes]) depths = numpy.concatenate([m...
[ "def", "mesh", "(", "self", ")", ":", "meshes", "=", "[", "surface", ".", "mesh", "for", "surface", "in", "self", ".", "surfaces", "]", "lons", "=", "numpy", ".", "concatenate", "(", "[", "m", ".", "lons", "for", "m", "in", "meshes", "]", ")", "l...
:returns: mesh corresponding to the whole multi surface
[ ":", "returns", ":", "mesh", "corresponding", "to", "the", "whole", "multi", "surface" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L98-L106
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface._get_edge_set
def _get_edge_set(self, tol=0.1): """ Retrieve set of top edges from all of the individual surfaces, downsampling the upper edge based on the specified tolerance """ edges = [] for surface in self.surfaces: if isinstance(surface, GriddedSurface): ...
python
def _get_edge_set(self, tol=0.1): """ Retrieve set of top edges from all of the individual surfaces, downsampling the upper edge based on the specified tolerance """ edges = [] for surface in self.surfaces: if isinstance(surface, GriddedSurface): ...
[ "def", "_get_edge_set", "(", "self", ",", "tol", "=", "0.1", ")", ":", "edges", "=", "[", "]", "for", "surface", "in", "self", ".", "surfaces", ":", "if", "isinstance", "(", "surface", ",", "GriddedSurface", ")", ":", "return", "edges", ".", "append", ...
Retrieve set of top edges from all of the individual surfaces, downsampling the upper edge based on the specified tolerance
[ "Retrieve", "set", "of", "top", "edges", "from", "all", "of", "the", "individual", "surfaces", "downsampling", "the", "upper", "edge", "based", "on", "the", "specified", "tolerance" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L137-L159
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface.get_min_distance
def get_min_distance(self, mesh): """ For each point in ``mesh`` compute the minimum distance to each surface element and return the smallest value. See :meth:`superclass method <.base.BaseSurface.get_min_distance>` for spec of input and result values. """ ...
python
def get_min_distance(self, mesh): """ For each point in ``mesh`` compute the minimum distance to each surface element and return the smallest value. See :meth:`superclass method <.base.BaseSurface.get_min_distance>` for spec of input and result values. """ ...
[ "def", "get_min_distance", "(", "self", ",", "mesh", ")", ":", "dists", "=", "[", "surf", ".", "get_min_distance", "(", "mesh", ")", "for", "surf", "in", "self", ".", "surfaces", "]", "return", "numpy", ".", "min", "(", "dists", ",", "axis", "=", "0"...
For each point in ``mesh`` compute the minimum distance to each surface element and return the smallest value. See :meth:`superclass method <.base.BaseSurface.get_min_distance>` for spec of input and result values.
[ "For", "each", "point", "in", "mesh", "compute", "the", "minimum", "distance", "to", "each", "surface", "element", "and", "return", "the", "smallest", "value", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L161-L172
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface.get_closest_points
def get_closest_points(self, mesh): """ For each point in ``mesh`` find the closest surface element, and return the corresponding closest point. See :meth:`superclass method <.base.BaseSurface.get_closest_points>` for spec of input and result values. """ ...
python
def get_closest_points(self, mesh): """ For each point in ``mesh`` find the closest surface element, and return the corresponding closest point. See :meth:`superclass method <.base.BaseSurface.get_closest_points>` for spec of input and result values. """ ...
[ "def", "get_closest_points", "(", "self", ",", "mesh", ")", ":", "# first, for each point in mesh compute minimum distance to each", "# surface. The distance matrix is flattend, because mesh can be of", "# an arbitrary shape. By flattening we obtain a ``distances`` matrix", "# for which the fi...
For each point in ``mesh`` find the closest surface element, and return the corresponding closest point. See :meth:`superclass method <.base.BaseSurface.get_closest_points>` for spec of input and result values.
[ "For", "each", "point", "in", "mesh", "find", "the", "closest", "surface", "element", "and", "return", "the", "corresponding", "closest", "point", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L174-L216
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface.get_top_edge_depth
def get_top_edge_depth(self): """ Compute top edge depth of each surface element and return area-weighted average value (in km). """ areas = self._get_areas() depths = numpy.array( [surf.get_top_edge_depth() for surf in self.surfaces]) return numpy.sum...
python
def get_top_edge_depth(self): """ Compute top edge depth of each surface element and return area-weighted average value (in km). """ areas = self._get_areas() depths = numpy.array( [surf.get_top_edge_depth() for surf in self.surfaces]) return numpy.sum...
[ "def", "get_top_edge_depth", "(", "self", ")", ":", "areas", "=", "self", ".", "_get_areas", "(", ")", "depths", "=", "numpy", ".", "array", "(", "[", "surf", ".", "get_top_edge_depth", "(", ")", "for", "surf", "in", "self", ".", "surfaces", "]", ")", ...
Compute top edge depth of each surface element and return area-weighted average value (in km).
[ "Compute", "top", "edge", "depth", "of", "each", "surface", "element", "and", "return", "area", "-", "weighted", "average", "value", "(", "in", "km", ")", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L233-L241
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface.get_strike
def get_strike(self): """ Compute strike of each surface element and return area-weighted average value (in range ``[0, 360]``) using formula from: http://en.wikipedia.org/wiki/Mean_of_circular_quantities Note that the original formula has been adapted to compute a weighted ...
python
def get_strike(self): """ Compute strike of each surface element and return area-weighted average value (in range ``[0, 360]``) using formula from: http://en.wikipedia.org/wiki/Mean_of_circular_quantities Note that the original formula has been adapted to compute a weighted ...
[ "def", "get_strike", "(", "self", ")", ":", "areas", "=", "self", ".", "_get_areas", "(", ")", "strikes", "=", "numpy", ".", "array", "(", "[", "surf", ".", "get_strike", "(", ")", "for", "surf", "in", "self", ".", "surfaces", "]", ")", "v1", "=", ...
Compute strike of each surface element and return area-weighted average value (in range ``[0, 360]``) using formula from: http://en.wikipedia.org/wiki/Mean_of_circular_quantities Note that the original formula has been adapted to compute a weighted rather than arithmetic mean.
[ "Compute", "strike", "of", "each", "surface", "element", "and", "return", "area", "-", "weighted", "average", "value", "(", "in", "range", "[", "0", "360", "]", ")", "using", "formula", "from", ":", "http", ":", "//", "en", ".", "wikipedia", ".", "org"...
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L243-L260
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface.get_dip
def get_dip(self): """ Compute dip of each surface element and return area-weighted average value (in range ``(0, 90]``). Given that dip values are constrained in the range (0, 90], the simple formula for weighted mean is used. """ areas = self._get_areas() ...
python
def get_dip(self): """ Compute dip of each surface element and return area-weighted average value (in range ``(0, 90]``). Given that dip values are constrained in the range (0, 90], the simple formula for weighted mean is used. """ areas = self._get_areas() ...
[ "def", "get_dip", "(", "self", ")", ":", "areas", "=", "self", ".", "_get_areas", "(", ")", "dips", "=", "numpy", ".", "array", "(", "[", "surf", ".", "get_dip", "(", ")", "for", "surf", "in", "self", ".", "surfaces", "]", ")", "return", "numpy", ...
Compute dip of each surface element and return area-weighted average value (in range ``(0, 90]``). Given that dip values are constrained in the range (0, 90], the simple formula for weighted mean is used.
[ "Compute", "dip", "of", "each", "surface", "element", "and", "return", "area", "-", "weighted", "average", "value", "(", "in", "range", "(", "0", "90", "]", ")", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L262-L273
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface.get_width
def get_width(self): """ Compute width of each surface element, and return area-weighted average value (in km). """ areas = self._get_areas() widths = numpy.array([surf.get_width() for surf in self.surfaces]) return numpy.sum(areas * widths) / numpy.sum(areas)
python
def get_width(self): """ Compute width of each surface element, and return area-weighted average value (in km). """ areas = self._get_areas() widths = numpy.array([surf.get_width() for surf in self.surfaces]) return numpy.sum(areas * widths) / numpy.sum(areas)
[ "def", "get_width", "(", "self", ")", ":", "areas", "=", "self", ".", "_get_areas", "(", ")", "widths", "=", "numpy", ".", "array", "(", "[", "surf", ".", "get_width", "(", ")", "for", "surf", "in", "self", ".", "surfaces", "]", ")", "return", "num...
Compute width of each surface element, and return area-weighted average value (in km).
[ "Compute", "width", "of", "each", "surface", "element", "and", "return", "area", "-", "weighted", "average", "value", "(", "in", "km", ")", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L275-L283
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface.get_bounding_box
def get_bounding_box(self): """ Compute bounding box for each surface element, and then return the bounding box of all surface elements' bounding boxes. :return: A tuple of four items. These items represent western, eastern, northern and southern borders of the b...
python
def get_bounding_box(self): """ Compute bounding box for each surface element, and then return the bounding box of all surface elements' bounding boxes. :return: A tuple of four items. These items represent western, eastern, northern and southern borders of the b...
[ "def", "get_bounding_box", "(", "self", ")", ":", "lons", "=", "[", "]", "lats", "=", "[", "]", "for", "surf", "in", "self", ".", "surfaces", ":", "west", ",", "east", ",", "north", ",", "south", "=", "surf", ".", "get_bounding_box", "(", ")", "lon...
Compute bounding box for each surface element, and then return the bounding box of all surface elements' bounding boxes. :return: A tuple of four items. These items represent western, eastern, northern and southern borders of the bounding box respectively. Values are...
[ "Compute", "bounding", "box", "for", "each", "surface", "element", "and", "then", "return", "the", "bounding", "box", "of", "all", "surface", "elements", "bounding", "boxes", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L291-L307
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface.get_middle_point
def get_middle_point(self): """ If :class:`MultiSurface` is defined by a single surface, simply returns surface's middle point, otherwise find surface element closest to the surface's bounding box centroid and return corresponding middle point. Note that the concept of m...
python
def get_middle_point(self): """ If :class:`MultiSurface` is defined by a single surface, simply returns surface's middle point, otherwise find surface element closest to the surface's bounding box centroid and return corresponding middle point. Note that the concept of m...
[ "def", "get_middle_point", "(", "self", ")", ":", "if", "len", "(", "self", ".", "surfaces", ")", "==", "1", ":", "return", "self", ".", "surfaces", "[", "0", "]", ".", "get_middle_point", "(", ")", "west", ",", "east", ",", "north", ",", "south", ...
If :class:`MultiSurface` is defined by a single surface, simply returns surface's middle point, otherwise find surface element closest to the surface's bounding box centroid and return corresponding middle point. Note that the concept of middle point for a multi surface is ambiguous ...
[ "If", ":", "class", ":", "MultiSurface", "is", "defined", "by", "a", "single", "surface", "simply", "returns", "surface", "s", "middle", "point", "otherwise", "find", "surface", "element", "closest", "to", "the", "surface", "s", "bounding", "box", "centroid", ...
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L309-L339
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface._get_areas
def _get_areas(self): """ Return surface elements area values in a numpy array. """ if self.areas is None: self.areas = [] for surf in self.surfaces: self.areas.append(surf.get_area()) self.areas = numpy.array(self.areas) retur...
python
def _get_areas(self): """ Return surface elements area values in a numpy array. """ if self.areas is None: self.areas = [] for surf in self.surfaces: self.areas.append(surf.get_area()) self.areas = numpy.array(self.areas) retur...
[ "def", "_get_areas", "(", "self", ")", ":", "if", "self", ".", "areas", "is", "None", ":", "self", ".", "areas", "=", "[", "]", "for", "surf", "in", "self", ".", "surfaces", ":", "self", ".", "areas", ".", "append", "(", "surf", ".", "get_area", ...
Return surface elements area values in a numpy array.
[ "Return", "surface", "elements", "area", "values", "in", "a", "numpy", "array", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L350-L360
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface._get_cartesian_edge_set
def _get_cartesian_edge_set(self): """ For the GC2 calculations a set of cartesian representations of the fault edges are needed. In this present case we use a common cartesian framework for all edges, as opposed to defining a separate orthographic projection per edge """...
python
def _get_cartesian_edge_set(self): """ For the GC2 calculations a set of cartesian representations of the fault edges are needed. In this present case we use a common cartesian framework for all edges, as opposed to defining a separate orthographic projection per edge """...
[ "def", "_get_cartesian_edge_set", "(", "self", ")", ":", "# Get projection space for cartesian projection", "edge_sets", "=", "numpy", ".", "vstack", "(", "self", ".", "edge_set", ")", "west", ",", "east", ",", "north", ",", "south", "=", "utils", ".", "get_sphe...
For the GC2 calculations a set of cartesian representations of the fault edges are needed. In this present case we use a common cartesian framework for all edges, as opposed to defining a separate orthographic projection per edge
[ "For", "the", "GC2", "calculations", "a", "set", "of", "cartesian", "representations", "of", "the", "fault", "edges", "are", "needed", ".", "In", "this", "present", "case", "we", "use", "a", "common", "cartesian", "framework", "for", "all", "edges", "as", ...
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L362-L392
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface._setup_gc2_framework
def _setup_gc2_framework(self): """ This method establishes the GC2 framework for a multi-segment (and indeed multi-typology) case based on the description in Spudich & Chiou (2015) - see section on Generalized Coordinate System for Multiple Rupture Traces """ # G...
python
def _setup_gc2_framework(self): """ This method establishes the GC2 framework for a multi-segment (and indeed multi-typology) case based on the description in Spudich & Chiou (2015) - see section on Generalized Coordinate System for Multiple Rupture Traces """ # G...
[ "def", "_setup_gc2_framework", "(", "self", ")", ":", "# Generate cartesian edge set", "edge_sets", "=", "self", ".", "_get_cartesian_edge_set", "(", ")", "self", ".", "gc2_config", "=", "{", "}", "# Determine furthest two points apart", "endpoint_set", "=", "numpy", ...
This method establishes the GC2 framework for a multi-segment (and indeed multi-typology) case based on the description in Spudich & Chiou (2015) - see section on Generalized Coordinate System for Multiple Rupture Traces
[ "This", "method", "establishes", "the", "GC2", "framework", "for", "a", "multi", "-", "segment", "(", "and", "indeed", "multi", "-", "typology", ")", "case", "based", "on", "the", "description", "in", "Spudich", "&", "Chiou", "(", "2015", ")", "-", "see"...
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L394-L452
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface._get_gc2_coordinates_for_rupture
def _get_gc2_coordinates_for_rupture(self, edge_sets): """ Calculates the GC2 coordinates for the nodes of the upper edge of the fault """ # Establish GC2 length - for use with Ry0 rup_gc2t, rup_gc2u = self.get_generalised_coordinates( edge_sets[:, 0], edge_s...
python
def _get_gc2_coordinates_for_rupture(self, edge_sets): """ Calculates the GC2 coordinates for the nodes of the upper edge of the fault """ # Establish GC2 length - for use with Ry0 rup_gc2t, rup_gc2u = self.get_generalised_coordinates( edge_sets[:, 0], edge_s...
[ "def", "_get_gc2_coordinates_for_rupture", "(", "self", ",", "edge_sets", ")", ":", "# Establish GC2 length - for use with Ry0", "rup_gc2t", ",", "rup_gc2u", "=", "self", ".", "get_generalised_coordinates", "(", "edge_sets", "[", ":", ",", "0", "]", ",", "edge_sets", ...
Calculates the GC2 coordinates for the nodes of the upper edge of the fault
[ "Calculates", "the", "GC2", "coordinates", "for", "the", "nodes", "of", "the", "upper", "edge", "of", "the", "fault" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L454-L464
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface._get_ut_i
def _get_ut_i(self, seg, sx, sy): """ Returns the U and T coordinate for a specific trace segment :param seg: End points of the segment edge :param sx: Sites longitudes rendered into coordinate system :param sy: Sites latitudes rendered into...
python
def _get_ut_i(self, seg, sx, sy): """ Returns the U and T coordinate for a specific trace segment :param seg: End points of the segment edge :param sx: Sites longitudes rendered into coordinate system :param sy: Sites latitudes rendered into...
[ "def", "_get_ut_i", "(", "self", ",", "seg", ",", "sx", ",", "sy", ")", ":", "p0x", ",", "p0y", ",", "p1x", ",", "p1y", "=", "seg", "[", "0", ",", "0", "]", ",", "seg", "[", "0", ",", "1", "]", ",", "seg", "[", "1", ",", "0", "]", ",", ...
Returns the U and T coordinate for a specific trace segment :param seg: End points of the segment edge :param sx: Sites longitudes rendered into coordinate system :param sy: Sites latitudes rendered into coordinate system
[ "Returns", "the", "U", "and", "T", "coordinate", "for", "a", "specific", "trace", "segment" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L466-L489
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface.get_generalised_coordinates
def get_generalised_coordinates(self, lons, lats): """ Transforms the site positions into the generalised coordinate form described by Spudich and Chiou (2015) for the multi-rupture and/or discordant case Spudich, Paul and Chiou, Brian (2015) Strike-parallel and strike-normal ...
python
def get_generalised_coordinates(self, lons, lats): """ Transforms the site positions into the generalised coordinate form described by Spudich and Chiou (2015) for the multi-rupture and/or discordant case Spudich, Paul and Chiou, Brian (2015) Strike-parallel and strike-normal ...
[ "def", "get_generalised_coordinates", "(", "self", ",", "lons", ",", "lats", ")", ":", "# If the GC2 configuration has not been setup already - do it!", "if", "not", "self", ".", "gc2_config", ":", "self", ".", "_setup_gc2_framework", "(", ")", "# Initially the weights ar...
Transforms the site positions into the generalised coordinate form described by Spudich and Chiou (2015) for the multi-rupture and/or discordant case Spudich, Paul and Chiou, Brian (2015) Strike-parallel and strike-normal coordinate system around geometrically complicated rupture traces...
[ "Transforms", "the", "site", "positions", "into", "the", "generalised", "coordinate", "form", "described", "by", "Spudich", "and", "Chiou", "(", "2015", ")", "for", "the", "multi", "-", "rupture", "and", "/", "or", "discordant", "case" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L491-L568
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface.get_rx_distance
def get_rx_distance(self, mesh): """ For each point determine the corresponding rx distance using the GC2 configuration. See :meth:`superclass method <.base.BaseSurface.get_rx_distance>` for spec of input and result values. """ # If the GC2 calculations h...
python
def get_rx_distance(self, mesh): """ For each point determine the corresponding rx distance using the GC2 configuration. See :meth:`superclass method <.base.BaseSurface.get_rx_distance>` for spec of input and result values. """ # If the GC2 calculations h...
[ "def", "get_rx_distance", "(", "self", ",", "mesh", ")", ":", "# If the GC2 calculations have already been computed (by invoking Ry0", "# first) and the mesh is identical then class has GC2 attributes", "# already pre-calculated", "if", "not", "self", ".", "tmp_mesh", "or", "(", ...
For each point determine the corresponding rx distance using the GC2 configuration. See :meth:`superclass method <.base.BaseSurface.get_rx_distance>` for spec of input and result values.
[ "For", "each", "point", "determine", "the", "corresponding", "rx", "distance", "using", "the", "GC2", "configuration", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L570-L588
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface.get_ry0_distance
def get_ry0_distance(self, mesh): """ For each point determine the corresponding Ry0 distance using the GC2 configuration. See :meth:`superclass method <.base.BaseSurface.get_ry0_distance>` for spec of input and result values. """ # If the GC2 calculation...
python
def get_ry0_distance(self, mesh): """ For each point determine the corresponding Ry0 distance using the GC2 configuration. See :meth:`superclass method <.base.BaseSurface.get_ry0_distance>` for spec of input and result values. """ # If the GC2 calculation...
[ "def", "get_ry0_distance", "(", "self", ",", "mesh", ")", ":", "# If the GC2 calculations have already been computed (by invoking Ry0", "# first) and the mesh is identical then class has GC2 attributes", "# already pre-calculated", "if", "not", "self", ".", "tmp_mesh", "or", "(", ...
For each point determine the corresponding Ry0 distance using the GC2 configuration. See :meth:`superclass method <.base.BaseSurface.get_ry0_distance>` for spec of input and result values.
[ "For", "each", "point", "determine", "the", "corresponding", "Ry0", "distance", "using", "the", "GC2", "configuration", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L590-L622
gem/oq-engine
openquake/hmtk/comparison/rate_grids.py
RateGrid.from_model_files
def from_model_files(cls, limits, input_model, investigation_time=1.0, simple_mesh_spacing=1.0, complex_mesh_spacing=5.0, mfd_width=0.1, area_discretisation=10.0): """ Reads the hazard model from a file :param list limits: Grid conf...
python
def from_model_files(cls, limits, input_model, investigation_time=1.0, simple_mesh_spacing=1.0, complex_mesh_spacing=5.0, mfd_width=0.1, area_discretisation=10.0): """ Reads the hazard model from a file :param list limits: Grid conf...
[ "def", "from_model_files", "(", "cls", ",", "limits", ",", "input_model", ",", "investigation_time", "=", "1.0", ",", "simple_mesh_spacing", "=", "1.0", ",", "complex_mesh_spacing", "=", "5.0", ",", "mfd_width", "=", "0.1", ",", "area_discretisation", "=", "10.0...
Reads the hazard model from a file :param list limits: Grid configuration [west, east, xspc, south, north, yspc, upper, lower, zspc] :param str input_model: Path to input source model :param float investigation_time: Investig...
[ "Reads", "the", "hazard", "model", "from", "a", "file" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/comparison/rate_grids.py#L114-L144
gem/oq-engine
openquake/hmtk/comparison/rate_grids.py
RateGrid.get_rates
def get_rates(self, mmin, mmax=np.inf): """ Returns the cumulative rates greater than Mmin :param float mmin: Minimum magnitude """ nsrcs = self.number_sources() for iloc, source in enumerate(self.source_model): print("Source Number %s of %s, Name...
python
def get_rates(self, mmin, mmax=np.inf): """ Returns the cumulative rates greater than Mmin :param float mmin: Minimum magnitude """ nsrcs = self.number_sources() for iloc, source in enumerate(self.source_model): print("Source Number %s of %s, Name...
[ "def", "get_rates", "(", "self", ",", "mmin", ",", "mmax", "=", "np", ".", "inf", ")", ":", "nsrcs", "=", "self", ".", "number_sources", "(", ")", "for", "iloc", ",", "source", "in", "enumerate", "(", "self", ".", "source_model", ")", ":", "print", ...
Returns the cumulative rates greater than Mmin :param float mmin: Minimum magnitude
[ "Returns", "the", "cumulative", "rates", "greater", "than", "Mmin" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/comparison/rate_grids.py#L152-L178
gem/oq-engine
openquake/hmtk/comparison/rate_grids.py
RateGrid._get_point_location
def _get_point_location(self, location): """ Returns the location in the output grid corresponding to the cell in which the epicentre lays :param location: Source hypocentre as instance of :class: openquake.hazardlib.geo.point.Point :returns: ...
python
def _get_point_location(self, location): """ Returns the location in the output grid corresponding to the cell in which the epicentre lays :param location: Source hypocentre as instance of :class: openquake.hazardlib.geo.point.Point :returns: ...
[ "def", "_get_point_location", "(", "self", ",", "location", ")", ":", "if", "(", "location", ".", "longitude", "<", "self", ".", "xlim", "[", "0", "]", ")", "or", "(", "location", ".", "longitude", ">", "self", ".", "xlim", "[", "-", "1", "]", ")",...
Returns the location in the output grid corresponding to the cell in which the epicentre lays :param location: Source hypocentre as instance of :class: openquake.hazardlib.geo.point.Point :returns: xloc - Location of longitude cell yloc - Location...
[ "Returns", "the", "location", "in", "the", "output", "grid", "corresponding", "to", "the", "cell", "in", "which", "the", "epicentre", "lays" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/comparison/rate_grids.py#L180-L200
gem/oq-engine
openquake/hmtk/comparison/rate_grids.py
RateGrid._get_point_rates
def _get_point_rates(self, source, mmin, mmax=np.inf): """ Adds the rates for a point source :param source: Point source as instance of :class: openquake.hazardlib.source.point.PointSource :param float mmin: Minimum Magnitude :param float mmax...
python
def _get_point_rates(self, source, mmin, mmax=np.inf): """ Adds the rates for a point source :param source: Point source as instance of :class: openquake.hazardlib.source.point.PointSource :param float mmin: Minimum Magnitude :param float mmax...
[ "def", "_get_point_rates", "(", "self", ",", "source", ",", "mmin", ",", "mmax", "=", "np", ".", "inf", ")", ":", "xloc", ",", "yloc", "=", "self", ".", "_get_point_location", "(", "source", ".", "location", ")", "if", "(", "xloc", "is", "None", ")",...
Adds the rates for a point source :param source: Point source as instance of :class: openquake.hazardlib.source.point.PointSource :param float mmin: Minimum Magnitude :param float mmax: Maximum Magnitude
[ "Adds", "the", "rates", "for", "a", "point", "source" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/comparison/rate_grids.py#L202-L229
gem/oq-engine
openquake/hmtk/comparison/rate_grids.py
RateGrid._get_area_rates
def _get_area_rates(self, source, mmin, mmax=np.inf): """ Adds the rates from the area source by discretising the source to a set of point sources :param source: Area source as instance of :class: openquake.hazardlib.source.area.AreaSource """ poi...
python
def _get_area_rates(self, source, mmin, mmax=np.inf): """ Adds the rates from the area source by discretising the source to a set of point sources :param source: Area source as instance of :class: openquake.hazardlib.source.area.AreaSource """ poi...
[ "def", "_get_area_rates", "(", "self", ",", "source", ",", "mmin", ",", "mmax", "=", "np", ".", "inf", ")", ":", "points", "=", "list", "(", "source", ")", "for", "point", "in", "points", ":", "self", ".", "_get_point_rates", "(", "point", ",", "mmin...
Adds the rates from the area source by discretising the source to a set of point sources :param source: Area source as instance of :class: openquake.hazardlib.source.area.AreaSource
[ "Adds", "the", "rates", "from", "the", "area", "source", "by", "discretising", "the", "source", "to", "a", "set", "of", "point", "sources" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/comparison/rate_grids.py#L231-L242
gem/oq-engine
openquake/hmtk/comparison/rate_grids.py
RateGrid._get_fault_rates
def _get_fault_rates(self, source, mmin, mmax=np.inf): """ Adds the rates for a simple or complex fault source :param source: Fault source as instance of :class: openquake.hazardlib.source.simple_fault.SimpleFaultSource or openquake.hazardlib.source.complex_f...
python
def _get_fault_rates(self, source, mmin, mmax=np.inf): """ Adds the rates for a simple or complex fault source :param source: Fault source as instance of :class: openquake.hazardlib.source.simple_fault.SimpleFaultSource or openquake.hazardlib.source.complex_f...
[ "def", "_get_fault_rates", "(", "self", ",", "source", ",", "mmin", ",", "mmax", "=", "np", ".", "inf", ")", ":", "for", "rupt", "in", "list", "(", "source", ".", "iter_ruptures", "(", ")", ")", ":", "valid_rupt", "=", "(", "rupt", ".", "mag", ">="...
Adds the rates for a simple or complex fault source :param source: Fault source as instance of :class: openquake.hazardlib.source.simple_fault.SimpleFaultSource or openquake.hazardlib.source.complex_fault.ComplexFaultSource
[ "Adds", "the", "rates", "for", "a", "simple", "or", "complex", "fault", "source" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/comparison/rate_grids.py#L244-L265
gem/oq-engine
openquake/hmtk/comparison/rate_grids.py
RatePolygon._get_point_rates
def _get_point_rates(self, source, mmin, mmax=np.inf): """ Adds the rates for a point source :param source: Point source as instance of :class: openquake.hazardlib.source.point.PointSource :param float mmin: Minimum Magnitude :param float mmax...
python
def _get_point_rates(self, source, mmin, mmax=np.inf): """ Adds the rates for a point source :param source: Point source as instance of :class: openquake.hazardlib.source.point.PointSource :param float mmin: Minimum Magnitude :param float mmax...
[ "def", "_get_point_rates", "(", "self", ",", "source", ",", "mmin", ",", "mmax", "=", "np", ".", "inf", ")", ":", "src_mesh", "=", "Mesh", ".", "from_points_list", "(", "[", "source", ".", "location", "]", ")", "in_poly", "=", "self", ".", "limits", ...
Adds the rates for a point source :param source: Point source as instance of :class: openquake.hazardlib.source.point.PointSource :param float mmin: Minimum Magnitude :param float mmax: Maximum Magnitude
[ "Adds", "the", "rates", "for", "a", "point", "source" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/comparison/rate_grids.py#L303-L329
gem/oq-engine
openquake/hmtk/comparison/rate_grids.py
RatePolygon._get_fault_rates
def _get_fault_rates(self, source, mmin, mmax=np.inf): """ Adds the rates for a simple or complex fault source :param source: Fault source as instance of :class: openquake.hazardlib.source.simple_fault.SimpleFaultSource or openquake.hazardlib.source.complex_f...
python
def _get_fault_rates(self, source, mmin, mmax=np.inf): """ Adds the rates for a simple or complex fault source :param source: Fault source as instance of :class: openquake.hazardlib.source.simple_fault.SimpleFaultSource or openquake.hazardlib.source.complex_f...
[ "def", "_get_fault_rates", "(", "self", ",", "source", ",", "mmin", ",", "mmax", "=", "np", ".", "inf", ")", ":", "for", "rup", "in", "list", "(", "source", ".", "iter_ruptures", "(", ")", ")", ":", "if", "(", "rup", ".", "mag", "<", "mmin", ")",...
Adds the rates for a simple or complex fault source :param source: Fault source as instance of :class: openquake.hazardlib.source.simple_fault.SimpleFaultSource or openquake.hazardlib.source.complex_fault.ComplexFaultSource
[ "Adds", "the", "rates", "for", "a", "simple", "or", "complex", "fault", "source" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/comparison/rate_grids.py#L331-L356
gem/oq-engine
openquake/hazardlib/gsim/megawati_pan_2010.py
MegawatiPan2010.get_mean_and_stddevs
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types): """ See :meth:`superclass method <.base.GroundShakingIntensityModel.get_mean_and_stddevs>` for spec of input and result values. """ assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES ...
python
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types): """ See :meth:`superclass method <.base.GroundShakingIntensityModel.get_mean_and_stddevs>` for spec of input and result values. """ assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES ...
[ "def", "get_mean_and_stddevs", "(", "self", ",", "sites", ",", "rup", ",", "dists", ",", "imt", ",", "stddev_types", ")", ":", "assert", "all", "(", "stddev_type", "in", "self", ".", "DEFINED_FOR_STANDARD_DEVIATION_TYPES", "for", "stddev_type", "in", "stddev_typ...
See :meth:`superclass method <.base.GroundShakingIntensityModel.get_mean_and_stddevs>` for spec of input and result values.
[ "See", ":", "meth", ":", "superclass", "method", "<", ".", "base", ".", "GroundShakingIntensityModel", ".", "get_mean_and_stddevs", ">", "for", "spec", "of", "input", "and", "result", "values", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/megawati_pan_2010.py#L75-L90
gem/oq-engine
openquake/hazardlib/gsim/megawati_pan_2010.py
MegawatiPan2010._get_distance_scaling
def _get_distance_scaling(self, C, mag, rhypo): """ Returns the distance scalig term """ return (C["a3"] * np.log(rhypo)) + (C["a4"] + C["a5"] * mag) * rhypo
python
def _get_distance_scaling(self, C, mag, rhypo): """ Returns the distance scalig term """ return (C["a3"] * np.log(rhypo)) + (C["a4"] + C["a5"] * mag) * rhypo
[ "def", "_get_distance_scaling", "(", "self", ",", "C", ",", "mag", ",", "rhypo", ")", ":", "return", "(", "C", "[", "\"a3\"", "]", "*", "np", ".", "log", "(", "rhypo", ")", ")", "+", "(", "C", "[", "\"a4\"", "]", "+", "C", "[", "\"a5\"", "]", ...
Returns the distance scalig term
[ "Returns", "the", "distance", "scalig", "term" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/megawati_pan_2010.py#L98-L102
gem/oq-engine
openquake/hazardlib/gsim/rietbrock_2013.py
RietbrockEtAl2013SelfSimilar.get_mean_and_stddevs
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types): """ See :meth:`superclass method <.base.GroundShakingIntensityModel.get_mean_and_stddevs>` for spec of input and result values. """ # extract dictionaries of coefficients specific to required # ...
python
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types): """ See :meth:`superclass method <.base.GroundShakingIntensityModel.get_mean_and_stddevs>` for spec of input and result values. """ # extract dictionaries of coefficients specific to required # ...
[ "def", "get_mean_and_stddevs", "(", "self", ",", "sites", ",", "rup", ",", "dists", ",", "imt", ",", "stddev_types", ")", ":", "# extract dictionaries of coefficients specific to required", "# intensity measure type", "C", "=", "self", ".", "COEFFS", "[", "imt", "]"...
See :meth:`superclass method <.base.GroundShakingIntensityModel.get_mean_and_stddevs>` for spec of input and result values.
[ "See", ":", "meth", ":", "superclass", "method", "<", ".", "base", ".", "GroundShakingIntensityModel", ".", "get_mean_and_stddevs", ">", "for", "spec", "of", "input", "and", "result", "values", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/rietbrock_2013.py#L80-L100
gem/oq-engine
openquake/hazardlib/gsim/rietbrock_2013.py
RietbrockEtAl2013SelfSimilar._get_distance_scaling_term
def _get_distance_scaling_term(self, C, rjb, mag): """ Returns the distance scaling component of the model Equation 10, Page 63 """ # Depth adjusted distance, equation 11 (Page 63) rval = np.sqrt(rjb ** 2.0 + C["c11"] ** 2.0) f_0, f_1, f_2 = self._get_distance_seg...
python
def _get_distance_scaling_term(self, C, rjb, mag): """ Returns the distance scaling component of the model Equation 10, Page 63 """ # Depth adjusted distance, equation 11 (Page 63) rval = np.sqrt(rjb ** 2.0 + C["c11"] ** 2.0) f_0, f_1, f_2 = self._get_distance_seg...
[ "def", "_get_distance_scaling_term", "(", "self", ",", "C", ",", "rjb", ",", "mag", ")", ":", "# Depth adjusted distance, equation 11 (Page 63)", "rval", "=", "np", ".", "sqrt", "(", "rjb", "**", "2.0", "+", "C", "[", "\"c11\"", "]", "**", "2.0", ")", "f_0...
Returns the distance scaling component of the model Equation 10, Page 63
[ "Returns", "the", "distance", "scaling", "component", "of", "the", "model", "Equation", "10", "Page", "63" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/rietbrock_2013.py#L109-L120
gem/oq-engine
openquake/hazardlib/gsim/rietbrock_2013.py
RietbrockEtAl2013SelfSimilar._get_distance_segment_coefficients
def _get_distance_segment_coefficients(self, rval): """ Returns the coefficients describing the distance attenuation shape for three different distance bins, equations 12a - 12c """ # Get distance segment ends nsites = len(rval) # Equation 12a f_0 = np.log...
python
def _get_distance_segment_coefficients(self, rval): """ Returns the coefficients describing the distance attenuation shape for three different distance bins, equations 12a - 12c """ # Get distance segment ends nsites = len(rval) # Equation 12a f_0 = np.log...
[ "def", "_get_distance_segment_coefficients", "(", "self", ",", "rval", ")", ":", "# Get distance segment ends", "nsites", "=", "len", "(", "rval", ")", "# Equation 12a", "f_0", "=", "np", ".", "log10", "(", "self", ".", "CONSTS", "[", "\"r0\"", "]", "/", "rv...
Returns the coefficients describing the distance attenuation shape for three different distance bins, equations 12a - 12c
[ "Returns", "the", "coefficients", "describing", "the", "distance", "attenuation", "shape", "for", "three", "different", "distance", "bins", "equations", "12a", "-", "12c" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/rietbrock_2013.py#L122-L139
gem/oq-engine
openquake/commonlib/readinput.py
collect_files
def collect_files(dirpath, cond=lambda fullname: True): """ Recursively collect the files contained inside dirpath. :param dirpath: path to a readable directory :param cond: condition on the path to collect the file """ files = [] for fname in os.listdir(dirpath): fullname = os.path...
python
def collect_files(dirpath, cond=lambda fullname: True): """ Recursively collect the files contained inside dirpath. :param dirpath: path to a readable directory :param cond: condition on the path to collect the file """ files = [] for fname in os.listdir(dirpath): fullname = os.path...
[ "def", "collect_files", "(", "dirpath", ",", "cond", "=", "lambda", "fullname", ":", "True", ")", ":", "files", "=", "[", "]", "for", "fname", "in", "os", ".", "listdir", "(", "dirpath", ")", ":", "fullname", "=", "os", ".", "path", ".", "join", "(...
Recursively collect the files contained inside dirpath. :param dirpath: path to a readable directory :param cond: condition on the path to collect the file
[ "Recursively", "collect", "the", "files", "contained", "inside", "dirpath", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L69-L84
gem/oq-engine
openquake/commonlib/readinput.py
extract_from_zip
def extract_from_zip(path, candidates): """ Given a zip archive and a function to detect the presence of a given filename, unzip the archive into a temporary directory and return the full path of the file. Raise an IOError if the file cannot be found within the archive. :param path: pathname of...
python
def extract_from_zip(path, candidates): """ Given a zip archive and a function to detect the presence of a given filename, unzip the archive into a temporary directory and return the full path of the file. Raise an IOError if the file cannot be found within the archive. :param path: pathname of...
[ "def", "extract_from_zip", "(", "path", ",", "candidates", ")", ":", "temp_dir", "=", "tempfile", ".", "mkdtemp", "(", ")", "with", "zipfile", ".", "ZipFile", "(", "path", ")", "as", "archive", ":", "archive", ".", "extractall", "(", "temp_dir", ")", "re...
Given a zip archive and a function to detect the presence of a given filename, unzip the archive into a temporary directory and return the full path of the file. Raise an IOError if the file cannot be found within the archive. :param path: pathname of the archive :param candidates: list of names to...
[ "Given", "a", "zip", "archive", "and", "a", "function", "to", "detect", "the", "presence", "of", "a", "given", "filename", "unzip", "the", "archive", "into", "a", "temporary", "directory", "and", "return", "the", "full", "path", "of", "the", "file", ".", ...
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L87-L101
gem/oq-engine
openquake/commonlib/readinput.py
get_params
def get_params(job_inis, **kw): """ Parse one or more INI-style config files. :param job_inis: List of configuration files (or list containing a single zip archive) :param kw: Optionally override some parameters :returns: A dictionary of parameters """ input_zip = No...
python
def get_params(job_inis, **kw): """ Parse one or more INI-style config files. :param job_inis: List of configuration files (or list containing a single zip archive) :param kw: Optionally override some parameters :returns: A dictionary of parameters """ input_zip = No...
[ "def", "get_params", "(", "job_inis", ",", "*", "*", "kw", ")", ":", "input_zip", "=", "None", "if", "len", "(", "job_inis", ")", "==", "1", "and", "job_inis", "[", "0", "]", ".", "endswith", "(", "'.zip'", ")", ":", "input_zip", "=", "job_inis", "...
Parse one or more INI-style config files. :param job_inis: List of configuration files (or list containing a single zip archive) :param kw: Optionally override some parameters :returns: A dictionary of parameters
[ "Parse", "one", "or", "more", "INI", "-", "style", "config", "files", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L152-L191
gem/oq-engine
openquake/commonlib/readinput.py
get_oqparam
def get_oqparam(job_ini, pkg=None, calculators=None, hc_id=None, validate=1, **kw): """ Parse a dictionary of parameters from an INI-style config file. :param job_ini: Path to configuration file/archive or dictionary of parameters :param pkg: Python package where to find...
python
def get_oqparam(job_ini, pkg=None, calculators=None, hc_id=None, validate=1, **kw): """ Parse a dictionary of parameters from an INI-style config file. :param job_ini: Path to configuration file/archive or dictionary of parameters :param pkg: Python package where to find...
[ "def", "get_oqparam", "(", "job_ini", ",", "pkg", "=", "None", ",", "calculators", "=", "None", ",", "hc_id", "=", "None", ",", "validate", "=", "1", ",", "*", "*", "kw", ")", ":", "# UGLY: this is here to avoid circular imports", "from", "openquake", ".", ...
Parse a dictionary of parameters from an INI-style config file. :param job_ini: Path to configuration file/archive or dictionary of parameters :param pkg: Python package where to find the configuration file (optional) :param calculators: Sequence of calculator names (optional) used ...
[ "Parse", "a", "dictionary", "of", "parameters", "from", "an", "INI", "-", "style", "config", "file", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L194-L233
gem/oq-engine
openquake/commonlib/readinput.py
get_csv_header
def get_csv_header(fname, sep=','): """ :param fname: a CSV file :param sep: the separator (default comma) :returns: the first line of fname """ with open(fname, encoding='utf-8-sig') as f: return next(f).split(sep)
python
def get_csv_header(fname, sep=','): """ :param fname: a CSV file :param sep: the separator (default comma) :returns: the first line of fname """ with open(fname, encoding='utf-8-sig') as f: return next(f).split(sep)
[ "def", "get_csv_header", "(", "fname", ",", "sep", "=", "','", ")", ":", "with", "open", "(", "fname", ",", "encoding", "=", "'utf-8-sig'", ")", "as", "f", ":", "return", "next", "(", "f", ")", ".", "split", "(", "sep", ")" ]
:param fname: a CSV file :param sep: the separator (default comma) :returns: the first line of fname
[ ":", "param", "fname", ":", "a", "CSV", "file", ":", "param", "sep", ":", "the", "separator", "(", "default", "comma", ")", ":", "returns", ":", "the", "first", "line", "of", "fname" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L248-L255
gem/oq-engine
openquake/commonlib/readinput.py
read_csv
def read_csv(fname, sep=','): """ :param fname: a CSV file with an header and float fields :param sep: separato (default the comma) :return: a structured array of floats """ with open(fname, encoding='utf-8-sig') as f: header = next(f).strip().split(sep) dt = numpy.dtype([(h, num...
python
def read_csv(fname, sep=','): """ :param fname: a CSV file with an header and float fields :param sep: separato (default the comma) :return: a structured array of floats """ with open(fname, encoding='utf-8-sig') as f: header = next(f).strip().split(sep) dt = numpy.dtype([(h, num...
[ "def", "read_csv", "(", "fname", ",", "sep", "=", "','", ")", ":", "with", "open", "(", "fname", ",", "encoding", "=", "'utf-8-sig'", ")", "as", "f", ":", "header", "=", "next", "(", "f", ")", ".", "strip", "(", ")", ".", "split", "(", "sep", "...
:param fname: a CSV file with an header and float fields :param sep: separato (default the comma) :return: a structured array of floats
[ ":", "param", "fname", ":", "a", "CSV", "file", "with", "an", "header", "and", "float", "fields", ":", "param", "sep", ":", "separato", "(", "default", "the", "comma", ")", ":", "return", ":", "a", "structured", "array", "of", "floats" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L258-L268
gem/oq-engine
openquake/commonlib/readinput.py
get_mesh
def get_mesh(oqparam): """ Extract the mesh of points to compute from the sites, the sites_csv, or the region. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance """ global pmap, exposure, gmfs, eids if 'exposure' in oqparam.inputs and exposure is None: ...
python
def get_mesh(oqparam): """ Extract the mesh of points to compute from the sites, the sites_csv, or the region. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance """ global pmap, exposure, gmfs, eids if 'exposure' in oqparam.inputs and exposure is None: ...
[ "def", "get_mesh", "(", "oqparam", ")", ":", "global", "pmap", ",", "exposure", ",", "gmfs", ",", "eids", "if", "'exposure'", "in", "oqparam", ".", "inputs", "and", "exposure", "is", "None", ":", "# read it only once", "exposure", "=", "get_exposure", "(", ...
Extract the mesh of points to compute from the sites, the sites_csv, or the region. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance
[ "Extract", "the", "mesh", "of", "points", "to", "compute", "from", "the", "sites", "the", "sites_csv", "or", "the", "region", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L271-L339
gem/oq-engine
openquake/commonlib/readinput.py
get_site_model
def get_site_model(oqparam): """ Convert the NRML file into an array of site parameters. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: an array with fields lon, lat, vs30, ... """ req_site_params = get_gsim_lt(oqparam).req_site_params ...
python
def get_site_model(oqparam): """ Convert the NRML file into an array of site parameters. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: an array with fields lon, lat, vs30, ... """ req_site_params = get_gsim_lt(oqparam).req_site_params ...
[ "def", "get_site_model", "(", "oqparam", ")", ":", "req_site_params", "=", "get_gsim_lt", "(", "oqparam", ")", ".", "req_site_params", "arrays", "=", "[", "]", "for", "fname", "in", "oqparam", ".", "inputs", "[", "'site_model'", "]", ":", "if", "isinstance",...
Convert the NRML file into an array of site parameters. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: an array with fields lon, lat, vs30, ...
[ "Convert", "the", "NRML", "file", "into", "an", "array", "of", "site", "parameters", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L342-L386
gem/oq-engine
openquake/commonlib/readinput.py
get_site_collection
def get_site_collection(oqparam): """ Returns a SiteCollection instance by looking at the points and the site model defined by the configuration parameters. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance """ mesh = get_mesh(oqparam) req_site_params = g...
python
def get_site_collection(oqparam): """ Returns a SiteCollection instance by looking at the points and the site model defined by the configuration parameters. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance """ mesh = get_mesh(oqparam) req_site_params = g...
[ "def", "get_site_collection", "(", "oqparam", ")", ":", "mesh", "=", "get_mesh", "(", "oqparam", ")", "req_site_params", "=", "get_gsim_lt", "(", "oqparam", ")", ".", "req_site_params", "if", "oqparam", ".", "inputs", ".", "get", "(", "'site_model'", ")", ":...
Returns a SiteCollection instance by looking at the points and the site model defined by the configuration parameters. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance
[ "Returns", "a", "SiteCollection", "instance", "by", "looking", "at", "the", "points", "and", "the", "site", "model", "defined", "by", "the", "configuration", "parameters", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L389-L439
gem/oq-engine
openquake/commonlib/readinput.py
get_gsim_lt
def get_gsim_lt(oqparam, trts=['*']): """ :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param trts: a sequence of tectonic region types as strings; trts=['*'] means that there is no filtering :returns: a GsimLogicTree instance obtained by ...
python
def get_gsim_lt(oqparam, trts=['*']): """ :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param trts: a sequence of tectonic region types as strings; trts=['*'] means that there is no filtering :returns: a GsimLogicTree instance obtained by ...
[ "def", "get_gsim_lt", "(", "oqparam", ",", "trts", "=", "[", "'*'", "]", ")", ":", "if", "'gsim_logic_tree'", "not", "in", "oqparam", ".", "inputs", ":", "return", "logictree", ".", "GsimLogicTree", ".", "from_", "(", "oqparam", ".", "gsim", ")", "gsim_f...
:param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param trts: a sequence of tectonic region types as strings; trts=['*'] means that there is no filtering :returns: a GsimLogicTree instance obtained by filtering on the provided tectonic region ...
[ ":", "param", "oqparam", ":", "an", ":", "class", ":", "openquake", ".", "commonlib", ".", "oqvalidation", ".", "OqParam", "instance", ":", "param", "trts", ":", "a", "sequence", "of", "tectonic", "region", "types", "as", "strings", ";", "trts", "=", "["...
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L442-L471
gem/oq-engine
openquake/commonlib/readinput.py
get_rlzs_by_gsim
def get_rlzs_by_gsim(oqparam): """ Return an ordered dictionary gsim -> [realization index]. Work for gsim logic trees with a single tectonic region type. """ cinfo = source.CompositionInfo.fake(get_gsim_lt(oqparam)) ra = cinfo.get_rlzs_assoc() dic = {} for rlzi, gsim_by_trt in enumerate...
python
def get_rlzs_by_gsim(oqparam): """ Return an ordered dictionary gsim -> [realization index]. Work for gsim logic trees with a single tectonic region type. """ cinfo = source.CompositionInfo.fake(get_gsim_lt(oqparam)) ra = cinfo.get_rlzs_assoc() dic = {} for rlzi, gsim_by_trt in enumerate...
[ "def", "get_rlzs_by_gsim", "(", "oqparam", ")", ":", "cinfo", "=", "source", ".", "CompositionInfo", ".", "fake", "(", "get_gsim_lt", "(", "oqparam", ")", ")", "ra", "=", "cinfo", ".", "get_rlzs_assoc", "(", ")", "dic", "=", "{", "}", "for", "rlzi", ",...
Return an ordered dictionary gsim -> [realization index]. Work for gsim logic trees with a single tectonic region type.
[ "Return", "an", "ordered", "dictionary", "gsim", "-", ">", "[", "realization", "index", "]", ".", "Work", "for", "gsim", "logic", "trees", "with", "a", "single", "tectonic", "region", "type", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L485-L495
gem/oq-engine
openquake/commonlib/readinput.py
get_rupture
def get_rupture(oqparam): """ Read the `rupture_model` file and by filter the site collection :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: an hazardlib rupture """ rup_model = oqparam.inputs['rupture_model'] [rup_node] = nrml.read(r...
python
def get_rupture(oqparam): """ Read the `rupture_model` file and by filter the site collection :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: an hazardlib rupture """ rup_model = oqparam.inputs['rupture_model'] [rup_node] = nrml.read(r...
[ "def", "get_rupture", "(", "oqparam", ")", ":", "rup_model", "=", "oqparam", ".", "inputs", "[", "'rupture_model'", "]", "[", "rup_node", "]", "=", "nrml", ".", "read", "(", "rup_model", ")", "conv", "=", "sourceconverter", ".", "RuptureConverter", "(", "o...
Read the `rupture_model` file and by filter the site collection :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: an hazardlib rupture
[ "Read", "the", "rupture_model", "file", "and", "by", "filter", "the", "site", "collection" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L498-L514
gem/oq-engine
openquake/commonlib/readinput.py
get_source_model_lt
def get_source_model_lt(oqparam, validate=True): """ :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: a :class:`openquake.commonlib.logictree.SourceModelLogicTree` instance """ fname = oqparam.inputs.get('source_model_logic_tree') if...
python
def get_source_model_lt(oqparam, validate=True): """ :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: a :class:`openquake.commonlib.logictree.SourceModelLogicTree` instance """ fname = oqparam.inputs.get('source_model_logic_tree') if...
[ "def", "get_source_model_lt", "(", "oqparam", ",", "validate", "=", "True", ")", ":", "fname", "=", "oqparam", ".", "inputs", ".", "get", "(", "'source_model_logic_tree'", ")", "if", "fname", ":", "# NB: converting the random_seed into an integer is needed on Windows", ...
:param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: a :class:`openquake.commonlib.logictree.SourceModelLogicTree` instance
[ ":", "param", "oqparam", ":", "an", ":", "class", ":", "openquake", ".", "commonlib", ".", "oqvalidation", ".", "OqParam", "instance", ":", "returns", ":", "a", ":", "class", ":", "openquake", ".", "commonlib", ".", "logictree", ".", "SourceModelLogicTree", ...
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L517-L533
gem/oq-engine
openquake/commonlib/readinput.py
check_nonparametric_sources
def check_nonparametric_sources(fname, smodel, investigation_time): """ :param fname: full path to a source model file :param smodel: source model object :param investigation_time: investigation_time to compare with in the case of nonparametric sources :returns: ...
python
def check_nonparametric_sources(fname, smodel, investigation_time): """ :param fname: full path to a source model file :param smodel: source model object :param investigation_time: investigation_time to compare with in the case of nonparametric sources :returns: ...
[ "def", "check_nonparametric_sources", "(", "fname", ",", "smodel", ",", "investigation_time", ")", ":", "# NonParametricSeismicSources", "np", "=", "[", "src", "for", "sg", "in", "smodel", ".", "src_groups", "for", "src", "in", "sg", "if", "hasattr", "(", "src...
:param fname: full path to a source model file :param smodel: source model object :param investigation_time: investigation_time to compare with in the case of nonparametric sources :returns: the nonparametric sources in the model :raises: a ValueError if t...
[ ":", "param", "fname", ":", "full", "path", "to", "a", "source", "model", "file", ":", "param", "smodel", ":", "source", "model", "object", ":", "param", "investigation_time", ":", "investigation_time", "to", "compare", "with", "in", "the", "case", "of", "...
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L536-L558
gem/oq-engine
openquake/commonlib/readinput.py
store_sm
def store_sm(smodel, filename, monitor): """ :param smodel: a :class:`openquake.hazardlib.nrml.SourceModel` instance :param filename: path to an hdf5 file (cache_XXX.hdf5) :param monitor: a Monitor instance with an .hdf5 attribute """ h5 = monitor.hdf5 with monitor('store source model'): ...
python
def store_sm(smodel, filename, monitor): """ :param smodel: a :class:`openquake.hazardlib.nrml.SourceModel` instance :param filename: path to an hdf5 file (cache_XXX.hdf5) :param monitor: a Monitor instance with an .hdf5 attribute """ h5 = monitor.hdf5 with monitor('store source model'): ...
[ "def", "store_sm", "(", "smodel", ",", "filename", ",", "monitor", ")", ":", "h5", "=", "monitor", ".", "hdf5", "with", "monitor", "(", "'store source model'", ")", ":", "sources", "=", "h5", "[", "'source_info'", "]", "source_geom", "=", "h5", "[", "'so...
:param smodel: a :class:`openquake.hazardlib.nrml.SourceModel` instance :param filename: path to an hdf5 file (cache_XXX.hdf5) :param monitor: a Monitor instance with an .hdf5 attribute
[ ":", "param", "smodel", ":", "a", ":", "class", ":", "openquake", ".", "hazardlib", ".", "nrml", ".", "SourceModel", "instance", ":", "param", "filename", ":", "path", "to", "an", "hdf5", "file", "(", "cache_XXX", ".", "hdf5", ")", ":", "param", "monit...
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L608-L637
gem/oq-engine
openquake/commonlib/readinput.py
get_source_models
def get_source_models(oqparam, gsim_lt, source_model_lt, monitor, in_memory=True, srcfilter=None): """ Build all the source models generated by the logic tree. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param gsim_lt: a :class:`o...
python
def get_source_models(oqparam, gsim_lt, source_model_lt, monitor, in_memory=True, srcfilter=None): """ Build all the source models generated by the logic tree. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param gsim_lt: a :class:`o...
[ "def", "get_source_models", "(", "oqparam", ",", "gsim_lt", ",", "source_model_lt", ",", "monitor", ",", "in_memory", "=", "True", ",", "srcfilter", "=", "None", ")", ":", "make_sm", "=", "SourceModelFactory", "(", ")", "spinning_off", "=", "oqparam", ".", "...
Build all the source models generated by the logic tree. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param gsim_lt: a :class:`openquake.commonlib.logictree.GsimLogicTree` instance :param source_model_lt: a :class:`openquake.commonlib.logictree.Sour...
[ "Build", "all", "the", "source", "models", "generated", "by", "the", "logic", "tree", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L640-L790
gem/oq-engine
openquake/commonlib/readinput.py
random_filtered_sources
def random_filtered_sources(sources, srcfilter, seed): """ :param sources: a list of sources :param srcfilte: a SourceFilter instance :param seed: a random seed :returns: an empty list or a list with a single filtered source """ random.seed(seed) while sources: src = random.choic...
python
def random_filtered_sources(sources, srcfilter, seed): """ :param sources: a list of sources :param srcfilte: a SourceFilter instance :param seed: a random seed :returns: an empty list or a list with a single filtered source """ random.seed(seed) while sources: src = random.choic...
[ "def", "random_filtered_sources", "(", "sources", ",", "srcfilter", ",", "seed", ")", ":", "random", ".", "seed", "(", "seed", ")", "while", "sources", ":", "src", "=", "random", ".", "choice", "(", "sources", ")", "if", "srcfilter", ".", "get_close_sites"...
:param sources: a list of sources :param srcfilte: a SourceFilter instance :param seed: a random seed :returns: an empty list or a list with a single filtered source
[ ":", "param", "sources", ":", "a", "list", "of", "sources", ":", "param", "srcfilte", ":", "a", "SourceFilter", "instance", ":", "param", "seed", ":", "a", "random", "seed", ":", "returns", ":", "an", "empty", "list", "or", "a", "list", "with", "a", ...
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L800-L813
gem/oq-engine
openquake/commonlib/readinput.py
get_composite_source_model
def get_composite_source_model(oqparam, monitor=None, in_memory=True, srcfilter=SourceFilter(None, {})): """ Parse the XML and build a complete composite source model in memory. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param m...
python
def get_composite_source_model(oqparam, monitor=None, in_memory=True, srcfilter=SourceFilter(None, {})): """ Parse the XML and build a complete composite source model in memory. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param m...
[ "def", "get_composite_source_model", "(", "oqparam", ",", "monitor", "=", "None", ",", "in_memory", "=", "True", ",", "srcfilter", "=", "SourceFilter", "(", "None", ",", "{", "}", ")", ")", ":", "ucerf", "=", "oqparam", ".", "calculation_mode", ".", "start...
Parse the XML and build a complete composite source model in memory. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param monitor: a `openquake.baselib.performance.Monitor` instance :param in_memory: if False, just parse the XML without instantiating...
[ "Parse", "the", "XML", "and", "build", "a", "complete", "composite", "source", "model", "in", "memory", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L816-L892
gem/oq-engine
openquake/commonlib/readinput.py
get_risk_model
def get_risk_model(oqparam): """ Return a :class:`openquake.risklib.riskinput.CompositeRiskModel` instance :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance """ tmap = _get_taxonomy_mapping(oqparam.inputs) fragdict = get_risk_models(oqparam, 'fragility') v...
python
def get_risk_model(oqparam): """ Return a :class:`openquake.risklib.riskinput.CompositeRiskModel` instance :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance """ tmap = _get_taxonomy_mapping(oqparam.inputs) fragdict = get_risk_models(oqparam, 'fragility') v...
[ "def", "get_risk_model", "(", "oqparam", ")", ":", "tmap", "=", "_get_taxonomy_mapping", "(", "oqparam", ".", "inputs", ")", "fragdict", "=", "get_risk_models", "(", "oqparam", ",", "'fragility'", ")", "vulndict", "=", "get_risk_models", "(", "oqparam", ",", "...
Return a :class:`openquake.risklib.riskinput.CompositeRiskModel` instance :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance
[ "Return", "a", ":", "class", ":", "openquake", ".", "risklib", ".", "riskinput", ".", "CompositeRiskModel", "instance" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L910-L946
gem/oq-engine
openquake/commonlib/readinput.py
get_exposure
def get_exposure(oqparam): """ Read the full exposure in memory and build a list of :class:`openquake.risklib.asset.Asset` instances. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: an :class:`Exposure` instance or a compatible AssetCollection...
python
def get_exposure(oqparam): """ Read the full exposure in memory and build a list of :class:`openquake.risklib.asset.Asset` instances. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: an :class:`Exposure` instance or a compatible AssetCollection...
[ "def", "get_exposure", "(", "oqparam", ")", ":", "exposure", "=", "asset", ".", "Exposure", ".", "read", "(", "oqparam", ".", "inputs", "[", "'exposure'", "]", ",", "oqparam", ".", "calculation_mode", ",", "oqparam", ".", "region", ",", "oqparam", ".", "...
Read the full exposure in memory and build a list of :class:`openquake.risklib.asset.Asset` instances. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: an :class:`Exposure` instance or a compatible AssetCollection
[ "Read", "the", "full", "exposure", "in", "memory", "and", "build", "a", "list", "of", ":", "class", ":", "openquake", ".", "risklib", ".", "asset", ".", "Asset", "instances", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L949-L964
gem/oq-engine
openquake/commonlib/readinput.py
get_sitecol_assetcol
def get_sitecol_assetcol(oqparam, haz_sitecol=None, cost_types=()): """ :param oqparam: calculation parameters :param haz_sitecol: the hazard site collection :param cost_types: the expected cost types :returns: (site collection, asset collection, discarded) """ global exposure asset_haza...
python
def get_sitecol_assetcol(oqparam, haz_sitecol=None, cost_types=()): """ :param oqparam: calculation parameters :param haz_sitecol: the hazard site collection :param cost_types: the expected cost types :returns: (site collection, asset collection, discarded) """ global exposure asset_haza...
[ "def", "get_sitecol_assetcol", "(", "oqparam", ",", "haz_sitecol", "=", "None", ",", "cost_types", "=", "(", ")", ")", ":", "global", "exposure", "asset_hazard_distance", "=", "oqparam", ".", "asset_hazard_distance", "[", "'default'", "]", "if", "exposure", "is"...
:param oqparam: calculation parameters :param haz_sitecol: the hazard site collection :param cost_types: the expected cost types :returns: (site collection, asset collection, discarded)
[ ":", "param", "oqparam", ":", "calculation", "parameters", ":", "param", "haz_sitecol", ":", "the", "hazard", "site", "collection", ":", "param", "cost_types", ":", "the", "expected", "cost", "types", ":", "returns", ":", "(", "site", "collection", "asset", ...
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L967-L1022
gem/oq-engine
openquake/commonlib/readinput.py
get_pmap_from_csv
def get_pmap_from_csv(oqparam, fnames): """ :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param fnames: a space-separated list of .csv relative filenames :returns: the site mesh and the hazard curves read by the .csv files """ if not oqpar...
python
def get_pmap_from_csv(oqparam, fnames): """ :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param fnames: a space-separated list of .csv relative filenames :returns: the site mesh and the hazard curves read by the .csv files """ if not oqpar...
[ "def", "get_pmap_from_csv", "(", "oqparam", ",", "fnames", ")", ":", "if", "not", "oqparam", ".", "imtls", ":", "oqparam", ".", "set_risk_imtls", "(", "get_risk_models", "(", "oqparam", ")", ")", "if", "not", "oqparam", ".", "imtls", ":", "raise", "ValueEr...
:param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param fnames: a space-separated list of .csv relative filenames :returns: the site mesh and the hazard curves read by the .csv files
[ ":", "param", "oqparam", ":", "an", ":", "class", ":", "openquake", ".", "commonlib", ".", "oqvalidation", ".", "OqParam", "instance", ":", "param", "fnames", ":", "a", "space", "-", "separated", "list", "of", ".", "csv", "relative", "filenames", ":", "r...
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L1080-L1109
gem/oq-engine
openquake/commonlib/readinput.py
get_pmap_from_nrml
def get_pmap_from_nrml(oqparam, fname): """ :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param fname: an XML file containing hazard curves :returns: site mesh, curve array """ hcurves_by_imt = {} oqparam.hazard_imtls = imtls = {} ...
python
def get_pmap_from_nrml(oqparam, fname): """ :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param fname: an XML file containing hazard curves :returns: site mesh, curve array """ hcurves_by_imt = {} oqparam.hazard_imtls = imtls = {} ...
[ "def", "get_pmap_from_nrml", "(", "oqparam", ",", "fname", ")", ":", "hcurves_by_imt", "=", "{", "}", "oqparam", ".", "hazard_imtls", "=", "imtls", "=", "{", "}", "for", "hcurves", "in", "nrml", ".", "read", "(", "fname", ")", ":", "imt", "=", "hcurves...
:param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param fname: an XML file containing hazard curves :returns: site mesh, curve array
[ ":", "param", "oqparam", ":", "an", ":", "class", ":", "openquake", ".", "commonlib", ".", "oqvalidation", ".", "OqParam", "instance", ":", "param", "fname", ":", "an", "XML", "file", "containing", "hazard", "curves", ":", "returns", ":", "site", "mesh", ...
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L1113-L1142
gem/oq-engine
openquake/commonlib/readinput.py
get_scenario_from_nrml
def get_scenario_from_nrml(oqparam, fname): """ :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param fname: the NRML files containing the GMFs :returns: a pair (eids, gmf array) """ if not oqparam.imtls: oqparam.set_risk_imtls(get_r...
python
def get_scenario_from_nrml(oqparam, fname): """ :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param fname: the NRML files containing the GMFs :returns: a pair (eids, gmf array) """ if not oqparam.imtls: oqparam.set_risk_imtls(get_r...
[ "def", "get_scenario_from_nrml", "(", "oqparam", ",", "fname", ")", ":", "if", "not", "oqparam", ".", "imtls", ":", "oqparam", ".", "set_risk_imtls", "(", "get_risk_models", "(", "oqparam", ")", ")", "imts", "=", "sorted", "(", "oqparam", ".", "imtls", ")"...
:param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param fname: the NRML files containing the GMFs :returns: a pair (eids, gmf array)
[ ":", "param", "oqparam", ":", "an", ":", "class", ":", "openquake", ".", "commonlib", ".", "oqvalidation", ".", "OqParam", "instance", ":", "param", "fname", ":", "the", "NRML", "files", "containing", "the", "GMFs", ":", "returns", ":", "a", "pair", "(",...
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L1161-L1209
gem/oq-engine
openquake/commonlib/readinput.py
get_mesh_hcurves
def get_mesh_hcurves(oqparam): """ Read CSV data in the format `lon lat, v1-vN, w1-wN, ...`. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: the mesh of points and the data as a dictionary imt -> array of curves for each site """ i...
python
def get_mesh_hcurves(oqparam): """ Read CSV data in the format `lon lat, v1-vN, w1-wN, ...`. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: the mesh of points and the data as a dictionary imt -> array of curves for each site """ i...
[ "def", "get_mesh_hcurves", "(", "oqparam", ")", ":", "imtls", "=", "oqparam", ".", "imtls", "lon_lats", "=", "set", "(", ")", "data", "=", "AccumDict", "(", ")", "# imt -> list of arrays", "ncols", "=", "len", "(", "imtls", ")", "+", "1", "# lon_lat + curv...
Read CSV data in the format `lon lat, v1-vN, w1-wN, ...`. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: the mesh of points and the data as a dictionary imt -> array of curves for each site
[ "Read", "CSV", "data", "in", "the", "format", "lon", "lat", "v1", "-", "vN", "w1", "-", "wN", "...", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L1212-L1247
gem/oq-engine
openquake/commonlib/readinput.py
reduce_source_model
def reduce_source_model(smlt_file, source_ids, remove=True): """ Extract sources from the composite source model """ found = 0 to_remove = [] for paths in logictree.collect_info(smlt_file).smpaths.values(): for path in paths: logging.info('Reading %s', path) root ...
python
def reduce_source_model(smlt_file, source_ids, remove=True): """ Extract sources from the composite source model """ found = 0 to_remove = [] for paths in logictree.collect_info(smlt_file).smpaths.values(): for path in paths: logging.info('Reading %s', path) root ...
[ "def", "reduce_source_model", "(", "smlt_file", ",", "source_ids", ",", "remove", "=", "True", ")", ":", "found", "=", "0", "to_remove", "=", "[", "]", "for", "paths", "in", "logictree", ".", "collect_info", "(", "smlt_file", ")", ".", "smpaths", ".", "v...
Extract sources from the composite source model
[ "Extract", "sources", "from", "the", "composite", "source", "model" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L1251-L1292
gem/oq-engine
openquake/commonlib/readinput.py
get_input_files
def get_input_files(oqparam, hazard=False): """ :param oqparam: an OqParam instance :param hazard: if True, consider only the hazard files :returns: input path names in a specific order """ fnames = [] # files entering in the checksum for key in oqparam.inputs: fname = oqparam.input...
python
def get_input_files(oqparam, hazard=False): """ :param oqparam: an OqParam instance :param hazard: if True, consider only the hazard files :returns: input path names in a specific order """ fnames = [] # files entering in the checksum for key in oqparam.inputs: fname = oqparam.input...
[ "def", "get_input_files", "(", "oqparam", ",", "hazard", "=", "False", ")", ":", "fnames", "=", "[", "]", "# files entering in the checksum", "for", "key", "in", "oqparam", ".", "inputs", ":", "fname", "=", "oqparam", ".", "inputs", "[", "key", "]", "if", ...
:param oqparam: an OqParam instance :param hazard: if True, consider only the hazard files :returns: input path names in a specific order
[ ":", "param", "oqparam", ":", "an", "OqParam", "instance", ":", "param", "hazard", ":", "if", "True", "consider", "only", "the", "hazard", "files", ":", "returns", ":", "input", "path", "names", "in", "a", "specific", "order" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L1328-L1372
gem/oq-engine
openquake/commonlib/readinput.py
get_checksum32
def get_checksum32(oqparam, hazard=False): """ Build an unsigned 32 bit integer from the input files of a calculation. :param oqparam: an OqParam instance :param hazard: if True, consider only the hazard files :returns: the checkume """ # NB: using adler32 & 0xffffffff is the documented way...
python
def get_checksum32(oqparam, hazard=False): """ Build an unsigned 32 bit integer from the input files of a calculation. :param oqparam: an OqParam instance :param hazard: if True, consider only the hazard files :returns: the checkume """ # NB: using adler32 & 0xffffffff is the documented way...
[ "def", "get_checksum32", "(", "oqparam", ",", "hazard", "=", "False", ")", ":", "# NB: using adler32 & 0xffffffff is the documented way to get a checksum", "# which is the same between Python 2 and Python 3", "checksum", "=", "0", "for", "fname", "in", "get_input_files", "(", ...
Build an unsigned 32 bit integer from the input files of a calculation. :param oqparam: an OqParam instance :param hazard: if True, consider only the hazard files :returns: the checkume
[ "Build", "an", "unsigned", "32", "bit", "integer", "from", "the", "input", "files", "of", "a", "calculation", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L1388-L1415
gem/oq-engine
openquake/commands/dump.py
smart_save
def smart_save(dbpath, archive, calc_id): """ Make a copy of the db, remove the incomplete jobs and add the copy to the archive """ tmpdir = tempfile.mkdtemp() newdb = os.path.join(tmpdir, os.path.basename(dbpath)) shutil.copy(dbpath, newdb) try: with sqlite3.connect(newdb) as co...
python
def smart_save(dbpath, archive, calc_id): """ Make a copy of the db, remove the incomplete jobs and add the copy to the archive """ tmpdir = tempfile.mkdtemp() newdb = os.path.join(tmpdir, os.path.basename(dbpath)) shutil.copy(dbpath, newdb) try: with sqlite3.connect(newdb) as co...
[ "def", "smart_save", "(", "dbpath", ",", "archive", ",", "calc_id", ")", ":", "tmpdir", "=", "tempfile", ".", "mkdtemp", "(", ")", "newdb", "=", "os", ".", "path", ".", "join", "(", "tmpdir", ",", "os", ".", "path", ".", "basename", "(", "dbpath", ...
Make a copy of the db, remove the incomplete jobs and add the copy to the archive
[ "Make", "a", "copy", "of", "the", "db", "remove", "the", "incomplete", "jobs", "and", "add", "the", "copy", "to", "the", "archive" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/dump.py#L28-L45
gem/oq-engine
openquake/commands/dump.py
dump
def dump(archive, calc_id=0, user=None): """ Dump the openquake database and all the complete calculations into a zip file. In a multiuser installation must be run as administrator. """ t0 = time.time() assert archive.endswith('.zip'), archive getfnames = 'select ds_calc_dir || ".hdf5" from ...
python
def dump(archive, calc_id=0, user=None): """ Dump the openquake database and all the complete calculations into a zip file. In a multiuser installation must be run as administrator. """ t0 = time.time() assert archive.endswith('.zip'), archive getfnames = 'select ds_calc_dir || ".hdf5" from ...
[ "def", "dump", "(", "archive", ",", "calc_id", "=", "0", ",", "user", "=", "None", ")", ":", "t0", "=", "time", ".", "time", "(", ")", "assert", "archive", ".", "endswith", "(", "'.zip'", ")", ",", "archive", "getfnames", "=", "'select ds_calc_dir || \...
Dump the openquake database and all the complete calculations into a zip file. In a multiuser installation must be run as administrator.
[ "Dump", "the", "openquake", "database", "and", "all", "the", "complete", "calculations", "into", "a", "zip", "file", ".", "In", "a", "multiuser", "installation", "must", "be", "run", "as", "administrator", "." ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/dump.py#L49-L77
gem/oq-engine
openquake/hmtk/faults/mfd/anderson_luco_area_mmax.py
Type1RecurrenceModel.cumulative_value
def cumulative_value(self, slip, mmax, mag_value, bbar, dbar, beta): ''' Returns the rate of events with M > mag_value :param float slip: Slip rate in mm/yr :param float mmax: Maximum magnitude :param float mag_value: Magnitude value :...
python
def cumulative_value(self, slip, mmax, mag_value, bbar, dbar, beta): ''' Returns the rate of events with M > mag_value :param float slip: Slip rate in mm/yr :param float mmax: Maximum magnitude :param float mag_value: Magnitude value :...
[ "def", "cumulative_value", "(", "self", ",", "slip", ",", "mmax", ",", "mag_value", ",", "bbar", ",", "dbar", ",", "beta", ")", ":", "delta_m", "=", "(", "mmax", "-", "mag_value", ")", "a_1", "=", "self", ".", "_get_a1_value", "(", "bbar", ",", "dbar...
Returns the rate of events with M > mag_value :param float slip: Slip rate in mm/yr :param float mmax: Maximum magnitude :param float mag_value: Magnitude value :param float bbar: \bar{b} parameter (effectively = b * log(10.)) :par...
[ "Returns", "the", "rate", "of", "events", "with", "M", ">", "mag_value" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/mfd/anderson_luco_area_mmax.py#L83-L102
gem/oq-engine
openquake/hmtk/faults/mfd/anderson_luco_area_mmax.py
Type1RecurrenceModel._get_a1_value
def _get_a1_value(bbar, dbar, slip, beta, mmax): """ Returns the A1 value defined in I.9 (Table 2) """ return ((dbar - bbar) / dbar) * (slip / beta) *\ np.exp(-(dbar / 2.) * mmax)
python
def _get_a1_value(bbar, dbar, slip, beta, mmax): """ Returns the A1 value defined in I.9 (Table 2) """ return ((dbar - bbar) / dbar) * (slip / beta) *\ np.exp(-(dbar / 2.) * mmax)
[ "def", "_get_a1_value", "(", "bbar", ",", "dbar", ",", "slip", ",", "beta", ",", "mmax", ")", ":", "return", "(", "(", "dbar", "-", "bbar", ")", "/", "dbar", ")", "*", "(", "slip", "/", "beta", ")", "*", "np", ".", "exp", "(", "-", "(", "dbar...
Returns the A1 value defined in I.9 (Table 2)
[ "Returns", "the", "A1", "value", "defined", "in", "I", ".", "9", "(", "Table", "2", ")" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/mfd/anderson_luco_area_mmax.py#L105-L110
gem/oq-engine
openquake/hmtk/faults/mfd/anderson_luco_area_mmax.py
Type2RecurrenceModel.cumulative_value
def cumulative_value(self, slip, mmax, mag_value, bbar, dbar, beta): ''' Returns the rate of events with M > mag_value :param float slip: Slip rate in mm/yr :param float mmax: Maximum magnitude :param float mag_value: Magnitude value :...
python
def cumulative_value(self, slip, mmax, mag_value, bbar, dbar, beta): ''' Returns the rate of events with M > mag_value :param float slip: Slip rate in mm/yr :param float mmax: Maximum magnitude :param float mag_value: Magnitude value :...
[ "def", "cumulative_value", "(", "self", ",", "slip", ",", "mmax", ",", "mag_value", ",", "bbar", ",", "dbar", ",", "beta", ")", ":", "delta_m", "=", "mmax", "-", "mag_value", "a_2", "=", "self", ".", "_get_a2_value", "(", "bbar", ",", "dbar", ",", "s...
Returns the rate of events with M > mag_value :param float slip: Slip rate in mm/yr :param float mmax: Maximum magnitude :param float mag_value: Magnitude value :param float bbar: \bar{b} parameter (effectively = b * log(10.)) :par...
[ "Returns", "the", "rate", "of", "events", "with", "M", ">", "mag_value" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/mfd/anderson_luco_area_mmax.py#L119-L138
gem/oq-engine
openquake/hmtk/faults/mfd/anderson_luco_area_mmax.py
Type2RecurrenceModel._get_a2_value
def _get_a2_value(bbar, dbar, slip, beta, mmax): """ Returns the A2 value defined in II.8 (Table 3) """ return ((dbar - bbar) / bbar) * (slip / beta) *\ np.exp(-(dbar / 2.) * mmax)
python
def _get_a2_value(bbar, dbar, slip, beta, mmax): """ Returns the A2 value defined in II.8 (Table 3) """ return ((dbar - bbar) / bbar) * (slip / beta) *\ np.exp(-(dbar / 2.) * mmax)
[ "def", "_get_a2_value", "(", "bbar", ",", "dbar", ",", "slip", ",", "beta", ",", "mmax", ")", ":", "return", "(", "(", "dbar", "-", "bbar", ")", "/", "bbar", ")", "*", "(", "slip", "/", "beta", ")", "*", "np", ".", "exp", "(", "-", "(", "dbar...
Returns the A2 value defined in II.8 (Table 3)
[ "Returns", "the", "A2", "value", "defined", "in", "II", ".", "8", "(", "Table", "3", ")" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/mfd/anderson_luco_area_mmax.py#L141-L146
gem/oq-engine
openquake/hmtk/faults/mfd/anderson_luco_area_mmax.py
Type3RecurrenceModel.cumulative_value
def cumulative_value(self, slip, mmax, mag_value, bbar, dbar, beta): ''' Returns the rate of events with M > mag_value :param float slip: Slip rate in mm/yr :param float mmax: Maximum magnitude :param float mag_value: Magnitude value :...
python
def cumulative_value(self, slip, mmax, mag_value, bbar, dbar, beta): ''' Returns the rate of events with M > mag_value :param float slip: Slip rate in mm/yr :param float mmax: Maximum magnitude :param float mag_value: Magnitude value :...
[ "def", "cumulative_value", "(", "self", ",", "slip", ",", "mmax", ",", "mag_value", ",", "bbar", ",", "dbar", ",", "beta", ")", ":", "delta_m", "=", "mmax", "-", "mag_value", "a_3", "=", "self", ".", "_get_a3_value", "(", "bbar", ",", "dbar", ",", "s...
Returns the rate of events with M > mag_value :param float slip: Slip rate in mm/yr :param float mmax: Maximum magnitude :param float mag_value: Magnitude value :param float bbar: \bar{b} parameter (effectively = b * log(10.)) :par...
[ "Returns", "the", "rate", "of", "events", "with", "M", ">", "mag_value" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/mfd/anderson_luco_area_mmax.py#L155-L175
gem/oq-engine
openquake/hmtk/faults/mfd/anderson_luco_area_mmax.py
Type3RecurrenceModel._get_a3_value
def _get_a3_value(bbar, dbar, slip, beta, mmax): """ Returns the A3 value defined in III.4 (Table 4) """ return (dbar * (dbar - bbar) / (bbar ** 2.)) * (slip / beta) *\ np.exp(-(dbar / 2.) * mmax)
python
def _get_a3_value(bbar, dbar, slip, beta, mmax): """ Returns the A3 value defined in III.4 (Table 4) """ return (dbar * (dbar - bbar) / (bbar ** 2.)) * (slip / beta) *\ np.exp(-(dbar / 2.) * mmax)
[ "def", "_get_a3_value", "(", "bbar", ",", "dbar", ",", "slip", ",", "beta", ",", "mmax", ")", ":", "return", "(", "dbar", "*", "(", "dbar", "-", "bbar", ")", "/", "(", "bbar", "**", "2.", ")", ")", "*", "(", "slip", "/", "beta", ")", "*", "np...
Returns the A3 value defined in III.4 (Table 4)
[ "Returns", "the", "A3", "value", "defined", "in", "III", ".", "4", "(", "Table", "4", ")" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/mfd/anderson_luco_area_mmax.py#L178-L183
gem/oq-engine
openquake/hmtk/faults/mfd/anderson_luco_area_mmax.py
AndersonLucoAreaMmax.get_mfd
def get_mfd(self, slip, fault_width, shear_modulus=30.0, disp_length_ratio=1.25E-5): ''' Calculates activity rate on the fault :param float slip: Slip rate in mm/yr :param fault_width: Width of the fault (km) :param float shear_modulus: ...
python
def get_mfd(self, slip, fault_width, shear_modulus=30.0, disp_length_ratio=1.25E-5): ''' Calculates activity rate on the fault :param float slip: Slip rate in mm/yr :param fault_width: Width of the fault (km) :param float shear_modulus: ...
[ "def", "get_mfd", "(", "self", ",", "slip", ",", "fault_width", ",", "shear_modulus", "=", "30.0", ",", "disp_length_ratio", "=", "1.25E-5", ")", ":", "beta", "=", "np", ".", "sqrt", "(", "(", "disp_length_ratio", "*", "(", "10.0", "**", "C_VALUE", ")", ...
Calculates activity rate on the fault :param float slip: Slip rate in mm/yr :param fault_width: Width of the fault (km) :param float shear_modulus: Shear modulus of the fault (GPa) :param float disp_length_ratio: Displacement to length ...
[ "Calculates", "activity", "rate", "on", "the", "fault" ]
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/mfd/anderson_luco_area_mmax.py#L275-L320
conan-io/conan-package-tools
setup.py
load_version
def load_version(): """Loads a file content""" filename = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "cpt", "__init__.py")) with open(filename, "rt") as version_file: conan_init = version_file.read() version = re.searc...
python
def load_version(): """Loads a file content""" filename = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "cpt", "__init__.py")) with open(filename, "rt") as version_file: conan_init = version_file.read() version = re.searc...
[ "def", "load_version", "(", ")", ":", "filename", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "__file__", ")", ")", ",", "\"cpt\...
Loads a file content
[ "Loads", "a", "file", "content" ]
train
https://github.com/conan-io/conan-package-tools/blob/3d0f5f4dc5d9dc899a57626e8d8a125fc28b8324/setup.py#L25-L32
conan-io/conan-package-tools
cpt/packager.py
ConanMultiPackager.builds
def builds(self, confs): """For retro compatibility directly assigning builds""" self._named_builds = {} self._builds = [] for values in confs: if len(values) == 2: self._builds.append(BuildConf(values[0], values[1], {}, {}, self.reference)) elif l...
python
def builds(self, confs): """For retro compatibility directly assigning builds""" self._named_builds = {} self._builds = [] for values in confs: if len(values) == 2: self._builds.append(BuildConf(values[0], values[1], {}, {}, self.reference)) elif l...
[ "def", "builds", "(", "self", ",", "confs", ")", ":", "self", ".", "_named_builds", "=", "{", "}", "self", ".", "_builds", "=", "[", "]", "for", "values", "in", "confs", ":", "if", "len", "(", "values", ")", "==", "2", ":", "self", ".", "_builds"...
For retro compatibility directly assigning builds
[ "For", "retro", "compatibility", "directly", "assigning", "builds" ]
train
https://github.com/conan-io/conan-package-tools/blob/3d0f5f4dc5d9dc899a57626e8d8a125fc28b8324/cpt/packager.py#L357-L371
conan-io/conan-package-tools
cpt/profiles.py
patch_default_base_profile
def patch_default_base_profile(conan_api, profile_abs_path): """If we have a profile including default, but the users default in config is that the default is other, we have to change the include""" text = tools.load(profile_abs_path) if "include(default)" in text: # User didn't specified a custom prof...
python
def patch_default_base_profile(conan_api, profile_abs_path): """If we have a profile including default, but the users default in config is that the default is other, we have to change the include""" text = tools.load(profile_abs_path) if "include(default)" in text: # User didn't specified a custom prof...
[ "def", "patch_default_base_profile", "(", "conan_api", ",", "profile_abs_path", ")", ":", "text", "=", "tools", ".", "load", "(", "profile_abs_path", ")", "if", "\"include(default)\"", "in", "text", ":", "# User didn't specified a custom profile", "if", "Version", "("...
If we have a profile including default, but the users default in config is that the default is other, we have to change the include
[ "If", "we", "have", "a", "profile", "including", "default", "but", "the", "users", "default", "in", "config", "is", "that", "the", "default", "is", "other", "we", "have", "to", "change", "the", "include" ]
train
https://github.com/conan-io/conan-package-tools/blob/3d0f5f4dc5d9dc899a57626e8d8a125fc28b8324/cpt/profiles.py#L51-L68
edx/auth-backends
auth_backends/pipeline.py
get_user_if_exists
def get_user_if_exists(strategy, details, user=None, *args, **kwargs): """Return a User with the given username iff the User exists.""" if user: return {'is_new': False} try: username = details.get('username') # Return the user if it exists return { 'is_new': Fal...
python
def get_user_if_exists(strategy, details, user=None, *args, **kwargs): """Return a User with the given username iff the User exists.""" if user: return {'is_new': False} try: username = details.get('username') # Return the user if it exists return { 'is_new': Fal...
[ "def", "get_user_if_exists", "(", "strategy", ",", "details", ",", "user", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "user", ":", "return", "{", "'is_new'", ":", "False", "}", "try", ":", "username", "=", "details", ".",...
Return a User with the given username iff the User exists.
[ "Return", "a", "User", "with", "the", "given", "username", "iff", "the", "User", "exists", "." ]
train
https://github.com/edx/auth-backends/blob/493f93e9d87d0237f0fea6d75c7b70646ad6d31e/auth_backends/pipeline.py#L14-L31
edx/auth-backends
auth_backends/pipeline.py
update_email
def update_email(strategy, details, user=None, *args, **kwargs): """Update the user's email address using data from provider.""" if user: email = details.get('email') if email and user.email != email: user.email = email strategy.storage.user.changed(user)
python
def update_email(strategy, details, user=None, *args, **kwargs): """Update the user's email address using data from provider.""" if user: email = details.get('email') if email and user.email != email: user.email = email strategy.storage.user.changed(user)
[ "def", "update_email", "(", "strategy", ",", "details", ",", "user", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "user", ":", "email", "=", "details", ".", "get", "(", "'email'", ")", "if", "email", "and", "user", ".", ...
Update the user's email address using data from provider.
[ "Update", "the", "user", "s", "email", "address", "using", "data", "from", "provider", "." ]
train
https://github.com/edx/auth-backends/blob/493f93e9d87d0237f0fea6d75c7b70646ad6d31e/auth_backends/pipeline.py#L34-L41
edx/auth-backends
auth_backends/backends.py
_merge_two_dicts
def _merge_two_dicts(x, y): """ Given two dicts, merge them into a new dict as a shallow copy. Once Python 3.6+ only is supported, replace method with ``z = {**x, **y}`` """ z = x.copy() z.update(y) return z
python
def _merge_two_dicts(x, y): """ Given two dicts, merge them into a new dict as a shallow copy. Once Python 3.6+ only is supported, replace method with ``z = {**x, **y}`` """ z = x.copy() z.update(y) return z
[ "def", "_merge_two_dicts", "(", "x", ",", "y", ")", ":", "z", "=", "x", ".", "copy", "(", ")", "z", ".", "update", "(", "y", ")", "return", "z" ]
Given two dicts, merge them into a new dict as a shallow copy. Once Python 3.6+ only is supported, replace method with ``z = {**x, **y}``
[ "Given", "two", "dicts", "merge", "them", "into", "a", "new", "dict", "as", "a", "shallow", "copy", "." ]
train
https://github.com/edx/auth-backends/blob/493f93e9d87d0237f0fea6d75c7b70646ad6d31e/auth_backends/backends.py#L29-L37
edx/auth-backends
auth_backends/backends.py
EdXBackendMixin._map_user_details
def _map_user_details(self, response): """Maps key/values from the response to key/values in the user model. Does not transfer any key/value that is empty or not present in the response. """ dest = {} for source_key, dest_key in self.CLAIMS_TO_DETAILS_KEY_MAP.items(): ...
python
def _map_user_details(self, response): """Maps key/values from the response to key/values in the user model. Does not transfer any key/value that is empty or not present in the response. """ dest = {} for source_key, dest_key in self.CLAIMS_TO_DETAILS_KEY_MAP.items(): ...
[ "def", "_map_user_details", "(", "self", ",", "response", ")", ":", "dest", "=", "{", "}", "for", "source_key", ",", "dest_key", "in", "self", ".", "CLAIMS_TO_DETAILS_KEY_MAP", ".", "items", "(", ")", ":", "value", "=", "response", ".", "get", "(", "sour...
Maps key/values from the response to key/values in the user model. Does not transfer any key/value that is empty or not present in the response.
[ "Maps", "key", "/", "values", "from", "the", "response", "to", "key", "/", "values", "in", "the", "user", "model", "." ]
train
https://github.com/edx/auth-backends/blob/493f93e9d87d0237f0fea6d75c7b70646ad6d31e/auth_backends/backends.py#L66-L77
edx/auth-backends
auth_backends/backends.py
EdXOpenIdConnect.get_user_claims
def get_user_claims(self, access_token, claims=None, token_type='Bearer'): """Returns a dictionary with the values for each claim requested.""" data = self.get_json( self.USER_INFO_URL, headers={'Authorization': '{token_type} {token}'.format(token_type=token_type, token=access_to...
python
def get_user_claims(self, access_token, claims=None, token_type='Bearer'): """Returns a dictionary with the values for each claim requested.""" data = self.get_json( self.USER_INFO_URL, headers={'Authorization': '{token_type} {token}'.format(token_type=token_type, token=access_to...
[ "def", "get_user_claims", "(", "self", ",", "access_token", ",", "claims", "=", "None", ",", "token_type", "=", "'Bearer'", ")", ":", "data", "=", "self", ".", "get_json", "(", "self", ".", "USER_INFO_URL", ",", "headers", "=", "{", "'Authorization'", ":",...
Returns a dictionary with the values for each claim requested.
[ "Returns", "a", "dictionary", "with", "the", "values", "for", "each", "claim", "requested", "." ]
train
https://github.com/edx/auth-backends/blob/493f93e9d87d0237f0fea6d75c7b70646ad6d31e/auth_backends/backends.py#L170-L181
napalm-automation/napalm-logs
napalm_logs/server.py
NapalmLogsServerProc._setup_ipc
def _setup_ipc(self): ''' Setup the IPC pub and sub. Subscript to the listener IPC and publish to the device specific IPC. ''' log.debug('Setting up the server IPC puller to receive from the listener') self.ctx = zmq.Context() # subscribe to listener ...
python
def _setup_ipc(self): ''' Setup the IPC pub and sub. Subscript to the listener IPC and publish to the device specific IPC. ''' log.debug('Setting up the server IPC puller to receive from the listener') self.ctx = zmq.Context() # subscribe to listener ...
[ "def", "_setup_ipc", "(", "self", ")", ":", "log", ".", "debug", "(", "'Setting up the server IPC puller to receive from the listener'", ")", "self", ".", "ctx", "=", "zmq", ".", "Context", "(", ")", "# subscribe to listener", "self", ".", "sub", "=", "self", "....
Setup the IPC pub and sub. Subscript to the listener IPC and publish to the device specific IPC.
[ "Setup", "the", "IPC", "pub", "and", "sub", ".", "Subscript", "to", "the", "listener", "IPC", "and", "publish", "to", "the", "device", "specific", "IPC", "." ]
train
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/server.py#L55-L90
napalm-automation/napalm-logs
napalm_logs/server.py
NapalmLogsServerProc._cleanup_buffer
def _cleanup_buffer(self): ''' Periodically cleanup the buffer. ''' if not self._buffer: return while True: time.sleep(60) log.debug('Cleaning up buffer') items = self._buffer.items() # The ``items`` function should also...
python
def _cleanup_buffer(self): ''' Periodically cleanup the buffer. ''' if not self._buffer: return while True: time.sleep(60) log.debug('Cleaning up buffer') items = self._buffer.items() # The ``items`` function should also...
[ "def", "_cleanup_buffer", "(", "self", ")", ":", "if", "not", "self", ".", "_buffer", ":", "return", "while", "True", ":", "time", ".", "sleep", "(", "60", ")", "log", ".", "debug", "(", "'Cleaning up buffer'", ")", "items", "=", "self", ".", "_buffer"...
Periodically cleanup the buffer.
[ "Periodically", "cleanup", "the", "buffer", "." ]
train
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/server.py#L92-L104
napalm-automation/napalm-logs
napalm_logs/server.py
NapalmLogsServerProc._compile_prefixes
def _compile_prefixes(self): ''' Create a dict of all OS prefixes and their compiled regexs ''' self.compiled_prefixes = {} for dev_os, os_config in self.config.items(): if not os_config: continue self.compiled_prefixes[dev_os] = [] ...
python
def _compile_prefixes(self): ''' Create a dict of all OS prefixes and their compiled regexs ''' self.compiled_prefixes = {} for dev_os, os_config in self.config.items(): if not os_config: continue self.compiled_prefixes[dev_os] = [] ...
[ "def", "_compile_prefixes", "(", "self", ")", ":", "self", ".", "compiled_prefixes", "=", "{", "}", "for", "dev_os", ",", "os_config", "in", "self", ".", "config", ".", "items", "(", ")", ":", "if", "not", "os_config", ":", "continue", "self", ".", "co...
Create a dict of all OS prefixes and their compiled regexs
[ "Create", "a", "dict", "of", "all", "OS", "prefixes", "and", "their", "compiled", "regexs" ]
train
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/server.py#L106-L146
napalm-automation/napalm-logs
napalm_logs/server.py
NapalmLogsServerProc._identify_prefix
def _identify_prefix(self, msg, data): ''' Check the message again each OS prefix and if matched return the message dict ''' prefix_id = -1 for prefix in data: msg_dict = {} prefix_id += 1 match = None if '__python_fun__' in...
python
def _identify_prefix(self, msg, data): ''' Check the message again each OS prefix and if matched return the message dict ''' prefix_id = -1 for prefix in data: msg_dict = {} prefix_id += 1 match = None if '__python_fun__' in...
[ "def", "_identify_prefix", "(", "self", ",", "msg", ",", "data", ")", ":", "prefix_id", "=", "-", "1", "for", "prefix", "in", "data", ":", "msg_dict", "=", "{", "}", "prefix_id", "+=", "1", "match", "=", "None", "if", "'__python_fun__'", "in", "prefix"...
Check the message again each OS prefix and if matched return the message dict
[ "Check", "the", "message", "again", "each", "OS", "prefix", "and", "if", "matched", "return", "the", "message", "dict" ]
train
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/server.py#L150-L191
napalm-automation/napalm-logs
napalm_logs/server.py
NapalmLogsServerProc._identify_os
def _identify_os(self, msg): ''' Using the prefix of the syslog message, we are able to identify the operating system and then continue parsing. ''' ret = [] for dev_os, data in self.compiled_prefixes.items(): # TODO Should we prevent attepmting to determine t...
python
def _identify_os(self, msg): ''' Using the prefix of the syslog message, we are able to identify the operating system and then continue parsing. ''' ret = [] for dev_os, data in self.compiled_prefixes.items(): # TODO Should we prevent attepmting to determine t...
[ "def", "_identify_os", "(", "self", ",", "msg", ")", ":", "ret", "=", "[", "]", "for", "dev_os", ",", "data", "in", "self", ".", "compiled_prefixes", ".", "items", "(", ")", ":", "# TODO Should we prevent attepmting to determine the OS for the blacklisted?", "# [m...
Using the prefix of the syslog message, we are able to identify the operating system and then continue parsing.
[ "Using", "the", "prefix", "of", "the", "syslog", "message", "we", "are", "able", "to", "identify", "the", "operating", "system", "and", "then", "continue", "parsing", "." ]
train
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/server.py#L193-L215
napalm-automation/napalm-logs
napalm_logs/server.py
NapalmLogsServerProc.start
def start(self): ''' Take the messages from the queue, inspect and identify the operating system, then queue the message correspondingly. ''' # metric counters napalm_logs_server_messages_received = Counter( "napalm_logs_server_messages_received", ...
python
def start(self): ''' Take the messages from the queue, inspect and identify the operating system, then queue the message correspondingly. ''' # metric counters napalm_logs_server_messages_received = Counter( "napalm_logs_server_messages_received", ...
[ "def", "start", "(", "self", ")", ":", "# metric counters", "napalm_logs_server_messages_received", "=", "Counter", "(", "\"napalm_logs_server_messages_received\"", ",", "\"Count of messages received from listener processes\"", ")", "napalm_logs_server_skipped_buffered_messages", "="...
Take the messages from the queue, inspect and identify the operating system, then queue the message correspondingly.
[ "Take", "the", "messages", "from", "the", "queue", "inspect", "and", "identify", "the", "operating", "system", "then", "queue", "the", "message", "correspondingly", "." ]
train
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/server.py#L217-L329
napalm-automation/napalm-logs
napalm_logs/device.py
NapalmLogsDeviceProc._setup_ipc
def _setup_ipc(self): ''' Subscribe to the right topic in the device IPC and publish to the publisher proxy. ''' self.ctx = zmq.Context() # subscribe to device IPC log.debug('Creating the dealer IPC for %s', self._name) self.sub = self.ctx.socket(z...
python
def _setup_ipc(self): ''' Subscribe to the right topic in the device IPC and publish to the publisher proxy. ''' self.ctx = zmq.Context() # subscribe to device IPC log.debug('Creating the dealer IPC for %s', self._name) self.sub = self.ctx.socket(z...
[ "def", "_setup_ipc", "(", "self", ")", ":", "self", ".", "ctx", "=", "zmq", ".", "Context", "(", ")", "# subscribe to device IPC", "log", ".", "debug", "(", "'Creating the dealer IPC for %s'", ",", "self", ".", "_name", ")", "self", ".", "sub", "=", "self"...
Subscribe to the right topic in the device IPC and publish to the publisher proxy.
[ "Subscribe", "to", "the", "right", "topic", "in", "the", "device", "IPC", "and", "publish", "to", "the", "publisher", "proxy", "." ]
train
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/device.py#L52-L82
napalm-automation/napalm-logs
napalm_logs/device.py
NapalmLogsDeviceProc._compile_messages
def _compile_messages(self): ''' Create a list of all OS messages and their compiled regexs ''' self.compiled_messages = [] if not self._config: return for message_dict in self._config.get('messages', {}): error = message_dict['error'] ...
python
def _compile_messages(self): ''' Create a list of all OS messages and their compiled regexs ''' self.compiled_messages = [] if not self._config: return for message_dict in self._config.get('messages', {}): error = message_dict['error'] ...
[ "def", "_compile_messages", "(", "self", ")", ":", "self", ".", "compiled_messages", "=", "[", "]", "if", "not", "self", ".", "_config", ":", "return", "for", "message_dict", "in", "self", ".", "_config", ".", "get", "(", "'messages'", ",", "{", "}", "...
Create a list of all OS messages and their compiled regexs
[ "Create", "a", "list", "of", "all", "OS", "messages", "and", "their", "compiled", "regexs" ]
train
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/device.py#L84-L138
napalm-automation/napalm-logs
napalm_logs/device.py
NapalmLogsDeviceProc._parse
def _parse(self, msg_dict): ''' Parse a syslog message and check what OpenConfig object should be generated. ''' error_present = False # log.debug('Matching the message:') # log.debug(msg_dict) for message in self.compiled_messages: # log.debug...
python
def _parse(self, msg_dict): ''' Parse a syslog message and check what OpenConfig object should be generated. ''' error_present = False # log.debug('Matching the message:') # log.debug(msg_dict) for message in self.compiled_messages: # log.debug...
[ "def", "_parse", "(", "self", ",", "msg_dict", ")", ":", "error_present", "=", "False", "# log.debug('Matching the message:')", "# log.debug(msg_dict)", "for", "message", "in", "self", ".", "compiled_messages", ":", "# log.debug('Matching using:')", "# log.debug(message)", ...
Parse a syslog message and check what OpenConfig object should be generated.
[ "Parse", "a", "syslog", "message", "and", "check", "what", "OpenConfig", "object", "should", "be", "generated", "." ]
train
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/device.py#L140-L186
napalm-automation/napalm-logs
napalm_logs/device.py
NapalmLogsDeviceProc._emit
def _emit(self, **kwargs): ''' Emit an OpenConfig object given a certain combination of fields mappeed in the config to the corresponding hierarchy. ''' oc_dict = {} for mapping, result_key in kwargs['mapping']['variables'].items(): result = kwargs[result_key]...
python
def _emit(self, **kwargs): ''' Emit an OpenConfig object given a certain combination of fields mappeed in the config to the corresponding hierarchy. ''' oc_dict = {} for mapping, result_key in kwargs['mapping']['variables'].items(): result = kwargs[result_key]...
[ "def", "_emit", "(", "self", ",", "*", "*", "kwargs", ")", ":", "oc_dict", "=", "{", "}", "for", "mapping", ",", "result_key", "in", "kwargs", "[", "'mapping'", "]", "[", "'variables'", "]", ".", "items", "(", ")", ":", "result", "=", "kwargs", "["...
Emit an OpenConfig object given a certain combination of fields mappeed in the config to the corresponding hierarchy.
[ "Emit", "an", "OpenConfig", "object", "given", "a", "certain", "combination", "of", "fields", "mappeed", "in", "the", "config", "to", "the", "corresponding", "hierarchy", "." ]
train
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/device.py#L188-L200
napalm-automation/napalm-logs
napalm_logs/device.py
NapalmLogsDeviceProc._publish
def _publish(self, obj): ''' Publish the OC object. ''' bin_obj = umsgpack.packb(obj) self.pub.send(bin_obj)
python
def _publish(self, obj): ''' Publish the OC object. ''' bin_obj = umsgpack.packb(obj) self.pub.send(bin_obj)
[ "def", "_publish", "(", "self", ",", "obj", ")", ":", "bin_obj", "=", "umsgpack", ".", "packb", "(", "obj", ")", "self", ".", "pub", ".", "send", "(", "bin_obj", ")" ]
Publish the OC object.
[ "Publish", "the", "OC", "object", "." ]
train
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/device.py#L202-L207
napalm-automation/napalm-logs
napalm_logs/device.py
NapalmLogsDeviceProc.start
def start(self): ''' Start the worker process. ''' # metrics napalm_logs_device_messages_received = Counter( 'napalm_logs_device_messages_received', "Count of messages received by the device process", ['device_os'] ) napalm_logs...
python
def start(self): ''' Start the worker process. ''' # metrics napalm_logs_device_messages_received = Counter( 'napalm_logs_device_messages_received', "Count of messages received by the device process", ['device_os'] ) napalm_logs...
[ "def", "start", "(", "self", ")", ":", "# metrics", "napalm_logs_device_messages_received", "=", "Counter", "(", "'napalm_logs_device_messages_received'", ",", "\"Count of messages received by the device process\"", ",", "[", "'device_os'", "]", ")", "napalm_logs_device_raw_pub...
Start the worker process.
[ "Start", "the", "worker", "process", "." ]
train
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/device.py#L241-L351