mtpy.modeling.ws3dinv package
Submodules
mtpy.modeling.ws3dinv.data module
Merge transfer functions together
- class mtpy.modeling.ws3dinv.data.WSData(mt_dataframe=None, **kwargs)[source]
Bases:
objectIncludes tools for reading and writing data files intended to be used with ws3dinv.
- Example:
>>> import mtpy.modeling.ws3dinv as ws >>> import os >>> edi_path = r"/home/EDI_Files" >>> edi_list = [os.path.join(edi_path, edi) for edi in edi_path >>> ... if edi.find('.edi') > 0] >>> # create an evenly space period list in log space >>> p_list = np.logspace(np.log10(.001), np.log10(1000), 12) >>> wsdata = ws.WSData(edi_list=edi_list, period_list=p_list, >>> ... station_fn=r"/home/stations.txt") >>> wsdata.write_data_file()
Attributes
Description
data
- numpy structured array with keys:
data_fn
full path to data file
edi_list
list of edi files used to make data file
n_z
[ 4 | 8 ] number of impedance tensor elements default is 8
ncol
number of columns in out file from winglink default is 5
period_list
list of periods to invert for
ptol
if periods in edi files don’t match period_list then program looks for periods within ptol defualt is .15 or 15 percent
rotation_angle
Angle to rotate the data relative to north. Here the angle is measure clockwise from North, Assuming North is 0 and East is 90. Rotating data, and grid to align with regional geoelectric strike can improve the inversion. default is None
save_path
path to save the data file
station_fn
full path to station file written by WSStation
station_locations
- numpy structured array for station locations keys:
station –> station name
- east –> relative eastern location in
grid
- north –> relative northern location in
grid
if input a station file is written
station_east
relative locations of station in east direction
station_north
relative locations of station in north direction
station_names
names of stations
units
[ ‘mv’ | ‘else’ ] units of Z, needs to be mv for ws3dinv. default is ‘mv’
wl_out_fn
Winglink .out file which describes a 3D grid
wl_site_fn
Wingling .sites file which gives station locations
z_data
impedance tensors of data with shape: (n_station, n_periods, 2, 2)
z_data_err
error of data impedance tensors with error map applied, shape (n_stations, n_periods, 2, 2)
z_err
[ float | ‘data’ ] ‘data’ to set errors as data errors or give a percent error to impedance tensor elements default is .05 or 5% if given as percent, ie. 5% then it is converted to .05.
z_err_floor
percent error floor, anything below this error will be set to z_err_floor. default is None
z_err_map
[zxx, zxy, zyx, zyy] for n_z = 8 [zxy, zyx] for n_z = 4 Value in percent to multiply the error by, which give the user power to down weight bad data, so the resulting error will be z_err_map*z_err
Methods
Description
build_data
builds the data from .edi files
write_data_file
writes a data file from attribute data. This way you can read in a data file, change some parameters and rewrite.
read_data_file
reads in a ws3dinv data file
- property data_filename
Data filename.
- property dataframe
Dataframe function.
- property period
Period function.
- read_data_file(data_filename)[source]
Read in data file.
- Arguments::
- data_fnstring
full path to data file
- wl_sites_fnstring
full path to sites file output by winglink. This is to match the station name with station number.
- station_fnstring
full path to station location file written by WSStation
- Fills Attributes::
- datastructure np.ndarray
fills the attribute WSData.data with values
- period_listnp.ndarray()
fills the period list with values.
- write_data_file(**kwargs)[source]
Writes a data file based on the attribute data.
- Key Word Arguments::
- data_fnstring
full path to data file name
- save_pathstring
directory path to save data file, will be written as save_path/data_basename
- data_basenamestring
basename of data file to be saved as save_path/data_basename default is WSDataFile.dat
Note
if any of the data attributes have been reset, be sure to call build_data() before write_data_file.
mtpy.modeling.ws3dinv.startup module
Created on Tue Nov 7 09:33:52 2023
@author: jpeacock
- class mtpy.modeling.ws3dinv.startup.WSStartup(data_fn=None, initial_fn=None, **kwargs)[source]
Bases:
objectRead and write startup files
- Example:
>>> import mtpy.modeling.ws3dinv as ws >>> dfn = r"/home/MT/ws3dinv/Inv1/WSDataFile.dat" >>> ifn = r"/home/MT/ws3dinv/Inv1/init3d" >>> sws = ws.WSStartup(data_fn=dfn, initial_fn=ifn)
- apriori_fn full path to a priori model file
default is ‘default’
- control_fn full path to model index control file
default is ‘default’
data_fn full path to data file error_tol error tolerance level
default is ‘default’
initial_fn full path to initial model file lagrange starting lagrange multiplier
default is ‘default’
- max_iter max number of iterations
default is 10
- model_ls model length scale
default is 5 0.3 0.3 0.3
- output_stem output file name stem
default is ‘ws3dinv’
save_path directory to save file to startup_fn full path to startup file static_fn full path to statics file
default is ‘default’
- target_rms target rms
default is 1.0
=================== =======================================================.
- property startup_fn
Startup fn.
mtpy.modeling.ws3dinv.stations module
Created on Tue Nov 7 09:18:17 2023
@author: jpeacock
- class mtpy.modeling.ws3dinv.stations.WSStation(station_fn=None, **kwargs)[source]
Bases:
objectRead and write a station file where the locations are relative to the 3D mesh.
Attributes
Description
east
array of relative locations in east direction
elev
array of elevations for each station
names
array of station names
north
array of relative locations in north direction
station_fn
full path to station file
save_path
path to save file to
Methods
Description
read_station_file
reads in a station file
write_station_file
writes a station file
write_vtk_file
writes a vtk points file for station locations
- from_wl_write_station_file(sites_file, out_file, ncol=5)[source]
Write a ws station file from the outputs of winglink.
- Arguments::
- sites_fnstring
full path to sites file output from winglink
- out_fnstring
full path to .out file output from winglink
- ncolint
number of columns the data is in default is 5
- read_station_file(station_filename)[source]
Read in station file written by write_station_file.
- Arguments::
- station_fnstring
full path to station file
- Outputs::
- eastnp.ndarray(n_stations)
relative station locations in east direction
- northnp.ndarray(n_stations)
relative station locations in north direction
- elevnp.ndarray(n_stations)
relative station locations in vertical direction
- station_listlist or np.ndarray(n_stations)
name of stations
- property station_filename
Station filename.
- write_station_file(east=None, north=None, station_list=None, save_path=None, elev=None)[source]
Write a station file to go with the data file.
the locations are on a relative grid where (0, 0, 0) is the center of the grid. Also, the stations are assumed to be in the center of the cell.
- Arguments::
- eastnp.ndarray(n_stations)
relative station locations in east direction
- northnp.ndarray(n_stations)
relative station locations in north direction
- elevnp.ndarray(n_stations)
relative station locations in vertical direction
- station_listlist or np.ndarray(n_stations)
name of stations
- save_pathstring
directory or full path to save station file to if a directory the file will be saved as save_path/WS_Station_Locations.txt if save_path is none the current working directory is used as save_path
- Outputs::
station_fn : full path to station file
Module contents
Created on Tue Nov 7 11:42:53 2023
@author: jpeacock
- class mtpy.modeling.ws3dinv.WSData(mt_dataframe=None, **kwargs)[source]
Bases:
objectIncludes tools for reading and writing data files intended to be used with ws3dinv.
- Example:
>>> import mtpy.modeling.ws3dinv as ws >>> import os >>> edi_path = r"/home/EDI_Files" >>> edi_list = [os.path.join(edi_path, edi) for edi in edi_path >>> ... if edi.find('.edi') > 0] >>> # create an evenly space period list in log space >>> p_list = np.logspace(np.log10(.001), np.log10(1000), 12) >>> wsdata = ws.WSData(edi_list=edi_list, period_list=p_list, >>> ... station_fn=r"/home/stations.txt") >>> wsdata.write_data_file()
Attributes
Description
data
- numpy structured array with keys:
data_fn
full path to data file
edi_list
list of edi files used to make data file
n_z
[ 4 | 8 ] number of impedance tensor elements default is 8
ncol
number of columns in out file from winglink default is 5
period_list
list of periods to invert for
ptol
if periods in edi files don’t match period_list then program looks for periods within ptol defualt is .15 or 15 percent
rotation_angle
Angle to rotate the data relative to north. Here the angle is measure clockwise from North, Assuming North is 0 and East is 90. Rotating data, and grid to align with regional geoelectric strike can improve the inversion. default is None
save_path
path to save the data file
station_fn
full path to station file written by WSStation
station_locations
- numpy structured array for station locations keys:
station –> station name
- east –> relative eastern location in
grid
- north –> relative northern location in
grid
if input a station file is written
station_east
relative locations of station in east direction
station_north
relative locations of station in north direction
station_names
names of stations
units
[ ‘mv’ | ‘else’ ] units of Z, needs to be mv for ws3dinv. default is ‘mv’
wl_out_fn
Winglink .out file which describes a 3D grid
wl_site_fn
Wingling .sites file which gives station locations
z_data
impedance tensors of data with shape: (n_station, n_periods, 2, 2)
z_data_err
error of data impedance tensors with error map applied, shape (n_stations, n_periods, 2, 2)
z_err
[ float | ‘data’ ] ‘data’ to set errors as data errors or give a percent error to impedance tensor elements default is .05 or 5% if given as percent, ie. 5% then it is converted to .05.
z_err_floor
percent error floor, anything below this error will be set to z_err_floor. default is None
z_err_map
[zxx, zxy, zyx, zyy] for n_z = 8 [zxy, zyx] for n_z = 4 Value in percent to multiply the error by, which give the user power to down weight bad data, so the resulting error will be z_err_map*z_err
Methods
Description
build_data
builds the data from .edi files
write_data_file
writes a data file from attribute data. This way you can read in a data file, change some parameters and rewrite.
read_data_file
reads in a ws3dinv data file
- property data_filename
Data filename.
- property dataframe
Dataframe function.
- property period
Period function.
- read_data_file(data_filename)[source]
Read in data file.
- Arguments::
- data_fnstring
full path to data file
- wl_sites_fnstring
full path to sites file output by winglink. This is to match the station name with station number.
- station_fnstring
full path to station location file written by WSStation
- Fills Attributes::
- datastructure np.ndarray
fills the attribute WSData.data with values
- period_listnp.ndarray()
fills the period list with values.
- write_data_file(**kwargs)[source]
Writes a data file based on the attribute data.
- Key Word Arguments::
- data_fnstring
full path to data file name
- save_pathstring
directory path to save data file, will be written as save_path/data_basename
- data_basenamestring
basename of data file to be saved as save_path/data_basename default is WSDataFile.dat
Note
if any of the data attributes have been reset, be sure to call build_data() before write_data_file.
- class mtpy.modeling.ws3dinv.WSStartup(data_fn=None, initial_fn=None, **kwargs)[source]
Bases:
objectRead and write startup files
- Example:
>>> import mtpy.modeling.ws3dinv as ws >>> dfn = r"/home/MT/ws3dinv/Inv1/WSDataFile.dat" >>> ifn = r"/home/MT/ws3dinv/Inv1/init3d" >>> sws = ws.WSStartup(data_fn=dfn, initial_fn=ifn)
- apriori_fn full path to a priori model file
default is ‘default’
- control_fn full path to model index control file
default is ‘default’
data_fn full path to data file error_tol error tolerance level
default is ‘default’
initial_fn full path to initial model file lagrange starting lagrange multiplier
default is ‘default’
- max_iter max number of iterations
default is 10
- model_ls model length scale
default is 5 0.3 0.3 0.3
- output_stem output file name stem
default is ‘ws3dinv’
save_path directory to save file to startup_fn full path to startup file static_fn full path to statics file
default is ‘default’
- target_rms target rms
default is 1.0
=================== =======================================================.
- property startup_fn
Startup fn.
- class mtpy.modeling.ws3dinv.WSStation(station_fn=None, **kwargs)[source]
Bases:
objectRead and write a station file where the locations are relative to the 3D mesh.
Attributes
Description
east
array of relative locations in east direction
elev
array of elevations for each station
names
array of station names
north
array of relative locations in north direction
station_fn
full path to station file
save_path
path to save file to
Methods
Description
read_station_file
reads in a station file
write_station_file
writes a station file
write_vtk_file
writes a vtk points file for station locations
- from_wl_write_station_file(sites_file, out_file, ncol=5)[source]
Write a ws station file from the outputs of winglink.
- Arguments::
- sites_fnstring
full path to sites file output from winglink
- out_fnstring
full path to .out file output from winglink
- ncolint
number of columns the data is in default is 5
- read_station_file(station_filename)[source]
Read in station file written by write_station_file.
- Arguments::
- station_fnstring
full path to station file
- Outputs::
- eastnp.ndarray(n_stations)
relative station locations in east direction
- northnp.ndarray(n_stations)
relative station locations in north direction
- elevnp.ndarray(n_stations)
relative station locations in vertical direction
- station_listlist or np.ndarray(n_stations)
name of stations
- property station_filename
Station filename.
- write_station_file(east=None, north=None, station_list=None, save_path=None, elev=None)[source]
Write a station file to go with the data file.
the locations are on a relative grid where (0, 0, 0) is the center of the grid. Also, the stations are assumed to be in the center of the cell.
- Arguments::
- eastnp.ndarray(n_stations)
relative station locations in east direction
- northnp.ndarray(n_stations)
relative station locations in north direction
- elevnp.ndarray(n_stations)
relative station locations in vertical direction
- station_listlist or np.ndarray(n_stations)
name of stations
- save_pathstring
directory or full path to save station file to if a directory the file will be saved as save_path/WS_Station_Locations.txt if save_path is none the current working directory is used as save_path
- Outputs::
station_fn : full path to station file