Package CSAMT
Module AVG
This file is part of pyCSAMT.
pyCSAMT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
pyCSAMT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with pyCSAMT. If not, see <https://www.gnu.org/licenses/>.
Created on Wed Nov 18 16:45:35 2020
@author: KLaurent K. alias @Daniel03
- class pycsamt.ff.core.avg.Amps(amps_array=None, number_of_frequencies=None, number_of_stations=None, **kwargs)[source]
Square-Wave current (amps)
- amps_arraynp.ndarray (ndarray, 1)
evolution of current data on the site
- number_of_stationsint
number of survey_stations .
- number_of_frequencies: int
number of frequencies during the survey for each station location
Attributes
Type
Explanation
value
nd.array
data of Amp column on avgfile
max
float
maximum current enforce a that point
min
float
minimun current unit :amp (A)
loc
dict
main attribute location of station with the current enforce a that point .eg loc [‘S07’] show the current Amps-data at that point
More attributes can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core.avg import Avg >>> path=os.path.join(os.environ["pyCSAMT"], ... 'pycsamt', "data", "K1.AVG") >>> avg_obj=Avg(path) >>> amps_obj =avg_obj.Data_section.Amps.loc['S00'] >>> print(amp_obj)
- class pycsamt.ff.core.avg.Avg(data_fn=None, **kwargs)[source]
A super class of all content of AVG Zonge file
Deal with Zonge Engeering Avg file .
Methods
avg_to_edifile([data_fn, profile_fn, ...])Method to write avg file to SEG-EDIfile.Convert both files.Astatic or plainty avg file .if ASTATIC file is provided , will add the filter and filter values .if avg file is not astatic file , user an apply filter by setting filter to "tma, ama, or flma".Once apply , edifiles will exported by computing resistivities filtered
avg_to_jfile([avg_data_fn, profile_fn, ...])Method to write avg file to Jfile, convert both files ,
avg_write_2_to_1([data_fn, savepath])Method to rewrite avg Astatic file (F2) to main file F1 .
- avg_to_edifile(data_fn=None, profile_fn=None, savepath=None, apply_filter=None, reference_frequency=None, number_of_points=7.0, dipole_length=50.0, number_of_skin_depth=3.0, **kwargs)[source]
Method to write avg file to SEG-EDIfile.Convert both files.Astatic or plainty avg file .if ASTATIC file is provided , will add the filter and filter values .if avg file is not astatic file , user an apply filter by setting filter to “tma, ama, or flma”.Once apply , edifiles will exported by computing resistivities filtered
- Parameters
- * data_fnstr
full path to avgfile
- savepathstr
outdir to store edifiles if None , is your current work directory
- profile_fn: str
full path to station _profile file
- apply_filter: str
add the name of filter to process the avg file exported in edifiles. can be [TMA | AMA| FLMA] TMA - Trimming Moving Average AMA - Adaptative Moving avarage , FLMA - Fixed dipoleLength moving average (number of point=7) Dipolelength willbe computed automatically
- Returns
- obj, edi_obj
edi outputfiles or edi filtered file.
- Holdings additionals parameters
- Example
>>> from pycsamt.ff.core import avg >>> avg_obj= avg.Avg() >>> avg_obj.avg_to_edifile(data_fn= os.path.join( ... path_to_avgfile, avgfile) , ... profile_fn = os.path.join( ... path_to_avgfile, station_profile_file), ... savepath =save_edipath, ... apply_filter=None )
- avg_to_jfile(avg_data_fn=None, profile_fn=None, j_extension='dat', utm_zone='49N', **kws)[source]
- Method to write avg file to Jfile, convert both files ,
Astatic or plainty avg file to A.G. Jones format.
- Parameters
- * avg_data_fn:str
pathLike , path to your avg file
- profile_fn: str
pathLike, path to your profile/station file .
- j_extension: str
Extension type you want to export file . Default is “.dat”
- utm_zone: str
add if station_profile are not referenced yet. later , it would be removed .
- savepath: str
pathLike , path to save your outpufile
- write_info: bool
write the informations of your input file , export informations into Jfile,*Default* is False.
- survey_name: bool,
survey_area
- class pycsamt.ff.core.avg.Comp(comp_name=None, **kwargs)[source]
Components measured
Holds the following information:
- class pycsamt.ff.core.avg.Data(data_array=None, **kwargs)[source]
AVG Data informations , Container of all data infos .
- class pycsamt.ff.core.avg.Emag(e_mag_array=None, number_of_frequencies=None, number_of_stations=None, **kwargs)[source]
E-field magnitude (microVolts/(kiloMeter*Amp))
- class pycsamt.ff.core.avg.Ephz(e_phz_array=None, number_of_frequencies=None, number_of_stations=None, **kwargs)[source]
E-field phase (milliRadians)
- class pycsamt.ff.core.avg.Frequency(freq_array=None, normalize_freq_betw=None, **kwargs)[source]
Frequency informations - Frequency at which data was measured (Hertz). Frequency on Hz
Methods
normalize_frequency([normalize_freq_betw])method to interpolate frequencies.
- class pycsamt.ff.core.avg.Header(header_infos=None, **kwargs)[source]
Read the info Header of AVG file and rewrite Avgfile (main type, Type1) .
Methods
write_header_log([data_fn, savepath])Method to write your head log.
- write_header_log(data_fn=None, savepath=None)[source]
Method to write your head log. In fact just to see whether your Zonge Infos was set correctly.
- Parameters
- * data_fnstr
path to Avgfile
- savepathstr
path to your destination file . if None , path is your current work directory .
- :Example:
>>> from pycsamt.ff.core.avg.Avg import Header >>> Header().write_header_log(data_fn=path, ... ) >>> he=Header() ... he.write_header_log(data_fn=path, ... savepath=r'C:/Users\Administrator\Desktop') ... avg_obj.Header.write_header_log(data_fn=path, ... savepath=r'C:/Users/Administrator/Desktop')
- class pycsamt.ff.core.avg.Hmag(h_mag_array=None, number_of_frequencies=None, number_of_stations=None, **kwargs)[source]
H-field magnitude (picoTesla/Amp) (milliGammas/Amp)
- class pycsamt.ff.core.avg.Hphz(h_phz_array=None, number_of_frequencies=None, number_of_stations=None, **kwargs)[source]
H-field phase (milliRadians)
- class pycsamt.ff.core.avg.Phase(phase_array=None, number_of_frequencies=None, number_of_stations=None, **kwargs)[source]
- Impedance phase on milliRadians can be calculate using Ephz
object and Hphz object
Phase = E-phase - H-phase
- class pycsamt.ff.core.avg.ReceiverProperties(Rx_data=None, **kwargs)[source]
Class for receiver properties.
Methods
set_receiver_properties([Rx_data])Methods to set Receivers - properties infos from AVG files.
- class pycsamt.ff.core.avg.Resistivity(res_array=None, number_of_frequencies=None, number_of_stations=None, **kwargs)[source]
based on Cagniard Resistivity (Ohm-Meters) calculation
- class pycsamt.ff.core.avg.Skip_flag(skip_flag=None, **kwargs)[source]
skip flag values
drop data
skip data
good quality of data
Methods
setandget_skip_flag([skip_flag])simple method to set and get skip_flag.
- class pycsamt.ff.core.avg.SurveyAnnotation(survey_annotations_data=None, **kwargs)[source]
Class for survey annotations.
Methods
set_survey_annotations_infos([...])Method to set _survey annotations informations .
- class pycsamt.ff.core.avg.SurveyConfiguration(survey_config_data=None, **kwargs)[source]
Class for survey Survey configuration.
Methods
Method to set _survey configurations informations .
- class pycsamt.ff.core.avg.TransmitterProperties(**kwargs)[source]
Class for transmitter properties.
Methods
set_transmitter_properties([Tx_data])Method to set_Tx_properties.
- class pycsamt.ff.core.avg.Z_Tensor(z_array=None, phase_array=None, freq=None, z_error=None, **kwargs)[source]
- Impedance Tensor Z Calculation :
class can recompute the apparent resistity rho base on impedance Tensor Z.
See also
Zonge, K.L. and Hughes, L.J., 1991, Controlled source audio-frequency magnetotellurics,in Electromagnetic Methods in Applied Geophysics, ed. Nabighian, M.N., Vol. 2,Society of Exploration Geophysicists, pp. 713-809.
- Attributes
- freq
- phase
- rho
- z
- z_error
Methods
rhophi2rhoph_errors([res_array, ...])Compute the phase and resistivities error via res_array , phase_array and _z error.
z_and_zerr_2rhophi([z_array, freq])Method to compute resistivity and phase phase using Z_values and Zerror _values
- rhophi2rhoph_errors(res_array=None, phase_array=None, z_error=None, freq=None)[source]
Compute the phase and resistivities error via res_array , phase_array and _z error.
- Parameters
- * res_arrayndarray ,
resistivity value in ohm.m
- phase_arrayndarray ,
phase angle value in mradians
- z_errorndarray ,
impedance Tensor error
- freqndarray ,
frequency numbers in Hz
- Returns
- ——–
- ndarrays
resistivities error and phase errors values .
- z_and_zerr_2rhophi(z_array=None, freq=None)[source]
Method to compute resistivity and phase phase using Z_values and Zerror _values
- Parameters
- * z_arraycomplex
Impedance tensor complex_number The default is None.
- freqndarray,
frequency value. The default is None.
- Returns
- ndarray(ndarray,1)
resistivity value computed in ohm.m
- ndarray (ndarray, 1),
phase angle value in degree.
- class pycsamt.ff.core.avg.ZongeHardware(zonge_hardw_infos=None, **kwargs)[source]
Some features of zonge AMTAVG software.
Methods
set_harware_infos([zonge_hardw_infos])Method to set Harwares infos.
- class pycsamt.ff.core.avg.pcEmag(pc_e_mag_array=None, number_of_frequencies=None, number_of_stations=None, **kwargs)[source]
Statistical variation of magnitude values from averaged data blocks.
Standard Deviation/Average Emag (percent)
- class pycsamt.ff.core.avg.pcHmag(pc_h_mag_array=None, number_of_frequencies=None, number_of_stations=None, **kwargs)[source]
- Statistical variation of magnitude values from averaged data blocks.
Standard Deviation / Average Hmag (percent)
- pcHmagndarray
data array of statistical variataion of Hmag value on the field.
More attributes can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core.avg import Avg >>> path=os.path.join(os.environ["pyCSAMT"], ... 'pycsamt', "data", "K1.AVG") >>> avg_obj=Avg(path) >>> pchmag_obj =avg_obj.Data_section.pcHmag.loc['S05'] >>> print(pchmag_obj)
- class pycsamt.ff.core.avg.pcRho(pcRes_array=None, number_of_frequencies=None, number_of_stations=None, **kwargs)[source]
Statistical variation of magnitude values from averaged data blocks. Standard Deviation / Average Rho (percent)
- class pycsamt.ff.core.avg.sEphz(sEphz_array=None, number_of_frequencies=None, number_of_stations=None, **kwargs)[source]
Statistical variation of the data blocks averaged for this data point. 100 * Standard Deviation of Ephz values (milliradians)
Module CS
This file is part of pyCSAMT.
pyCSAMT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
pyCSAMT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with pyCSAMT. If not, see <https://www.gnu.org/licenses/>.
Created on Wed Dec 2 11:29:32 2020
@author: KouaoLaurent alias @Daniel03
- class pycsamt.ff.core.cs.CSAMT(data_fn=None, profile_fn=None, **kwargs)[source]
CSAMT class is super class container of all the information of the other classes,J, Avg and Edi. In fact, the CS object collect all
the information of the other classes, once questioned for specific uses. The purpose of the construction of this object to avoid the repetition of scripts throughout the project.Objet CSAMT can recognize the typycal
input obj of file and set attributes for use .
- Attributes
- dipolelength
- doi
- east
- elev
fpathassert path and redirect to file either single file,edifiles or Jfiles.
- freq
- lat
- lon
- north
- phase
- phase_err
- resistivity
- resistivity_err
- skindepth
- station
- station_distance
- station_separation
- z_err
- zxy
- zyx
Methods
find_path([path, ptol])Check path and return filepath , edipath or jpath .
- static find_path(path=None, ptol=0.7)[source]
Check path and return filepath , edipath or jpath .
- Parameters
path (str or pathlike) – full path to file or directory
ptol (float) – tolerance given by the program , less or egal to 1
- Returns
specific path
- Return type
str
Note
tolerence param inspects the number of EDI or J file located on the path and determine the typical
path of files either edipath or jpath.
- property fpath
assert path and redirect to file either single file,edifiles or Jfiles. find the specific path [EDI|J] path.
- class pycsamt.ff.core.cs.Location(**kwargs)[source]
Details of sation location . Classe used to convert cordinnates and check values for lat/lon , east/north
Attributes
Type
Description
latitude
float/ndarray,1
sation latitude
longitude
float/ndarray,1
station longitude
elevation
float/ndarray
station elevantion in m or ft
easting
float/ndarray.1
station easting coordinate (m)
northing
float/ndarray,1
station northing coordinate (m)
azimuth
float/ndarray,1
station azimuth in meter
stn_pos
ndarray,1
sation dipoleposition
utm_zone
str
UTM location zone
Methods
Description
convert_location_2_utm
convert position location lon/lat in utm easting northing
convert_location_2_latlon
convert location postion from east/north to latitude/longitude
- Attributes
- azimuth
- easting
- elevation
- latitude
- longitude
- northing
- stn_pos
- utm_zone
Methods
convert_location_2_latlon([utm_zone])Project coodinate on longitude latitude once data are utm at given reference ellispoid constrained to WGS-84.
convert_location_2_utm([latitude, longitude])Project coordinates to utm if coordinates are in degrees at given reference ellipsoid constrained to WGS84.
get_eastnorth_array_from_latlon(arr_lat, arr_lon)Method to quicly convert array of latitude and northing into easting northing
- convert_location_2_latlon(utm_zone=None)[source]
Project coodinate on longitude latitude once data are utm at given reference ellispoid constrained to WGS-84.
- convert_location_2_utm(latitude=None, longitude=None)[source]
Project coordinates to utm if coordinates are in degrees at given reference ellipsoid constrained to WGS84.
- Parameters
latitude (float) – latitude number
longitude (float) – longitude number
- get_eastnorth_array_from_latlon(arr_lat, arr_lon)[source]
Method to quicly convert array of latitude and northing into easting northing
- Parameters
arr_lat (array_like) – array of latitude value
array_lon (array_like) – array of longitude value.
- Returns
easting array
:rtype : array_like
- Returns
northing array
- Return type
array_like
- class pycsamt.ff.core.cs.Profile(profile_fn=None, **kwargs)[source]
Profile class deal with AVG Zonge station file and statation locations coordinates could be find in .stn file or SEG-EDI file.
- Parameters
profile_fn (str) – Path to Zonge *STN file of SEG-EDI locations or Zonge station file
Note
When EDI file is called , EDI-collecton auto populated profile attributes and coordinates are automatically rescalled.
Attributes
Type
Explanation
Location
class
Location class for Easting Northing azimuth details.
profile_angle
float
If user doesnt Know the angle profile . He can use the method “get_profile_angle” to get the value of profile angle.
stn_interval
(ndarray,1)
Array of station separation.
dipole_length
float
Dipole length value computed automatically.
lat/lon
(ndarray,1)
latitude/longitude of stations points .
east/north
(ndarray,1)
Easting and northing of stations points.
azimuth
(ndarray,1)
Azimuth array stations .
ele
(ndarray,1)
Elevation array at each station points.
stn_position
(ndarray,1)
Station position occupied at each stations.
More attributes can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core.cs import Profile >>> file_stn = 'K1.stn' >>> path = os.path.join(os.environ["pyCSAMT"], ... 'pycsamt','data', file_stn) >>> profile =Profile (profile_fn=path) >>> profile.straighten_profileline( X=profile.east, Y=profile.north,straight_type='n') >>> profile.rewrite_station_profile( ... easting=profile.east, ... northing=profile.north, ... elevation =profile.elev, ... add_azimuth=True) >>> separation = profile.stn_separation( ... easting = profile.east, ... northing =profile.north)
- Attributes
- east
- elev
- lat
- lon
- north
- stn_position
Methods
compute_dipolelength_from_coords([easting, ...])Fonction to compute dipole length from coordinates easting and northing values.
get_profile_angle([easting, northing])Method to compute profile angle .
read_stnprofile([profile_fn, easting, ...])Method to read profile station file.
reajust_coordinates_values([x, y, stn_fn, ...])Simple staticmethod to readjut coordinates values and write new station file.
rewrite_station_profile([easting, northing, ...])Mthod to rewrite station_profile or output new profile by straightening profile throught reajusting location coordinates values.User can use this method to create zonge stn file if coordinates are known.
stn_separation([easting, northing, interpolate])Compute the station separation Distance between every two stations
straighten_profileline([X, Y, ...])Method to straighten profile line and/or rescaled coordinates.
- static compute_dipolelength_from_coords(easting=None, northing=None, **kwargs)[source]
Fonction to compute dipole length from coordinates easting and northing values.
- Parameters
easting (array_like) – array of easting coordinate in meters
northing (array_like) – array of northing coordinate in meters
lat (array_like (ndarray,1)) – latitude coordinate in degree
lon (array_like (ndarray,1)) – longitude coordinate in degree
reference_ellipsoid (int) – id, Ellipsoid name, Equatorial Radius, square of eccentricity ,default is 23
- Returns
length of dipole during survey approximated .
- Return type
float
- Returns
position of dipole from reference station
- Return type
array_like(ndarray,1)
Note
the first electrode is located at 0 and second electrode to dipole length i.e [0, 50 , …, nn*50] where nn number of point -1. Data are relocated in center position of dipole.
- get_profile_angle(easting=None, northing=None)[source]
Method to compute profile angle .
- Parameters
easting (array_like) – easting corrdinate of the station point
northing – northing coordinate of station point.
:type northing:array-like
- Returns
profile angle in degrees.
- Return type
float
- read_stnprofile(profile_fn=None, easting=None, northing=None, elevation=None, split_type=None, **kwargs)[source]
Method to read profile station file. user can use its special file .user can specify a head of its file. method will read and will parse easting , northing , elevation , or lon, lat, elev or station . User can also provided easting , northing and elevation value .
- Parameters
- * profile_fn :str
path to station profile file
- split_type :str
How data is separed . Default is “”.
- eastingarray_like
easting coordinate (m),
- northingarray_like
northing coordinate value (m)
- latarray_like
latitude coordinate in degree
- lonarray_like
longitude coordinate in degree
- azimarray_like ,
azimuth in degree If not provided can computed automatically
- utm_zone :str
survey utm zone if not porvided and lat and lon is set , can compute automatically
- static reajust_coordinates_values(x=None, y=None, stn_fn=None, rewrite=False, savepath=None, **kwargs)[source]
Simple staticmethod to readjut coordinates values and write new station file. by default , the reajustment substract value. to add value to you old coordiantes , use negative X and Y method offer possibility of output new file by setting write to True. By convention we use X as EASTING correction and Y for NORTHING correction.
- Parameters
- * x: float
value for ajusting X coordinates _EASTING
- y: float
value for ajustig Y coordinates ._NORTHING
- stn_file: str
station profile file . it may be a STN file .
- rewrite: bool
rewrite a new station file after reajust coordinates.
- savepathstr
outdir pathLike to save your new profile file.
- Returns
- array_like
stations_pk , station profile pka value(m) . Electrode fixed point value.
- array_like
easting coordinate value (m)
- array_like
northing coordinate value (m)
- elevationarray_like
evelation point at each station (m)
- :Example :
>>> from pycsamt.ff.core.cs import Profile >>> stn_file =K1.stn >>> path = os.path.join(os.environ["pyCSAMT"], ... 'pycsamt','data', ... stn_file) >>> profile =Profile.reajust_coordinates_values( ... x=-300238.702 ,y=-2369.252 )
- rewrite_station_profile(easting=None, northing=None, elevation=None, area_name=None, username=None, add_azimuth=False, **kwargs)[source]
Mthod to rewrite station_profile or output new profile by straightening profile throught reajusting location coordinates values.User can use this method to create zonge
stn file if coordinates are known.
- Parameters
easting (array_like) – easting coordinates (m)
northing (array_like) – northing coordinates (m)
elevation (array_like) – elevation values (m)
username (str) – name of user
add_azimuth (bool) – compute azimuth positive down(clockwise)
- stn_separation(easting=None, northing=None, interpolate=False)[source]
Compute the station separation Distance between every two stations
- Parameters
- * eastingarray_like (ndarray, 1)
easting coordinates
- northingarray_like (ndarray,1)
northing coordinates
- interpolatebool
if interpolate is True will extend to N+1 number to much excatly the number of electrode. If false , it match the number of dipole N. Default is False.
- Returns
- array_like
separation value array
- float
separation mean or average separation value
- straighten_profileline(X=None, Y=None, straight_type='classic', reajust=(0, 0), output=False, **kwargs)[source]
Method to straighten profile line and/or rescaled coordinates. User can readjust coordinateq of profile by adding coordinate of readjustation Method provides 3 type of straighten profile. Default is “classic”, it could be “‘natural or distorded’, equidistant” . “natural or distorded Type” is not to straight a profile like a straight line but , it keeps the equidistant point of the station at normal place that the survey must be. sometimes on the field , crew may get around some obstacle and despite the line is not straight , the distance between station is distorded. Using ‘distord or natural type ‘ , it will show the right place station must be.
Note
for easier approch we use X as easting and Y as northing.
- Parameters
X (array_like (ndarry, array,1)) – easting coordinates array.
Y (array_like (ndarray,1)) – northing coordinates array
straight_type (str) – type of straighten ,it could be “equistant or egal, natural or distord”. default is “classic”
reajust (tuple) – coordinates for reajustment ( index 0 :x index 1 : y )
- class pycsamt.ff.core.cs.Site(data_fn=None, **kwargs)[source]
Specific site object Easy pack data :lat, lon, elev, azim, east, north, into dictionnary for easy access .
- Attributes
- azim
- east
- elev
- lat
- lon
- north
- stn_name
Methods
set_site_info([data_fn, easting, northing, ...])Set-info from site file, can read zonge stn profile fine or s et easting and northing coordinates.
- set_site_info(data_fn=None, easting=None, northing=None, utm_zone=None)[source]
Set-info from site file, can read zonge stn profile fine or s et easting and northing coordinates.
- Parameters
data_fn (str) – path to site data file . may Use Stn or other file of coordinates infos
utm_zone (str) – Utm zone WGS84
Module EDI
This file is part of pyCSAMT.
pyCSAMT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
pyCSAMT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with pyCSAMT. If not, see <https://www.gnu.org/licenses/>.
Created on Mon Jan 11 11:37:51 2021
@author: KouaoLaurent alias @Daniel03
- class pycsamt.ff.core.edi.Copyright(**kwargs)[source]
Information of copyright, mainly about how someone else can use these data. Be sure to read over the conditions_of_use.
Holds the following informations:
Attributes
Type
Explanation
references
References
citation of published work using these data
conditions_of_use
string
conditions of use of data used for testing program
release_status
string
release status [ open | public |proprietary]
More attributes can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core.edi import Copyright >>> Copyright(**{'owner':'University of CSAMT', ... 'contact':'Cagniard'})
- class pycsamt.ff.core.edi.DefineMeasurement(defineMeas_list=None, **kwargs)[source]
Begins Measurement definition data section . Defines Location of sensors and parameters pertainning to runs for each measurments .
- Attributes
- refelev
- reflat
- reflong
Methods
get_DefineMeasurement_info([edi_fn])Class method to get definemeasurement list.
read_define_measurement([...])readmeasurement inedilist and populate attributes .
write_define_measurement([...])Write definemeasurement method ,intend to write and rewrite measurements infos into list. informations must be on list as possible if not may set attribute manually i.e [key01=value02 , ..., keynn=valuenn + dictXX ]dictXX ={meas_e}, {meas_hx}, {meas_ey}{meas_hx}, {meas_hy} {meas_hz}.
- classmethod get_DefineMeasurement_info(edi_fn=None)[source]
Class method to get definemeasurement list.
- Parameters
edi_fn (str) – full path to edifiles.
- Returns
new class with infos list
- Return type
list
- read_define_measurement(define_measurement_list=None)[source]
readmeasurement inedilist and populate attributes .
- Parameters
define_measurement_list (list) – list of measurement data can be [key_01=value_01 , …, key_xx = value_xx] Emeas and Hmeas will be set on dictionnary and call the class to populate attribute default is None
- Example
>>> from pycsamt.ff.core.edi import DefineMeasurement >>> file_edi= 'S00_ss.edi' >>> path = os.path.join(os.environ["pyCSAMT"], ... 'pycsamt','data', file_edi_2) >>> definemeas =DefineMeasurement.get_measurement_info(edi_fn=path) >>> print(definemeas.define_measurement) >>> print(definemeas.meas_ex)
Note
to get measurement_hx or measurement_ex for instance get attribute <id> of Emeasurement , do the following script
- Example
>>> from pycsamt.ff.core.edi import DefineMeasurement >>> definemeas =DefineMeasurement.get_measurement_info(edi_fn=path) >>> print(definemeas.meas_ex.id) ... 1004.
- write_define_measurement(define_measurement_list=None)[source]
Write definemeasurement method ,intend to write and rewrite measurements infos into list. informations must be on list as possible if not may set attribute manually i.e [key01=value02 , …, keynn=valuenn + dictXX ]dictXX ={meas_e}, {meas_hx},
{meas_ey}{meas_hx}, {meas_hy} {meas_hz}
- Parameters
define_measurement_list (list) – list of define measuremenent
- Returns
new list of define_measurement
- Return type
list
- . .notes :: If no edifiles is provided , can write definemeasurement
by creating dict of Eand H measurment.
- Example
>>> ex_dict ={'id':1002, 'chtype':'Ex', 'x':0, 'y':0, 'z':0, 'x2':-50,'y2':0, 'z2':0, ... 'acqchan':0,'filter':'hanning', 'sensor':'ex', 'gain':None} >>> ey_dict ={'id':1003.1, 'chtype':'Ey', 'x':0, 'y':50, 'z':0, 'x2':0,'y2':0, 'z2':0, ... 'acqchan':0} >>> hy_dict ={'id':1003, 'chtype':'Hy', 'x':0, 'y':50, 'z':90, 'azm':0.0,'dip':35, ... 'acqchan':'hy','filter':'Hanning', 'sensor':None, 'gain':0, 'measdate':''} >>> definemeas =DefineMeasurement() >>> ex =Emeasurement(**ex_dict) >>> ey =Emeasurement(**ey_dict) >>> hy=Hmeasurement(**hy_dict) ... definemeas.__setattr__('meas_ex', ex) ... definemeas.__setattr__('meas_ey', ey) ... definemeas.__setattr__('meas_hy', hy) >>> print(definemeas.write_define_measurement())
- class pycsamt.ff.core.edi.Edi(edi_filename=None, **kwargs)[source]
Ediclass is for especialy dedicated to .edi files, mainly reading and writingwhich are meant to follow the archaic EDI format put forward by SEG.Can read impedance, Tipper but not spectra. To read spectra format please consult MTpy documentation https://mtpy2.readthedocs.io/en/develop/ The Edi class contains a class for each major section of the .edi file.
Note
Frequency and components are ordered from highest to lowest frequency.
- Attributes
- elev
- lat
- lon
- processingsoftware
- station
Methods
read_edi([edifile])Read edifile and populate attribute to each data section of edi.
write_edifile([edi_fn, new_edifilename, ...])Method to write edifiles from data setting oin attribute of Edi or from existing file.
- read_edi(edifile=None)[source]
Read edifile and populate attribute to each data section of edi.
- Parameters
edifile (str) – full path to edifile
- write_edifile(edi_fn=None, new_edifilename=None, datatype=None, savepath=None, add_filter_array=None, **kwargs)[source]
Method to write edifiles from data setting oin attribute of Edi or from existing file. Can write also EMAP data are filled attribute of EDI.
- Parameters
edifile (str) – new edifile name .If None , will write edi using station_name plus type of survey (MT of EMAP) plus year of writing as< S00_emap.2021.edi> or <S00_mt.2021.edi>
datatype (str) – type of file , “mt” or “emap” if None , program will detect which file is provided . If datatype is set , program will be force to rewrite edi into given format.
savepath (str) – path to save edifile. If None save to your current work directory
add_filter_array – ndarray(nfreq, 2, 2), EDI edifile is EMAP section data , if add filter is provided , will recompute rho.
- Returns
new_edifile , full path to edifile
- Return type
str
- class pycsamt.ff.core.edi.Edi_collection(list_of_edifiles=None, edipath=None, survey_name=None)[source]
Super class to deal with Edifiles .Collect edifiles and set important properties form Controled Source audiofrequency magnetotelluRic ,
two(2) components XY and YX will be set and calculated .
- Attributes
- elevation
- latitude
- longitude
- phs_err_xy
- phs_err_yx
- phs_xy
- phs_yx
- res_err_xy
- res_err_yx
- res_xy
- res_yx
- stnames
- z_err_xy
- z_err_yx
- z_xy
- z_yx
- class pycsamt.ff.core.edi.Emeasurement(**kws)[source]
Define the electrode location , and run parameters for electric field measurement. EMeasurement contains metadata for an electric field measurement.
Attributes
Description (Restriction)
id
Measurement ID , channel number (‘required ‘)
chtype
Type of Hmeasurement[ Ex | Ey ](required)
x
x (m) north offset from first electrode (reauired)
y
y (m) offest from ref for first electrode(reauired)
z
z offset from the ref for first electrode(reauired)
x2
x offset from the 2nd electrode (‘required’)
y2
y offset from the 2nd electrode (required)
z2
z offset from the 2nd electrode (“”)
acqchan
name of the channel acquired usually same as chtype
filter
description of sensor to run (“”)
gain
gain used for run (“”)
measdate
date of run (“”)
To Fill Metadata , let take this example
- Example
>>> import pycsamt.ff.core.edi as csedi >>> emeas_dict = {'id': '1000.4', 'chtype':'ex', 'x':0, ... 'y':0, 'azm':0, 'acqchan':'ex', } >>> emeas = csedi.Hmeasurement(**emeas_dict) ... print(emeas.chtype) ... print(emeas.azm) ... print(emeas.measdate)
- class pycsamt.ff.core.edi.Head(edi_header_list=None, **kwargs)[source]
The edi head block contains a series of options which (1) identity the data set, (2) describe whn , where and by whoom was acquired , and (3) describe when , how and by whom it was written.
- Attributes
- elev
- lat
- long
Methods
get_header_list_from_edi([edi_fn])Class method to return edi_head_list .
read_head([edi_header_list])read_header_list and set attributes values
write_head_info([head_list_infos])Write list info .
- classmethod get_header_list_from_edi(edi_fn=None)[source]
Class method to return edi_head_list .
- Paramedi_fn
full path to edifile
- read_head(edi_header_list=None)[source]
read_header_list and set attributes values
- Parameters
edi_header_list (list) – list of edifile header infos
- Example
>>> from pycsamt.ff.core.edi import Head >>>> file_edi= 'S00_ss.edi' >>>> path = os.path.join(os.environ["pyCSAMT"], ... 'pycsamt','data', file_edi) >>> edihead= Head.get_header_list_from_edi(edi_fn=path) >>> print(edihead.lat) >>> print(edihead.long) >>> print(edihead.elev) >>> print(edihead.acqby)
- write_head_info(head_list_infos=None)[source]
Write list info . Can read edi and rewrite list or to provide input as [‘key_01=value_01’, ‘key_02=value_02’, …,’key_nn=value_nn’]
Note
If value is None , don’t need to write the key .
- Parameters
head_list_infos (list) – list , list of head info
- Returns
write_info list , list ready to write to let EDI file more visible .
- Return type
list
- Example
>>> from pycsamt.ff.core.edi import Head >>> path = os.path.join(os.environ["pyCSAMT"], ... 'pycsamt','data', S00_ss.edi) >>> edihead= Head.get_header_list_from_edi(edi_fn=path) >>> print(edihead.write_head_info( ... head_list_infos = edihead.edi_header))
- class pycsamt.ff.core.edi.Hmeasurement(**kws)[source]
Define the sensor location and orientation , and run parameters for a magnetic field measurement.HMeasurement contains metadata for a magnetic field measurement.
Attributes
Description
id
Measurement ID , channel number
chtype
Type of Hmeasurment[ HX | HY | HZ | RHX | RHY ]
x
x (m) north offset from reference sensor
y
y (m) offest from ref sensor
azm
angle of sensor relative to north = 0
acqchan
name of the channel acquired usually same as chtype
dip
dip angle for sensor (“”)
filter
description of sensor to run (“”)
gain
gain used for run (“”)
measdate
date of run (“”)
To fill Metadata, let get a look of this example
- Example
>>> import pycsamt.ff.core.edi as csedi >>> hmeas_dict = {'id': '1000.3', 'chtype':'hx', 'x':0, ... 'y':0, 'azm':0, 'sensor':'None'} >>> hmeas = csedi.Hmeasurement(**hmeas_dict ) >>> print(hmeas.chtype) >>> print(hmeas.azm) >>> print(hmeas.measdate) >>> print(hmeas.sensor)
- class pycsamt.ff.core.edi.Info(edi_info_list=None, **kwargs)[source]
Class EDI info class , collect information of the survey.
- > INFO
MAXINFO=999
PROJECT=SAMTEX
SURVEY=Kaapvaal 2003
YEAR=2003
PROCESSEDBY=SAMTEX team
PROCESSINGSOFTWARE=JONES 2.3
PROCESSINGTAG=
SITENAME=South Africa
RUNLIST=
REMOTEREF=
REMOTESITE=
SIGNCONVENTION=exp(+ iomega t)
Attributes
Type
Explanation
maxrun
int>=1
maximum number of text lines in info text(maybe less)
Source
class obj
Porvenace of data to rewrite
Processing
Processing obj
How data where processed
Notes
Note class
info additions
Methods
get_info_list_from_edi([edi_fn])Class to get edinfo from edifiles
read_info([edi_info_list])readinformation and populate attaribute info can set other attributes once read and not present on the file.
write_edi_info([edi_info_list])Write edi information info .
- classmethod get_info_list_from_edi(edi_fn=None)[source]
Class to get edinfo from edifiles
- Parameters
edi_fn (str) – full path to edifile
- Returns
edi_info_list
- Return type
list
- read_info(edi_info_list=None)[source]
readinformation and populate attaribute info can set other attributes once read and not present on the file.
- Parameters
edi_info_list (list) – list of infos files
- write_edi_info(edi_info_list=None)[source]
Write edi information info . Can read edi and rewrite list or to provide input as [‘key_01=value_01’, ‘key_02=value_02’, …,’key_nn=value_nn’ ] Note : If value is absent i.e None , don’t write the key . Info write method add somefield notes informations from other softwares if exists.
- Parameters
edi_info_list (list) – list of infos contain in info sections
- Returns
list of info
- Return type
list
- Example
>>> from pycsamt.ff.core.edi import Info >>> file_edi_2='SAMTEX.edi_2.edi' >>> file_edi= 'S00_ss.edi' >>> path = os.path.join(os.environ["pyCSAMT"], ... 'pycsamt','data', file_edi_2) >>> info_obj =Info.get_info_list_from_edi(edi_fn=path) >>> print(info_obj.write_edi_info())
- class pycsamt.ff.core.edi.MTEMAP(mt_or_emap_section_list=None, **kwargs)[source]
Begins an MT and EMAP data section .Defines the default measurement for MT sounding and Defines the measurments which makeup an EMAP lines.
>=MTSECT
>=EMAPSECT
SECTID=””
SECTID=S00
NFREQ=**
NCHAN=4
HX= 1001.001
MAXBLKS=999
HY= 1002.001
NDIPOLE =47
HZ= 1003.001
NFREQ=17
EX= 1004.001
HX= 0.
EY= 1005.001
HY= .0
HZ= NONE
CHKSUM =None
- Parameters
mt_or_emap_section_list (list) – mt and emap section can read ediflies by calling class method <’get_mtemap_section_list’>
Attributes
Description
Default
Restriction
sectid
Name of this section
None
str or””
nfreq
Number of frequencies
required
int >=1
maxblks
maximum number of blocks of this section
None
int>=1
ndipole
Number of dipoles in the EMAP line
required
type
Descrip. of spatial filter type used
None
str or “”
hx
Meas ID for Hx measurement
None
Def Meas Id or “
hy
Meas ID for Hy measurement
None
Def Meas Id or “
hz
Meas ID for Hz measurement
None
Def Meas Id or “
ex
Meas ID for Ex measurement
None
Def Meas Id or “
ey
Meas ID for Ey measurement
None
Def Meas Id or “
rx
Meas ID for Rx measurement
None
Def Meas Id or “
ry
Meas ID for Ry measurement
None
Def Meas Id or “
chksum
checksum total for dvalues
None
Num of “”
Note
MTEMAP can recognize function to value provided with type of data acquired either MT or EMAP. More attributes can be added by inputing a key word dictionary. …
- Example
>>> MTEMAP(**{'ex':'0011.001', 'hx':'0013.001','sectid':'Niable','nfreq':47, ... 'ey':'0012.001', 'hy':0014.001 , 'hz': 0015.001 }) >>> MTEMAP (**{'sectid':'yobkro','nfreq':18 , 'maxblks':100, 'hx':"1003.1", ... 'ex':'1005.4','hz':'1006.3', 'ey':1002.3 , 'hy':'1000.2','chksum':47, ... 'ndipole':47, 'type':'hann'})
- Attributes
- start_data_lines_num
- temp_sectid
Methods
get_mtemap_section_list([edi_fn])MT or EMAP section_classmethod to get special MT info or EMAP info in edifile
read_mtemap_section([mt_or_emap_section_list])Read mtsection and set attribute . values can be set as key
write_mtemap_section([...])Method to write MT or EMAP section into list by providing list as ['key01= value01', ..., keyxx=valuexx ]. Method can recognize whether edifile provided is MT or EMAP then can read file according to.
- classmethod get_mtemap_section_list(edi_fn=None)[source]
MT or EMAP section_classmethod to get special MT info or EMAP info in edifile
- Parameters
edi_fn (str) – full path to edifile
- Returns
newclass contained a list of mtemap infos
- Return type
list
- read_mtemap_section(mt_or_emap_section_list=None)[source]
- Read mtsection and set attribute . values can be set as key
[key01=value01, …, keynn=valuenn]
- Parameters
mt_or_emap_section_list (list) – mt or emap section list
- Example
>>> import pycsamt.ff.core.edi as csedi >>> mtsection_obj= csedi.MTEMAP.get_mtemap_section_list(edi_fn =path) >>> info = mtsection_obj.read_mtemap_section() >>> print(mtsection_obj.sectid)
- write_mtemap_section(mt_or_emap_section_list=None, nfreq=None)[source]
Method to write MT or EMAP section into list by providing list as [‘key01= value01’, …, keyxx=valuexx ]. Method can recognize whether
edifile provided is MT or EMAP then can read file according to.
- Parameters
mt_or_emap_section_list (list) – list of mt or eamp sectiionvalidate by egal (‘=’)
- Example
>>> from pycsamt.ff.core.edi import MTEMAP >>> mtemapinfo ={'sectid':'yobkro','nfreq':18 , 'maxblks':100, 'hx':"1003.1", ... 'ex':'1005.4','hz':'1006.3', 'ey':1002.3 , ... 'hy':'1000.2'}#'chksum':18, 'ndipole':47, 'type':'hann' >>> mtemapsection_obj = MTEMAP(**mtinfo) ... writeinfomtemapsect = mtemapsection_obj.write_mtemap_section() ... print(writeinfomtemapsect)
- class pycsamt.ff.core.edi.Person(**kwargs)[source]
Information for a person
Holds the following information:
Attributes
Type
Explanation
email
string
email of person
name
string
name of person
organization
string
name of person’s organization
organization_url
string
organizations web address
More attributes can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core.edi import Person >>> person =Person(**{'name':'ABA', 'email':'aba@cagniard.res.org', ... 'phone':'00225-0769980706', ... 'organization':'CagniadRES'}) >>> person.name ... ABA >>> person.organisation ... CagniardRES
- class pycsamt.ff.core.edi.Processing(**kwargs)[source]
Information for a Edi processing
Holds the following information:
Attributes
Type
Explanation
ProcessingSoftware
class
Software obj : Input software info.
processedby
str
name handler of dataprocessing
processingtag
str
specifictag
runlist
list
—
remoteref
str
reference point for remoting
remotesite
str
reference site name
signconvention
str
convention sign provide default
More attributes can be added by inputing a key word dictionary
- class pycsamt.ff.core.edi.References(**kwargs)[source]
References information for a citation.
Holds the following information:
Attributes
Type
Explanation
author
string
Author names
title
string
Title of article, or publication
journal
string
Name of journal
doi
string
DOI number
year
int
year published
More attributes can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core.edi import References >>> refobj = References(**{'volume':18, 'pages':'234--214', ... 'title':'pyCSAMT :python toolbox for CSAMT' , ... 'journal':'Computers and Geosciences', ... 'year':'2021', 'author':'DMaryE'}) >>> print(refobj.journal)
- class pycsamt.ff.core.edi.Software(**kwargs)[source]
software info
Holds the following information:
Attributes
Type
Explanation
name
string
name of software
version
string
version of sotware
Author
string
Author of software
release
string
latest version release
More attributes can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core.edi import Software >>> Software(**{'release':'0.11.23'})
- class pycsamt.ff.core.edi.Source(**kwargs)[source]
Information of the file history, how it was made
Holds the following information:
Attributes
Type
Explanation
project
string
where the project have been done
sitename
string
where the survey have been taken place
creationdate
string
creation time of file YYYY-MM-DD,hh:mm:ss
creatingsoftware
string
name of program creating the file
author
Person
person whom created the file
submitter
Person
person whom is submitting file for archiving
More attributes can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core.edi import Source >>> Source(**{'archive':'IRIS', ... 'reprocessed_by':'grad_student'})
- pycsamt.ff.core.edi.gather_measurement_key_value_with_str_parser(old_measurement_list, parser=None)[source]
fonction to rebuild xmeasurement list , to solder list with egal. In the case where no value is found at the last item, we will add “None” .
- Parameters
old_measurement_list (list) – measurement list to solder
parser (str) – can be egal or all you want, Default is None mean parser ‘=’.
- Returns
list solded with egal like <key=value>
- Return type
list
- Example
>>> from pycsamt.ff.core.edi import gather_measurement_key_value_with_str_parser >>> measm = [ ['>HMEAS', 'ID=1001.001', 'CHTYPE=HX', 'X=', '0.0', 'Y=', ... '0.0', 'Z=', '0.0', 'AZM=', '0.0', 'TS='], ... ['>HMEAS', 'ID=1002.001', 'CHTYPE=HY', 'X=', '0.0', ... 'Y=', '0.0', 'Z=', '0.0', 'AZM=', '90.0'], ... ['>HMEAS', 'ID=1003.001', 'CHTYPE=HZ', 'X=', '0.0', 'Y=', ... '0.0', 'Z=', '0.0', 'AZM=', '0.0', 'TS=', '']] >>> for item in measm: ... print(gather_measurement_key_value_with_str_parser(old_measurement_list=item) ) ... ['ID=1001.001', 'CHTYPE=HX', 'X=0.0', 'Y=0.0', 'Z=0.0', 'AZM=0.0', 'TS=None'] ... ['ID=1002.001', 'CHTYPE=HY', 'X=0.0', 'Y=0.0', 'Z=0.0', 'AZM=90.0'] ... ['ID=1003.001', 'CHTYPE=HZ', 'X=0.0', 'Y=0.0', 'Z=0.0', 'AZM=0.0', 'TS=None']
- pycsamt.ff.core.edi.minimum_parser_to_write_edi(edilines, parser=None)[source]
This fonction validate edifile for writing , string with egal. We assume that dictionnary in list will be for definemeasurment E and H fieds.
- Parameters
edilines (list) – list of items to parse
parser (str) – parser edifile section DefineMeasurement, can be change. default is egal (=)
- Example
>>> from pycsamt.ff.core.edi import DefineMeasurement >>> file_edi= 'S00_ss.edi' >>> path = os.path.join(os.environ["pyCSAMT"], ... 'pycsamt','data', file_edi_2) >>> definemeas =DefineMeasurement.get_measurement_info(edi_fn=path) >>> minimparser = minimum_parser_to_write_edi( ... edilines =definemeas.define_measurement) >>> print(minimparser)
Module J
This file is part of pyCSAMT.
pyCSAMT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
pyCSAMT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with pyCSAMT. If not, see <https://www.gnu.org/licenses/>.
Created on Thu Dec 3 22:31:16 2020
@author: @Daniel03
- class pycsamt.ff.core.j.J(j_fn=None, **kws)[source]
Class deal with A.G. Jones j-file. see : http://mtnet.info/docs/jformat.txt
- Attributes
- japp_rho
- jerror
- jimag
- jmode
- jperiod
- jpha
- jphamax
- jphamin
- jreal
- jrhomax
- jrhomin
- jweight
- jwpha
- jwrho
Methods
jMode([polarization_type])Jmode is conformited a different set of H-Polarization ans E-Polarization.
jname(number_of_sites[, survey_name])Staticmethod for generate alphanumeric station name (case sensitive when reading A.G Jones files) survey XXX, station 001.
read_j([j_fn])Method to read Jformat file.
- jMode(polarization_type='RXY')[source]
Jmode is conformited a different set of H-Polarization ans E-Polarization. for more detail :
See also
- :Convention:The convention used is for RXY to represent
the E-polarization (TE) mode, and for RYX to represent the B-polarization mode.
- static jname(number_of_sites, survey_name=None)[source]
Staticmethod for generate alphanumeric station name (case sensitive when reading A.G Jones files) survey XXX, station 001.
- Parameters
number_of_sites (int) – number of stations .
survey_name (str) – place location name .
- Returns
list of alphanumeric station names
- Return type
list
- class pycsamt.ff.core.j.J_collection(list_of_jfiles=None, survey_name=None, **kwargs)[source]
J collection Class . Collect jfiles
- Attributes
- azimuth
- elevation
- latitude
- longitude
- stnames
Methods
collect_jfiles([list_of_jfiles, jpath])Collect the Jfile from jlist from jpath.Read and populate attributes .
j2edi([jfn, savepath])Method to convert j-files to edi files.
plot_Topo_Stn_Azim([list_of_jfiles, plot, ...])plot Topography , Stn _Azim from Jfiles
rewrite_jfiles([list_of_jfiles, savepath, ...])Method to rewrite A.G.
- collect_jfiles(list_of_jfiles=None, jpath=None)[source]
Collect the Jfile from jlist from jpath.Read and populate attributes .
- Parameters
list_of_jfiles (list) – list of jfiles
- j2edi(jfn=None, savepath=None, **kwargs)[source]
Method to convert j-files to edi files. Method calls CSAMT class object and get from this class edi infos
- Parameters
jfn – collection of jfiles or path-like str
- Return type
str
- Returns
edifiles from Jobjects
- Example
>>> from pycsamt.ff.core.j import J_collection as JObjs >>> path2j = 'data/j' >>> jObjs= JObjs().j2edi(path2j)
- plot_Topo_Stn_Azim(list_of_jfiles=None, plot='*', show_stations=False, compute_azimuth=True, savefig=None)[source]
plot Topography , Stn _Azim from Jfiles
- Parameters
list_of_jfiles (list) – list of jfiles
plot (str or int) –
- type of plot ‘*’ means all the 03 plots or
use topo, stn, azim to plot
individually. default is ‘*’
show_stations (bool) – see the stations names as xlabel .
compute_azimuth (bool) – if add azimuth, set azimuth to False Default is True
savefig (str) – PathLike - path to save your figure
Note
Work but not stable …
- rewrite_jfiles(list_of_jfiles=None, savepath=None, survey_name=None, j_extension='.dat')[source]
Method to rewrite A.G. johnson file (J-Format file).
See also
- Parameters
list_of_files (list) – collection of Jfiles
survey_name (str) – name of exploration area
j_extension (str) – output format, Default is ‘.dat’
savepath (str) – output directory .If None , file will be store in current work directory
Module z
This file is part of pyCSAMT.
pyCSAMT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
pyCSAMT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with pyCSAMT. If not, see <https://www.gnu.org/licenses/>.
- class pycsamt.ff.core.z.ResPhase(z_array=None, z_err_array=None, freq=None, **kwargs)[source]
resistivity and phase container .. module:: Z .. moduleauthor:: Jared Peacock <jpeacock@usgs.gov> .. moduleauthor:: Lars Krieger
- Attributes
- phase
- phase_det
- phase_det_err
- phase_err
- phase_err_xx
- phase_err_xy
- phase_err_yx
- phase_err_yy
- phase_xx
- phase_xy
- phase_yx
- phase_yy
- res_det
- res_det_err
- res_err_xx
- res_err_xy
- res_err_yx
- res_err_yy
- res_xx
- res_xy
- res_yx
- res_yy
- resistivity
- resistivity_err
Methods
compute_resistivity_phase([z_array, ...])compute resistivity and phase from z and z_err
set_res_phase(res_array, phase_array, freq)Set values for resistivity (res - in Ohm m) and phase (phase - in degrees), including error propagation.
- compute_resistivity_phase(z_array=None, z_err_array=None, freq=None)[source]
compute resistivity and phase from z and z_err
- set_res_phase(res_array, phase_array, freq, res_err_array=None, phase_err_array=None)[source]
Set values for resistivity (res - in Ohm m) and phase (phase - in degrees), including error propagation.
- Parameters
res_array (np.ndarray(num_freq, 2, 2)) – resistivity array in Ohm-m
phase_array (np.ndarray(num_freq, 2, 2)) – phase array in degrees
freq (np.ndarray(num_freq)) – frequency array in Hz
res_err_array (np.ndarray(num_freq, 2, 2)) – resistivity error array in Ohm-m
phase_err_array (np.ndarray(num_freq, 2, 2)) – phase error array in degrees
- class pycsamt.ff.core.z.Tipper(tipper_array=None, tipper_err_array=None, freq=None)[source]
Tipper class –> generates a Tipper-object.
Errors are given as standard deviations (sqrt(VAR))
- Parameters
tipper_array (np.ndarray((nf, 1, 2), dtype='complex')) – tipper array in the shape of [Tx, Ty] default is None
tipper_err_array (np.ndarray((nf, 1, 2))) – array of estimated tipper errors in the shape of [Tx, Ty]. Must be the same shape as tipper_array. default is None
freq (np.ndarray(nf)) – array of frequencies corresponding to the tipper elements. Must be same length as tipper_array. default is None
Attributes
Description
freq
array of frequencies corresponding to elements of z
rotation_angle
angle of which data is rotated by
tipper
tipper array
tipper_err
tipper error array
Methods
Description
mag_direction
computes magnitude and direction of real and imaginary induction arrows.
amp_phase
computes amplitude and phase of Tx and Ty.
rotate
rotates the data by the given angle
- Attributes
- amplitude
- amplitude_err
- angle_err
- angle_imag
- angle_real
- freq
- mag_err
- mag_imag
- mag_real
- phase
- phase_err
- tipper
- tipper_err
Methods
Sets attributes:
computes the magnitude and direction of the real and imaginary induction vectors.
rotate(alpha)Rotate Tipper array.
set_amp_phase(r_array, phi_array)Set values for amplitude(r) and argument (phi - in degrees).
set_mag_direction(mag_real, ang_real, ...)computes the tipper from the magnitude and direction of the real and imaginary components.
- compute_amp_phase()[source]
- Sets attributes:
amplitude
phase
amplitude_err
phase_err
values for resistivity are in in Ohm m and phase in degrees.
- compute_mag_direction()[source]
computes the magnitude and direction of the real and imaginary induction vectors.
- rotate(alpha)[source]
Rotate Tipper array.
Rotation angle must be given in degrees. All angles are referenced to geographic North=0, positive in clockwise direction. (Mathematically negative!)
In non-rotated state, ‘X’ refs to North and ‘Y’ to East direction.
- Updates the attributes:
tipper
tipper_err
rotation_angle
- class pycsamt.ff.core.z.Z(z_array=None, z_err_array=None, freq=None)[source]
Z class - generates an impedance tensor (Z) object.
Z is a complex array of the form (n_freq, 2, 2), with indices in the following order:
Zxx: (0,0)
Zxy: (0,1)
Zyx: (1,0)
Zyy: (1,1)
All errors are given as standard deviations (sqrt(VAR))
- Parameters
z_array (numpy.ndarray(n_freq, 2, 2)) – array containing complex impedance values
z_err_array (numpy.ndarray(n_freq, 2, 2)) – array containing error values (standard deviation) of impedance tensor elements
freq (np.ndarray(n_freq)) – array of frequency values corresponding to impedance tensor elements.
Attributes
Description
freq
array of frequencies corresponding to elements of z
rotation_angle
angle of which data is rotated by
z
impedance tensor
z_err
estimated errors of impedance tensor
resistivity
apparent resisitivity estimated from z in Ohm-m
resistivity_err
apparent resisitivity error
phase
impedance phase (deg)
phase_err
error in impedance phase
Methods
Description
det
calculates determinant of z with errors
invariants
calculates the invariants of z
inverse
calculates the inverse of z
remove_distortion
removes distortion given a distortion matrix
remove_ss
removes static shift by assumin Z = S * Z_0
norm
calculates the norm of Z
only1d
zeros diagonal components and computes the absolute valued mean of the off-diagonal components.
only2d
zeros diagonal components
res_phase
computes resistivity and phase
rotate
rotates z positive clockwise, angle assumes North is 0.
set_res_phase
recalculates z and z_err, needs attribute freq
skew
calculates the invariant skew (off diagonal trace)
trace
calculates the trace of z
- Example
>>> import mtpy.core.z as mtz >>> import numpy as np >>> z_test = np.array([[0+0j, 1+1j], [-1-1j, 0+0j]]) >>> z_object = mtz.Z(z_array=z_test, freq=[1]) >>> z_object.rotate(45) >>> z_object.resistivity
- Attributes
detReturn the determinant of Z
det_errReturn the determinant of Z error
freqFrequencies for each impedance tensor element
invariantsReturn a dictionary of Z-invariants.
inverseReturn the inverse of Z.
normReturn the 2-/Frobenius-norm of Z
norm_errReturn the 2-/Frobenius-norm of Z error
only_1dReturn Z in 1D form.
only_2dReturn Z in 2D form.
- phase
- phase_det
- phase_det_err
- phase_err
- phase_err_xx
- phase_err_xy
- phase_err_yx
- phase_err_yy
- phase_xx
- phase_xy
- phase_yx
- phase_yy
- res_det
- res_det_err
- res_err_xx
- res_err_xy
- res_err_yx
- res_err_yy
- res_xx
- res_xy
- res_yx
- res_yy
- resistivity
- resistivity_err
skewReturns the skew of Z as defined by Z[0, 1] + Z[1, 0]
skew_errReturns the skew error of Z as defined by Z_err[0, 1] + Z_err[1, 0]
traceReturn the trace of Z
trace_errReturn the trace of Z
zImpedance tensor
- z_err
Methods
compute_resistivity_phase([z_array, ...])compute resistivity and phase from z and z_err
remove_distortion(distortion_tensor[, ...])Remove distortion D form an observed impedance tensor Z to obtain the uperturbed "correct" Z0: Z = D * Z0
remove_ss([reduce_res_factor_x, ...])Remove the static shift by providing the respective correction factors for the resistivity in the x and y components.
rotate(alpha)Rotate Z array by angle alpha.
set_res_phase(res_array, phase_array, freq)Set values for resistivity (res - in Ohm m) and phase (phase - in degrees), including error propagation.
- property det
Return the determinant of Z
- Returns
det_Z
- Return type
np.ndarray(nfreq)
- property det_err
Return the determinant of Z error
- Returns
det_Z_err
- Return type
np.ndarray(nfreq)
- property freq
Frequencies for each impedance tensor element
Units are Hz.
- property invariants
Return a dictionary of Z-invariants.
- property inverse
Return the inverse of Z.
(no error propagation included yet)
- property norm
Return the 2-/Frobenius-norm of Z
- Returns
norm
- Return type
np.ndarray(nfreq)
- property norm_err
Return the 2-/Frobenius-norm of Z error
- Returns
norm_err
- Return type
np.ndarray(nfreq)
- property only_1d
Return Z in 1D form.
If Z is not 1D per se, the diagonal elements are set to zero, the off-diagonal elements keep their signs, but their absolute is set to the mean of the original Z off-diagonal absolutes.
- property only_2d
Return Z in 2D form.
If Z is not 2D per se, the diagonal elements are set to zero.
- remove_distortion(distortion_tensor, distortion_err_tensor=None)[source]
Remove distortion D form an observed impedance tensor Z to obtain the uperturbed “correct” Z0: Z = D * Z0
Propagation of errors/uncertainties included
- Parameters
distortion_tensor (np.ndarray(2, 2, dtype=real)) – real distortion tensor as a 2x2
distortion_err_tensor – default is None
- Return type
np.ndarray(2, 2, dtype=’real’)
- returns
impedance tensor with distorion removed
- Return type
np.ndarray(num_freq, 2, 2, dtype=’complex’)
- returns
impedance tensor error after distortion is removed
- Return type
np.ndarray(num_freq, 2, 2, dtype=’complex’)
- Example
>>> import mtpy.core.z as mtz >>> distortion = np.array([[1.2, .5],[.35, 2.1]]) >>> d, new_z, new_z_err = z_obj.remove_distortion(distortion)
- remove_ss(reduce_res_factor_x=1.0, reduce_res_factor_y=1.0)[source]
Remove the static shift by providing the respective correction factors for the resistivity in the x and y components. (Factors can be determined by using the “Analysis” module for the impedance tensor)
Assume the original observed tensor Z is built by a static shift S and an unperturbated “correct” Z0 :
Z = S * Z0
- therefore the correct Z will be :
Z0 = S^(-1) * Z
- Parameters
reduce_res_factor_x (float or iterable list or array) – static shift factor to be applied to x components (ie z[:, 0, :]). This is assumed to be in resistivity scale
reduce_res_factor_y (float or iterable list or array) – static shift factor to be applied to y components (ie z[:, 1, :]). This is assumed to be in resistivity scale
- Returns
static shift matrix,
- Return type
np.ndarray ((2, 2))
- Returns
corrected Z
- Return type
mtpy.core.z.Z
Note
The factors are in resistivity scale, so the entries of the matrix “S” need to be given by their square-roots!
- rotate(alpha)[source]
Rotate Z array by angle alpha.
Rotation angle must be given in degrees. All angles are referenced to geographic North, positive in clockwise direction. (Mathematically negative!)
In non-rotated state, X refs to North and Y to East direction.
- Updates the attributes
z
z_err
zrot
resistivity
phase
resistivity_err
phase_err
- property skew
Returns the skew of Z as defined by Z[0, 1] + Z[1, 0]
Note
This is not the MT skew, but simply the linear algebra skew
- Returns
skew
- Return type
np.ndarray(nfreq, 2, 2)
- property skew_err
Returns the skew error of Z as defined by Z_err[0, 1] + Z_err[1, 0]
Note
This is not the MT skew, but simply the linear algebra skew
- Returns
skew_err
- Return type
np.ndarray(nfreq, 2, 2)
- property trace
Return the trace of Z
- Returns
Trace(z)
- Return type
np.ndarray(nfreq, 2, 2)
- property trace_err
Return the trace of Z
- Returns
Trace(z)
- Return type
np.ndarray(nfreq, 2, 2)
- property z
Impedance tensor
np.ndarray(nfreq, 2, 2)
- pycsamt.ff.core.z.correct4sensor_orientation(Z_prime, Bx=0, By=90, Ex=0, Ey=90, Z_prime_error=None)[source]
Correct a Z-array for wrong orientation of the sensors.
- Assume, E’ is measured by sensors orientated with the angles
E’x: a E’y: b
- Assume, B’ is measured by sensors orientated with the angles
B’x: c B’y: d
- With those data, one obtained the impedance tensor Z’:
E’ = Z’ * B’
- Now we define change-of-basis matrices T,U so that
E = T * E’ B = U * B’
=> T contains the expression of the E’-basis in terms of E (the standard basis) and U contains the expression of the B’-basis in terms of B (the standard basis) The respective expressions for E’x-basis vector and E’y-basis vector are the columns of T. The respective expressions for B’x-basis vector and B’y-basis vector are the columns of U.
We obtain the impedance tensor in default coordinates as:
- E’ = Z’ * B’ => T^(-1) * E = Z’ * U^(-1) * B
=> E = T * Z’ * U^(-1) * B => Z = T * Z’ * U^(-1)
- Parameters
Z_prime – impedance tensor to be adjusted
Bx (float (angle in degrees)) – orientation of Bx relative to geographic north (0) default is 0
By –
Ex (float (angle in degrees)) – orientation of Ex relative to geographic north (0) default is 0
Ey (float (angle in degrees)) – orientation of Ey relative to geographic north (0) default is 90
Z_prime_error (np.ndarray(Z_prime.shape)) – impedance tensor error (std) default is None
- Dtype Z_prime
np.ndarray(num_freq, 2, 2, dtype=’complex’)
- Returns
adjusted impedance tensor
- Return type
np.ndarray(Z_prime.shape, dtype=’complex’)
- Returns
impedance tensor standard deviation in default orientation
- Return type
np.ndarray(Z_prime.shape, dtype=’real’)