repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
gem/oq-engine
openquake/commands/webui.py
webui
def webui(cmd, hostport='127.0.0.1:8800', skip_browser=False): """ start the webui server in foreground or perform other operation on the django application """ dbpath = os.path.realpath(os.path.expanduser(config.dbserver.file)) if os.path.isfile(dbpath) and not os.access(dbpath, os.W_OK): ...
python
def webui(cmd, hostport='127.0.0.1:8800', skip_browser=False): """ start the webui server in foreground or perform other operation on the django application """ dbpath = os.path.realpath(os.path.expanduser(config.dbserver.file)) if os.path.isfile(dbpath) and not os.access(dbpath, os.W_OK): ...
[ "def", "webui", "(", "cmd", ",", "hostport", "=", "'127.0.0.1:8800'", ",", "skip_browser", "=", "False", ")", ":", "dbpath", "=", "os", ".", "path", ".", "realpath", "(", "os", ".", "path", ".", "expanduser", "(", "config", ".", "dbserver", ".", "file"...
start the webui server in foreground or perform other operation on the django application
[ "start", "the", "webui", "server", "in", "foreground", "or", "perform", "other", "operation", "on", "the", "django", "application" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/webui.py#L51-L64
train
gem/oq-engine
openquake/hazardlib/gsim/abrahamson_2014.py
AbrahamsonEtAl2014._get_basic_term
def _get_basic_term(self, C, rup, dists): """ Compute and return basic form, see page 1030. """ # Fictitious depth calculation if rup.mag > 5.: c4m = C['c4'] elif rup.mag > 4.: c4m = C['c4'] - (C['c4']-1.) * (5. - rup.mag) else: ...
python
def _get_basic_term(self, C, rup, dists): """ Compute and return basic form, see page 1030. """ # Fictitious depth calculation if rup.mag > 5.: c4m = C['c4'] elif rup.mag > 4.: c4m = C['c4'] - (C['c4']-1.) * (5. - rup.mag) else: ...
[ "def", "_get_basic_term", "(", "self", ",", "C", ",", "rup", ",", "dists", ")", ":", "if", "rup", ".", "mag", ">", "5.", ":", "c4m", "=", "C", "[", "'c4'", "]", "elif", "rup", ".", "mag", ">", "4.", ":", "c4m", "=", "C", "[", "'c4'", "]", "...
Compute and return basic form, see page 1030.
[ "Compute", "and", "return", "basic", "form", "see", "page", "1030", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/abrahamson_2014.py#L130-L162
train
gem/oq-engine
openquake/hazardlib/gsim/abrahamson_2014.py
AbrahamsonEtAl2014._get_vs30star
def _get_vs30star(self, vs30, imt): """ This computes equations 8 and 9 at page 1034 """ # compute the v1 value (see eq. 9, page 1034) if imt.name == "SA": t = imt.period if t <= 0.50: v1 = 1500.0 elif t < 3.0: v...
python
def _get_vs30star(self, vs30, imt): """ This computes equations 8 and 9 at page 1034 """ # compute the v1 value (see eq. 9, page 1034) if imt.name == "SA": t = imt.period if t <= 0.50: v1 = 1500.0 elif t < 3.0: v...
[ "def", "_get_vs30star", "(", "self", ",", "vs30", ",", "imt", ")", ":", "if", "imt", ".", "name", "==", "\"SA\"", ":", "t", "=", "imt", ".", "period", "if", "t", "<=", "0.50", ":", "v1", "=", "1500.0", "elif", "t", "<", "3.0", ":", "v1", "=", ...
This computes equations 8 and 9 at page 1034
[ "This", "computes", "equations", "8", "and", "9", "at", "page", "1034" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/abrahamson_2014.py#L186-L207
train
gem/oq-engine
openquake/hazardlib/gsim/abrahamson_2014.py
AbrahamsonEtAl2014._get_site_response_term
def _get_site_response_term(self, C, imt, vs30, sa1180): """ Compute and return site response model term see page 1033 """ # vs30 star vs30_star = self._get_vs30star(vs30, imt) # compute the site term site_resp_term = np.zeros_like(vs30) gt_vlin = vs30 >= ...
python
def _get_site_response_term(self, C, imt, vs30, sa1180): """ Compute and return site response model term see page 1033 """ # vs30 star vs30_star = self._get_vs30star(vs30, imt) # compute the site term site_resp_term = np.zeros_like(vs30) gt_vlin = vs30 >= ...
[ "def", "_get_site_response_term", "(", "self", ",", "C", ",", "imt", ",", "vs30", ",", "sa1180", ")", ":", "vs30_star", "=", "self", ".", "_get_vs30star", "(", "vs30", ",", "imt", ")", "site_resp_term", "=", "np", ".", "zeros_like", "(", "vs30", ")", "...
Compute and return site response model term see page 1033
[ "Compute", "and", "return", "site", "response", "model", "term", "see", "page", "1033" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/abrahamson_2014.py#L209-L229
train
gem/oq-engine
openquake/hazardlib/gsim/abrahamson_2014.py
AbrahamsonEtAl2014._get_hanging_wall_term
def _get_hanging_wall_term(self, C, dists, rup): """ Compute and return hanging wall model term, see page 1038. """ if rup.dip == 90.0: return np.zeros_like(dists.rx) else: Fhw = np.zeros_like(dists.rx) Fhw[dists.rx > 0] = 1. # Comp...
python
def _get_hanging_wall_term(self, C, dists, rup): """ Compute and return hanging wall model term, see page 1038. """ if rup.dip == 90.0: return np.zeros_like(dists.rx) else: Fhw = np.zeros_like(dists.rx) Fhw[dists.rx > 0] = 1. # Comp...
[ "def", "_get_hanging_wall_term", "(", "self", ",", "C", ",", "dists", ",", "rup", ")", ":", "if", "rup", ".", "dip", "==", "90.0", ":", "return", "np", ".", "zeros_like", "(", "dists", ".", "rx", ")", "else", ":", "Fhw", "=", "np", ".", "zeros_like...
Compute and return hanging wall model term, see page 1038.
[ "Compute", "and", "return", "hanging", "wall", "model", "term", "see", "page", "1038", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/abrahamson_2014.py#L231-L283
train
gem/oq-engine
openquake/hazardlib/gsim/abrahamson_2014.py
AbrahamsonEtAl2014._get_top_of_rupture_depth_term
def _get_top_of_rupture_depth_term(self, C, imt, rup): """ Compute and return top of rupture depth term. See paragraph 'Depth-to-Top of Rupture Model', page 1042. """ if rup.ztor >= 20.0: return C['a15'] else: return C['a15'] * rup.ztor / 20.0
python
def _get_top_of_rupture_depth_term(self, C, imt, rup): """ Compute and return top of rupture depth term. See paragraph 'Depth-to-Top of Rupture Model', page 1042. """ if rup.ztor >= 20.0: return C['a15'] else: return C['a15'] * rup.ztor / 20.0
[ "def", "_get_top_of_rupture_depth_term", "(", "self", ",", "C", ",", "imt", ",", "rup", ")", ":", "if", "rup", ".", "ztor", ">=", "20.0", ":", "return", "C", "[", "'a15'", "]", "else", ":", "return", "C", "[", "'a15'", "]", "*", "rup", ".", "ztor",...
Compute and return top of rupture depth term. See paragraph 'Depth-to-Top of Rupture Model', page 1042.
[ "Compute", "and", "return", "top", "of", "rupture", "depth", "term", ".", "See", "paragraph", "Depth", "-", "to", "-", "Top", "of", "Rupture", "Model", "page", "1042", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/abrahamson_2014.py#L285-L293
train
gem/oq-engine
openquake/hazardlib/gsim/abrahamson_2014.py
AbrahamsonEtAl2014._get_soil_depth_term
def _get_soil_depth_term(self, C, z1pt0, vs30): """ Compute and return soil depth term. See page 1042. """ # Get reference z1pt0 z1ref = self._get_z1pt0ref(vs30) # Get z1pt0 z10 = copy.deepcopy(z1pt0) # This is used for the calculation of the motion on re...
python
def _get_soil_depth_term(self, C, z1pt0, vs30): """ Compute and return soil depth term. See page 1042. """ # Get reference z1pt0 z1ref = self._get_z1pt0ref(vs30) # Get z1pt0 z10 = copy.deepcopy(z1pt0) # This is used for the calculation of the motion on re...
[ "def", "_get_soil_depth_term", "(", "self", ",", "C", ",", "z1pt0", ",", "vs30", ")", ":", "z1ref", "=", "self", ".", "_get_z1pt0ref", "(", "vs30", ")", "z10", "=", "copy", ".", "deepcopy", "(", "z1pt0", ")", "idx", "=", "z1pt0", "<", "0", "z10", "...
Compute and return soil depth term. See page 1042.
[ "Compute", "and", "return", "soil", "depth", "term", ".", "See", "page", "1042", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/abrahamson_2014.py#L303-L325
train
gem/oq-engine
openquake/hazardlib/gsim/abrahamson_2014.py
AbrahamsonEtAl2014._get_stddevs
def _get_stddevs(self, C, imt, rup, sites, stddev_types, sa1180, dists): """ Return standard deviations as described in paragraph 'Equations for standard deviation', page 1046. """ std_intra = self._get_intra_event_std(C, rup.mag, sa1180, sites.vs30, ...
python
def _get_stddevs(self, C, imt, rup, sites, stddev_types, sa1180, dists): """ Return standard deviations as described in paragraph 'Equations for standard deviation', page 1046. """ std_intra = self._get_intra_event_std(C, rup.mag, sa1180, sites.vs30, ...
[ "def", "_get_stddevs", "(", "self", ",", "C", ",", "imt", ",", "rup", ",", "sites", ",", "stddev_types", ",", "sa1180", ",", "dists", ")", ":", "std_intra", "=", "self", ".", "_get_intra_event_std", "(", "C", ",", "rup", ".", "mag", ",", "sa1180", ",...
Return standard deviations as described in paragraph 'Equations for standard deviation', page 1046.
[ "Return", "standard", "deviations", "as", "described", "in", "paragraph", "Equations", "for", "standard", "deviation", "page", "1046", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/abrahamson_2014.py#L334-L352
train
gem/oq-engine
openquake/hazardlib/gsim/abrahamson_2014.py
AbrahamsonEtAl2014._get_intra_event_std
def _get_intra_event_std(self, C, mag, sa1180, vs30, vs30measured, rrup): """ Returns Phi as described at pages 1046 and 1047 """ phi_al = self._get_phi_al_regional(C, mag, vs30measured, rrup) derAmp = self._get_derivative(C, sa1180, vs30) phi...
python
def _get_intra_event_std(self, C, mag, sa1180, vs30, vs30measured, rrup): """ Returns Phi as described at pages 1046 and 1047 """ phi_al = self._get_phi_al_regional(C, mag, vs30measured, rrup) derAmp = self._get_derivative(C, sa1180, vs30) phi...
[ "def", "_get_intra_event_std", "(", "self", ",", "C", ",", "mag", ",", "sa1180", ",", "vs30", ",", "vs30measured", ",", "rrup", ")", ":", "phi_al", "=", "self", ".", "_get_phi_al_regional", "(", "C", ",", "mag", ",", "vs30measured", ",", "rrup", ")", "...
Returns Phi as described at pages 1046 and 1047
[ "Returns", "Phi", "as", "described", "at", "pages", "1046", "and", "1047" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/abrahamson_2014.py#L354-L373
train
gem/oq-engine
openquake/hazardlib/gsim/abrahamson_2014.py
AbrahamsonEtAl2014._get_derivative
def _get_derivative(self, C, sa1180, vs30): """ Returns equation 30 page 1047 """ derAmp = np.zeros_like(vs30) n = self.CONSTS['n'] c = C['c'] b = C['b'] idx = vs30 < C['vlin'] derAmp[idx] = (b * sa1180[idx] * (-1./(sa1180[idx]+c) + ...
python
def _get_derivative(self, C, sa1180, vs30): """ Returns equation 30 page 1047 """ derAmp = np.zeros_like(vs30) n = self.CONSTS['n'] c = C['c'] b = C['b'] idx = vs30 < C['vlin'] derAmp[idx] = (b * sa1180[idx] * (-1./(sa1180[idx]+c) + ...
[ "def", "_get_derivative", "(", "self", ",", "C", ",", "sa1180", ",", "vs30", ")", ":", "derAmp", "=", "np", ".", "zeros_like", "(", "vs30", ")", "n", "=", "self", ".", "CONSTS", "[", "'n'", "]", "c", "=", "C", "[", "'c'", "]", "b", "=", "C", ...
Returns equation 30 page 1047
[ "Returns", "equation", "30", "page", "1047" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/abrahamson_2014.py#L375-L386
train
gem/oq-engine
openquake/hazardlib/gsim/abrahamson_2014.py
AbrahamsonEtAl2014RegJPN._get_regional_term
def _get_regional_term(self, C, imt, vs30, rrup): """ Compute regional term for Japan. See page 1043 """ f3 = interpolate.interp1d( [150, 250, 350, 450, 600, 850, 1150, 2000], [C['a36'], C['a37'], C['a38'], C['a39'], C['a40'], C['a41'], C['a42'], C['a...
python
def _get_regional_term(self, C, imt, vs30, rrup): """ Compute regional term for Japan. See page 1043 """ f3 = interpolate.interp1d( [150, 250, 350, 450, 600, 850, 1150, 2000], [C['a36'], C['a37'], C['a38'], C['a39'], C['a40'], C['a41'], C['a42'], C['a...
[ "def", "_get_regional_term", "(", "self", ",", "C", ",", "imt", ",", "vs30", ",", "rrup", ")", ":", "f3", "=", "interpolate", ".", "interp1d", "(", "[", "150", ",", "250", ",", "350", ",", "450", ",", "600", ",", "850", ",", "1150", ",", "2000", ...
Compute regional term for Japan. See page 1043
[ "Compute", "regional", "term", "for", "Japan", ".", "See", "page", "1043" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/abrahamson_2014.py#L511-L520
train
gem/oq-engine
openquake/hazardlib/gsim/yu_2013.py
gc
def gc(coeff, mag): """ Returns the set of coefficients to be used for the calculation of GM as a function of earthquake magnitude :param coeff: A dictionary of parameters for the selected IMT :param mag: Magnitude value :returns: The set of coefficients """ if m...
python
def gc(coeff, mag): """ Returns the set of coefficients to be used for the calculation of GM as a function of earthquake magnitude :param coeff: A dictionary of parameters for the selected IMT :param mag: Magnitude value :returns: The set of coefficients """ if m...
[ "def", "gc", "(", "coeff", ",", "mag", ")", ":", "if", "mag", ">", "6.5", ":", "a1ca", "=", "coeff", "[", "'ua'", "]", "a1cb", "=", "coeff", "[", "'ub'", "]", "a1cc", "=", "coeff", "[", "'uc'", "]", "a1cd", "=", "coeff", "[", "'ud'", "]", "a1...
Returns the set of coefficients to be used for the calculation of GM as a function of earthquake magnitude :param coeff: A dictionary of parameters for the selected IMT :param mag: Magnitude value :returns: The set of coefficients
[ "Returns", "the", "set", "of", "coefficients", "to", "be", "used", "for", "the", "calculation", "of", "GM", "as", "a", "function", "of", "earthquake", "magnitude" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/yu_2013.py#L34-L68
train
gem/oq-engine
openquake/hazardlib/gsim/yu_2013.py
rbf
def rbf(ra, coeff, mag): """ Calculate the median ground motion for a given magnitude and distance :param ra: Distance value [km] :param coeff: The set of coefficients :param mag: Magnitude value :returns: """ a1ca, a1cb, a1cc, a1cd, a1ce, a2ca, a2cb, a2cc, a2cd...
python
def rbf(ra, coeff, mag): """ Calculate the median ground motion for a given magnitude and distance :param ra: Distance value [km] :param coeff: The set of coefficients :param mag: Magnitude value :returns: """ a1ca, a1cb, a1cc, a1cd, a1ce, a2ca, a2cb, a2cc, a2cd...
[ "def", "rbf", "(", "ra", ",", "coeff", ",", "mag", ")", ":", "a1ca", ",", "a1cb", ",", "a1cc", ",", "a1cd", ",", "a1ce", ",", "a2ca", ",", "a2cb", ",", "a2cc", ",", "a2cd", ",", "a2ce", "=", "gc", "(", "coeff", ",", "mag", ")", "term1", "=", ...
Calculate the median ground motion for a given magnitude and distance :param ra: Distance value [km] :param coeff: The set of coefficients :param mag: Magnitude value :returns:
[ "Calculate", "the", "median", "ground", "motion", "for", "a", "given", "magnitude", "and", "distance" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/yu_2013.py#L71-L88
train
gem/oq-engine
openquake/hazardlib/gsim/yu_2013.py
fnc
def fnc(ra, *args): """ Function used in the minimisation problem. :param ra: Semi-axis of the ellipses used in the Yu et al. :returns: The absolute difference between the epicentral distance and the adjusted distance """ # # epicentral distance repi = args[0] ...
python
def fnc(ra, *args): """ Function used in the minimisation problem. :param ra: Semi-axis of the ellipses used in the Yu et al. :returns: The absolute difference between the epicentral distance and the adjusted distance """ # # epicentral distance repi = args[0] ...
[ "def", "fnc", "(", "ra", ",", "*", "args", ")", ":", "repi", "=", "args", "[", "0", "]", "theta", "=", "args", "[", "1", "]", "mag", "=", "args", "[", "2", "]", "coeff", "=", "args", "[", "3", "]", "rb", "=", "rbf", "(", "ra", ",", "coeff...
Function used in the minimisation problem. :param ra: Semi-axis of the ellipses used in the Yu et al. :returns: The absolute difference between the epicentral distance and the adjusted distance
[ "Function", "used", "in", "the", "minimisation", "problem", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/yu_2013.py#L91-L119
train
gem/oq-engine
openquake/hazardlib/gsim/yu_2013.py
get_ras
def get_ras(repi, theta, mag, coeff): """ Computes equivalent distance :param repi: Epicentral distance :param theta: Azimuth value :param mag: Magnitude :param coeff: GMPE coefficients """ rx = 100. ras = 200. # # calculate the difference bet...
python
def get_ras(repi, theta, mag, coeff): """ Computes equivalent distance :param repi: Epicentral distance :param theta: Azimuth value :param mag: Magnitude :param coeff: GMPE coefficients """ rx = 100. ras = 200. # # calculate the difference bet...
[ "def", "get_ras", "(", "repi", ",", "theta", ",", "mag", ",", "coeff", ")", ":", "rx", "=", "100.", "ras", "=", "200.", "dff", "=", "fnc", "(", "ras", ",", "repi", ",", "theta", ",", "mag", ",", "coeff", ")", "while", "abs", "(", "dff", ")", ...
Computes equivalent distance :param repi: Epicentral distance :param theta: Azimuth value :param mag: Magnitude :param coeff: GMPE coefficients
[ "Computes", "equivalent", "distance" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/yu_2013.py#L122-L150
train
gem/oq-engine
openquake/hazardlib/gsim/shahjouei_pezeshk_2016.py
ShahjoueiPezeshk2016._get_stddevs
def _get_stddevs(self, C, stddev_types, rup, imt, num_sites): """ Return standard deviations as defined in eq. 4 and 5, page 744, based on table 8, page 744. Eq. 5 yields std dev in natural log, so convert to log10 """ stddevs = [] for stddev_type in stddev_types:...
python
def _get_stddevs(self, C, stddev_types, rup, imt, num_sites): """ Return standard deviations as defined in eq. 4 and 5, page 744, based on table 8, page 744. Eq. 5 yields std dev in natural log, so convert to log10 """ stddevs = [] for stddev_type in stddev_types:...
[ "def", "_get_stddevs", "(", "self", ",", "C", ",", "stddev_types", ",", "rup", ",", "imt", ",", "num_sites", ")", ":", "stddevs", "=", "[", "]", "for", "stddev_type", "in", "stddev_types", ":", "sigma_mean", "=", "self", ".", "_compute_standard_dev", "(", ...
Return standard deviations as defined in eq. 4 and 5, page 744, based on table 8, page 744. Eq. 5 yields std dev in natural log, so convert to log10
[ "Return", "standard", "deviations", "as", "defined", "in", "eq", ".", "4", "and", "5", "page", "744", "based", "on", "table", "8", "page", "744", ".", "Eq", ".", "5", "yields", "std", "dev", "in", "natural", "log", "so", "convert", "to", "log10" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/shahjouei_pezeshk_2016.py#L103-L115
train
gem/oq-engine
openquake/hazardlib/gsim/shahjouei_pezeshk_2016.py
ShahjoueiPezeshk2016._compute_standard_dev
def _compute_standard_dev(self, rup, imt, C): """ Compute the the standard deviation in terms of magnitude described on page 744, eq. 4 """ sigma_mean = 0. if imt.name in "SA PGA": psi = -6.898E-3 else: psi = -3.054E-5 if rup.mag <=...
python
def _compute_standard_dev(self, rup, imt, C): """ Compute the the standard deviation in terms of magnitude described on page 744, eq. 4 """ sigma_mean = 0. if imt.name in "SA PGA": psi = -6.898E-3 else: psi = -3.054E-5 if rup.mag <=...
[ "def", "_compute_standard_dev", "(", "self", ",", "rup", ",", "imt", ",", "C", ")", ":", "sigma_mean", "=", "0.", "if", "imt", ".", "name", "in", "\"SA PGA\"", ":", "psi", "=", "-", "6.898E-3", "else", ":", "psi", "=", "-", "3.054E-5", "if", "rup", ...
Compute the the standard deviation in terms of magnitude described on page 744, eq. 4
[ "Compute", "the", "the", "standard", "deviation", "in", "terms", "of", "magnitude", "described", "on", "page", "744", "eq", ".", "4" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/shahjouei_pezeshk_2016.py#L164-L178
train
gem/oq-engine
openquake/server/dbapi.py
Db.insert
def insert(self, table, columns, rows): """ Insert several rows with executemany. Return a cursor. """ cursor = self.conn.cursor() if len(rows): templ, _args = match('INSERT INTO ?s (?S) VALUES (?X)', table, columns, rows[0]) ...
python
def insert(self, table, columns, rows): """ Insert several rows with executemany. Return a cursor. """ cursor = self.conn.cursor() if len(rows): templ, _args = match('INSERT INTO ?s (?S) VALUES (?X)', table, columns, rows[0]) ...
[ "def", "insert", "(", "self", ",", "table", ",", "columns", ",", "rows", ")", ":", "cursor", "=", "self", ".", "conn", ".", "cursor", "(", ")", "if", "len", "(", "rows", ")", ":", "templ", ",", "_args", "=", "match", "(", "'INSERT INTO ?s (?S) VALUES...
Insert several rows with executemany. Return a cursor.
[ "Insert", "several", "rows", "with", "executemany", ".", "Return", "a", "cursor", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/dbapi.py#L362-L371
train
gem/oq-engine
openquake/hazardlib/calc/hazard_curve.py
_cluster
def _cluster(param, tom, imtls, gsims, grp_ids, pmap): """ Computes the probability map in case of a cluster group """ pmapclu = AccumDict({grp_id: ProbabilityMap(len(imtls.array), len(gsims)) for grp_id in grp_ids}) # Get temporal occurrence model # Number of occurrence...
python
def _cluster(param, tom, imtls, gsims, grp_ids, pmap): """ Computes the probability map in case of a cluster group """ pmapclu = AccumDict({grp_id: ProbabilityMap(len(imtls.array), len(gsims)) for grp_id in grp_ids}) # Get temporal occurrence model # Number of occurrence...
[ "def", "_cluster", "(", "param", ",", "tom", ",", "imtls", ",", "gsims", ",", "grp_ids", ",", "pmap", ")", ":", "pmapclu", "=", "AccumDict", "(", "{", "grp_id", ":", "ProbabilityMap", "(", "len", "(", "imtls", ".", "array", ")", ",", "len", "(", "g...
Computes the probability map in case of a cluster group
[ "Computes", "the", "probability", "map", "in", "case", "of", "a", "cluster", "group" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/calc/hazard_curve.py#L71-L91
train
gem/oq-engine
openquake/hazardlib/gsim/kale_2015.py
KaleEtAl2015Turkey._get_stddevs
def _get_stddevs(self, C, rup, shape, stddev_types): """ Return standard deviations as defined in p. 971. """ weight = self._compute_weight_std(C, rup.mag) std_intra = weight * C["sd1"] * np.ones(shape) std_inter = weight * C["sd2"] * np.ones(shape) ...
python
def _get_stddevs(self, C, rup, shape, stddev_types): """ Return standard deviations as defined in p. 971. """ weight = self._compute_weight_std(C, rup.mag) std_intra = weight * C["sd1"] * np.ones(shape) std_inter = weight * C["sd2"] * np.ones(shape) ...
[ "def", "_get_stddevs", "(", "self", ",", "C", ",", "rup", ",", "shape", ",", "stddev_types", ")", ":", "weight", "=", "self", ".", "_compute_weight_std", "(", "C", ",", "rup", ".", "mag", ")", "std_intra", "=", "weight", "*", "C", "[", "\"sd1\"", "]"...
Return standard deviations as defined in p. 971.
[ "Return", "standard", "deviations", "as", "defined", "in", "p", ".", "971", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/kale_2015.py#L99-L116
train
gem/oq-engine
openquake/hazardlib/gsim/kale_2015.py
KaleEtAl2015Turkey._compute_weight_std
def _compute_weight_std(self, C, mag): """ Common part of equations 8 and 9, page 971. """ if mag < 6.0: return C['a1'] elif mag >= 6.0 and mag < 6.5: return C['a1'] + (C['a2'] - C['a1']) * ((mag - 6.0) / 0.5) else: return C['a...
python
def _compute_weight_std(self, C, mag): """ Common part of equations 8 and 9, page 971. """ if mag < 6.0: return C['a1'] elif mag >= 6.0 and mag < 6.5: return C['a1'] + (C['a2'] - C['a1']) * ((mag - 6.0) / 0.5) else: return C['a...
[ "def", "_compute_weight_std", "(", "self", ",", "C", ",", "mag", ")", ":", "if", "mag", "<", "6.0", ":", "return", "C", "[", "'a1'", "]", "elif", "mag", ">=", "6.0", "and", "mag", "<", "6.5", ":", "return", "C", "[", "'a1'", "]", "+", "(", "C",...
Common part of equations 8 and 9, page 971.
[ "Common", "part", "of", "equations", "8", "and", "9", "page", "971", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/kale_2015.py#L118-L127
train
gem/oq-engine
openquake/hazardlib/gsim/kale_2015.py
KaleEtAl2015Turkey._compute_magnitude_scaling_term
def _compute_magnitude_scaling_term(self, C, mag): """ Compute and return magnitude scaling term in equation 2, page 970. """ c1 = self.CONSTS['c1'] if mag <= c1: return C['b1'] + C['b2'] * (mag - c1) + C['b3'] * (8.5 - mag) ** 2 else: ...
python
def _compute_magnitude_scaling_term(self, C, mag): """ Compute and return magnitude scaling term in equation 2, page 970. """ c1 = self.CONSTS['c1'] if mag <= c1: return C['b1'] + C['b2'] * (mag - c1) + C['b3'] * (8.5 - mag) ** 2 else: ...
[ "def", "_compute_magnitude_scaling_term", "(", "self", ",", "C", ",", "mag", ")", ":", "c1", "=", "self", ".", "CONSTS", "[", "'c1'", "]", "if", "mag", "<=", "c1", ":", "return", "C", "[", "'b1'", "]", "+", "C", "[", "'b2'", "]", "*", "(", "mag",...
Compute and return magnitude scaling term in equation 2, page 970.
[ "Compute", "and", "return", "magnitude", "scaling", "term", "in", "equation", "2", "page", "970", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/kale_2015.py#L129-L138
train
gem/oq-engine
openquake/hazardlib/gsim/kale_2015.py
KaleEtAl2015Turkey._compute_geometric_decay_term
def _compute_geometric_decay_term(self, C, mag, dists): """ Compute and return geometric decay term in equation 3, page 970. """ c1 = self.CONSTS['c1'] return ( (C['b4'] + C['b5'] * (mag - c1)) * np.log(np.sqrt(dists.rjb ** 2.0 + C['b6'] **...
python
def _compute_geometric_decay_term(self, C, mag, dists): """ Compute and return geometric decay term in equation 3, page 970. """ c1 = self.CONSTS['c1'] return ( (C['b4'] + C['b5'] * (mag - c1)) * np.log(np.sqrt(dists.rjb ** 2.0 + C['b6'] **...
[ "def", "_compute_geometric_decay_term", "(", "self", ",", "C", ",", "mag", ",", "dists", ")", ":", "c1", "=", "self", ".", "CONSTS", "[", "'c1'", "]", "return", "(", "(", "C", "[", "'b4'", "]", "+", "C", "[", "'b5'", "]", "*", "(", "mag", "-", ...
Compute and return geometric decay term in equation 3, page 970.
[ "Compute", "and", "return", "geometric", "decay", "term", "in", "equation", "3", "page", "970", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/kale_2015.py#L140-L149
train
gem/oq-engine
openquake/hazardlib/gsim/kale_2015.py
KaleEtAl2015Turkey._compute_anelestic_attenuation_term
def _compute_anelestic_attenuation_term(self, C, dists): """ Compute and return anelastic attenuation term in equation 5, page 970. """ f_aat = np.zeros_like(dists.rjb) idx = dists.rjb > 80.0 f_aat[idx] = C["b10"] * (dists.rjb[idx] - 80.0) return f...
python
def _compute_anelestic_attenuation_term(self, C, dists): """ Compute and return anelastic attenuation term in equation 5, page 970. """ f_aat = np.zeros_like(dists.rjb) idx = dists.rjb > 80.0 f_aat[idx] = C["b10"] * (dists.rjb[idx] - 80.0) return f...
[ "def", "_compute_anelestic_attenuation_term", "(", "self", ",", "C", ",", "dists", ")", ":", "f_aat", "=", "np", ".", "zeros_like", "(", "dists", ".", "rjb", ")", "idx", "=", "dists", ".", "rjb", ">", "80.0", "f_aat", "[", "idx", "]", "=", "C", "[", ...
Compute and return anelastic attenuation term in equation 5, page 970.
[ "Compute", "and", "return", "anelastic", "attenuation", "term", "in", "equation", "5", "page", "970", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/kale_2015.py#L161-L169
train
gem/oq-engine
openquake/hazardlib/gsim/kale_2015.py
KaleEtAl2015Turkey._compute_non_linear_term
def _compute_non_linear_term(self, C, pga_only, sites): """ Compute non-linear term, equation 6, page 970. """ Vref = self.CONSTS['Vref'] Vcon = self.CONSTS['Vcon'] c = self.CONSTS['c'] n = self.CONSTS['n'] lnS = np.zeros_like(sites.vs30) ...
python
def _compute_non_linear_term(self, C, pga_only, sites): """ Compute non-linear term, equation 6, page 970. """ Vref = self.CONSTS['Vref'] Vcon = self.CONSTS['Vcon'] c = self.CONSTS['c'] n = self.CONSTS['n'] lnS = np.zeros_like(sites.vs30) ...
[ "def", "_compute_non_linear_term", "(", "self", ",", "C", ",", "pga_only", ",", "sites", ")", ":", "Vref", "=", "self", ".", "CONSTS", "[", "'Vref'", "]", "Vcon", "=", "self", ".", "CONSTS", "[", "'Vcon'", "]", "c", "=", "self", ".", "CONSTS", "[", ...
Compute non-linear term, equation 6, page 970.
[ "Compute", "non", "-", "linear", "term", "equation", "6", "page", "970", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/kale_2015.py#L171-L197
train
gem/oq-engine
openquake/hazardlib/gsim/kale_2015.py
KaleEtAl2015Turkey._compute_mean
def _compute_mean(self, C, mag, dists, rake): """ Compute and return mean value without site conditions, that is equations 2-5, page 970. """ mean = ( self._compute_magnitude_scaling_term(C, mag) + self._compute_geometric_decay_term(C, mag, dists) +...
python
def _compute_mean(self, C, mag, dists, rake): """ Compute and return mean value without site conditions, that is equations 2-5, page 970. """ mean = ( self._compute_magnitude_scaling_term(C, mag) + self._compute_geometric_decay_term(C, mag, dists) +...
[ "def", "_compute_mean", "(", "self", ",", "C", ",", "mag", ",", "dists", ",", "rake", ")", ":", "mean", "=", "(", "self", ".", "_compute_magnitude_scaling_term", "(", "C", ",", "mag", ")", "+", "self", ".", "_compute_geometric_decay_term", "(", "C", ",",...
Compute and return mean value without site conditions, that is equations 2-5, page 970.
[ "Compute", "and", "return", "mean", "value", "without", "site", "conditions", "that", "is", "equations", "2", "-", "5", "page", "970", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/kale_2015.py#L199-L211
train
gem/oq-engine
openquake/hazardlib/source/multi.py
MultiPointSource.get_bounding_box
def get_bounding_box(self, maxdist): """ Bounding box containing all the point sources, enlarged by the maximum distance. """ return utils.get_bounding_box([ps.location for ps in self], maxdist)
python
def get_bounding_box(self, maxdist): """ Bounding box containing all the point sources, enlarged by the maximum distance. """ return utils.get_bounding_box([ps.location for ps in self], maxdist)
[ "def", "get_bounding_box", "(", "self", ",", "maxdist", ")", ":", "return", "utils", ".", "get_bounding_box", "(", "[", "ps", ".", "location", "for", "ps", "in", "self", "]", ",", "maxdist", ")" ]
Bounding box containing all the point sources, enlarged by the maximum distance.
[ "Bounding", "box", "containing", "all", "the", "point", "sources", "enlarged", "by", "the", "maximum", "distance", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/source/multi.py#L109-L114
train
gem/oq-engine
openquake/hazardlib/gsim/pezeshk_2011.py
PezeshkEtAl2011._compute_standard_dev
def _compute_standard_dev(self, rup, imt, C): """ Compute the the standard deviation in terms of magnitude described on p. 1866, eq. 6 """ sigma_mean = 0. if rup.mag <= 7.0: sigma_mean = (C['c12'] * rup.mag) + C['c13'] elif rup.mag > 7.0: s...
python
def _compute_standard_dev(self, rup, imt, C): """ Compute the the standard deviation in terms of magnitude described on p. 1866, eq. 6 """ sigma_mean = 0. if rup.mag <= 7.0: sigma_mean = (C['c12'] * rup.mag) + C['c13'] elif rup.mag > 7.0: s...
[ "def", "_compute_standard_dev", "(", "self", ",", "rup", ",", "imt", ",", "C", ")", ":", "sigma_mean", "=", "0.", "if", "rup", ".", "mag", "<=", "7.0", ":", "sigma_mean", "=", "(", "C", "[", "'c12'", "]", "*", "rup", ".", "mag", ")", "+", "C", ...
Compute the the standard deviation in terms of magnitude described on p. 1866, eq. 6
[ "Compute", "the", "the", "standard", "deviation", "in", "terms", "of", "magnitude", "described", "on", "p", ".", "1866", "eq", ".", "6" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/pezeshk_2011.py#L158-L168
train
gem/oq-engine
openquake/hmtk/strain/shift.py
Shift.get_rate_osr_normal_transform
def get_rate_osr_normal_transform(self, threshold_moment, id0): ''' Gets seismicity rate for special case of the ridge condition with spreading and transform component :param float threshold_moment: Moment required for calculating activity rate :param np.ndarray id0...
python
def get_rate_osr_normal_transform(self, threshold_moment, id0): ''' Gets seismicity rate for special case of the ridge condition with spreading and transform component :param float threshold_moment: Moment required for calculating activity rate :param np.ndarray id0...
[ "def", "get_rate_osr_normal_transform", "(", "self", ",", "threshold_moment", ",", "id0", ")", ":", "e1h_ridge", "=", "np", ".", "zeros", "(", "np", ".", "sum", "(", "id0", ")", ",", "dtype", "=", "float", ")", "e2h_ridge", "=", "self", ".", "strain", ...
Gets seismicity rate for special case of the ridge condition with spreading and transform component :param float threshold_moment: Moment required for calculating activity rate :param np.ndarray id0: Logical vector indicating the cells to which this condition applies ...
[ "Gets", "seismicity", "rate", "for", "special", "case", "of", "the", "ridge", "condition", "with", "spreading", "and", "transform", "component" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/strain/shift.py#L369-L411
train
gem/oq-engine
openquake/hmtk/strain/shift.py
Shift.get_rate_osr_convergent_transform
def get_rate_osr_convergent_transform(self, threshold_moment, id0): ''' Calculates seismicity rate for special case of the ridge condition with convergence and transform :param float threshold_moment: Moment required for calculating activity rate :param np.ndarray i...
python
def get_rate_osr_convergent_transform(self, threshold_moment, id0): ''' Calculates seismicity rate for special case of the ridge condition with convergence and transform :param float threshold_moment: Moment required for calculating activity rate :param np.ndarray i...
[ "def", "get_rate_osr_convergent_transform", "(", "self", ",", "threshold_moment", ",", "id0", ")", ":", "e1h_ocb", "=", "self", ".", "strain", ".", "data", "[", "'e1h'", "]", "[", "id0", "]", "+", "self", ".", "strain", ".", "data", "[", "'e2h'", "]", ...
Calculates seismicity rate for special case of the ridge condition with convergence and transform :param float threshold_moment: Moment required for calculating activity rate :param np.ndarray id0: Logical vector indicating the cells to which this condition applies ...
[ "Calculates", "seismicity", "rate", "for", "special", "case", "of", "the", "ridge", "condition", "with", "convergence", "and", "transform" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/strain/shift.py#L413-L453
train
gem/oq-engine
openquake/hazardlib/scalerel/leonard2014.py
Leonard2014_SCR.get_median_area
def get_median_area(self, mag, rake): """ Calculates median fault area from magnitude. """ if rake is None: # Return average of strike-slip and dip-slip curves return power(10.0, (mag - 4.185)) elif (-45 <= rake <= 45) or (rake >= 135) or (rake <= -135): ...
python
def get_median_area(self, mag, rake): """ Calculates median fault area from magnitude. """ if rake is None: # Return average of strike-slip and dip-slip curves return power(10.0, (mag - 4.185)) elif (-45 <= rake <= 45) or (rake >= 135) or (rake <= -135): ...
[ "def", "get_median_area", "(", "self", ",", "mag", ",", "rake", ")", ":", "if", "rake", "is", "None", ":", "return", "power", "(", "10.0", ",", "(", "mag", "-", "4.185", ")", ")", "elif", "(", "-", "45", "<=", "rake", "<=", "45", ")", "or", "("...
Calculates median fault area from magnitude.
[ "Calculates", "median", "fault", "area", "from", "magnitude", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/scalerel/leonard2014.py#L36-L48
train
gem/oq-engine
openquake/server/views.py
_get_base_url
def _get_base_url(request): """ Construct a base URL, given a request object. This comprises the protocol prefix (http:// or https://) and the host, which can include the port number. For example: http://www.openquake.org or https://www.openquake.org:8000. """ if request.is_secure(): ...
python
def _get_base_url(request): """ Construct a base URL, given a request object. This comprises the protocol prefix (http:// or https://) and the host, which can include the port number. For example: http://www.openquake.org or https://www.openquake.org:8000. """ if request.is_secure(): ...
[ "def", "_get_base_url", "(", "request", ")", ":", "if", "request", ".", "is_secure", "(", ")", ":", "base_url", "=", "'https://%s'", "else", ":", "base_url", "=", "'http://%s'", "base_url", "%=", "request", ".", "META", "[", "'HTTP_HOST'", "]", "return", "...
Construct a base URL, given a request object. This comprises the protocol prefix (http:// or https://) and the host, which can include the port number. For example: http://www.openquake.org or https://www.openquake.org:8000.
[ "Construct", "a", "base", "URL", "given", "a", "request", "object", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/views.py#L108-L121
train
gem/oq-engine
openquake/server/views.py
_prepare_job
def _prepare_job(request, candidates): """ Creates a temporary directory, move uploaded files there and select the job file by looking at the candidate names. :returns: full path of the job_file """ temp_dir = tempfile.mkdtemp() inifiles = [] arch = request.FILES.get('archive') if a...
python
def _prepare_job(request, candidates): """ Creates a temporary directory, move uploaded files there and select the job file by looking at the candidate names. :returns: full path of the job_file """ temp_dir = tempfile.mkdtemp() inifiles = [] arch = request.FILES.get('archive') if a...
[ "def", "_prepare_job", "(", "request", ",", "candidates", ")", ":", "temp_dir", "=", "tempfile", ".", "mkdtemp", "(", ")", "inifiles", "=", "[", "]", "arch", "=", "request", ".", "FILES", ".", "get", "(", "'archive'", ")", "if", "arch", "is", "None", ...
Creates a temporary directory, move uploaded files there and select the job file by looking at the candidate names. :returns: full path of the job_file
[ "Creates", "a", "temporary", "directory", "move", "uploaded", "files", "there", "and", "select", "the", "job", "file", "by", "looking", "at", "the", "candidate", "names", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/views.py#L124-L144
train
gem/oq-engine
openquake/server/views.py
ajax_login
def ajax_login(request): """ Accept a POST request to login. :param request: `django.http.HttpRequest` object, containing mandatory parameters username and password required. """ username = request.POST['username'] password = request.POST['password'] user = authenticate(user...
python
def ajax_login(request): """ Accept a POST request to login. :param request: `django.http.HttpRequest` object, containing mandatory parameters username and password required. """ username = request.POST['username'] password = request.POST['password'] user = authenticate(user...
[ "def", "ajax_login", "(", "request", ")", ":", "username", "=", "request", ".", "POST", "[", "'username'", "]", "password", "=", "request", ".", "POST", "[", "'password'", "]", "user", "=", "authenticate", "(", "username", "=", "username", ",", "password",...
Accept a POST request to login. :param request: `django.http.HttpRequest` object, containing mandatory parameters username and password required.
[ "Accept", "a", "POST", "request", "to", "login", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/views.py#L150-L171
train
gem/oq-engine
openquake/server/views.py
get_available_gsims
def get_available_gsims(request): """ Return a list of strings with the available GSIMs """ gsims = list(gsim.get_available_gsims()) return HttpResponse(content=json.dumps(gsims), content_type=JSON)
python
def get_available_gsims(request): """ Return a list of strings with the available GSIMs """ gsims = list(gsim.get_available_gsims()) return HttpResponse(content=json.dumps(gsims), content_type=JSON)
[ "def", "get_available_gsims", "(", "request", ")", ":", "gsims", "=", "list", "(", "gsim", ".", "get_available_gsims", "(", ")", ")", "return", "HttpResponse", "(", "content", "=", "json", ".", "dumps", "(", "gsims", ")", ",", "content_type", "=", "JSON", ...
Return a list of strings with the available GSIMs
[ "Return", "a", "list", "of", "strings", "with", "the", "available", "GSIMs" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/views.py#L207-L212
train
gem/oq-engine
openquake/server/views.py
validate_nrml
def validate_nrml(request): """ Leverage oq-risklib to check if a given XML text is a valid NRML :param request: a `django.http.HttpRequest` object containing the mandatory parameter 'xml_text': the text of the XML to be validated as NRML :returns: a JSON object, containing: * ...
python
def validate_nrml(request): """ Leverage oq-risklib to check if a given XML text is a valid NRML :param request: a `django.http.HttpRequest` object containing the mandatory parameter 'xml_text': the text of the XML to be validated as NRML :returns: a JSON object, containing: * ...
[ "def", "validate_nrml", "(", "request", ")", ":", "xml_text", "=", "request", ".", "POST", ".", "get", "(", "'xml_text'", ")", "if", "not", "xml_text", ":", "return", "HttpResponseBadRequest", "(", "'Please provide the \"xml_text\" parameter'", ")", "xml_file", "=...
Leverage oq-risklib to check if a given XML text is a valid NRML :param request: a `django.http.HttpRequest` object containing the mandatory parameter 'xml_text': the text of the XML to be validated as NRML :returns: a JSON object, containing: * 'valid': a boolean indicating if the pro...
[ "Leverage", "oq", "-", "risklib", "to", "check", "if", "a", "given", "XML", "text", "is", "a", "valid", "NRML" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/views.py#L226-L276
train
gem/oq-engine
openquake/server/views.py
calc_list
def calc_list(request, id=None): # view associated to the endpoints /v1/calc/list and /v1/calc/:id/status """ Get a list of calculations and report their id, status, calculation_mode, is_running, description, and a url where more detailed information can be accessed. This is called several times by ...
python
def calc_list(request, id=None): # view associated to the endpoints /v1/calc/list and /v1/calc/:id/status """ Get a list of calculations and report their id, status, calculation_mode, is_running, description, and a url where more detailed information can be accessed. This is called several times by ...
[ "def", "calc_list", "(", "request", ",", "id", "=", "None", ")", ":", "base_url", "=", "_get_base_url", "(", "request", ")", "calc_data", "=", "logs", ".", "dbcmd", "(", "'get_calcs'", ",", "request", ".", "GET", ",", "utils", ".", "get_valid_users", "("...
Get a list of calculations and report their id, status, calculation_mode, is_running, description, and a url where more detailed information can be accessed. This is called several times by the Javascript. Responses are in JSON.
[ "Get", "a", "list", "of", "calculations", "and", "report", "their", "id", "status", "calculation_mode", "is_running", "description", "and", "a", "url", "where", "more", "detailed", "information", "can", "be", "accessed", ".", "This", "is", "called", "several", ...
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/views.py#L298-L335
train
gem/oq-engine
openquake/server/views.py
calc_abort
def calc_abort(request, calc_id): """ Abort the given calculation, it is it running """ job = logs.dbcmd('get_job', calc_id) if job is None: message = {'error': 'Unknown job %s' % calc_id} return HttpResponse(content=json.dumps(message), content_type=JSON) if job.status not in (...
python
def calc_abort(request, calc_id): """ Abort the given calculation, it is it running """ job = logs.dbcmd('get_job', calc_id) if job is None: message = {'error': 'Unknown job %s' % calc_id} return HttpResponse(content=json.dumps(message), content_type=JSON) if job.status not in (...
[ "def", "calc_abort", "(", "request", ",", "calc_id", ")", ":", "job", "=", "logs", ".", "dbcmd", "(", "'get_job'", ",", "calc_id", ")", "if", "job", "is", "None", ":", "message", "=", "{", "'error'", ":", "'Unknown job %s'", "%", "calc_id", "}", "retur...
Abort the given calculation, it is it running
[ "Abort", "the", "given", "calculation", "it", "is", "it", "running" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/views.py#L341-L372
train
gem/oq-engine
openquake/server/views.py
calc_remove
def calc_remove(request, calc_id): """ Remove the calculation id """ # Only the owner can remove a job user = utils.get_user(request) try: message = logs.dbcmd('del_calc', calc_id, user) except dbapi.NotFound: return HttpResponseNotFound() if 'success' in message: ...
python
def calc_remove(request, calc_id): """ Remove the calculation id """ # Only the owner can remove a job user = utils.get_user(request) try: message = logs.dbcmd('del_calc', calc_id, user) except dbapi.NotFound: return HttpResponseNotFound() if 'success' in message: ...
[ "def", "calc_remove", "(", "request", ",", "calc_id", ")", ":", "user", "=", "utils", ".", "get_user", "(", "request", ")", "try", ":", "message", "=", "logs", ".", "dbcmd", "(", "'del_calc'", ",", "calc_id", ",", "user", ")", "except", "dbapi", ".", ...
Remove the calculation id
[ "Remove", "the", "calculation", "id" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/views.py#L378-L400
train
gem/oq-engine
openquake/server/views.py
log_to_json
def log_to_json(log): """Convert a log record into a list of strings""" return [log.timestamp.isoformat()[:22], log.level, log.process, log.message]
python
def log_to_json(log): """Convert a log record into a list of strings""" return [log.timestamp.isoformat()[:22], log.level, log.process, log.message]
[ "def", "log_to_json", "(", "log", ")", ":", "return", "[", "log", ".", "timestamp", ".", "isoformat", "(", ")", "[", ":", "22", "]", ",", "log", ".", "level", ",", "log", ".", "process", ",", "log", ".", "message", "]" ]
Convert a log record into a list of strings
[ "Convert", "a", "log", "record", "into", "a", "list", "of", "strings" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/views.py#L403-L406
train
gem/oq-engine
openquake/server/views.py
calc_log_size
def calc_log_size(request, calc_id): """ Get the current number of lines in the log """ try: response_data = logs.dbcmd('get_log_size', calc_id) except dbapi.NotFound: return HttpResponseNotFound() return HttpResponse(content=json.dumps(response_data), content_type=JSON)
python
def calc_log_size(request, calc_id): """ Get the current number of lines in the log """ try: response_data = logs.dbcmd('get_log_size', calc_id) except dbapi.NotFound: return HttpResponseNotFound() return HttpResponse(content=json.dumps(response_data), content_type=JSON)
[ "def", "calc_log_size", "(", "request", ",", "calc_id", ")", ":", "try", ":", "response_data", "=", "logs", ".", "dbcmd", "(", "'get_log_size'", ",", "calc_id", ")", "except", "dbapi", ".", "NotFound", ":", "return", "HttpResponseNotFound", "(", ")", "return...
Get the current number of lines in the log
[ "Get", "the", "current", "number", "of", "lines", "in", "the", "log" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/views.py#L426-L434
train
gem/oq-engine
openquake/server/views.py
submit_job
def submit_job(job_ini, username, hazard_job_id=None): """ Create a job object from the given job.ini file in the job directory and run it in a new process. Returns the job ID and PID. """ job_id = logs.init('job') oq = engine.job_from_file( job_ini, job_id, username, hazard_calculation_...
python
def submit_job(job_ini, username, hazard_job_id=None): """ Create a job object from the given job.ini file in the job directory and run it in a new process. Returns the job ID and PID. """ job_id = logs.init('job') oq = engine.job_from_file( job_ini, job_id, username, hazard_calculation_...
[ "def", "submit_job", "(", "job_ini", ",", "username", ",", "hazard_job_id", "=", "None", ")", ":", "job_id", "=", "logs", ".", "init", "(", "'job'", ")", "oq", "=", "engine", ".", "job_from_file", "(", "job_ini", ",", "job_id", ",", "username", ",", "h...
Create a job object from the given job.ini file in the job directory and run it in a new process. Returns the job ID and PID.
[ "Create", "a", "job", "object", "from", "the", "given", "job", ".", "ini", "file", "in", "the", "job", "directory", "and", "run", "it", "in", "a", "new", "process", ".", "Returns", "the", "job", "ID", "and", "PID", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/views.py#L502-L520
train
gem/oq-engine
openquake/server/views.py
calc_result
def calc_result(request, result_id): """ Download a specific result, by ``result_id``. The common abstracted functionality for getting hazard or risk results. :param request: `django.http.HttpRequest` object. Can contain a `export_type` GET param (the default is 'xml' if no param is sp...
python
def calc_result(request, result_id): """ Download a specific result, by ``result_id``. The common abstracted functionality for getting hazard or risk results. :param request: `django.http.HttpRequest` object. Can contain a `export_type` GET param (the default is 'xml' if no param is sp...
[ "def", "calc_result", "(", "request", ",", "result_id", ")", ":", "try", ":", "job_id", ",", "job_status", ",", "job_user", ",", "datadir", ",", "ds_key", "=", "logs", ".", "dbcmd", "(", "'get_result'", ",", "result_id", ")", "if", "not", "utils", ".", ...
Download a specific result, by ``result_id``. The common abstracted functionality for getting hazard or risk results. :param request: `django.http.HttpRequest` object. Can contain a `export_type` GET param (the default is 'xml' if no param is specified). :param result_id: The id of...
[ "Download", "a", "specific", "result", "by", "result_id", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/views.py#L587-L653
train
gem/oq-engine
openquake/server/views.py
extract
def extract(request, calc_id, what): """ Wrapper over the `oq extract` command. If `setting.LOCKDOWN` is true only calculations owned by the current user can be retrieved. """ job = logs.dbcmd('get_job', int(calc_id)) if job is None: return HttpResponseNotFound() if not utils.user_ha...
python
def extract(request, calc_id, what): """ Wrapper over the `oq extract` command. If `setting.LOCKDOWN` is true only calculations owned by the current user can be retrieved. """ job = logs.dbcmd('get_job', int(calc_id)) if job is None: return HttpResponseNotFound() if not utils.user_ha...
[ "def", "extract", "(", "request", ",", "calc_id", ",", "what", ")", ":", "job", "=", "logs", ".", "dbcmd", "(", "'get_job'", ",", "int", "(", "calc_id", ")", ")", "if", "job", "is", "None", ":", "return", "HttpResponseNotFound", "(", ")", "if", "not"...
Wrapper over the `oq extract` command. If `setting.LOCKDOWN` is true only calculations owned by the current user can be retrieved.
[ "Wrapper", "over", "the", "oq", "extract", "command", ".", "If", "setting", ".", "LOCKDOWN", "is", "true", "only", "calculations", "owned", "by", "the", "current", "user", "can", "be", "retrieved", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/views.py#L658-L703
train
gem/oq-engine
openquake/server/views.py
calc_datastore
def calc_datastore(request, job_id): """ Download a full datastore file. :param request: `django.http.HttpRequest` object. :param job_id: The id of the requested datastore :returns: A `django.http.HttpResponse` containing the content of the requested artifact, if pre...
python
def calc_datastore(request, job_id): """ Download a full datastore file. :param request: `django.http.HttpRequest` object. :param job_id: The id of the requested datastore :returns: A `django.http.HttpResponse` containing the content of the requested artifact, if pre...
[ "def", "calc_datastore", "(", "request", ",", "job_id", ")", ":", "job", "=", "logs", ".", "dbcmd", "(", "'get_job'", ",", "int", "(", "job_id", ")", ")", "if", "job", "is", "None", ":", "return", "HttpResponseNotFound", "(", ")", "if", "not", "utils",...
Download a full datastore file. :param request: `django.http.HttpRequest` object. :param job_id: The id of the requested datastore :returns: A `django.http.HttpResponse` containing the content of the requested artifact, if present, else throws a 404
[ "Download", "a", "full", "datastore", "file", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/views.py#L708-L732
train
gem/oq-engine
openquake/server/views.py
calc_oqparam
def calc_oqparam(request, job_id): """ Return the calculation parameters as a JSON """ job = logs.dbcmd('get_job', int(job_id)) if job is None: return HttpResponseNotFound() if not utils.user_has_permission(request, job.user_name): return HttpResponseForbidden() with datasto...
python
def calc_oqparam(request, job_id): """ Return the calculation parameters as a JSON """ job = logs.dbcmd('get_job', int(job_id)) if job is None: return HttpResponseNotFound() if not utils.user_has_permission(request, job.user_name): return HttpResponseForbidden() with datasto...
[ "def", "calc_oqparam", "(", "request", ",", "job_id", ")", ":", "job", "=", "logs", ".", "dbcmd", "(", "'get_job'", ",", "int", "(", "job_id", ")", ")", "if", "job", "is", "None", ":", "return", "HttpResponseNotFound", "(", ")", "if", "not", "utils", ...
Return the calculation parameters as a JSON
[ "Return", "the", "calculation", "parameters", "as", "a", "JSON" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/views.py#L737-L749
train
gem/oq-engine
openquake/server/views.py
on_same_fs
def on_same_fs(request): """ Accept a POST request to check access to a FS available by a client. :param request: `django.http.HttpRequest` object, containing mandatory parameters filename and checksum. """ filename = request.POST['filename'] checksum_in = request.POST['checksum...
python
def on_same_fs(request): """ Accept a POST request to check access to a FS available by a client. :param request: `django.http.HttpRequest` object, containing mandatory parameters filename and checksum. """ filename = request.POST['filename'] checksum_in = request.POST['checksum...
[ "def", "on_same_fs", "(", "request", ")", ":", "filename", "=", "request", ".", "POST", "[", "'filename'", "]", "checksum_in", "=", "request", ".", "POST", "[", "'checksum'", "]", "checksum", "=", "0", "try", ":", "data", "=", "open", "(", "filename", ...
Accept a POST request to check access to a FS available by a client. :param request: `django.http.HttpRequest` object, containing mandatory parameters filename and checksum.
[ "Accept", "a", "POST", "request", "to", "check", "access", "to", "a", "FS", "available", "by", "a", "client", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/views.py#L769-L791
train
gem/oq-engine
openquake/calculators/classical_damage.py
classical_damage
def classical_damage(riskinputs, riskmodel, param, monitor): """ Core function for a classical damage computation. :param riskinputs: :class:`openquake.risklib.riskinput.RiskInput` objects :param riskmodel: a :class:`openquake.risklib.riskinput.CompositeRiskModel` instance :param pa...
python
def classical_damage(riskinputs, riskmodel, param, monitor): """ Core function for a classical damage computation. :param riskinputs: :class:`openquake.risklib.riskinput.RiskInput` objects :param riskmodel: a :class:`openquake.risklib.riskinput.CompositeRiskModel` instance :param pa...
[ "def", "classical_damage", "(", "riskinputs", ",", "riskmodel", ",", "param", ",", "monitor", ")", ":", "result", "=", "AccumDict", "(", "accum", "=", "AccumDict", "(", ")", ")", "for", "ri", "in", "riskinputs", ":", "for", "out", "in", "riskmodel", ".",...
Core function for a classical damage computation. :param riskinputs: :class:`openquake.risklib.riskinput.RiskInput` objects :param riskmodel: a :class:`openquake.risklib.riskinput.CompositeRiskModel` instance :param param: dictionary of extra parameters :param monitor: :...
[ "Core", "function", "for", "a", "classical", "damage", "computation", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/classical_damage.py#L26-L47
train
gem/oq-engine
openquake/hmtk/seismicity/gcmt_catalogue.py
cmp_mat
def cmp_mat(a, b): """ Sorts two matrices returning a positive or zero value """ c = 0 for x, y in zip(a.flat, b.flat): c = cmp(abs(x), abs(y)) if c != 0: return c return c
python
def cmp_mat(a, b): """ Sorts two matrices returning a positive or zero value """ c = 0 for x, y in zip(a.flat, b.flat): c = cmp(abs(x), abs(y)) if c != 0: return c return c
[ "def", "cmp_mat", "(", "a", ",", "b", ")", ":", "c", "=", "0", "for", "x", ",", "y", "in", "zip", "(", "a", ".", "flat", ",", "b", ".", "flat", ")", ":", "c", "=", "cmp", "(", "abs", "(", "x", ")", ",", "abs", "(", "y", ")", ")", "if"...
Sorts two matrices returning a positive or zero value
[ "Sorts", "two", "matrices", "returning", "a", "positive", "or", "zero", "value" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/gcmt_catalogue.py#L62-L71
train
gem/oq-engine
openquake/hmtk/seismicity/gcmt_catalogue.py
GCMTCentroid._get_centroid_time
def _get_centroid_time(self, time_diff): """ Calculates the time difference between the date-time classes """ source_time = datetime.datetime.combine(self.date, self.time) second_diff = floor(fabs(time_diff)) microsecond_diff = int(1000. * (time_diff - second_diff)) ...
python
def _get_centroid_time(self, time_diff): """ Calculates the time difference between the date-time classes """ source_time = datetime.datetime.combine(self.date, self.time) second_diff = floor(fabs(time_diff)) microsecond_diff = int(1000. * (time_diff - second_diff)) ...
[ "def", "_get_centroid_time", "(", "self", ",", "time_diff", ")", ":", "source_time", "=", "datetime", ".", "datetime", ".", "combine", "(", "self", ".", "date", ",", "self", ".", "time", ")", "second_diff", "=", "floor", "(", "fabs", "(", "time_diff", ")...
Calculates the time difference between the date-time classes
[ "Calculates", "the", "time", "difference", "between", "the", "date", "-", "time", "classes" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/gcmt_catalogue.py#L120-L134
train
gem/oq-engine
openquake/hmtk/seismicity/gcmt_catalogue.py
GCMTMomentTensor._to_ned
def _to_ned(self): """ Switches the reference frame to NED """ if self.ref_frame is 'USE': # Rotate return utils.use_to_ned(self.tensor), \ utils.use_to_ned(self.tensor_sigma) elif self.ref_frame is 'NED': # Alreadt NED ...
python
def _to_ned(self): """ Switches the reference frame to NED """ if self.ref_frame is 'USE': # Rotate return utils.use_to_ned(self.tensor), \ utils.use_to_ned(self.tensor_sigma) elif self.ref_frame is 'NED': # Alreadt NED ...
[ "def", "_to_ned", "(", "self", ")", ":", "if", "self", ".", "ref_frame", "is", "'USE'", ":", "return", "utils", ".", "use_to_ned", "(", "self", ".", "tensor", ")", ",", "utils", ".", "use_to_ned", "(", "self", ".", "tensor_sigma", ")", "elif", "self", ...
Switches the reference frame to NED
[ "Switches", "the", "reference", "frame", "to", "NED" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/gcmt_catalogue.py#L193-L206
train
gem/oq-engine
openquake/hmtk/seismicity/gcmt_catalogue.py
GCMTMomentTensor._to_use
def _to_use(self): """ Returns a tensor in the USE reference frame """ if self.ref_frame is 'NED': # Rotate return utils.ned_to_use(self.tensor), \ utils.ned_to_use(self.tensor_sigma) elif self.ref_frame is 'USE': # Already USE ...
python
def _to_use(self): """ Returns a tensor in the USE reference frame """ if self.ref_frame is 'NED': # Rotate return utils.ned_to_use(self.tensor), \ utils.ned_to_use(self.tensor_sigma) elif self.ref_frame is 'USE': # Already USE ...
[ "def", "_to_use", "(", "self", ")", ":", "if", "self", ".", "ref_frame", "is", "'NED'", ":", "return", "utils", ".", "ned_to_use", "(", "self", ".", "tensor", ")", ",", "utils", ".", "ned_to_use", "(", "self", ".", "tensor_sigma", ")", "elif", "self", ...
Returns a tensor in the USE reference frame
[ "Returns", "a", "tensor", "in", "the", "USE", "reference", "frame" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/gcmt_catalogue.py#L208-L221
train
gem/oq-engine
openquake/hmtk/seismicity/gcmt_catalogue.py
GCMTMomentTensor.get_nodal_planes
def get_nodal_planes(self): """ Returns the nodal planes by eigendecomposition of the moment tensor """ # Convert reference frame to NED self.tensor, self.tensor_sigma = self._to_ned() self.ref_frame = 'NED' # Eigenvalue decomposition # Tensor _, e...
python
def get_nodal_planes(self): """ Returns the nodal planes by eigendecomposition of the moment tensor """ # Convert reference frame to NED self.tensor, self.tensor_sigma = self._to_ned() self.ref_frame = 'NED' # Eigenvalue decomposition # Tensor _, e...
[ "def", "get_nodal_planes", "(", "self", ")", ":", "self", ".", "tensor", ",", "self", ".", "tensor_sigma", "=", "self", ".", "_to_ned", "(", ")", "self", ".", "ref_frame", "=", "'NED'", "_", ",", "evect", "=", "utils", ".", "eigendecompose", "(", "self...
Returns the nodal planes by eigendecomposition of the moment tensor
[ "Returns", "the", "nodal", "planes", "by", "eigendecomposition", "of", "the", "moment", "tensor" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/gcmt_catalogue.py#L239-L276
train
gem/oq-engine
openquake/hmtk/seismicity/gcmt_catalogue.py
GCMTMomentTensor.get_principal_axes
def get_principal_axes(self): """ Uses the eigendecomposition to extract the principal axes from the moment tensor - returning an instance of the GCMTPrincipalAxes class """ # Perform eigendecomposition - returns in order P, B, T _ = self.eigendecompose(normalise=True) ...
python
def get_principal_axes(self): """ Uses the eigendecomposition to extract the principal axes from the moment tensor - returning an instance of the GCMTPrincipalAxes class """ # Perform eigendecomposition - returns in order P, B, T _ = self.eigendecompose(normalise=True) ...
[ "def", "get_principal_axes", "(", "self", ")", ":", "_", "=", "self", ".", "eigendecompose", "(", "normalise", "=", "True", ")", "principal_axes", "=", "GCMTPrincipalAxes", "(", ")", "principal_axes", ".", "p_axis", "=", "{", "'eigenvalue'", ":", "self", "."...
Uses the eigendecomposition to extract the principal axes from the moment tensor - returning an instance of the GCMTPrincipalAxes class
[ "Uses", "the", "eigendecomposition", "to", "extract", "the", "principal", "axes", "from", "the", "moment", "tensor", "-", "returning", "an", "instance", "of", "the", "GCMTPrincipalAxes", "class" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/gcmt_catalogue.py#L278-L303
train
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" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/gcmt_catalogue.py#L424-L445
train
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" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L137-L159
train
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", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L161-L172
train
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", ")", ":", "dists", "=", "numpy", ".", "array", "(", "[", "surf", ".", "get_min_distance", "(", "mesh", ")", ".", "flatten", "(", ")", "for", "surf", "in", "self", ".", "surfaces", "]", ")", "idx"...
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", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L174-L216
train
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", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L291-L307
train
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", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L350-L360
train
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", ")", ":", "edge_sets", "=", "numpy", ".", "vstack", "(", "self", ".", "edge_set", ")", "west", ",", "east", ",", "north", ",", "south", "=", "utils", ".", "get_spherical_bounding_box", "(", "edge_sets", "[", "...
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", ...
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L362-L392
train
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", ")", ":", "rup_gc2t", ",", "rup_gc2u", "=", "self", ".", "get_generalised_coordinates", "(", "edge_sets", "[", ":", ",", "0", "]", ",", "edge_sets", "[", ":", ",", "1", "]", ")", "se...
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" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L454-L464
train
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" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L466-L489
train
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", "not", "self", ".", "tmp_mesh", "or", "(", "self", ".", "tmp_mesh", "==", "mesh", ")", ":", "self", ".", "gc2t", ",", "self", ".", "gc2u", "=", "self", ".", "get_generalised_coordinate...
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", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L570-L588
train
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", "not", "self", ".", "tmp_mesh", "or", "(", "self", ".", "tmp_mesh", "==", "mesh", ")", ":", "self", ".", "gc2t", ",", "self", ".", "gc2u", "=", "self", ".", "get_generalised_coordinat...
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", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L590-L622
train
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" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/comparison/rate_grids.py#L114-L144
train
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" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/comparison/rate_grids.py#L152-L178
train
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" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/comparison/rate_grids.py#L180-L200
train
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" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/comparison/rate_grids.py#L231-L242
train
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" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/megawati_pan_2010.py#L98-L102
train
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", ")", ":", "rval", "=", "np", ".", "sqrt", "(", "rjb", "**", "2.0", "+", "C", "[", "\"c11\"", "]", "**", "2.0", ")", "f_0", ",", "f_1", ",", "f_2", "=", "self", ...
Returns the distance scaling component of the model Equation 10, Page 63
[ "Returns", "the", "distance", "scaling", "component", "of", "the", "model", "Equation", "10", "Page", "63" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/rietbrock_2013.py#L109-L120
train
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", ")", ":", "nsites", "=", "len", "(", "rval", ")", "f_0", "=", "np", ".", "log10", "(", "self", ".", "CONSTS", "[", "\"r0\"", "]", "/", "rval", ")", "f_0", "[", "rval", ">", "self"...
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" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/rietbrock_2013.py#L122-L139
train
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", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L69-L84
train
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", ".", ...
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L87-L101
train
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", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L152-L191
train
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", ")", ":", "from", "openquake", ".", "calculators", "import", "base", "OqParam", ".", ...
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", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L194-L233
train
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", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L342-L386
train
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", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L389-L439
train
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" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L498-L514
train
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", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L816-L892
train
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", "(", ")", "ncols", "=", "len", "(", "imtls", ")", "+", "1", "csvfile", "=", "oqparam", ".", "input...
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", "...", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L1212-L1247
train
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" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L1251-L1292
train
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", ")", ":", "checksum", "=", "0", "for", "fname", "in", "get_input_files", "(", "oqparam", ",", "hazard", ")", ":", "checksum", "=", "_checksum", "(", "fname", ",", "checksum", ")", "if"...
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", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L1388-L1415
train
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" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/dump.py#L28-L45
train
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", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/dump.py#L49-L77
train
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" ]
3d0f5f4dc5d9dc899a57626e8d8a125fc28b8324
https://github.com/conan-io/conan-package-tools/blob/3d0f5f4dc5d9dc899a57626e8d8a125fc28b8324/setup.py#L25-L32
train
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" ]
3d0f5f4dc5d9dc899a57626e8d8a125fc28b8324
https://github.com/conan-io/conan-package-tools/blob/3d0f5f4dc5d9dc899a57626e8d8a125fc28b8324/cpt/packager.py#L357-L371
train
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", ":", "if", "Version", "(", "conan_version", ")", "<", "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" ]
3d0f5f4dc5d9dc899a57626e8d8a125fc28b8324
https://github.com/conan-io/conan-package-tools/blob/3d0f5f4dc5d9dc899a57626e8d8a125fc28b8324/cpt/profiles.py#L51-L68
train
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", ".", "ge...
Return a User with the given username iff the User exists.
[ "Return", "a", "User", "with", "the", "given", "username", "iff", "the", "User", "exists", "." ]
493f93e9d87d0237f0fea6d75c7b70646ad6d31e
https://github.com/edx/auth-backends/blob/493f93e9d87d0237f0fea6d75c7b70646ad6d31e/auth_backends/pipeline.py#L14-L31
train
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", ".", "emai...
Update the user's email address using data from provider.
[ "Update", "the", "user", "s", "email", "address", "using", "data", "from", "provider", "." ]
493f93e9d87d0237f0fea6d75c7b70646ad6d31e
https://github.com/edx/auth-backends/blob/493f93e9d87d0237f0fea6d75c7b70646ad6d31e/auth_backends/pipeline.py#L34-L41
train
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", "." ]
493f93e9d87d0237f0fea6d75c7b70646ad6d31e
https://github.com/edx/auth-backends/blob/493f93e9d87d0237f0fea6d75c7b70646ad6d31e/auth_backends/backends.py#L170-L181
train
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", "(", ")", "self", ".", "sub", "=", "self", ".", "ctx", ".", "socket"...
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", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/server.py#L55-L90
train
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", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/server.py#L92-L104
train
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" ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/server.py#L106-L146
train
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" ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/server.py#L150-L191
train
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", "(", ")", ":", "log", ".", "debug", "(", "'Matching under %s'", ",", "dev_os", ")", "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", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/server.py#L193-L215
train
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", "(", ")", "log", ".", "debug", "(", "'Creating the dealer IPC for %s'", ",", "self", ".", "_name", ")", "self", ".", "sub", "=", "self", ".", "ctx", ".", "soc...
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", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/device.py#L52-L82
train
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" ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/device.py#L84-L138
train
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", "for", "message", "in", "self", ".", "compiled_messages", ":", "match_on", "=", "message", "[", "'match_on'", "]", "if", "match_on", "not", "in", "msg_dict", ":", "cont...
Parse a syslog message and check what OpenConfig object should be generated.
[ "Parse", "a", "syslog", "message", "and", "check", "what", "OpenConfig", "object", "should", "be", "generated", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/device.py#L140-L186
train
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", "[", "r...
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", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/device.py#L188-L200
train