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/hazardlib/sourcewriter.py
build_truncated_gr_mfd
def build_truncated_gr_mfd(mfd): """ Parses the truncated Gutenberg Richter MFD as a Node :param mfd: MFD as instance of :class: `openquake.hazardlib.mfd.truncated_gr.TruncatedGRMFD` :returns: Instance of :class:`openquake.baselib.node.Node` """ return Node("truncGutenbe...
python
def build_truncated_gr_mfd(mfd): """ Parses the truncated Gutenberg Richter MFD as a Node :param mfd: MFD as instance of :class: `openquake.hazardlib.mfd.truncated_gr.TruncatedGRMFD` :returns: Instance of :class:`openquake.baselib.node.Node` """ return Node("truncGutenbe...
[ "def", "build_truncated_gr_mfd", "(", "mfd", ")", ":", "return", "Node", "(", "\"truncGutenbergRichterMFD\"", ",", "{", "\"aValue\"", ":", "mfd", ".", "a_val", ",", "\"bValue\"", ":", "mfd", ".", "b_val", ",", "\"minMag\"", ":", "mfd", ".", "min_mag", ",", ...
Parses the truncated Gutenberg Richter MFD as a Node :param mfd: MFD as instance of :class: `openquake.hazardlib.mfd.truncated_gr.TruncatedGRMFD` :returns: Instance of :class:`openquake.baselib.node.Node`
[ "Parses", "the", "truncated", "Gutenberg", "Richter", "MFD", "as", "a", "Node" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourcewriter.py#L173-L185
train
gem/oq-engine
openquake/hazardlib/sourcewriter.py
build_arbitrary_mfd
def build_arbitrary_mfd(mfd): """ Parses the arbitrary MFD as a Node :param mfd: MFD as instance of :class: `openquake.hazardlib.mfd.arbitrary.ArbitraryMFD` :returns: Instance of :class:`openquake.baselib.node.Node` """ magnitudes = Node("magnitudes", text=mfd.magnitudes...
python
def build_arbitrary_mfd(mfd): """ Parses the arbitrary MFD as a Node :param mfd: MFD as instance of :class: `openquake.hazardlib.mfd.arbitrary.ArbitraryMFD` :returns: Instance of :class:`openquake.baselib.node.Node` """ magnitudes = Node("magnitudes", text=mfd.magnitudes...
[ "def", "build_arbitrary_mfd", "(", "mfd", ")", ":", "magnitudes", "=", "Node", "(", "\"magnitudes\"", ",", "text", "=", "mfd", ".", "magnitudes", ")", "occur_rates", "=", "Node", "(", "\"occurRates\"", ",", "text", "=", "mfd", ".", "occurrence_rates", ")", ...
Parses the arbitrary MFD as a Node :param mfd: MFD as instance of :class: `openquake.hazardlib.mfd.arbitrary.ArbitraryMFD` :returns: Instance of :class:`openquake.baselib.node.Node`
[ "Parses", "the", "arbitrary", "MFD", "as", "a", "Node" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourcewriter.py#L189-L201
train
gem/oq-engine
openquake/hazardlib/sourcewriter.py
build_youngs_coppersmith_mfd
def build_youngs_coppersmith_mfd(mfd): """ Parses the Youngs & Coppersmith MFD as a node. Note that the MFD does not hold the total moment rate, but only the characteristic rate. Therefore the node is written to the characteristic rate version regardless of whether or not it was originally created f...
python
def build_youngs_coppersmith_mfd(mfd): """ Parses the Youngs & Coppersmith MFD as a node. Note that the MFD does not hold the total moment rate, but only the characteristic rate. Therefore the node is written to the characteristic rate version regardless of whether or not it was originally created f...
[ "def", "build_youngs_coppersmith_mfd", "(", "mfd", ")", ":", "return", "Node", "(", "\"YoungsCoppersmithMFD\"", ",", "{", "\"minMag\"", ":", "mfd", ".", "min_mag", ",", "\"bValue\"", ":", "mfd", ".", "b_val", ",", "\"characteristicMag\"", ":", "mfd", ".", "cha...
Parses the Youngs & Coppersmith MFD as a node. Note that the MFD does not hold the total moment rate, but only the characteristic rate. Therefore the node is written to the characteristic rate version regardless of whether or not it was originally created from total moment rate :param mfd: MFD ...
[ "Parses", "the", "Youngs", "&", "Coppersmith", "MFD", "as", "a", "node", ".", "Note", "that", "the", "MFD", "does", "not", "hold", "the", "total", "moment", "rate", "but", "only", "the", "characteristic", "rate", ".", "Therefore", "the", "node", "is", "w...
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourcewriter.py#L205-L223
train
gem/oq-engine
openquake/hazardlib/sourcewriter.py
build_multi_mfd
def build_multi_mfd(mfd): """ Parses the MultiMFD as a Node :param mfd: MFD as instance of :class: `openquake.hazardlib.mfd.multi_mfd.MultiMFD` :returns: Instance of :class:`openquake.baselib.node.Node` """ node = Node("multiMFD", dict(kind=mfd.kind, size=mfd.size)) ...
python
def build_multi_mfd(mfd): """ Parses the MultiMFD as a Node :param mfd: MFD as instance of :class: `openquake.hazardlib.mfd.multi_mfd.MultiMFD` :returns: Instance of :class:`openquake.baselib.node.Node` """ node = Node("multiMFD", dict(kind=mfd.kind, size=mfd.size)) ...
[ "def", "build_multi_mfd", "(", "mfd", ")", ":", "node", "=", "Node", "(", "\"multiMFD\"", ",", "dict", "(", "kind", "=", "mfd", ".", "kind", ",", "size", "=", "mfd", ".", "size", ")", ")", "for", "name", "in", "sorted", "(", "mfd", ".", "kwargs", ...
Parses the MultiMFD as a Node :param mfd: MFD as instance of :class: `openquake.hazardlib.mfd.multi_mfd.MultiMFD` :returns: Instance of :class:`openquake.baselib.node.Node`
[ "Parses", "the", "MultiMFD", "as", "a", "Node" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourcewriter.py#L227-L249
train
gem/oq-engine
openquake/hazardlib/sourcewriter.py
build_nodal_plane_dist
def build_nodal_plane_dist(npd): """ Returns the nodal plane distribution as a Node instance :param npd: Nodal plane distribution as instance of :class: `openquake.hazardlib.pmf.PMF` :returns: Instance of :class:`openquake.baselib.node.Node` """ npds = [] for prob, n...
python
def build_nodal_plane_dist(npd): """ Returns the nodal plane distribution as a Node instance :param npd: Nodal plane distribution as instance of :class: `openquake.hazardlib.pmf.PMF` :returns: Instance of :class:`openquake.baselib.node.Node` """ npds = [] for prob, n...
[ "def", "build_nodal_plane_dist", "(", "npd", ")", ":", "npds", "=", "[", "]", "for", "prob", ",", "npd", "in", "npd", ".", "data", ":", "nodal_plane", "=", "Node", "(", "\"nodalPlane\"", ",", "{", "\"dip\"", ":", "npd", ".", "dip", ",", "\"probability\...
Returns the nodal plane distribution as a Node instance :param npd: Nodal plane distribution as instance of :class: `openquake.hazardlib.pmf.PMF` :returns: Instance of :class:`openquake.baselib.node.Node`
[ "Returns", "the", "nodal", "plane", "distribution", "as", "a", "Node", "instance" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourcewriter.py#L252-L268
train
gem/oq-engine
openquake/hazardlib/sourcewriter.py
build_hypo_depth_dist
def build_hypo_depth_dist(hdd): """ Returns the hypocentral depth distribution as a Node instance :param hdd: Hypocentral depth distribution as an instance of :class: `openquake.hzardlib.pmf.PMF` :returns: Instance of :class:`openquake.baselib.node.Node` """ hdds = [] ...
python
def build_hypo_depth_dist(hdd): """ Returns the hypocentral depth distribution as a Node instance :param hdd: Hypocentral depth distribution as an instance of :class: `openquake.hzardlib.pmf.PMF` :returns: Instance of :class:`openquake.baselib.node.Node` """ hdds = [] ...
[ "def", "build_hypo_depth_dist", "(", "hdd", ")", ":", "hdds", "=", "[", "]", "for", "(", "prob", ",", "depth", ")", "in", "hdd", ".", "data", ":", "hdds", ".", "append", "(", "Node", "(", "\"hypoDepth\"", ",", "{", "\"depth\"", ":", "depth", ",", "...
Returns the hypocentral depth distribution as a Node instance :param hdd: Hypocentral depth distribution as an instance of :class: `openquake.hzardlib.pmf.PMF` :returns: Instance of :class:`openquake.baselib.node.Node`
[ "Returns", "the", "hypocentral", "depth", "distribution", "as", "a", "Node", "instance" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourcewriter.py#L271-L285
train
gem/oq-engine
openquake/hazardlib/sourcewriter.py
get_distributed_seismicity_source_nodes
def get_distributed_seismicity_source_nodes(source): """ Returns list of nodes of attributes common to all distributed seismicity source classes :param source: Seismic source as instance of :class: `openquake.hazardlib.source.area.AreaSource` or :class: `openquake.hazardlib.sour...
python
def get_distributed_seismicity_source_nodes(source): """ Returns list of nodes of attributes common to all distributed seismicity source classes :param source: Seismic source as instance of :class: `openquake.hazardlib.source.area.AreaSource` or :class: `openquake.hazardlib.sour...
[ "def", "get_distributed_seismicity_source_nodes", "(", "source", ")", ":", "source_nodes", "=", "[", "]", "source_nodes", ".", "append", "(", "Node", "(", "\"magScaleRel\"", ",", "text", "=", "source", ".", "magnitude_scaling_relationship", ".", "__class__", ".", ...
Returns list of nodes of attributes common to all distributed seismicity source classes :param source: Seismic source as instance of :class: `openquake.hazardlib.source.area.AreaSource` or :class: `openquake.hazardlib.source.point.PointSource` :returns: List of instances of ...
[ "Returns", "list", "of", "nodes", "of", "attributes", "common", "to", "all", "distributed", "seismicity", "source", "classes" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourcewriter.py#L288-L316
train
gem/oq-engine
openquake/hazardlib/sourcewriter.py
get_fault_source_nodes
def get_fault_source_nodes(source): """ Returns list of nodes of attributes common to all fault source classes :param source: Fault source as instance of :class: `openquake.hazardlib.source.simple_fault.SimpleFaultSource` or :class: `openquake.hazardlib.source.complex_fault.ComplexF...
python
def get_fault_source_nodes(source): """ Returns list of nodes of attributes common to all fault source classes :param source: Fault source as instance of :class: `openquake.hazardlib.source.simple_fault.SimpleFaultSource` or :class: `openquake.hazardlib.source.complex_fault.ComplexF...
[ "def", "get_fault_source_nodes", "(", "source", ")", ":", "source_nodes", "=", "[", "]", "source_nodes", ".", "append", "(", "Node", "(", "\"magScaleRel\"", ",", "text", "=", "source", ".", "magnitude_scaling_relationship", ".", "__class__", ".", "__name__", ")"...
Returns list of nodes of attributes common to all fault source classes :param source: Fault source as instance of :class: `openquake.hazardlib.source.simple_fault.SimpleFaultSource` or :class: `openquake.hazardlib.source.complex_fault.ComplexFaultSource` :returns: List of instan...
[ "Returns", "list", "of", "nodes", "of", "attributes", "common", "to", "all", "fault", "source", "classes" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourcewriter.py#L348-L376
train
gem/oq-engine
openquake/hazardlib/sourcewriter.py
get_source_attributes
def get_source_attributes(source): """ Retreives a dictionary of source attributes from the source class :param source: Seismic source as instance of :class: `openquake.hazardlib.source.base.BaseSeismicSource` :returns: Dictionary of source attributes """ attrs = {"id": ...
python
def get_source_attributes(source): """ Retreives a dictionary of source attributes from the source class :param source: Seismic source as instance of :class: `openquake.hazardlib.source.base.BaseSeismicSource` :returns: Dictionary of source attributes """ attrs = {"id": ...
[ "def", "get_source_attributes", "(", "source", ")", ":", "attrs", "=", "{", "\"id\"", ":", "source", ".", "source_id", ",", "\"name\"", ":", "source", ".", "name", ",", "\"tectonicRegion\"", ":", "source", ".", "tectonic_region_type", "}", "if", "isinstance", ...
Retreives a dictionary of source attributes from the source class :param source: Seismic source as instance of :class: `openquake.hazardlib.source.base.BaseSeismicSource` :returns: Dictionary of source attributes
[ "Retreives", "a", "dictionary", "of", "source", "attributes", "from", "the", "source", "class" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourcewriter.py#L379-L399
train
gem/oq-engine
openquake/hazardlib/sourcewriter.py
build_area_source_node
def build_area_source_node(area_source): """ Parses an area source to a Node class :param area_source: Area source as instance of :class: `openquake.hazardlib.source.area.AreaSource` :returns: Instance of :class:`openquake.baselib.node.Node` """ # parse geometry sour...
python
def build_area_source_node(area_source): """ Parses an area source to a Node class :param area_source: Area source as instance of :class: `openquake.hazardlib.source.area.AreaSource` :returns: Instance of :class:`openquake.baselib.node.Node` """ # parse geometry sour...
[ "def", "build_area_source_node", "(", "area_source", ")", ":", "source_nodes", "=", "[", "build_area_source_geometry", "(", "area_source", ")", "]", "source_nodes", ".", "extend", "(", "get_distributed_seismicity_source_nodes", "(", "area_source", ")", ")", "return", ...
Parses an area source to a Node class :param area_source: Area source as instance of :class: `openquake.hazardlib.source.area.AreaSource` :returns: Instance of :class:`openquake.baselib.node.Node`
[ "Parses", "an", "area", "source", "to", "a", "Node", "class" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourcewriter.py#L403-L418
train
gem/oq-engine
openquake/hazardlib/sourcewriter.py
build_simple_fault_source_node
def build_simple_fault_source_node(fault_source): """ Parses a simple fault source to a Node class :param fault_source: Simple fault source as instance of :class: `openquake.hazardlib.source.simple_fault.SimpleFaultSource` :returns: Instance of :class:`openquake.baselib.node.Nod...
python
def build_simple_fault_source_node(fault_source): """ Parses a simple fault source to a Node class :param fault_source: Simple fault source as instance of :class: `openquake.hazardlib.source.simple_fault.SimpleFaultSource` :returns: Instance of :class:`openquake.baselib.node.Nod...
[ "def", "build_simple_fault_source_node", "(", "fault_source", ")", ":", "source_nodes", "=", "[", "build_simple_fault_geometry", "(", "fault_source", ")", "]", "source_nodes", ".", "extend", "(", "get_fault_source_nodes", "(", "fault_source", ")", ")", "return", "Node...
Parses a simple fault source to a Node class :param fault_source: Simple fault source as instance of :class: `openquake.hazardlib.source.simple_fault.SimpleFaultSource` :returns: Instance of :class:`openquake.baselib.node.Node`
[ "Parses", "a", "simple", "fault", "source", "to", "a", "Node", "class" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourcewriter.py#L524-L540
train
gem/oq-engine
openquake/hazardlib/sourcewriter.py
build_complex_fault_source_node
def build_complex_fault_source_node(fault_source): """ Parses a complex fault source to a Node class :param fault_source: Simple fault source as instance of :class: `openquake.hazardlib.source.complex_fault.ComplexFaultSource` :returns: Instance of :class:`openquake.baselib.node...
python
def build_complex_fault_source_node(fault_source): """ Parses a complex fault source to a Node class :param fault_source: Simple fault source as instance of :class: `openquake.hazardlib.source.complex_fault.ComplexFaultSource` :returns: Instance of :class:`openquake.baselib.node...
[ "def", "build_complex_fault_source_node", "(", "fault_source", ")", ":", "source_nodes", "=", "[", "build_complex_fault_geometry", "(", "fault_source", ")", "]", "source_nodes", ".", "extend", "(", "get_fault_source_nodes", "(", "fault_source", ")", ")", "return", "No...
Parses a complex fault source to a Node class :param fault_source: Simple fault source as instance of :class: `openquake.hazardlib.source.complex_fault.ComplexFaultSource` :returns: Instance of :class:`openquake.baselib.node.Node`
[ "Parses", "a", "complex", "fault", "source", "to", "a", "Node", "class" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourcewriter.py#L544-L560
train
gem/oq-engine
openquake/hazardlib/sourcewriter.py
write_source_model
def write_source_model(dest, sources_or_groups, name=None, investigation_time=None): """ Writes a source model to XML. :param dest: Destination path :param sources_or_groups: Source model in different formats :param name: Name of the source model (if m...
python
def write_source_model(dest, sources_or_groups, name=None, investigation_time=None): """ Writes a source model to XML. :param dest: Destination path :param sources_or_groups: Source model in different formats :param name: Name of the source model (if m...
[ "def", "write_source_model", "(", "dest", ",", "sources_or_groups", ",", "name", "=", "None", ",", "investigation_time", "=", "None", ")", ":", "if", "isinstance", "(", "sources_or_groups", ",", "nrml", ".", "SourceModel", ")", ":", "with", "open", "(", "des...
Writes a source model to XML. :param dest: Destination path :param sources_or_groups: Source model in different formats :param name: Name of the source model (if missing, extracted from the filename)
[ "Writes", "a", "source", "model", "to", "XML", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourcewriter.py#L610-L641
train
gem/oq-engine
openquake/hazardlib/gsim/sharma_2009.py
SharmaEtAl2009._get_stddevs
def _get_stddevs(self, coeffs, stddev_types, num_sites): """ Return total sigma as reported in Table 2, p. 1202. """ stddevs = [] for stddev_type in stddev_types: assert stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES stddevs.append(coeffs['sigma'...
python
def _get_stddevs(self, coeffs, stddev_types, num_sites): """ Return total sigma as reported in Table 2, p. 1202. """ stddevs = [] for stddev_type in stddev_types: assert stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES stddevs.append(coeffs['sigma'...
[ "def", "_get_stddevs", "(", "self", ",", "coeffs", ",", "stddev_types", ",", "num_sites", ")", ":", "stddevs", "=", "[", "]", "for", "stddev_type", "in", "stddev_types", ":", "assert", "stddev_type", "in", "self", ".", "DEFINED_FOR_STANDARD_DEVIATION_TYPES", "st...
Return total sigma as reported in Table 2, p. 1202.
[ "Return", "total", "sigma", "as", "reported", "in", "Table", "2", "p", ".", "1202", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/sharma_2009.py#L121-L129
train
gem/oq-engine
openquake/hazardlib/gsim/sharma_2009.py
SharmaEtAl2009.get_fault_type_dummy_variables
def get_fault_type_dummy_variables(self, rup): """ Fault-type classification dummy variable based on rup.rake. "``H`` is 1 for a strike-slip mechanism and 0 for a reverse mechanism" (p. 1201). Note: UserWarning is raised if mechanism is determined to be normal ...
python
def get_fault_type_dummy_variables(self, rup): """ Fault-type classification dummy variable based on rup.rake. "``H`` is 1 for a strike-slip mechanism and 0 for a reverse mechanism" (p. 1201). Note: UserWarning is raised if mechanism is determined to be normal ...
[ "def", "get_fault_type_dummy_variables", "(", "self", ",", "rup", ")", ":", "is_normal", "=", "np", ".", "array", "(", "self", ".", "RAKE_THRESH", "<", "-", "rup", ".", "rake", "<", "(", "180.", "-", "self", ".", "RAKE_THRESH", ")", ")", "is_reverse", ...
Fault-type classification dummy variable based on rup.rake. "``H`` is 1 for a strike-slip mechanism and 0 for a reverse mechanism" (p. 1201). Note: UserWarning is raised if mechanism is determined to be normal faulting, since as summarized in Table 2 on p. 1197 the data...
[ "Fault", "-", "type", "classification", "dummy", "variable", "based", "on", "rup", ".", "rake", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/sharma_2009.py#L176-L208
train
gem/oq-engine
openquake/hmtk/parsers/strain/strain_csv_parser.py
ReadStrainCsv.read_data
def read_data(self, scaling_factor=1E-9, strain_headers=None): ''' Reads the data from the csv file :param float scaling_factor: Scaling factor used for all strain values (default 1E-9 for nanostrain) :param list strain_headers: List of the variables...
python
def read_data(self, scaling_factor=1E-9, strain_headers=None): ''' Reads the data from the csv file :param float scaling_factor: Scaling factor used for all strain values (default 1E-9 for nanostrain) :param list strain_headers: List of the variables...
[ "def", "read_data", "(", "self", ",", "scaling_factor", "=", "1E-9", ",", "strain_headers", "=", "None", ")", ":", "if", "strain_headers", ":", "self", ".", "strain", ".", "data_variables", "=", "strain_headers", "else", ":", "self", ".", "strain", ".", "d...
Reads the data from the csv file :param float scaling_factor: Scaling factor used for all strain values (default 1E-9 for nanostrain) :param list strain_headers: List of the variables in the file that correspond to strain parameters :returns: ...
[ "Reads", "the", "data", "from", "the", "csv", "file" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/strain/strain_csv_parser.py#L82-L132
train
gem/oq-engine
openquake/hmtk/parsers/strain/strain_csv_parser.py
ReadStrainCsv._check_invalid_longitudes
def _check_invalid_longitudes(self): ''' Checks to ensure that all longitudes are in the range -180. to 180 ''' idlon = self.strain.data['longitude'] > 180. if np.any(idlon): self.strain.data['longitude'][idlon] = \ self.strain.data['longitude'][idlon]...
python
def _check_invalid_longitudes(self): ''' Checks to ensure that all longitudes are in the range -180. to 180 ''' idlon = self.strain.data['longitude'] > 180. if np.any(idlon): self.strain.data['longitude'][idlon] = \ self.strain.data['longitude'][idlon]...
[ "def", "_check_invalid_longitudes", "(", "self", ")", ":", "idlon", "=", "self", ".", "strain", ".", "data", "[", "'longitude'", "]", ">", "180.", "if", "np", ".", "any", "(", "idlon", ")", ":", "self", ".", "strain", ".", "data", "[", "'longitude'", ...
Checks to ensure that all longitudes are in the range -180. to 180
[ "Checks", "to", "ensure", "that", "all", "longitudes", "are", "in", "the", "range", "-", "180", ".", "to", "180" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/strain/strain_csv_parser.py#L134-L141
train
gem/oq-engine
openquake/hmtk/parsers/strain/strain_csv_parser.py
WriteStrainCsv.write_file
def write_file(self, strain, scaling_factor=1E-9): ''' Main writer function for the csv file :param strain: Instance of :class: openquake.hmtk.strain.geodetic_strain.GeodeticStrain :param float scaling_factor: Scaling factor used for all strain values (default 1E...
python
def write_file(self, strain, scaling_factor=1E-9): ''' Main writer function for the csv file :param strain: Instance of :class: openquake.hmtk.strain.geodetic_strain.GeodeticStrain :param float scaling_factor: Scaling factor used for all strain values (default 1E...
[ "def", "write_file", "(", "self", ",", "strain", ",", "scaling_factor", "=", "1E-9", ")", ":", "if", "not", "isinstance", "(", "strain", ",", "GeodeticStrain", ")", ":", "raise", "ValueError", "(", "'Strain data must be instance of GeodeticStrain'", ")", "for", ...
Main writer function for the csv file :param strain: Instance of :class: openquake.hmtk.strain.geodetic_strain.GeodeticStrain :param float scaling_factor: Scaling factor used for all strain values (default 1E-9 for nanostrain)
[ "Main", "writer", "function", "for", "the", "csv", "file" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/strain/strain_csv_parser.py#L160-L196
train
gem/oq-engine
openquake/hmtk/parsers/strain/strain_csv_parser.py
WriteStrainCsv.slice_rates_to_data
def slice_rates_to_data(self, strain): ''' For the strain data, checks to see if seismicity rates have been calculated. If so, each column in the array is sliced and stored as a single vector in the strain.data dictionary with the corresponding magnitude as a key. :param...
python
def slice_rates_to_data(self, strain): ''' For the strain data, checks to see if seismicity rates have been calculated. If so, each column in the array is sliced and stored as a single vector in the strain.data dictionary with the corresponding magnitude as a key. :param...
[ "def", "slice_rates_to_data", "(", "self", ",", "strain", ")", ":", "output_variables", "=", "list", "(", "strain", ".", "data", ")", "cond", "=", "(", "isinstance", "(", "strain", ".", "target_magnitudes", ",", "np", ".", "ndarray", ")", "or", "isinstance...
For the strain data, checks to see if seismicity rates have been calculated. If so, each column in the array is sliced and stored as a single vector in the strain.data dictionary with the corresponding magnitude as a key. :param strain: Instance of :class: openquake.hmtk.str...
[ "For", "the", "strain", "data", "checks", "to", "see", "if", "seismicity", "rates", "have", "been", "calculated", ".", "If", "so", "each", "column", "in", "the", "array", "is", "sliced", "and", "stored", "as", "a", "single", "vector", "in", "the", "strai...
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/parsers/strain/strain_csv_parser.py#L198-L228
train
gem/oq-engine
openquake/baselib/__init__.py
read
def read(*paths, **validators): """ Load the configuration, make each section available in a separate dict. The configuration location can specified via an environment variable: - OQ_CONFIG_FILE In the absence of this environment variable the following paths will be used: - sys.prefi...
python
def read(*paths, **validators): """ Load the configuration, make each section available in a separate dict. The configuration location can specified via an environment variable: - OQ_CONFIG_FILE In the absence of this environment variable the following paths will be used: - sys.prefi...
[ "def", "read", "(", "*", "paths", ",", "**", "validators", ")", ":", "paths", "=", "config", ".", "paths", "+", "list", "(", "paths", ")", "parser", "=", "configparser", ".", "ConfigParser", "(", ")", "found", "=", "parser", ".", "read", "(", "os", ...
Load the configuration, make each section available in a separate dict. The configuration location can specified via an environment variable: - OQ_CONFIG_FILE In the absence of this environment variable the following paths will be used: - sys.prefix + /openquake.cfg when in a virtualenv ...
[ "Load", "the", "configuration", "make", "each", "section", "available", "in", "a", "separate", "dict", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/__init__.py#L56-L84
train
gem/oq-engine
openquake/baselib/__init__.py
boolean
def boolean(flag): """ Convert string in boolean """ s = flag.lower() if s in ('1', 'yes', 'true'): return True elif s in ('0', 'no', 'false'): return False raise ValueError('Unknown flag %r' % s)
python
def boolean(flag): """ Convert string in boolean """ s = flag.lower() if s in ('1', 'yes', 'true'): return True elif s in ('0', 'no', 'false'): return False raise ValueError('Unknown flag %r' % s)
[ "def", "boolean", "(", "flag", ")", ":", "s", "=", "flag", ".", "lower", "(", ")", "if", "s", "in", "(", "'1'", ",", "'yes'", ",", "'true'", ")", ":", "return", "True", "elif", "s", "in", "(", "'0'", ",", "'no'", ",", "'false'", ")", ":", "re...
Convert string in boolean
[ "Convert", "string", "in", "boolean" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/__init__.py#L90-L99
train
gem/oq-engine
openquake/hazardlib/gsim/atkinson_boore_2006.py
AtkinsonBoore2006._get_mean
def _get_mean(self, vs30, mag, rrup, imt, scale_fac): """ Compute and return mean """ C_HR, C_BC, C_SR, SC = self._extract_coeffs(imt) rrup = self._clip_distances(rrup) f0 = self._compute_f0_factor(rrup) f1 = self._compute_f1_factor(rrup) f2 = self._comp...
python
def _get_mean(self, vs30, mag, rrup, imt, scale_fac): """ Compute and return mean """ C_HR, C_BC, C_SR, SC = self._extract_coeffs(imt) rrup = self._clip_distances(rrup) f0 = self._compute_f0_factor(rrup) f1 = self._compute_f1_factor(rrup) f2 = self._comp...
[ "def", "_get_mean", "(", "self", ",", "vs30", ",", "mag", ",", "rrup", ",", "imt", ",", "scale_fac", ")", ":", "C_HR", ",", "C_BC", ",", "C_SR", ",", "SC", "=", "self", ".", "_extract_coeffs", "(", "imt", ")", "rrup", "=", "self", ".", "_clip_dista...
Compute and return mean
[ "Compute", "and", "return", "mean" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/atkinson_boore_2006.py#L109-L142
train
gem/oq-engine
openquake/hazardlib/gsim/atkinson_boore_2006.py
AtkinsonBoore2006._get_pga_bc
def _get_pga_bc(self, f0, f1, f2, SC, mag, rrup, vs30, scale_fac): """ Compute and return PGA on BC boundary """ pga_bc = np.zeros_like(vs30) self._compute_mean(self.COEFFS_BC[PGA()], f0, f1, f2, SC, mag, rrup, vs30 < 2000.0, pga_bc, scale_fac) ...
python
def _get_pga_bc(self, f0, f1, f2, SC, mag, rrup, vs30, scale_fac): """ Compute and return PGA on BC boundary """ pga_bc = np.zeros_like(vs30) self._compute_mean(self.COEFFS_BC[PGA()], f0, f1, f2, SC, mag, rrup, vs30 < 2000.0, pga_bc, scale_fac) ...
[ "def", "_get_pga_bc", "(", "self", ",", "f0", ",", "f1", ",", "f2", ",", "SC", ",", "mag", ",", "rrup", ",", "vs30", ",", "scale_fac", ")", ":", "pga_bc", "=", "np", ".", "zeros_like", "(", "vs30", ")", "self", ".", "_compute_mean", "(", "self", ...
Compute and return PGA on BC boundary
[ "Compute", "and", "return", "PGA", "on", "BC", "boundary" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/atkinson_boore_2006.py#L144-L152
train
gem/oq-engine
openquake/hazardlib/gsim/atkinson_boore_2006.py
AtkinsonBoore2006._extract_coeffs
def _extract_coeffs(self, imt): """ Extract dictionaries of coefficients specific to required intensity measure type. """ C_HR = self.COEFFS_HARD_ROCK[imt] C_BC = self.COEFFS_BC[imt] C_SR = self.COEFFS_SOIL_RESPONSE[imt] SC = self.COEFFS_STRESS[imt] ...
python
def _extract_coeffs(self, imt): """ Extract dictionaries of coefficients specific to required intensity measure type. """ C_HR = self.COEFFS_HARD_ROCK[imt] C_BC = self.COEFFS_BC[imt] C_SR = self.COEFFS_SOIL_RESPONSE[imt] SC = self.COEFFS_STRESS[imt] ...
[ "def", "_extract_coeffs", "(", "self", ",", "imt", ")", ":", "C_HR", "=", "self", ".", "COEFFS_HARD_ROCK", "[", "imt", "]", "C_BC", "=", "self", ".", "COEFFS_BC", "[", "imt", "]", "C_SR", "=", "self", ".", "COEFFS_SOIL_RESPONSE", "[", "imt", "]", "SC",...
Extract dictionaries of coefficients specific to required intensity measure type.
[ "Extract", "dictionaries", "of", "coefficients", "specific", "to", "required", "intensity", "measure", "type", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/atkinson_boore_2006.py#L154-L164
train
gem/oq-engine
openquake/calculators/getters.py
PmapGetter.init
def init(self): """ Read the poes and set the .data attribute with the hazard curves """ if hasattr(self, 'data'): # already initialized return if isinstance(self.dstore, str): self.dstore = hdf5.File(self.dstore, 'r') else: self.dstor...
python
def init(self): """ Read the poes and set the .data attribute with the hazard curves """ if hasattr(self, 'data'): # already initialized return if isinstance(self.dstore, str): self.dstore = hdf5.File(self.dstore, 'r') else: self.dstor...
[ "def", "init", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'data'", ")", ":", "return", "if", "isinstance", "(", "self", ".", "dstore", ",", "str", ")", ":", "self", ".", "dstore", "=", "hdf5", ".", "File", "(", "self", ".", "dstor...
Read the poes and set the .data attribute with the hazard curves
[ "Read", "the", "poes", "and", "set", "the", ".", "data", "attribute", "with", "the", "hazard", "curves" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/getters.py#L66-L91
train
gem/oq-engine
openquake/calculators/getters.py
PmapGetter.get_mean
def get_mean(self, grp=None): """ Compute the mean curve as a ProbabilityMap :param grp: if not None must be a string of the form "grp-XX"; in that case returns the mean considering only the contribution for group XX """ self.init() if len(self.we...
python
def get_mean(self, grp=None): """ Compute the mean curve as a ProbabilityMap :param grp: if not None must be a string of the form "grp-XX"; in that case returns the mean considering only the contribution for group XX """ self.init() if len(self.we...
[ "def", "get_mean", "(", "self", ",", "grp", "=", "None", ")", ":", "self", ".", "init", "(", ")", "if", "len", "(", "self", ".", "weights", ")", "==", "1", ":", "pmap", "=", "self", ".", "get", "(", "0", ",", "grp", ")", "for", "sid", ",", ...
Compute the mean curve as a ProbabilityMap :param grp: if not None must be a string of the form "grp-XX"; in that case returns the mean considering only the contribution for group XX
[ "Compute", "the", "mean", "curve", "as", "a", "ProbabilityMap" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/getters.py#L189-L212
train
gem/oq-engine
openquake/calculators/getters.py
GmfGetter.init
def init(self): """ Initialize the computers. Should be called on the workers """ if hasattr(self, 'computers'): # init already called return with hdf5.File(self.rupgetter.filename, 'r') as parent: self.weights = parent['weights'].value self.compu...
python
def init(self): """ Initialize the computers. Should be called on the workers """ if hasattr(self, 'computers'): # init already called return with hdf5.File(self.rupgetter.filename, 'r') as parent: self.weights = parent['weights'].value self.compu...
[ "def", "init", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'computers'", ")", ":", "return", "with", "hdf5", ".", "File", "(", "self", ".", "rupgetter", ".", "filename", ",", "'r'", ")", "as", "parent", ":", "self", ".", "weights", "...
Initialize the computers. Should be called on the workers
[ "Initialize", "the", "computers", ".", "Should", "be", "called", "on", "the", "workers" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/getters.py#L306-L326
train
gem/oq-engine
openquake/hazardlib/gsim/skarlatoudis_2013.py
SkarlatoudisEtAlSSlab2013._compute_forearc_backarc_term
def _compute_forearc_backarc_term(self, C, sites, dists, rup): """ Compute back-arc term of Equation 3 """ # flag 1 (R < 335 & R >= 205) flag1 = np.zeros(len(dists.rhypo)) ind1 = np.logical_and((dists.rhypo < 335), (dists.rhypo >= 205)) flag1[ind1] = 1.0 ...
python
def _compute_forearc_backarc_term(self, C, sites, dists, rup): """ Compute back-arc term of Equation 3 """ # flag 1 (R < 335 & R >= 205) flag1 = np.zeros(len(dists.rhypo)) ind1 = np.logical_and((dists.rhypo < 335), (dists.rhypo >= 205)) flag1[ind1] = 1.0 ...
[ "def", "_compute_forearc_backarc_term", "(", "self", ",", "C", ",", "sites", ",", "dists", ",", "rup", ")", ":", "flag1", "=", "np", ".", "zeros", "(", "len", "(", "dists", ".", "rhypo", ")", ")", "ind1", "=", "np", ".", "logical_and", "(", "(", "d...
Compute back-arc term of Equation 3
[ "Compute", "back", "-", "arc", "term", "of", "Equation", "3" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/skarlatoudis_2013.py#L177-L219
train
gem/oq-engine
openquake/hazardlib/gsim/gmpe_table.py
AmplificationTable._build_data
def _build_data(self, amplification_group): """ Creates the numpy array tables from the hdf5 tables """ # Determine shape of the tables n_levels = len(amplification_group) # Checks the first group in the amplification group and returns the # shape of the SA array ...
python
def _build_data(self, amplification_group): """ Creates the numpy array tables from the hdf5 tables """ # Determine shape of the tables n_levels = len(amplification_group) # Checks the first group in the amplification group and returns the # shape of the SA array ...
[ "def", "_build_data", "(", "self", ",", "amplification_group", ")", ":", "n_levels", "=", "len", "(", "amplification_group", ")", "level", "=", "next", "(", "iter", "(", "amplification_group", ")", ")", "n_d", ",", "n_p", ",", "n_m", "=", "amplification_grou...
Creates the numpy array tables from the hdf5 tables
[ "Creates", "the", "numpy", "array", "tables", "from", "the", "hdf5", "tables" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/gmpe_table.py#L112-L150
train
gem/oq-engine
openquake/hazardlib/gsim/gmpe_table.py
AmplificationTable.get_amplification_factors
def get_amplification_factors(self, imt, sctx, rctx, dists, stddev_types): """ Returns the amplification factors for the given rupture and site conditions. :param imt: Intensity measure type as an instance of the :class: `openquake.hazardlib.imt` :param s...
python
def get_amplification_factors(self, imt, sctx, rctx, dists, stddev_types): """ Returns the amplification factors for the given rupture and site conditions. :param imt: Intensity measure type as an instance of the :class: `openquake.hazardlib.imt` :param s...
[ "def", "get_amplification_factors", "(", "self", ",", "imt", ",", "sctx", ",", "rctx", ",", "dists", ",", "stddev_types", ")", ":", "dist_level_table", "=", "self", ".", "get_mean_table", "(", "imt", ",", "rctx", ")", "sigma_tables", "=", "self", ".", "get...
Returns the amplification factors for the given rupture and site conditions. :param imt: Intensity measure type as an instance of the :class: `openquake.hazardlib.imt` :param sctx: SiteCollection instance :param rctx: Rupture instance ...
[ "Returns", "the", "amplification", "factors", "for", "the", "given", "rupture", "and", "site", "conditions", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/gmpe_table.py#L158-L202
train
gem/oq-engine
openquake/hazardlib/gsim/gmpe_table.py
AmplificationTable.get_mean_table
def get_mean_table(self, imt, rctx): """ Returns amplification factors for the mean, given the rupture and intensity measure type. :returns: amplification table as an array of [Number Distances, Number Levels] """ # Levels by Distances if ...
python
def get_mean_table(self, imt, rctx): """ Returns amplification factors for the mean, given the rupture and intensity measure type. :returns: amplification table as an array of [Number Distances, Number Levels] """ # Levels by Distances if ...
[ "def", "get_mean_table", "(", "self", ",", "imt", ",", "rctx", ")", ":", "if", "imt", ".", "name", "in", "'PGA PGV'", ":", "interpolator", "=", "interp1d", "(", "self", ".", "magnitudes", ",", "numpy", ".", "log10", "(", "self", ".", "mean", "[", "im...
Returns amplification factors for the mean, given the rupture and intensity measure type. :returns: amplification table as an array of [Number Distances, Number Levels]
[ "Returns", "amplification", "factors", "for", "the", "mean", "given", "the", "rupture", "and", "intensity", "measure", "type", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/gmpe_table.py#L204-L229
train
gem/oq-engine
openquake/hazardlib/gsim/gmpe_table.py
AmplificationTable.get_sigma_tables
def get_sigma_tables(self, imt, rctx, stddev_types): """ Returns modification factors for the standard deviations, given the rupture and intensity measure type. :returns: List of standard deviation modification tables, each as an array of [Number Distances, Numbe...
python
def get_sigma_tables(self, imt, rctx, stddev_types): """ Returns modification factors for the standard deviations, given the rupture and intensity measure type. :returns: List of standard deviation modification tables, each as an array of [Number Distances, Numbe...
[ "def", "get_sigma_tables", "(", "self", ",", "imt", ",", "rctx", ",", "stddev_types", ")", ":", "output_tables", "=", "[", "]", "for", "stddev_type", "in", "stddev_types", ":", "if", "imt", ".", "name", "in", "'PGA PGV'", ":", "interpolator", "=", "interp1...
Returns modification factors for the standard deviations, given the rupture and intensity measure type. :returns: List of standard deviation modification tables, each as an array of [Number Distances, Number Levels]
[ "Returns", "modification", "factors", "for", "the", "standard", "deviations", "given", "the", "rupture", "and", "intensity", "measure", "type", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/gmpe_table.py#L231-L263
train
gem/oq-engine
openquake/hazardlib/gsim/gmpe_table.py
GMPETable.init
def init(self, fle=None): """ Executes the preprocessing steps at the instantiation stage to read in the tables from hdf5 and hold them in memory. """ if fle is None: fname = self.kwargs.get('gmpe_table', self.GMPE_TABLE) if fname is None: ...
python
def init(self, fle=None): """ Executes the preprocessing steps at the instantiation stage to read in the tables from hdf5 and hold them in memory. """ if fle is None: fname = self.kwargs.get('gmpe_table', self.GMPE_TABLE) if fname is None: ...
[ "def", "init", "(", "self", ",", "fle", "=", "None", ")", ":", "if", "fle", "is", "None", ":", "fname", "=", "self", ".", "kwargs", ".", "get", "(", "'gmpe_table'", ",", "self", ".", "GMPE_TABLE", ")", "if", "fname", "is", "None", ":", "raise", "...
Executes the preprocessing steps at the instantiation stage to read in the tables from hdf5 and hold them in memory.
[ "Executes", "the", "preprocessing", "steps", "at", "the", "instantiation", "stage", "to", "read", "in", "the", "tables", "from", "hdf5", "and", "hold", "them", "in", "memory", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/gmpe_table.py#L306-L342
train
gem/oq-engine
openquake/hazardlib/gsim/gmpe_table.py
GMPETable._setup_amplification
def _setup_amplification(self, fle): """ If amplification data is specified then reads into memory and updates the required rupture and site parameters """ self.amplification = AmplificationTable(fle["Amplification"], self.m_w, ...
python
def _setup_amplification(self, fle): """ If amplification data is specified then reads into memory and updates the required rupture and site parameters """ self.amplification = AmplificationTable(fle["Amplification"], self.m_w, ...
[ "def", "_setup_amplification", "(", "self", ",", "fle", ")", ":", "self", ".", "amplification", "=", "AmplificationTable", "(", "fle", "[", "\"Amplification\"", "]", ",", "self", ".", "m_w", ",", "self", ".", "distances", ")", "if", "self", ".", "amplifica...
If amplification data is specified then reads into memory and updates the required rupture and site parameters
[ "If", "amplification", "data", "is", "specified", "then", "reads", "into", "memory", "and", "updates", "the", "required", "rupture", "and", "site", "parameters" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/gmpe_table.py#L364-L380
train
gem/oq-engine
openquake/hazardlib/gsim/gmpe_table.py
GMPETable._supported_imts
def _supported_imts(self): """ Updates the list of supported IMTs from the tables """ imt_list = [] for key in self.imls: if "SA" in key: imt_list.append(imt_module.SA) elif key == "T": continue else: ...
python
def _supported_imts(self): """ Updates the list of supported IMTs from the tables """ imt_list = [] for key in self.imls: if "SA" in key: imt_list.append(imt_module.SA) elif key == "T": continue else: ...
[ "def", "_supported_imts", "(", "self", ")", ":", "imt_list", "=", "[", "]", "for", "key", "in", "self", ".", "imls", ":", "if", "\"SA\"", "in", "key", ":", "imt_list", ".", "append", "(", "imt_module", ".", "SA", ")", "elif", "key", "==", "\"T\"", ...
Updates the list of supported IMTs from the tables
[ "Updates", "the", "list", "of", "supported", "IMTs", "from", "the", "tables" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/gmpe_table.py#L382-L398
train
gem/oq-engine
openquake/hazardlib/gsim/gmpe_table.py
GMPETable.get_mean_and_stddevs
def get_mean_and_stddevs(self, sctx, rctx, dctx, imt, stddev_types): """ Returns the mean and standard deviations """ # Return Distance Tables imls = self._return_tables(rctx.mag, imt, "IMLs") # Get distance vector for the given magnitude idx = numpy.searchsorted(...
python
def get_mean_and_stddevs(self, sctx, rctx, dctx, imt, stddev_types): """ Returns the mean and standard deviations """ # Return Distance Tables imls = self._return_tables(rctx.mag, imt, "IMLs") # Get distance vector for the given magnitude idx = numpy.searchsorted(...
[ "def", "get_mean_and_stddevs", "(", "self", ",", "sctx", ",", "rctx", ",", "dctx", ",", "imt", ",", "stddev_types", ")", ":", "imls", "=", "self", ".", "_return_tables", "(", "rctx", ".", "mag", ",", "imt", ",", "\"IMLs\"", ")", "idx", "=", "numpy", ...
Returns the mean and standard deviations
[ "Returns", "the", "mean", "and", "standard", "deviations" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/gmpe_table.py#L400-L425
train
gem/oq-engine
openquake/hazardlib/gsim/gmpe_table.py
GMPETable._get_stddevs
def _get_stddevs(self, dists, mag, dctx, imt, stddev_types): """ Returns the total standard deviation of the intensity measure level from the tables. :param fle: HDF5 data stream as instance of :class:`h5py.File` :param distances: The distance vector for ...
python
def _get_stddevs(self, dists, mag, dctx, imt, stddev_types): """ Returns the total standard deviation of the intensity measure level from the tables. :param fle: HDF5 data stream as instance of :class:`h5py.File` :param distances: The distance vector for ...
[ "def", "_get_stddevs", "(", "self", ",", "dists", ",", "mag", ",", "dctx", ",", "imt", ",", "stddev_types", ")", ":", "stddevs", "=", "[", "]", "for", "stddev_type", "in", "stddev_types", ":", "if", "stddev_type", "not", "in", "self", ".", "DEFINED_FOR_S...
Returns the total standard deviation of the intensity measure level from the tables. :param fle: HDF5 data stream as instance of :class:`h5py.File` :param distances: The distance vector for the given magnitude and IMT :param key: The distance type ...
[ "Returns", "the", "total", "standard", "deviation", "of", "the", "intensity", "measure", "level", "from", "the", "tables", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/gmpe_table.py#L454-L480
train
gem/oq-engine
openquake/hazardlib/gsim/gmpe_table.py
GMPETable._return_tables
def _return_tables(self, mag, imt, val_type): """ Returns the vector of ground motions or standard deviations corresponding to the specific magnitude and intensity measure type. :param val_type: String indicating the type of data {"IMLs", "Total", "Inter" etc} """ ...
python
def _return_tables(self, mag, imt, val_type): """ Returns the vector of ground motions or standard deviations corresponding to the specific magnitude and intensity measure type. :param val_type: String indicating the type of data {"IMLs", "Total", "Inter" etc} """ ...
[ "def", "_return_tables", "(", "self", ",", "mag", ",", "imt", ",", "val_type", ")", ":", "if", "imt", ".", "name", "in", "'PGA PGV'", ":", "if", "val_type", "==", "\"IMLs\"", ":", "iml_table", "=", "self", ".", "imls", "[", "imt", ".", "name", "]", ...
Returns the vector of ground motions or standard deviations corresponding to the specific magnitude and intensity measure type. :param val_type: String indicating the type of data {"IMLs", "Total", "Inter" etc}
[ "Returns", "the", "vector", "of", "ground", "motions", "or", "standard", "deviations", "corresponding", "to", "the", "specific", "magnitude", "and", "intensity", "measure", "type", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/gmpe_table.py#L482-L518
train
gem/oq-engine
openquake/hazardlib/gsim/gmpe_table.py
GMPETable.apply_magnitude_interpolation
def apply_magnitude_interpolation(self, mag, iml_table): """ Interpolates the tables to the required magnitude level :param float mag: Magnitude :param iml_table: Intensity measure level table """ # do not allow "mag" to exceed maximum table magni...
python
def apply_magnitude_interpolation(self, mag, iml_table): """ Interpolates the tables to the required magnitude level :param float mag: Magnitude :param iml_table: Intensity measure level table """ # do not allow "mag" to exceed maximum table magni...
[ "def", "apply_magnitude_interpolation", "(", "self", ",", "mag", ",", "iml_table", ")", ":", "if", "mag", ">", "self", ".", "m_w", "[", "-", "1", "]", ":", "mag", "=", "self", ".", "m_w", "[", "-", "1", "]", "if", "mag", "<", "self", ".", "m_w", ...
Interpolates the tables to the required magnitude level :param float mag: Magnitude :param iml_table: Intensity measure level table
[ "Interpolates", "the", "tables", "to", "the", "required", "magnitude", "level" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/gmpe_table.py#L520-L542
train
gem/oq-engine
openquake/hazardlib/gsim/sadigh_1997.py
SadighEtAl1997._get_mean_deep_soil
def _get_mean_deep_soil(self, mag, rake, rrup, is_reverse, imt): """ Calculate and return the mean intensity for deep soil sites. Implements an equation from table 4. """ if mag <= self.NEAR_FIELD_SATURATION_MAG: c4 = self.COEFFS_SOIL_IMT_INDEPENDENT['c4lowmag'] ...
python
def _get_mean_deep_soil(self, mag, rake, rrup, is_reverse, imt): """ Calculate and return the mean intensity for deep soil sites. Implements an equation from table 4. """ if mag <= self.NEAR_FIELD_SATURATION_MAG: c4 = self.COEFFS_SOIL_IMT_INDEPENDENT['c4lowmag'] ...
[ "def", "_get_mean_deep_soil", "(", "self", ",", "mag", ",", "rake", ",", "rrup", ",", "is_reverse", ",", "imt", ")", ":", "if", "mag", "<=", "self", ".", "NEAR_FIELD_SATURATION_MAG", ":", "c4", "=", "self", ".", "COEFFS_SOIL_IMT_INDEPENDENT", "[", "'c4lowmag...
Calculate and return the mean intensity for deep soil sites. Implements an equation from table 4.
[ "Calculate", "and", "return", "the", "mean", "intensity", "for", "deep", "soil", "sites", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/sadigh_1997.py#L114-L139
train
gem/oq-engine
openquake/hazardlib/gsim/sadigh_1997.py
SadighEtAl1997._get_mean_rock
def _get_mean_rock(self, mag, _rake, rrup, is_reverse, imt): """ Calculate and return the mean intensity for rock sites. Implements an equation from table 2. """ if mag <= self.NEAR_FIELD_SATURATION_MAG: C = self.COEFFS_ROCK_LOWMAG[imt] else: C = ...
python
def _get_mean_rock(self, mag, _rake, rrup, is_reverse, imt): """ Calculate and return the mean intensity for rock sites. Implements an equation from table 2. """ if mag <= self.NEAR_FIELD_SATURATION_MAG: C = self.COEFFS_ROCK_LOWMAG[imt] else: C = ...
[ "def", "_get_mean_rock", "(", "self", ",", "mag", ",", "_rake", ",", "rrup", ",", "is_reverse", ",", "imt", ")", ":", "if", "mag", "<=", "self", ".", "NEAR_FIELD_SATURATION_MAG", ":", "C", "=", "self", ".", "COEFFS_ROCK_LOWMAG", "[", "imt", "]", "else", ...
Calculate and return the mean intensity for rock sites. Implements an equation from table 2.
[ "Calculate", "and", "return", "the", "mean", "intensity", "for", "rock", "sites", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/sadigh_1997.py#L141-L163
train
gem/oq-engine
openquake/hazardlib/gsim/sadigh_1997.py
SadighEtAl1997._get_stddev_rock
def _get_stddev_rock(self, mag, imt): """ Calculate and return total standard deviation for rock sites. Implements formulae from table 3. """ C = self.COEFFS_ROCK_STDDERR[imt] if mag > C['maxmag']: return C['maxsigma'] else: return C['sigm...
python
def _get_stddev_rock(self, mag, imt): """ Calculate and return total standard deviation for rock sites. Implements formulae from table 3. """ C = self.COEFFS_ROCK_STDDERR[imt] if mag > C['maxmag']: return C['maxsigma'] else: return C['sigm...
[ "def", "_get_stddev_rock", "(", "self", ",", "mag", ",", "imt", ")", ":", "C", "=", "self", ".", "COEFFS_ROCK_STDDERR", "[", "imt", "]", "if", "mag", ">", "C", "[", "'maxmag'", "]", ":", "return", "C", "[", "'maxsigma'", "]", "else", ":", "return", ...
Calculate and return total standard deviation for rock sites. Implements formulae from table 3.
[ "Calculate", "and", "return", "total", "standard", "deviation", "for", "rock", "sites", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/sadigh_1997.py#L165-L175
train
gem/oq-engine
openquake/hazardlib/gsim/sadigh_1997.py
SadighEtAl1997._get_stddev_deep_soil
def _get_stddev_deep_soil(self, mag, imt): """ Calculate and return total standard deviation for deep soil sites. Implements formulae from the last column of table 4. """ # footnote from table 4 says that stderr for magnitudes over 7 # is equal to one of magnitude 7. ...
python
def _get_stddev_deep_soil(self, mag, imt): """ Calculate and return total standard deviation for deep soil sites. Implements formulae from the last column of table 4. """ # footnote from table 4 says that stderr for magnitudes over 7 # is equal to one of magnitude 7. ...
[ "def", "_get_stddev_deep_soil", "(", "self", ",", "mag", ",", "imt", ")", ":", "if", "mag", ">", "7", ":", "mag", "=", "7", "C", "=", "self", ".", "COEFFS_SOIL", "[", "imt", "]", "return", "C", "[", "'sigma0'", "]", "+", "C", "[", "'magfactor'", ...
Calculate and return total standard deviation for deep soil sites. Implements formulae from the last column of table 4.
[ "Calculate", "and", "return", "total", "standard", "deviation", "for", "deep", "soil", "sites", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/sadigh_1997.py#L177-L188
train
gem/oq-engine
openquake/commands/zip.py
zip
def zip(what, archive_zip='', risk_file=''): """ Zip into an archive one or two job.ini files with all related files """ if os.path.isdir(what): oqzip.zip_all(what) elif what.endswith('.xml') and '<logicTree' in open(what).read(512): # hack to see if the NRML file is of kind logicTre...
python
def zip(what, archive_zip='', risk_file=''): """ Zip into an archive one or two job.ini files with all related files """ if os.path.isdir(what): oqzip.zip_all(what) elif what.endswith('.xml') and '<logicTree' in open(what).read(512): # hack to see if the NRML file is of kind logicTre...
[ "def", "zip", "(", "what", ",", "archive_zip", "=", "''", ",", "risk_file", "=", "''", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "what", ")", ":", "oqzip", ".", "zip_all", "(", "what", ")", "elif", "what", ".", "endswith", "(", "'.xml...
Zip into an archive one or two job.ini files with all related files
[ "Zip", "into", "an", "archive", "one", "or", "two", "job", ".", "ini", "files", "with", "all", "related", "files" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/zip.py#L25-L40
train
gem/oq-engine
openquake/commands/reduce.py
reduce
def reduce(fname, reduction_factor): """ Produce a submodel from `fname` by sampling the nodes randomly. Supports source models, site models and exposure models. As a special case, it is also able to reduce .csv files by sampling the lines. This is a debugging utility to reduce large computations to...
python
def reduce(fname, reduction_factor): """ Produce a submodel from `fname` by sampling the nodes randomly. Supports source models, site models and exposure models. As a special case, it is also able to reduce .csv files by sampling the lines. This is a debugging utility to reduce large computations to...
[ "def", "reduce", "(", "fname", ",", "reduction_factor", ")", ":", "if", "fname", ".", "endswith", "(", "'.csv'", ")", ":", "with", "open", "(", "fname", ")", "as", "f", ":", "line", "=", "f", ".", "readline", "(", ")", "if", "csv", ".", "Sniffer", ...
Produce a submodel from `fname` by sampling the nodes randomly. Supports source models, site models and exposure models. As a special case, it is also able to reduce .csv files by sampling the lines. This is a debugging utility to reduce large computations to small ones.
[ "Produce", "a", "submodel", "from", "fname", "by", "sampling", "the", "nodes", "randomly", ".", "Supports", "source", "models", "site", "models", "and", "exposure", "models", ".", "As", "a", "special", "case", "it", "is", "also", "able", "to", "reduce", "....
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/reduce.py#L60-L111
train
gem/oq-engine
openquake/hazardlib/geo/surface/base.py
downsample_mesh
def downsample_mesh(mesh, tol=1.0): """ Returns a mesh sampled at a lower resolution - if the difference in azimuth is larger than the specified tolerance a turn is assumed :returns: Downsampled mesh as instance of :class: openquake.hazardlib.geo.mesh.RectangularMesh """ idx = _...
python
def downsample_mesh(mesh, tol=1.0): """ Returns a mesh sampled at a lower resolution - if the difference in azimuth is larger than the specified tolerance a turn is assumed :returns: Downsampled mesh as instance of :class: openquake.hazardlib.geo.mesh.RectangularMesh """ idx = _...
[ "def", "downsample_mesh", "(", "mesh", ",", "tol", "=", "1.0", ")", ":", "idx", "=", "_find_turning_points", "(", "mesh", ",", "tol", ")", "if", "mesh", ".", "depths", "is", "not", "None", ":", "return", "RectangularMesh", "(", "lons", "=", "mesh", "."...
Returns a mesh sampled at a lower resolution - if the difference in azimuth is larger than the specified tolerance a turn is assumed :returns: Downsampled mesh as instance of :class: openquake.hazardlib.geo.mesh.RectangularMesh
[ "Returns", "a", "mesh", "sampled", "at", "a", "lower", "resolution", "-", "if", "the", "difference", "in", "azimuth", "is", "larger", "than", "the", "specified", "tolerance", "a", "turn", "is", "assumed" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/base.py#L64-L80
train
gem/oq-engine
openquake/hazardlib/geo/surface/base.py
downsample_trace
def downsample_trace(mesh, tol=1.0): """ Downsamples the upper edge of a fault within a rectangular mesh, retaining node points only if changes in direction on the order of tol are found :returns: Downsampled edge as a numpy array of [long, lat, depth] """ idx = _find_turning_points(mes...
python
def downsample_trace(mesh, tol=1.0): """ Downsamples the upper edge of a fault within a rectangular mesh, retaining node points only if changes in direction on the order of tol are found :returns: Downsampled edge as a numpy array of [long, lat, depth] """ idx = _find_turning_points(mes...
[ "def", "downsample_trace", "(", "mesh", ",", "tol", "=", "1.0", ")", ":", "idx", "=", "_find_turning_points", "(", "mesh", ",", "tol", ")", "if", "mesh", ".", "depths", "is", "not", "None", ":", "return", "numpy", ".", "column_stack", "(", "[", "mesh",...
Downsamples the upper edge of a fault within a rectangular mesh, retaining node points only if changes in direction on the order of tol are found :returns: Downsampled edge as a numpy array of [long, lat, depth]
[ "Downsamples", "the", "upper", "edge", "of", "a", "fault", "within", "a", "rectangular", "mesh", "retaining", "node", "points", "only", "if", "changes", "in", "direction", "on", "the", "order", "of", "tol", "are", "found" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/base.py#L83-L97
train
gem/oq-engine
openquake/hazardlib/geo/surface/base.py
BaseSurface.get_ry0_distance
def get_ry0_distance(self, mesh): """ Compute the minimum distance between each point of a mesh and the great circle arcs perpendicular to the average strike direction of the fault trace and passing through the end-points of the trace. :param mesh: :class:`~openquake...
python
def get_ry0_distance(self, mesh): """ Compute the minimum distance between each point of a mesh and the great circle arcs perpendicular to the average strike direction of the fault trace and passing through the end-points of the trace. :param mesh: :class:`~openquake...
[ "def", "get_ry0_distance", "(", "self", ",", "mesh", ")", ":", "top_edge", "=", "self", ".", "mesh", "[", "0", ":", "1", "]", "mean_strike", "=", "self", ".", "get_strike", "(", ")", "dst1", "=", "geodetic", ".", "distance_to_arc", "(", "top_edge", "."...
Compute the minimum distance between each point of a mesh and the great circle arcs perpendicular to the average strike direction of the fault trace and passing through the end-points of the trace. :param mesh: :class:`~openquake.hazardlib.geo.mesh.Mesh` of points to calculate ...
[ "Compute", "the", "minimum", "distance", "between", "each", "point", "of", "a", "mesh", "and", "the", "great", "circle", "arcs", "perpendicular", "to", "the", "average", "strike", "direction", "of", "the", "fault", "trace", "and", "passing", "through", "the", ...
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/base.py#L148-L180
train
gem/oq-engine
openquake/hazardlib/geo/surface/base.py
BaseSurface.get_rx_distance
def get_rx_distance(self, mesh): """ Compute distance between each point of mesh and surface's great circle arc. Distance is measured perpendicular to the rupture strike, from the surface projection of the updip edge of the rupture, with the down dip direction being posi...
python
def get_rx_distance(self, mesh): """ Compute distance between each point of mesh and surface's great circle arc. Distance is measured perpendicular to the rupture strike, from the surface projection of the updip edge of the rupture, with the down dip direction being posi...
[ "def", "get_rx_distance", "(", "self", ",", "mesh", ")", ":", "top_edge", "=", "self", ".", "mesh", "[", "0", ":", "1", "]", "dists", "=", "[", "]", "if", "top_edge", ".", "lons", ".", "shape", "[", "1", "]", "<", "3", ":", "i", "=", "0", "p1...
Compute distance between each point of mesh and surface's great circle arc. Distance is measured perpendicular to the rupture strike, from the surface projection of the updip edge of the rupture, with the down dip direction being positive (this distance is usually called ``Rx``)...
[ "Compute", "distance", "between", "each", "point", "of", "mesh", "and", "surface", "s", "great", "circle", "arc", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/base.py#L182-L266
train
gem/oq-engine
openquake/hazardlib/geo/surface/base.py
BaseSurface.get_top_edge_depth
def get_top_edge_depth(self): """ Return minimum depth of surface's top edge. :returns: Float value, the vertical distance between the earth surface and the shallowest point in surface's top edge in km. """ top_edge = self.mesh[0:1] if top_edge.de...
python
def get_top_edge_depth(self): """ Return minimum depth of surface's top edge. :returns: Float value, the vertical distance between the earth surface and the shallowest point in surface's top edge in km. """ top_edge = self.mesh[0:1] if top_edge.de...
[ "def", "get_top_edge_depth", "(", "self", ")", ":", "top_edge", "=", "self", ".", "mesh", "[", "0", ":", "1", "]", "if", "top_edge", ".", "depths", "is", "None", ":", "return", "0", "else", ":", "return", "numpy", ".", "min", "(", "top_edge", ".", ...
Return minimum depth of surface's top edge. :returns: Float value, the vertical distance between the earth surface and the shallowest point in surface's top edge in km.
[ "Return", "minimum", "depth", "of", "surface", "s", "top", "edge", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/base.py#L268-L280
train
gem/oq-engine
openquake/hazardlib/geo/surface/base.py
BaseSurface.get_area
def get_area(self): """ Compute area as the sum of the mesh cells area values. """ mesh = self.mesh _, _, _, area = mesh.get_cell_dimensions() return numpy.sum(area)
python
def get_area(self): """ Compute area as the sum of the mesh cells area values. """ mesh = self.mesh _, _, _, area = mesh.get_cell_dimensions() return numpy.sum(area)
[ "def", "get_area", "(", "self", ")", ":", "mesh", "=", "self", ".", "mesh", "_", ",", "_", ",", "_", ",", "area", "=", "mesh", ".", "get_cell_dimensions", "(", ")", "return", "numpy", ".", "sum", "(", "area", ")" ]
Compute area as the sum of the mesh cells area values.
[ "Compute", "area", "as", "the", "sum", "of", "the", "mesh", "cells", "area", "values", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/base.py#L290-L297
train
gem/oq-engine
openquake/hazardlib/geo/surface/base.py
BaseSurface.get_surface_boundaries
def get_surface_boundaries(self): """ Returns the boundaries in the same format as a multiplanar surface, with two one-element lists of lons and lats """ mesh = self.mesh lons = numpy.concatenate((mesh.lons[0, :], mesh.lons[1:, -1], ...
python
def get_surface_boundaries(self): """ Returns the boundaries in the same format as a multiplanar surface, with two one-element lists of lons and lats """ mesh = self.mesh lons = numpy.concatenate((mesh.lons[0, :], mesh.lons[1:, -1], ...
[ "def", "get_surface_boundaries", "(", "self", ")", ":", "mesh", "=", "self", ".", "mesh", "lons", "=", "numpy", ".", "concatenate", "(", "(", "mesh", ".", "lons", "[", "0", ",", ":", "]", ",", "mesh", ".", "lons", "[", "1", ":", ",", "-", "1", ...
Returns the boundaries in the same format as a multiplanar surface, with two one-element lists of lons and lats
[ "Returns", "the", "boundaries", "in", "the", "same", "format", "as", "a", "multiplanar", "surface", "with", "two", "one", "-", "element", "lists", "of", "lons", "and", "lats" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/base.py#L326-L340
train
gem/oq-engine
openquake/hazardlib/geo/surface/base.py
BaseSurface.get_resampled_top_edge
def get_resampled_top_edge(self, angle_var=0.1): """ This methods computes a simplified representation of a fault top edge by removing the points that are not describing a change of direction, provided a certain tolerance angle. :param float angle_var: Number represe...
python
def get_resampled_top_edge(self, angle_var=0.1): """ This methods computes a simplified representation of a fault top edge by removing the points that are not describing a change of direction, provided a certain tolerance angle. :param float angle_var: Number represe...
[ "def", "get_resampled_top_edge", "(", "self", ",", "angle_var", "=", "0.1", ")", ":", "mesh", "=", "self", ".", "mesh", "top_edge", "=", "[", "Point", "(", "mesh", ".", "lons", "[", "0", "]", "[", "0", "]", ",", "mesh", ".", "lats", "[", "0", "]"...
This methods computes a simplified representation of a fault top edge by removing the points that are not describing a change of direction, provided a certain tolerance angle. :param float angle_var: Number representing the maximum deviation (in degrees) admitted without...
[ "This", "methods", "computes", "a", "simplified", "representation", "of", "a", "fault", "top", "edge", "by", "removing", "the", "points", "that", "are", "not", "describing", "a", "change", "of", "direction", "provided", "a", "certain", "tolerance", "angle", "....
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/base.py#L342-L375
train
gem/oq-engine
openquake/hazardlib/geo/surface/base.py
BaseSurface.get_hypo_location
def get_hypo_location(self, mesh_spacing, hypo_loc=None): """ The method determines the location of the hypocentre within the rupture :param mesh: :class:`~openquake.hazardlib.geo.mesh.Mesh` of points :param mesh_spacing: The desired distance between two adjacent...
python
def get_hypo_location(self, mesh_spacing, hypo_loc=None): """ The method determines the location of the hypocentre within the rupture :param mesh: :class:`~openquake.hazardlib.geo.mesh.Mesh` of points :param mesh_spacing: The desired distance between two adjacent...
[ "def", "get_hypo_location", "(", "self", ",", "mesh_spacing", ",", "hypo_loc", "=", "None", ")", ":", "mesh", "=", "self", ".", "mesh", "centroid", "=", "mesh", ".", "get_middle_point", "(", ")", "if", "hypo_loc", "is", "None", ":", "return", "centroid", ...
The method determines the location of the hypocentre within the rupture :param mesh: :class:`~openquake.hazardlib.geo.mesh.Mesh` of points :param mesh_spacing: The desired distance between two adjacent points in source's ruptures' mesh, in km. Mainly this parameter a...
[ "The", "method", "determines", "the", "location", "of", "the", "hypocentre", "within", "the", "rupture" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/base.py#L377-L414
train
gem/oq-engine
openquake/engine/tools/viewlog.py
viewlog
def viewlog(calc_id, host='localhost', port=8000): """ Extract the log of the given calculation ID from the WebUI """ base_url = 'http://%s:%s/v1/calc/' % (host, port) start = 0 psize = 10 # page size try: while True: url = base_url + '%d/log/%d:%d' % (calc_id, start, st...
python
def viewlog(calc_id, host='localhost', port=8000): """ Extract the log of the given calculation ID from the WebUI """ base_url = 'http://%s:%s/v1/calc/' % (host, port) start = 0 psize = 10 # page size try: while True: url = base_url + '%d/log/%d:%d' % (calc_id, start, st...
[ "def", "viewlog", "(", "calc_id", ",", "host", "=", "'localhost'", ",", "port", "=", "8000", ")", ":", "base_url", "=", "'http://%s:%s/v1/calc/'", "%", "(", "host", ",", "port", ")", "start", "=", "0", "psize", "=", "10", "try", ":", "while", "True", ...
Extract the log of the given calculation ID from the WebUI
[ "Extract", "the", "log", "of", "the", "given", "calculation", "ID", "from", "the", "WebUI" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/engine/tools/viewlog.py#L33-L49
train
gem/oq-engine
openquake/baselib/parallel.py
pickle_sequence
def pickle_sequence(objects): """ Convert an iterable of objects into a list of pickled objects. If the iterable contains copies, the pickling will be done only once. If the iterable contains objects already pickled, they will not be pickled again. :param objects: a sequence of objects to pickl...
python
def pickle_sequence(objects): """ Convert an iterable of objects into a list of pickled objects. If the iterable contains copies, the pickling will be done only once. If the iterable contains objects already pickled, they will not be pickled again. :param objects: a sequence of objects to pickl...
[ "def", "pickle_sequence", "(", "objects", ")", ":", "cache", "=", "{", "}", "out", "=", "[", "]", "for", "obj", "in", "objects", ":", "obj_id", "=", "id", "(", "obj", ")", "if", "obj_id", "not", "in", "cache", ":", "if", "isinstance", "(", "obj", ...
Convert an iterable of objects into a list of pickled objects. If the iterable contains copies, the pickling will be done only once. If the iterable contains objects already pickled, they will not be pickled again. :param objects: a sequence of objects to pickle
[ "Convert", "an", "iterable", "of", "objects", "into", "a", "list", "of", "pickled", "objects", ".", "If", "the", "iterable", "contains", "copies", "the", "pickling", "will", "be", "done", "only", "once", ".", "If", "the", "iterable", "contains", "objects", ...
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/parallel.py#L294-L313
train
gem/oq-engine
openquake/baselib/parallel.py
check_mem_usage
def check_mem_usage(soft_percent=None, hard_percent=None): """ Display a warning if we are running out of memory """ soft_percent = soft_percent or config.memory.soft_mem_limit hard_percent = hard_percent or config.memory.hard_mem_limit used_mem_percent = psutil.virtual_memory().percent if u...
python
def check_mem_usage(soft_percent=None, hard_percent=None): """ Display a warning if we are running out of memory """ soft_percent = soft_percent or config.memory.soft_mem_limit hard_percent = hard_percent or config.memory.hard_mem_limit used_mem_percent = psutil.virtual_memory().percent if u...
[ "def", "check_mem_usage", "(", "soft_percent", "=", "None", ",", "hard_percent", "=", "None", ")", ":", "soft_percent", "=", "soft_percent", "or", "config", ".", "memory", ".", "soft_mem_limit", "hard_percent", "=", "hard_percent", "or", "config", ".", "memory",...
Display a warning if we are running out of memory
[ "Display", "a", "warning", "if", "we", "are", "running", "out", "of", "memory" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/parallel.py#L370-L383
train
gem/oq-engine
openquake/baselib/parallel.py
init_workers
def init_workers(): """Waiting function, used to wake up the process pool""" setproctitle('oq-worker') # unregister raiseMasterKilled in oq-workers to avoid deadlock # since processes are terminated via pool.terminate() signal.signal(signal.SIGTERM, signal.SIG_DFL) # prctl is still useful (on Li...
python
def init_workers(): """Waiting function, used to wake up the process pool""" setproctitle('oq-worker') # unregister raiseMasterKilled in oq-workers to avoid deadlock # since processes are terminated via pool.terminate() signal.signal(signal.SIGTERM, signal.SIG_DFL) # prctl is still useful (on Li...
[ "def", "init_workers", "(", ")", ":", "setproctitle", "(", "'oq-worker'", ")", "signal", ".", "signal", "(", "signal", ".", "SIGTERM", ",", "signal", ".", "SIG_DFL", ")", "try", ":", "import", "prctl", "except", "ImportError", ":", "pass", "else", ":", "...
Waiting function, used to wake up the process pool
[ "Waiting", "function", "used", "to", "wake", "up", "the", "process", "pool" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/parallel.py#L567-L581
train
gem/oq-engine
openquake/baselib/parallel.py
Result.get
def get(self): """ Returns the underlying value or raise the underlying exception """ val = self.pik.unpickle() if self.tb_str: etype = val.__class__ msg = '\n%s%s: %s' % (self.tb_str, etype.__name__, val) if issubclass(etype, KeyError): ...
python
def get(self): """ Returns the underlying value or raise the underlying exception """ val = self.pik.unpickle() if self.tb_str: etype = val.__class__ msg = '\n%s%s: %s' % (self.tb_str, etype.__name__, val) if issubclass(etype, KeyError): ...
[ "def", "get", "(", "self", ")", ":", "val", "=", "self", ".", "pik", ".", "unpickle", "(", ")", "if", "self", ".", "tb_str", ":", "etype", "=", "val", ".", "__class__", "msg", "=", "'\\n%s%s: %s'", "%", "(", "self", ".", "tb_str", ",", "etype", "...
Returns the underlying value or raise the underlying exception
[ "Returns", "the", "underlying", "value", "or", "raise", "the", "underlying", "exception" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/parallel.py#L337-L349
train
gem/oq-engine
openquake/baselib/parallel.py
IterResult.sum
def sum(cls, iresults): """ Sum the data transfer information of a set of results """ res = object.__new__(cls) res.received = [] res.sent = 0 for iresult in iresults: res.received.extend(iresult.received) res.sent += iresult.sent ...
python
def sum(cls, iresults): """ Sum the data transfer information of a set of results """ res = object.__new__(cls) res.received = [] res.sent = 0 for iresult in iresults: res.received.extend(iresult.received) res.sent += iresult.sent ...
[ "def", "sum", "(", "cls", ",", "iresults", ")", ":", "res", "=", "object", ".", "__new__", "(", "cls", ")", "res", ".", "received", "=", "[", "]", "res", ".", "sent", "=", "0", "for", "iresult", "in", "iresults", ":", "res", ".", "received", ".",...
Sum the data transfer information of a set of results
[ "Sum", "the", "data", "transfer", "information", "of", "a", "set", "of", "results" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/parallel.py#L532-L547
train
gem/oq-engine
openquake/baselib/parallel.py
Starmap.log_percent
def log_percent(self): """ Log the progress of the computation in percentage """ done = self.total - self.todo percent = int(float(done) / self.total * 100) if not hasattr(self, 'prev_percent'): # first time self.prev_percent = 0 self.progress('Se...
python
def log_percent(self): """ Log the progress of the computation in percentage """ done = self.total - self.todo percent = int(float(done) / self.total * 100) if not hasattr(self, 'prev_percent'): # first time self.prev_percent = 0 self.progress('Se...
[ "def", "log_percent", "(", "self", ")", ":", "done", "=", "self", ".", "total", "-", "self", ".", "todo", "percent", "=", "int", "(", "float", "(", "done", ")", "/", "self", ".", "total", "*", "100", ")", "if", "not", "hasattr", "(", "self", ",",...
Log the progress of the computation in percentage
[ "Log", "the", "progress", "of", "the", "computation", "in", "percentage" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/parallel.py#L691-L705
train
gem/oq-engine
openquake/baselib/parallel.py
Starmap.submit
def submit(self, *args, func=None, monitor=None): """ Submit the given arguments to the underlying task """ monitor = monitor or self.monitor func = func or self.task_func if not hasattr(self, 'socket'): # first time self.__class__.running_tasks = self.tasks ...
python
def submit(self, *args, func=None, monitor=None): """ Submit the given arguments to the underlying task """ monitor = monitor or self.monitor func = func or self.task_func if not hasattr(self, 'socket'): # first time self.__class__.running_tasks = self.tasks ...
[ "def", "submit", "(", "self", ",", "*", "args", ",", "func", "=", "None", ",", "monitor", "=", "None", ")", ":", "monitor", "=", "monitor", "or", "self", ".", "monitor", "func", "=", "func", "or", "self", ".", "task_func", "if", "not", "hasattr", "...
Submit the given arguments to the underlying task
[ "Submit", "the", "given", "arguments", "to", "the", "underlying", "task" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/parallel.py#L707-L724
train
gem/oq-engine
openquake/baselib/parallel.py
Starmap.reduce
def reduce(self, agg=operator.add, acc=None): """ Submit all tasks and reduce the results """ return self.submit_all().reduce(agg, acc)
python
def reduce(self, agg=operator.add, acc=None): """ Submit all tasks and reduce the results """ return self.submit_all().reduce(agg, acc)
[ "def", "reduce", "(", "self", ",", "agg", "=", "operator", ".", "add", ",", "acc", "=", "None", ")", ":", "return", "self", ".", "submit_all", "(", ")", ".", "reduce", "(", "agg", ",", "acc", ")" ]
Submit all tasks and reduce the results
[ "Submit", "all", "tasks", "and", "reduce", "the", "results" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/parallel.py#L748-L752
train
gem/oq-engine
openquake/hazardlib/probability_map.py
ProbabilityCurve.convert
def convert(self, imtls, idx=0): """ Convert a probability curve into a record of dtype `imtls.dt`. :param imtls: DictArray instance :param idx: extract the data corresponding to the given inner index """ curve = numpy.zeros(1, imtls.dt) for imt in imtls: ...
python
def convert(self, imtls, idx=0): """ Convert a probability curve into a record of dtype `imtls.dt`. :param imtls: DictArray instance :param idx: extract the data corresponding to the given inner index """ curve = numpy.zeros(1, imtls.dt) for imt in imtls: ...
[ "def", "convert", "(", "self", ",", "imtls", ",", "idx", "=", "0", ")", ":", "curve", "=", "numpy", ".", "zeros", "(", "1", ",", "imtls", ".", "dt", ")", "for", "imt", "in", "imtls", ":", "curve", "[", "imt", "]", "=", "self", ".", "array", "...
Convert a probability curve into a record of dtype `imtls.dt`. :param imtls: DictArray instance :param idx: extract the data corresponding to the given inner index
[ "Convert", "a", "probability", "curve", "into", "a", "record", "of", "dtype", "imtls", ".", "dt", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/probability_map.py#L96-L106
train
gem/oq-engine
openquake/hazardlib/probability_map.py
ProbabilityMap.nbytes
def nbytes(self): """The size of the underlying array""" try: N, L, I = get_shape([self]) except AllEmptyProbabilityMaps: return 0 return BYTES_PER_FLOAT * N * L * I
python
def nbytes(self): """The size of the underlying array""" try: N, L, I = get_shape([self]) except AllEmptyProbabilityMaps: return 0 return BYTES_PER_FLOAT * N * L * I
[ "def", "nbytes", "(", "self", ")", ":", "try", ":", "N", ",", "L", ",", "I", "=", "get_shape", "(", "[", "self", "]", ")", "except", "AllEmptyProbabilityMaps", ":", "return", "0", "return", "BYTES_PER_FLOAT", "*", "N", "*", "L", "*", "I" ]
The size of the underlying array
[ "The", "size", "of", "the", "underlying", "array" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/probability_map.py#L194-L200
train
gem/oq-engine
openquake/hazardlib/probability_map.py
ProbabilityMap.convert
def convert(self, imtls, nsites, idx=0): """ Convert a probability map into a composite array of length `nsites` and dtype `imtls.dt`. :param imtls: DictArray instance :param nsites: the total number of sites :param idx: index on the z...
python
def convert(self, imtls, nsites, idx=0): """ Convert a probability map into a composite array of length `nsites` and dtype `imtls.dt`. :param imtls: DictArray instance :param nsites: the total number of sites :param idx: index on the z...
[ "def", "convert", "(", "self", ",", "imtls", ",", "nsites", ",", "idx", "=", "0", ")", ":", "curves", "=", "numpy", ".", "zeros", "(", "nsites", ",", "imtls", ".", "dt", ")", "for", "imt", "in", "curves", ".", "dtype", ".", "names", ":", "curves_...
Convert a probability map into a composite array of length `nsites` and dtype `imtls.dt`. :param imtls: DictArray instance :param nsites: the total number of sites :param idx: index on the z-axis (default 0)
[ "Convert", "a", "probability", "map", "into", "a", "composite", "array", "of", "length", "nsites", "and", "dtype", "imtls", ".", "dt", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/probability_map.py#L203-L220
train
gem/oq-engine
openquake/hazardlib/probability_map.py
ProbabilityMap.filter
def filter(self, sids): """ Extracs a submap of self for the given sids. """ dic = self.__class__(self.shape_y, self.shape_z) for sid in sids: try: dic[sid] = self[sid] except KeyError: pass return dic
python
def filter(self, sids): """ Extracs a submap of self for the given sids. """ dic = self.__class__(self.shape_y, self.shape_z) for sid in sids: try: dic[sid] = self[sid] except KeyError: pass return dic
[ "def", "filter", "(", "self", ",", "sids", ")", ":", "dic", "=", "self", ".", "__class__", "(", "self", ".", "shape_y", ",", "self", ".", "shape_z", ")", "for", "sid", "in", "sids", ":", "try", ":", "dic", "[", "sid", "]", "=", "self", "[", "si...
Extracs a submap of self for the given sids.
[ "Extracs", "a", "submap", "of", "self", "for", "the", "given", "sids", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/probability_map.py#L247-L257
train
gem/oq-engine
openquake/hazardlib/probability_map.py
ProbabilityMap.extract
def extract(self, inner_idx): """ Extracts a component of the underlying ProbabilityCurves, specified by the index `inner_idx`. """ out = self.__class__(self.shape_y, 1) for sid in self: curve = self[sid] array = curve.array[:, inner_idx].reshape(-...
python
def extract(self, inner_idx): """ Extracts a component of the underlying ProbabilityCurves, specified by the index `inner_idx`. """ out = self.__class__(self.shape_y, 1) for sid in self: curve = self[sid] array = curve.array[:, inner_idx].reshape(-...
[ "def", "extract", "(", "self", ",", "inner_idx", ")", ":", "out", "=", "self", ".", "__class__", "(", "self", ".", "shape_y", ",", "1", ")", "for", "sid", "in", "self", ":", "curve", "=", "self", "[", "sid", "]", "array", "=", "curve", ".", "arra...
Extracts a component of the underlying ProbabilityCurves, specified by the index `inner_idx`.
[ "Extracts", "a", "component", "of", "the", "underlying", "ProbabilityCurves", "specified", "by", "the", "index", "inner_idx", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/probability_map.py#L259-L269
train
gem/oq-engine
openquake/commands/compare.py
compare
def compare(what, imt, calc_ids, files, samplesites=100, rtol=.1, atol=1E-4): """ Compare the hazard curves or maps of two or more calculations """ sids, imtls, poes, arrays = getdata(what, calc_ids, samplesites) try: levels = imtls[imt] except KeyError: sys.exit( '%s...
python
def compare(what, imt, calc_ids, files, samplesites=100, rtol=.1, atol=1E-4): """ Compare the hazard curves or maps of two or more calculations """ sids, imtls, poes, arrays = getdata(what, calc_ids, samplesites) try: levels = imtls[imt] except KeyError: sys.exit( '%s...
[ "def", "compare", "(", "what", ",", "imt", ",", "calc_ids", ",", "files", ",", "samplesites", "=", "100", ",", "rtol", "=", ".1", ",", "atol", "=", "1E-4", ")", ":", "sids", ",", "imtls", ",", "poes", ",", "arrays", "=", "getdata", "(", "what", "...
Compare the hazard curves or maps of two or more calculations
[ "Compare", "the", "hazard", "curves", "or", "maps", "of", "two", "or", "more", "calculations" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/compare.py#L69-L107
train
gem/oq-engine
openquake/hmtk/plotting/seismicity/catalogue_plots.py
build_filename
def build_filename(filename, filetype='png', resolution=300): """ Uses the input properties to create the string of the filename :param str filename: Name of the file :param str filetype: Type of file :param int resolution: DPI resolution of the output figure """ fil...
python
def build_filename(filename, filetype='png', resolution=300): """ Uses the input properties to create the string of the filename :param str filename: Name of the file :param str filetype: Type of file :param int resolution: DPI resolution of the output figure """ fil...
[ "def", "build_filename", "(", "filename", ",", "filetype", "=", "'png'", ",", "resolution", "=", "300", ")", ":", "filevals", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "if", "filevals", "[", "1", "]", ":", "filetype", "=", "fileval...
Uses the input properties to create the string of the filename :param str filename: Name of the file :param str filetype: Type of file :param int resolution: DPI resolution of the output figure
[ "Uses", "the", "input", "properties", "to", "create", "the", "string", "of", "the", "filename" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/catalogue_plots.py#L61-L81
train
gem/oq-engine
openquake/hmtk/plotting/seismicity/catalogue_plots.py
_get_catalogue_bin_limits
def _get_catalogue_bin_limits(catalogue, dmag): """ Returns the magnitude bins corresponing to the catalogue """ mag_bins = np.arange( float(np.floor(np.min(catalogue.data['magnitude']))) - dmag, float(np.ceil(np.max(catalogue.data['magnitude']))) + dmag, dmag) counter = np.h...
python
def _get_catalogue_bin_limits(catalogue, dmag): """ Returns the magnitude bins corresponing to the catalogue """ mag_bins = np.arange( float(np.floor(np.min(catalogue.data['magnitude']))) - dmag, float(np.ceil(np.max(catalogue.data['magnitude']))) + dmag, dmag) counter = np.h...
[ "def", "_get_catalogue_bin_limits", "(", "catalogue", ",", "dmag", ")", ":", "mag_bins", "=", "np", ".", "arange", "(", "float", "(", "np", ".", "floor", "(", "np", ".", "min", "(", "catalogue", ".", "data", "[", "'magnitude'", "]", ")", ")", ")", "-...
Returns the magnitude bins corresponing to the catalogue
[ "Returns", "the", "magnitude", "bins", "corresponing", "to", "the", "catalogue" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/catalogue_plots.py#L103-L114
train
gem/oq-engine
openquake/hmtk/plotting/seismicity/catalogue_plots.py
plot_depth_histogram
def plot_depth_histogram( catalogue, bin_width, normalisation=False, bootstrap=None, filename=None, figure_size=(8, 6), filetype='png', dpi=300, ax=None): """ Creates a histogram of the depths in the catalogue :param catalogue: Earthquake catalogue as instance of :class: ...
python
def plot_depth_histogram( catalogue, bin_width, normalisation=False, bootstrap=None, filename=None, figure_size=(8, 6), filetype='png', dpi=300, ax=None): """ Creates a histogram of the depths in the catalogue :param catalogue: Earthquake catalogue as instance of :class: ...
[ "def", "plot_depth_histogram", "(", "catalogue", ",", "bin_width", ",", "normalisation", "=", "False", ",", "bootstrap", "=", "None", ",", "filename", "=", "None", ",", "figure_size", "=", "(", "8", ",", "6", ")", ",", "filetype", "=", "'png'", ",", "dpi...
Creates a histogram of the depths in the catalogue :param catalogue: Earthquake catalogue as instance of :class: openquake.hmtk.seismicity.catalogue.Catalogue :param float bin_width: Width of the histogram for the depth bins :param bool normalisation: Normalise the histogram...
[ "Creates", "a", "histogram", "of", "the", "depths", "in", "the", "catalogue" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/catalogue_plots.py#L117-L158
train
gem/oq-engine
openquake/hmtk/plotting/seismicity/catalogue_plots.py
plot_magnitude_depth_density
def plot_magnitude_depth_density( catalogue, mag_int, depth_int, logscale=False, normalisation=False, bootstrap=None, filename=None, figure_size=(8, 6), filetype='png', dpi=300, ax=None): """ Creates a density plot of the magnitude and depth distribution :param catalogue: Ea...
python
def plot_magnitude_depth_density( catalogue, mag_int, depth_int, logscale=False, normalisation=False, bootstrap=None, filename=None, figure_size=(8, 6), filetype='png', dpi=300, ax=None): """ Creates a density plot of the magnitude and depth distribution :param catalogue: Ea...
[ "def", "plot_magnitude_depth_density", "(", "catalogue", ",", "mag_int", ",", "depth_int", ",", "logscale", "=", "False", ",", "normalisation", "=", "False", ",", "bootstrap", "=", "None", ",", "filename", "=", "None", ",", "figure_size", "=", "(", "8", ",",...
Creates a density plot of the magnitude and depth distribution :param catalogue: Earthquake catalogue as instance of :class: openquake.hmtk.seismicity.catalogue.Catalogue :param float mag_int: Width of the histogram for the magnitude bins :param float depth_int: Width of the...
[ "Creates", "a", "density", "plot", "of", "the", "magnitude", "and", "depth", "distribution" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/catalogue_plots.py#L161-L218
train
gem/oq-engine
openquake/hmtk/plotting/seismicity/catalogue_plots.py
plot_magnitude_time_scatter
def plot_magnitude_time_scatter( catalogue, plot_error=False, fmt_string='o', filename=None, figure_size=(8, 6), filetype='png', dpi=300, ax=None): """ Creates a simple scatter plot of magnitude with time :param catalogue: Earthquake catalogue as instance of :class: openquak...
python
def plot_magnitude_time_scatter( catalogue, plot_error=False, fmt_string='o', filename=None, figure_size=(8, 6), filetype='png', dpi=300, ax=None): """ Creates a simple scatter plot of magnitude with time :param catalogue: Earthquake catalogue as instance of :class: openquak...
[ "def", "plot_magnitude_time_scatter", "(", "catalogue", ",", "plot_error", "=", "False", ",", "fmt_string", "=", "'o'", ",", "filename", "=", "None", ",", "figure_size", "=", "(", "8", ",", "6", ")", ",", "filetype", "=", "'png'", ",", "dpi", "=", "300",...
Creates a simple scatter plot of magnitude with time :param catalogue: Earthquake catalogue as instance of :class: openquake.hmtk.seismicity.catalogue.Catalogue :param bool plot_error: Choose to plot error bars (True) or not (False) :param str fmt_string: Symbology of plot
[ "Creates", "a", "simple", "scatter", "plot", "of", "magnitude", "with", "time" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/catalogue_plots.py#L221-L258
train
gem/oq-engine
openquake/hmtk/plotting/seismicity/catalogue_plots.py
plot_magnitude_time_density
def plot_magnitude_time_density( catalogue, mag_int, time_int, completeness=None, normalisation=False, logscale=True, bootstrap=None, xlim=[], ylim=[], filename=None, figure_size=(8, 6), filetype='png', dpi=300, ax=None): """ Creates a plot of magnitude-time density :param catalogue...
python
def plot_magnitude_time_density( catalogue, mag_int, time_int, completeness=None, normalisation=False, logscale=True, bootstrap=None, xlim=[], ylim=[], filename=None, figure_size=(8, 6), filetype='png', dpi=300, ax=None): """ Creates a plot of magnitude-time density :param catalogue...
[ "def", "plot_magnitude_time_density", "(", "catalogue", ",", "mag_int", ",", "time_int", ",", "completeness", "=", "None", ",", "normalisation", "=", "False", ",", "logscale", "=", "True", ",", "bootstrap", "=", "None", ",", "xlim", "=", "[", "]", ",", "yl...
Creates a plot of magnitude-time density :param catalogue: Earthquake catalogue as instance of :class: openquake.hmtk.seismicity.catalogue.Catalogue :param float mag_int: Width of the histogram for the magnitude bins :param float time_int: Width of the histogram for the time...
[ "Creates", "a", "plot", "of", "magnitude", "-", "time", "density" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/catalogue_plots.py#L261-L342
train
gem/oq-engine
openquake/hmtk/plotting/seismicity/catalogue_plots.py
_plot_completeness
def _plot_completeness(ax, comw, start_time, end_time): ''' Adds completeness intervals to a plot ''' comw = np.array(comw) comp = np.column_stack([np.hstack([end_time, comw[:, 0], start_time]), np.hstack([comw[0, 1], comw[:, 1], comw[-1, 1]])]) ax.step(comp[:-1, 0], ...
python
def _plot_completeness(ax, comw, start_time, end_time): ''' Adds completeness intervals to a plot ''' comw = np.array(comw) comp = np.column_stack([np.hstack([end_time, comw[:, 0], start_time]), np.hstack([comw[0, 1], comw[:, 1], comw[-1, 1]])]) ax.step(comp[:-1, 0], ...
[ "def", "_plot_completeness", "(", "ax", ",", "comw", ",", "start_time", ",", "end_time", ")", ":", "comw", "=", "np", ".", "array", "(", "comw", ")", "comp", "=", "np", ".", "column_stack", "(", "[", "np", ".", "hstack", "(", "[", "end_time", ",", ...
Adds completeness intervals to a plot
[ "Adds", "completeness", "intervals", "to", "a", "plot" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/catalogue_plots.py#L345-L353
train
gem/oq-engine
openquake/hmtk/plotting/seismicity/catalogue_plots.py
get_completeness_adjusted_table
def get_completeness_adjusted_table(catalogue, completeness, dmag, offset=1.0E-5, end_year=None, plot=False, figure_size=(8, 6), filename=None, filetype='png', dpi=300, ax=None): """ Counts the number of ...
python
def get_completeness_adjusted_table(catalogue, completeness, dmag, offset=1.0E-5, end_year=None, plot=False, figure_size=(8, 6), filename=None, filetype='png', dpi=300, ax=None): """ Counts the number of ...
[ "def", "get_completeness_adjusted_table", "(", "catalogue", ",", "completeness", ",", "dmag", ",", "offset", "=", "1.0E-5", ",", "end_year", "=", "None", ",", "plot", "=", "False", ",", "figure_size", "=", "(", "8", ",", "6", ")", ",", "filename", "=", "...
Counts the number of earthquakes in each magnitude bin and normalises the rate to annual rates, taking into account the completeness
[ "Counts", "the", "number", "of", "earthquakes", "in", "each", "magnitude", "bin", "and", "normalises", "the", "rate", "to", "annual", "rates", "taking", "into", "account", "the", "completeness" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/catalogue_plots.py#L356-L417
train
gem/oq-engine
openquake/hmtk/plotting/seismicity/catalogue_plots.py
plot_observed_recurrence
def plot_observed_recurrence( catalogue, completeness, dmag, end_year=None, filename=None, figure_size=(8, 6), filetype='png', dpi=300, ax=None): """ Plots the observed recurrence taking into account the completeness """ # Get completeness adjusted recurrence table if isinstance(comp...
python
def plot_observed_recurrence( catalogue, completeness, dmag, end_year=None, filename=None, figure_size=(8, 6), filetype='png', dpi=300, ax=None): """ Plots the observed recurrence taking into account the completeness """ # Get completeness adjusted recurrence table if isinstance(comp...
[ "def", "plot_observed_recurrence", "(", "catalogue", ",", "completeness", ",", "dmag", ",", "end_year", "=", "None", ",", "filename", "=", "None", ",", "figure_size", "=", "(", "8", ",", "6", ")", ",", "filetype", "=", "'png'", ",", "dpi", "=", "300", ...
Plots the observed recurrence taking into account the completeness
[ "Plots", "the", "observed", "recurrence", "taking", "into", "account", "the", "completeness" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/seismicity/catalogue_plots.py#L420-L452
train
gem/oq-engine
openquake/hmtk/strain/geodetic_strain.py
GeodeticStrain.get_number_observations
def get_number_observations(self): ''' Returns the number of observations in the data file ''' if isinstance(self.data, dict) and ('exx' in self.data.keys()): return len(self.data['exx']) else: return 0
python
def get_number_observations(self): ''' Returns the number of observations in the data file ''' if isinstance(self.data, dict) and ('exx' in self.data.keys()): return len(self.data['exx']) else: return 0
[ "def", "get_number_observations", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "data", ",", "dict", ")", "and", "(", "'exx'", "in", "self", ".", "data", ".", "keys", "(", ")", ")", ":", "return", "len", "(", "self", ".", "data", "["...
Returns the number of observations in the data file
[ "Returns", "the", "number", "of", "observations", "in", "the", "data", "file" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/strain/geodetic_strain.py#L137-L144
train
gem/oq-engine
openquake/commands/plot_lc.py
plot_lc
def plot_lc(calc_id, aid=None): """ Plot loss curves given a calculation id and an asset ordinal. """ # read the hazard data dstore = util.read(calc_id) dset = dstore['agg_curves-rlzs'] if aid is None: # plot the global curves plt = make_figure(dset.attrs['return_periods'], dset.val...
python
def plot_lc(calc_id, aid=None): """ Plot loss curves given a calculation id and an asset ordinal. """ # read the hazard data dstore = util.read(calc_id) dset = dstore['agg_curves-rlzs'] if aid is None: # plot the global curves plt = make_figure(dset.attrs['return_periods'], dset.val...
[ "def", "plot_lc", "(", "calc_id", ",", "aid", "=", "None", ")", ":", "dstore", "=", "util", ".", "read", "(", "calc_id", ")", "dset", "=", "dstore", "[", "'agg_curves-rlzs'", "]", "if", "aid", "is", "None", ":", "plt", "=", "make_figure", "(", "dset"...
Plot loss curves given a calculation id and an asset ordinal.
[ "Plot", "loss", "curves", "given", "a", "calculation", "id", "and", "an", "asset", "ordinal", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/plot_lc.py#L41-L52
train
gem/oq-engine
openquake/hazardlib/gsim/nshmp_2014.py
get_weighted_poes
def get_weighted_poes(gsim, sctx, rctx, dctx, imt, imls, truncation_level, weighting=DEFAULT_WEIGHTING): """ This function implements the NGA West 2 GMPE epistemic uncertainty adjustment factor without re-calculating the actual GMPE each time. :param gsim: Instance of the ...
python
def get_weighted_poes(gsim, sctx, rctx, dctx, imt, imls, truncation_level, weighting=DEFAULT_WEIGHTING): """ This function implements the NGA West 2 GMPE epistemic uncertainty adjustment factor without re-calculating the actual GMPE each time. :param gsim: Instance of the ...
[ "def", "get_weighted_poes", "(", "gsim", ",", "sctx", ",", "rctx", ",", "dctx", ",", "imt", ",", "imls", ",", "truncation_level", ",", "weighting", "=", "DEFAULT_WEIGHTING", ")", ":", "if", "truncation_level", "is", "not", "None", "and", "truncation_level", ...
This function implements the NGA West 2 GMPE epistemic uncertainty adjustment factor without re-calculating the actual GMPE each time. :param gsim: Instance of the GMPE :param list weighting: Weightings as a list of tuples of (weight, number standard deviations of the epistemic unce...
[ "This", "function", "implements", "the", "NGA", "West", "2", "GMPE", "epistemic", "uncertainty", "adjustment", "factor", "without", "re", "-", "calculating", "the", "actual", "GMPE", "each", "time", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/nshmp_2014.py#L102-L146
train
gem/oq-engine
openquake/commonlib/shapefileparser.py
register_fields
def register_fields(w): """ Register shapefile fields. """ PARAMS_LIST = [BASE_PARAMS, GEOMETRY_PARAMS, MFD_PARAMS] for PARAMS in PARAMS_LIST: for _, param, dtype in PARAMS: w.field(param, fieldType=dtype, size=FIELD_SIZE) PARAMS_LIST = [ RATE_PARAMS, STRIKE_PARAMS, ...
python
def register_fields(w): """ Register shapefile fields. """ PARAMS_LIST = [BASE_PARAMS, GEOMETRY_PARAMS, MFD_PARAMS] for PARAMS in PARAMS_LIST: for _, param, dtype in PARAMS: w.field(param, fieldType=dtype, size=FIELD_SIZE) PARAMS_LIST = [ RATE_PARAMS, STRIKE_PARAMS, ...
[ "def", "register_fields", "(", "w", ")", ":", "PARAMS_LIST", "=", "[", "BASE_PARAMS", ",", "GEOMETRY_PARAMS", ",", "MFD_PARAMS", "]", "for", "PARAMS", "in", "PARAMS_LIST", ":", "for", "_", ",", "param", ",", "dtype", "in", "PARAMS", ":", "w", ".", "field...
Register shapefile fields.
[ "Register", "shapefile", "fields", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L86-L103
train
gem/oq-engine
openquake/commonlib/shapefileparser.py
extract_source_params
def extract_source_params(src): """ Extract params from source object. """ tags = get_taglist(src) data = [] for key, param, vtype in BASE_PARAMS: if key in src.attrib: if vtype == "c": data.append((param, src.attrib[key])) elif vtype == "f": ...
python
def extract_source_params(src): """ Extract params from source object. """ tags = get_taglist(src) data = [] for key, param, vtype in BASE_PARAMS: if key in src.attrib: if vtype == "c": data.append((param, src.attrib[key])) elif vtype == "f": ...
[ "def", "extract_source_params", "(", "src", ")", ":", "tags", "=", "get_taglist", "(", "src", ")", "data", "=", "[", "]", "for", "key", ",", "param", ",", "vtype", "in", "BASE_PARAMS", ":", "if", "key", "in", "src", ".", "attrib", ":", "if", "vtype",...
Extract params from source object.
[ "Extract", "params", "from", "source", "object", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L120-L143
train
gem/oq-engine
openquake/commonlib/shapefileparser.py
parse_complex_fault_geometry
def parse_complex_fault_geometry(node): """ Parses a complex fault geometry node returning both the attributes and parameters in a dictionary """ assert "complexFaultGeometry" in node.tag # Get general attributes geometry = {"intermediateEdges": []} for subnode in node: crds = su...
python
def parse_complex_fault_geometry(node): """ Parses a complex fault geometry node returning both the attributes and parameters in a dictionary """ assert "complexFaultGeometry" in node.tag # Get general attributes geometry = {"intermediateEdges": []} for subnode in node: crds = su...
[ "def", "parse_complex_fault_geometry", "(", "node", ")", ":", "assert", "\"complexFaultGeometry\"", "in", "node", ".", "tag", "geometry", "=", "{", "\"intermediateEdges\"", ":", "[", "]", "}", "for", "subnode", "in", "node", ":", "crds", "=", "subnode", ".", ...
Parses a complex fault geometry node returning both the attributes and parameters in a dictionary
[ "Parses", "a", "complex", "fault", "geometry", "node", "returning", "both", "the", "attributes", "and", "parameters", "in", "a", "dictionary" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L201-L231
train
gem/oq-engine
openquake/commonlib/shapefileparser.py
parse_planar_fault_geometry
def parse_planar_fault_geometry(node): """ Parses a planar fault geometry node returning both the attributes and parameters in a dictionary """ assert "planarSurface" in node.tag geometry = {"strike": node.attrib["strike"], "dip": node.attrib["dip"]} upper_depth = numpy.inf ...
python
def parse_planar_fault_geometry(node): """ Parses a planar fault geometry node returning both the attributes and parameters in a dictionary """ assert "planarSurface" in node.tag geometry = {"strike": node.attrib["strike"], "dip": node.attrib["dip"]} upper_depth = numpy.inf ...
[ "def", "parse_planar_fault_geometry", "(", "node", ")", ":", "assert", "\"planarSurface\"", "in", "node", ".", "tag", "geometry", "=", "{", "\"strike\"", ":", "node", ".", "attrib", "[", "\"strike\"", "]", ",", "\"dip\"", ":", "node", ".", "attrib", "[", "...
Parses a planar fault geometry node returning both the attributes and parameters in a dictionary
[ "Parses", "a", "planar", "fault", "geometry", "node", "returning", "both", "the", "attributes", "and", "parameters", "in", "a", "dictionary" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L234-L256
train
gem/oq-engine
openquake/commonlib/shapefileparser.py
extract_mfd_params
def extract_mfd_params(src): """ Extracts the MFD parameters from an object """ tags = get_taglist(src) if "incrementalMFD" in tags: mfd_node = src.nodes[tags.index("incrementalMFD")] elif "truncGutenbergRichterMFD" in tags: mfd_node = src.nodes[tags.index("truncGutenbergRichterM...
python
def extract_mfd_params(src): """ Extracts the MFD parameters from an object """ tags = get_taglist(src) if "incrementalMFD" in tags: mfd_node = src.nodes[tags.index("incrementalMFD")] elif "truncGutenbergRichterMFD" in tags: mfd_node = src.nodes[tags.index("truncGutenbergRichterM...
[ "def", "extract_mfd_params", "(", "src", ")", ":", "tags", "=", "get_taglist", "(", "src", ")", "if", "\"incrementalMFD\"", "in", "tags", ":", "mfd_node", "=", "src", ".", "nodes", "[", "tags", ".", "index", "(", "\"incrementalMFD\"", ")", "]", "elif", "...
Extracts the MFD parameters from an object
[ "Extracts", "the", "MFD", "parameters", "from", "an", "object" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L322-L359
train
gem/oq-engine
openquake/commonlib/shapefileparser.py
extract_source_hypocentral_depths
def extract_source_hypocentral_depths(src): """ Extract source hypocentral depths. """ if "pointSource" not in src.tag and "areaSource" not in src.tag: hds = dict([(key, None) for key, _ in HDEPTH_PARAMS]) hdsw = dict([(key, None) for key, _ in HDW_PARAMS]) return hds, hdsw ...
python
def extract_source_hypocentral_depths(src): """ Extract source hypocentral depths. """ if "pointSource" not in src.tag and "areaSource" not in src.tag: hds = dict([(key, None) for key, _ in HDEPTH_PARAMS]) hdsw = dict([(key, None) for key, _ in HDW_PARAMS]) return hds, hdsw ...
[ "def", "extract_source_hypocentral_depths", "(", "src", ")", ":", "if", "\"pointSource\"", "not", "in", "src", ".", "tag", "and", "\"areaSource\"", "not", "in", "src", ".", "tag", ":", "hds", "=", "dict", "(", "[", "(", "key", ",", "None", ")", "for", ...
Extract source hypocentral depths.
[ "Extract", "source", "hypocentral", "depths", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L397-L425
train
gem/oq-engine
openquake/commonlib/shapefileparser.py
extract_source_planes_strikes_dips
def extract_source_planes_strikes_dips(src): """ Extract strike and dip angles for source defined by multiple planes. """ if "characteristicFaultSource" not in src.tag: strikes = dict([(key, None) for key, _ in PLANES_STRIKES_PARAM]) dips = dict([(key, None) for key, _ in PLANES_DIPS_PAR...
python
def extract_source_planes_strikes_dips(src): """ Extract strike and dip angles for source defined by multiple planes. """ if "characteristicFaultSource" not in src.tag: strikes = dict([(key, None) for key, _ in PLANES_STRIKES_PARAM]) dips = dict([(key, None) for key, _ in PLANES_DIPS_PAR...
[ "def", "extract_source_planes_strikes_dips", "(", "src", ")", ":", "if", "\"characteristicFaultSource\"", "not", "in", "src", ".", "tag", ":", "strikes", "=", "dict", "(", "[", "(", "key", ",", "None", ")", "for", "key", ",", "_", "in", "PLANES_STRIKES_PARAM...
Extract strike and dip angles for source defined by multiple planes.
[ "Extract", "strike", "and", "dip", "angles", "for", "source", "defined", "by", "multiple", "planes", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L428-L456
train
gem/oq-engine
openquake/commonlib/shapefileparser.py
set_params
def set_params(w, src): """ Set source parameters. """ params = extract_source_params(src) # this is done because for characteristic sources geometry is in # 'surface' attribute params.update(extract_geometry_params(src)) mfd_pars, rate_pars = extract_mfd_params(src) params.update(m...
python
def set_params(w, src): """ Set source parameters. """ params = extract_source_params(src) # this is done because for characteristic sources geometry is in # 'surface' attribute params.update(extract_geometry_params(src)) mfd_pars, rate_pars = extract_mfd_params(src) params.update(m...
[ "def", "set_params", "(", "w", ",", "src", ")", ":", "params", "=", "extract_source_params", "(", "src", ")", "params", ".", "update", "(", "extract_geometry_params", "(", "src", ")", ")", "mfd_pars", ",", "rate_pars", "=", "extract_mfd_params", "(", "src", ...
Set source parameters.
[ "Set", "source", "parameters", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L459-L486
train
gem/oq-engine
openquake/commonlib/shapefileparser.py
set_area_geometry
def set_area_geometry(w, src): """ Set area polygon as shapefile geometry """ assert "areaSource" in src.tag geometry_node = src.nodes[get_taglist(src).index("areaGeometry")] area_attrs = parse_area_geometry(geometry_node) w.poly(parts=[area_attrs["polygon"].tolist()])
python
def set_area_geometry(w, src): """ Set area polygon as shapefile geometry """ assert "areaSource" in src.tag geometry_node = src.nodes[get_taglist(src).index("areaGeometry")] area_attrs = parse_area_geometry(geometry_node) w.poly(parts=[area_attrs["polygon"].tolist()])
[ "def", "set_area_geometry", "(", "w", ",", "src", ")", ":", "assert", "\"areaSource\"", "in", "src", ".", "tag", "geometry_node", "=", "src", ".", "nodes", "[", "get_taglist", "(", "src", ")", ".", "index", "(", "\"areaGeometry\"", ")", "]", "area_attrs", ...
Set area polygon as shapefile geometry
[ "Set", "area", "polygon", "as", "shapefile", "geometry" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L489-L496
train
gem/oq-engine
openquake/commonlib/shapefileparser.py
set_point_geometry
def set_point_geometry(w, src): """ Set point location as shapefile geometry. """ assert "pointSource" in src.tag geometry_node = src.nodes[get_taglist(src).index("pointGeometry")] point_attrs = parse_point_geometry(geometry_node) w.point(point_attrs["point"][0], point_attrs["point"][1])
python
def set_point_geometry(w, src): """ Set point location as shapefile geometry. """ assert "pointSource" in src.tag geometry_node = src.nodes[get_taglist(src).index("pointGeometry")] point_attrs = parse_point_geometry(geometry_node) w.point(point_attrs["point"][0], point_attrs["point"][1])
[ "def", "set_point_geometry", "(", "w", ",", "src", ")", ":", "assert", "\"pointSource\"", "in", "src", ".", "tag", "geometry_node", "=", "src", ".", "nodes", "[", "get_taglist", "(", "src", ")", ".", "index", "(", "\"pointGeometry\"", ")", "]", "point_attr...
Set point location as shapefile geometry.
[ "Set", "point", "location", "as", "shapefile", "geometry", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L499-L506
train
gem/oq-engine
openquake/commonlib/shapefileparser.py
set_simple_fault_geometry
def set_simple_fault_geometry(w, src): """ Set simple fault trace coordinates as shapefile geometry. :parameter w: Writer :parameter src: source """ assert "simpleFaultSource" in src.tag geometry_node = src.nodes[get_taglist(src).index("simpleFaultGeometry")] fault_attrs...
python
def set_simple_fault_geometry(w, src): """ Set simple fault trace coordinates as shapefile geometry. :parameter w: Writer :parameter src: source """ assert "simpleFaultSource" in src.tag geometry_node = src.nodes[get_taglist(src).index("simpleFaultGeometry")] fault_attrs...
[ "def", "set_simple_fault_geometry", "(", "w", ",", "src", ")", ":", "assert", "\"simpleFaultSource\"", "in", "src", ".", "tag", "geometry_node", "=", "src", ".", "nodes", "[", "get_taglist", "(", "src", ")", ".", "index", "(", "\"simpleFaultGeometry\"", ")", ...
Set simple fault trace coordinates as shapefile geometry. :parameter w: Writer :parameter src: source
[ "Set", "simple", "fault", "trace", "coordinates", "as", "shapefile", "geometry", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L509-L521
train
gem/oq-engine
openquake/commonlib/shapefileparser.py
set_simple_fault_geometry_3D
def set_simple_fault_geometry_3D(w, src): """ Builds a 3D polygon from a node instance """ assert "simpleFaultSource" in src.tag geometry_node = src.nodes[get_taglist(src).index("simpleFaultGeometry")] fault_attrs = parse_simple_fault_geometry(geometry_node) build_polygon_from_fault_attrs(w,...
python
def set_simple_fault_geometry_3D(w, src): """ Builds a 3D polygon from a node instance """ assert "simpleFaultSource" in src.tag geometry_node = src.nodes[get_taglist(src).index("simpleFaultGeometry")] fault_attrs = parse_simple_fault_geometry(geometry_node) build_polygon_from_fault_attrs(w,...
[ "def", "set_simple_fault_geometry_3D", "(", "w", ",", "src", ")", ":", "assert", "\"simpleFaultSource\"", "in", "src", ".", "tag", "geometry_node", "=", "src", ".", "nodes", "[", "get_taglist", "(", "src", ")", ".", "index", "(", "\"simpleFaultGeometry\"", ")"...
Builds a 3D polygon from a node instance
[ "Builds", "a", "3D", "polygon", "from", "a", "node", "instance" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L543-L550
train
gem/oq-engine
openquake/commonlib/shapefileparser.py
SourceModel.appraise_source_model
def appraise_source_model(self): """ Identify parameters defined in NRML source model file, so that shapefile contains only source model specific fields. """ for src in self.sources: # source params src_taglist = get_taglist(src) if "areaSource...
python
def appraise_source_model(self): """ Identify parameters defined in NRML source model file, so that shapefile contains only source model specific fields. """ for src in self.sources: # source params src_taglist = get_taglist(src) if "areaSource...
[ "def", "appraise_source_model", "(", "self", ")", ":", "for", "src", "in", "self", ".", "sources", ":", "src_taglist", "=", "get_taglist", "(", "src", ")", "if", "\"areaSource\"", "in", "src", ".", "tag", ":", "self", ".", "has_area_source", "=", "True", ...
Identify parameters defined in NRML source model file, so that shapefile contains only source model specific fields.
[ "Identify", "parameters", "defined", "in", "NRML", "source", "model", "file", "so", "that", "shapefile", "contains", "only", "source", "model", "specific", "fields", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L826-L884
train
gem/oq-engine
openquake/commonlib/shapefileparser.py
SourceModelParser.write
def write(self, destination, source_model, name=None): """ Exports to NRML """ if os.path.exists(destination): os.remove(destination) self.destination = destination if name: source_model.name = name output_source_model = Node("sourceModel",...
python
def write(self, destination, source_model, name=None): """ Exports to NRML """ if os.path.exists(destination): os.remove(destination) self.destination = destination if name: source_model.name = name output_source_model = Node("sourceModel",...
[ "def", "write", "(", "self", ",", "destination", ",", "source_model", ",", "name", "=", "None", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "destination", ")", ":", "os", ".", "remove", "(", "destination", ")", "self", ".", "destination", ...
Exports to NRML
[ "Exports", "to", "NRML" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L937-L956
train
gem/oq-engine
openquake/commonlib/shapefileparser.py
ShapefileParser.filter_params
def filter_params(self, src_mod): """ Remove params uneeded by source_model """ # point and area related params STRIKE_PARAMS[src_mod.num_np:] = [] DIP_PARAMS[src_mod.num_np:] = [] RAKE_PARAMS[src_mod.num_np:] = [] NPW_PARAMS[src_mod.num_np:] = [] ...
python
def filter_params(self, src_mod): """ Remove params uneeded by source_model """ # point and area related params STRIKE_PARAMS[src_mod.num_np:] = [] DIP_PARAMS[src_mod.num_np:] = [] RAKE_PARAMS[src_mod.num_np:] = [] NPW_PARAMS[src_mod.num_np:] = [] ...
[ "def", "filter_params", "(", "self", ",", "src_mod", ")", ":", "STRIKE_PARAMS", "[", "src_mod", ".", "num_np", ":", "]", "=", "[", "]", "DIP_PARAMS", "[", "src_mod", ".", "num_np", ":", "]", "=", "[", "]", "RAKE_PARAMS", "[", "src_mod", ".", "num_np", ...
Remove params uneeded by source_model
[ "Remove", "params", "uneeded", "by", "source_model" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/shapefileparser.py#L960-L992
train
gem/oq-engine
openquake/baselib/node.py
tostring
def tostring(node, indent=4, nsmap=None): """ Convert a node into an XML string by using the StreamingXMLWriter. This is useful for testing purposes. :param node: a node object (typically an ElementTree object) :param indent: the indentation to use in the XML (default 4 spaces) """ out = io...
python
def tostring(node, indent=4, nsmap=None): """ Convert a node into an XML string by using the StreamingXMLWriter. This is useful for testing purposes. :param node: a node object (typically an ElementTree object) :param indent: the indentation to use in the XML (default 4 spaces) """ out = io...
[ "def", "tostring", "(", "node", ",", "indent", "=", "4", ",", "nsmap", "=", "None", ")", ":", "out", "=", "io", ".", "BytesIO", "(", ")", "writer", "=", "StreamingXMLWriter", "(", "out", ",", "indent", ",", "nsmap", "=", "nsmap", ")", "writer", "."...
Convert a node into an XML string by using the StreamingXMLWriter. This is useful for testing purposes. :param node: a node object (typically an ElementTree object) :param indent: the indentation to use in the XML (default 4 spaces)
[ "Convert", "a", "node", "into", "an", "XML", "string", "by", "using", "the", "StreamingXMLWriter", ".", "This", "is", "useful", "for", "testing", "purposes", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L216-L227
train
gem/oq-engine
openquake/baselib/node.py
parse
def parse(source, remove_comments=True, **kw): """Thin wrapper around ElementTree.parse""" return ElementTree.parse(source, SourceLineParser(), **kw)
python
def parse(source, remove_comments=True, **kw): """Thin wrapper around ElementTree.parse""" return ElementTree.parse(source, SourceLineParser(), **kw)
[ "def", "parse", "(", "source", ",", "remove_comments", "=", "True", ",", "**", "kw", ")", ":", "return", "ElementTree", ".", "parse", "(", "source", ",", "SourceLineParser", "(", ")", ",", "**", "kw", ")" ]
Thin wrapper around ElementTree.parse
[ "Thin", "wrapper", "around", "ElementTree", ".", "parse" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L350-L352
train
gem/oq-engine
openquake/baselib/node.py
iterparse
def iterparse(source, events=('end',), remove_comments=True, **kw): """Thin wrapper around ElementTree.iterparse""" return ElementTree.iterparse(source, events, SourceLineParser(), **kw)
python
def iterparse(source, events=('end',), remove_comments=True, **kw): """Thin wrapper around ElementTree.iterparse""" return ElementTree.iterparse(source, events, SourceLineParser(), **kw)
[ "def", "iterparse", "(", "source", ",", "events", "=", "(", "'end'", ",", ")", ",", "remove_comments", "=", "True", ",", "**", "kw", ")", ":", "return", "ElementTree", ".", "iterparse", "(", "source", ",", "events", ",", "SourceLineParser", "(", ")", "...
Thin wrapper around ElementTree.iterparse
[ "Thin", "wrapper", "around", "ElementTree", ".", "iterparse" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L355-L357
train
gem/oq-engine
openquake/baselib/node.py
_displayattrs
def _displayattrs(attrib, expandattrs): """ Helper function to display the attributes of a Node object in lexicographic order. :param attrib: dictionary with the attributes :param expandattrs: if True also displays the value of the attributes """ if not attrib: return '' if expa...
python
def _displayattrs(attrib, expandattrs): """ Helper function to display the attributes of a Node object in lexicographic order. :param attrib: dictionary with the attributes :param expandattrs: if True also displays the value of the attributes """ if not attrib: return '' if expa...
[ "def", "_displayattrs", "(", "attrib", ",", "expandattrs", ")", ":", "if", "not", "attrib", ":", "return", "''", "if", "expandattrs", ":", "alist", "=", "[", "'%s=%r'", "%", "item", "for", "item", "in", "sorted", "(", "attrib", ".", "items", "(", ")", ...
Helper function to display the attributes of a Node object in lexicographic order. :param attrib: dictionary with the attributes :param expandattrs: if True also displays the value of the attributes
[ "Helper", "function", "to", "display", "the", "attributes", "of", "a", "Node", "object", "in", "lexicographic", "order", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/node.py#L363-L377
train