pySW4.prep.stations module

Python module for placing stations to record synthetic seismograms in SW4 simulations.

author:Shahar Shani-Kadmiel (s.shanikadmiel@tudelft.nl)
copyright:Shahar Shani-Kadmiel
license:This code is distributed under the terms of the GNU Lesser General Public License, Version 3 (https://www.gnu.org/copyleft/lesser.html)
_append2infile(infile, name, string)[source]

Helper function. Copy an existing SW4 input file, add name to the filename, open the new file in append mode and write the string to the end of the file.

inventory2station_locations(inv, mode='displacement', writeEvery=100, name='st', nsew=0, fmt='%.3f', infile=None)[source]

Place stations to record synthetics at specific locations.

Extracts station locations from an Inventory object and generate an SW4 inputfile string.

Parameters:

inv : str or Inventory

Path to a StationXML file or an Inventory object.

mode : {‘displacement’ (default), ‘velocity’, ‘div’, ‘curl’, ‘strains’}

Mode of the recorded motions.

writeEvery : int

Cycle interval to write the data to disk.

nsew : int

The components of the station:

  • 0 - x, y, z (default), or
  • 1 - East, North, Vertical

fmt : str

Format of the coordinates, default is ‘%.3f’.

infile : str

Path (relative or absolute) to the SW4 inputfile. Stations are added to a copy of the specified file and saved with the string name appended to the infile name. (name is ‘array’ by default).

If set to None, a formated string is returned that can then be copied manually to an input file.

Returns:

str

Filename of the newly saved inputfile or a formatted string that can be copied manually to an SW4 inputfile.

station_array(x1=None, x2=None, y1=None, y2=None, lon1=None, lon2=None, lat1=None, lat2=None, depth=0, number_of_stations=None, spacing=None, name='array', mode='displacement', writeEvery=100, nsew=0, fmt='%.3f', infile=None)[source]

Place stations to record synthetics on a line.

Corners of the array can be given in -

Catersian grid coordinates:

x1, y1, x2, y2

or in -

Geographical coordinates:

lon1, lat1, lon2, lat2

Parameters:

depth : float

Depth of the stations in the array.

number_of_stations : int or tuple or None

If int, number of stations is the same in both directions. To set a different number of stations in each direction provide a tuple. If None, the spacing argument is expected.

spacing : float or tuple or None

If float, spacing between stations is taken to be the same in both directions. To set different spacing in each direction provide a tuple. If None, the number_of_stations argument is expected.

spacing must be given in meters if Cartesian grid coordinates are used or in decimal degrees if Geographical coordinates are used.

name : str

Prefix name of the sac file name.

mode : {‘displacement’ (default), ‘velocity’, ‘div’, ‘curl’, ‘strains’}

Mode of the recorded motions.

writeEvery : int

Cycle interval to write the data to disk.

nsew : int

The components of the station:

  • 0 - x, y, z (default), or
  • 1 - East, North, Vertical

fmt : str

Format of the coordinates, default is ‘%.3f’.

infile : str

Path (relative or absolute) to the SW4 inputfile. Stations are added to a copy of the specified file and saved with the string name appended to the infile name. (name is ‘array’ by default).

If set to None, a formated string is returned that can then be copied manually to an input file.

Returns:

str

Filename of the newly saved inputfile or a formatted string that can be copied manually to an SW4 inputfile.

station_line(x1=None, x2=None, y1=None, y2=None, lon1=None, lon2=None, lat1=None, lat2=None, depth1=0, depth2=0, number_of_stations=3, name='line', mode='displacement', writeEvery=100, nsew=0, fmt='%.3f', infile=None)[source]

Place stations to record synthetics on a line.

Start- and end-point can be given in -

Catersian grid coordinates:

x1, y1, depth1, x2, y2, depth2

or in -

Geographical coordinates:

lon1, lat1, depth1, lon2, lat2, depth2

Parameters:

number_of_stations : int

Number of stations to place on the line (defaults to 3 - one at each end and another one in the middle).

name : str

Prefix name of the sac file name.

mode : {‘displacement’ (default), ‘velocity’, ‘div’, ‘curl’, ‘strains’}

Mode of the recorded motions.

writeEvery : int

Cycle interval to write the data to disk.

nsew : int

The components of the station:

  • 0 - x, y, z (default), or
  • 1 - East, North, Vertical

fmt : str

Format of the coordinates, default is ‘%.3f’.

infile : str

Path (relative or absolute) to the SW4 inputfile. Stations are added to a copy of the specified file and saved with the string name appended to the infile name. (name is ‘array’ by default).

If set to None, a formated string is returned that can then be copied manually to an input file.

Returns:

str

Filename of the newly saved inputfile or a formatted string that can be copied manually to an SW4 inputfile.

station_location(x=None, y=None, lat=None, lon=None, depth=0, name='st', mode='displacement', writeEvery=100, nsew=0, fmt='%.3f', infile=None)[source]

Place stations to record synthetics at specific locations.

Can handle a single station or a list of stations. If several stations are passes, x, y (or lat, lon), and name must be the same length.

Locations may be given in -

Catersian grid coordinates:

x, y, depth

or in -

Geographical coordinates:

lon, lat, depth

Parameters:

name : str

Prefix name of the sac file name.

mode : {‘displacement’ (default), ‘velocity’, ‘div’, ‘curl’, ‘strains’}

Mode of the recorded motions.

writeEvery : int

Cycle interval to write the data to disk.

nsew : int

The components of the station:

  • 0 - x, y, z (default), or
  • 1 - East, North, Vertical

fmt : str

Format of the coordinates, default is ‘%.3f’.

infile : str

Path (relative or absolute) to the SW4 inputfile. Stations are added to a copy of the specified file and saved with the string name appended to the infile name. (name is ‘array’ by default).

If set to None, a formated string is returned that can then be copied manually to an input file.

Returns:

str

Filename of the newly saved inputfile or a formatted string that can be copied manually to an SW4 inputfile.