pySW4.sw4_metadata module¶
Parsing routines for SW4 input and output files and directories.
author: | Shahar Shani-Kadmiel (s.shanikadmiel@tudelft.nl) Omry Volk (omryv@post.bgu.ac.il) Tobias Megies (megies@geophysik.uni-muenchen.de) |
---|---|
copyright: | Shahar Shani-Kadmiel (s.shanikadmiel@tudelft.nl) Omry Volk (omryv@post.bgu.ac.il) Tobias Megies (megies@geophysik.uni-muenchen.de) |
license: | This code is distributed under the terms of the GNU Lesser General Public License, Version 3 (https://www.gnu.org/copyleft/lesser.html) |
-
class
Inputfile
(filename)[source]¶ Bases:
obspy.core.util.attribdict.AttribDict
A container for the simulation metadata parsed from the SW4 inputfile.
Parameters: filename : str or
AttribDict
Path (relative or absolute) of an SW4 input file.
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version
= 189¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
get_coordinates
(key, xi=None, elev=None, plane=0, coordinate=0, distance=inf)[source]¶ Gets coordinates for input keys that have 3D coordinates:
Catersian grid coordinates:
x, y, z (or depth)
or in -
Geographical coordinates:
lon, lat, depth (or z)
Parameters: key : str
Keyword to look for.
xi : array-like
x coordinate along the cross-section
elev : array-like
Elevation of the top surface. Same size as xi. Used to correct the returned y-plotting coordinate if depth is encounterd.
plane : int
Indicates cross-section (
0
or1
) or map (2
).coordinate : float
Plane coordinate.
distance : float
Threshold distance from the plane coordinate to include. By default everything is included but this can cause too many symbols to be plotted obscuring the image.
Returns: 2-sequence
x- and y-plotting coordinates.
Examples
>>> get_coordinates('source')
for easy plotting with
plot()
.
-
-
class
Outputfile
(filename)[source]¶ Bases:
obspy.core.util.attribdict.AttribDict
A container for simulation metadata parsed from the SW4 STDOUT saved to a file.
The keywords the parser looks for are:
- ‘Grid’ - Information about the grid discretization.
- ‘Receiver INFO’ - Cartesian (x, y, z) coordinates of recievers placed with geographical (lon, lat, z or depth) coordinates.
- ‘Geographic and Cartesian’ - corners of the computational grid.
- ‘Start Time’ - of the simulation.
- ‘Goal Time’ - time to simulate.
- ‘Number of time steps’ - steps to compute.
- ‘dt’ - size of each time step
- ‘Total seismic moment’ - sum of all sources in the simulation.
- ‘Moment magnitude’ - Moment magnitude based on \(M_0\) .
Parameters: filename : str or
AttribDict
Path (relative or absolute) of an SW4 input file.
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version
= 189¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_decode_string_value
(string_item)[source]¶ Converts string representations of int/float to the corresponding Python type.
Parameters: string_item: str
Configuration value from SW4 input file in its string representation.
Returns: int or float or str
Configuration value from SW4 input file as the correct Python type (bool values specified as
0
or1
in SW4 input file will still be ofint
type).
-
_parse_input_file_and_folder
(input_file=None, folder=None)[source]¶ Helper function to unify input location (or None) and output folder to work on.
Use cases (in order of preference):
input_file="/path/to/input", folder=None
: input file is used for metadata and location of output folderinput_file="/path/to/input", folder="/path/to/output"
: input file is used for metadata, folder location is specified separately (make sure to not mismatch).input_file=None, folder="/path/to/output"
: Do not use metadata from input (station locations etc. will not show up in plots) and only use output files from specified location.