Package CSAMT
Module AVG
- 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 .
- Parameters
**data_fn** (str) – path to AVG file
Attributes
Type
Explanation
Header
class
container of Header informations
Data_section
class
container of all Data informations
Skip_flag
str
value to jugde the quality of data can filled automatically . If no skp value is provide , the program will judge quality of provided data and set to him a score .
More attributes can be added by inputing a key word dictionary
- Example
>>> Avg_object =Data(data_array=avg_data ) >>> stn=DATA.Station.name >>> freq=DATA.Frequency.value
- 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_fn (*) – full path to avgfile
savepath (*) – outdir to store edifiles if None , is your current work directory
profile_fn (*) – full path to station _profile file
apply_filter (*) – 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
edi outputfiles or edi filtered file.
- Return type
obj, edi_obj
Holdings additionals parameters
Optional
Type
Description
reference_frequency
float
frequency at clean data.Default is computed automatically
number_of_points=7.
int
number of point to for weighted window,. Default is 7.
dipole_length
float
length of dipole in meter. For CSAMT, Default is 50.
number_of_skin_depth
float
number of skin_depth can be 1 to 10 when using filter AMA. Default is 3.
- 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 (*) – pathLike , path to your avg file
profile_fn (*) – pathLike, path to your profile/station file .
j_extension (*) – Extension type you want to export file . Default is “.dat”
utm_zone (*) – add if station_profile are not referenced yet. later , it would be removed .
savepath (*) – pathLike , path to save your outpufile
write_info (*) – write the informations of your input file , export informations into Jfile,*Default* is False.
survey_name (*) – survey_area
- class pycsamt.ff.core.avg.Comp(comp_name=None, **kwargs)[source]
Components measured
Holds the following information:
- Parameters
**comp_name** (str) – path to avg filename
**new_component** (str) –
component type which data will acquired . make sure once change it , the method to calculate impedande Z and rotating angle will also change to
ExHy Zxy (Ex/Hy)
EyHz Zyx (Ey/Hx)
EyHy Zyy (Ey/Hy)
ExHx Zxx (Ex/Hx)
Attributes
Type
Explanation
name
str
name of components will filled automatically
length
float
lenght of the survey lines
More attributes can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core.avg import Comp >>> path=os.path.join(os.environ["pyCSAMT"], 'pycsamt', "data", "K1.AVG") >>> component=Comp(path, component_name='EyHx') >>> print(component.name)
- class pycsamt.ff.core.avg.Data(data_array=None, **kwargs)[source]
AVG Data informations , Container of all data infos .
- Parameters
**data_array** (np.ndarray) – Data collected form the site, It contains all the informations during survey. It could read a user own data build by classifying data according the main AVG file
Attributes
Type
Explanation
Station
(ndarray, 1)
station length infos . unit : m
Frequency
(ndarray, 1)
frequency using during survey ,unit : Hz
Amps
(ndarray, 1)
current induction values using during survey , unit : Amp
Emag
(ndarray, 1)
Electric field magnitude(Unit.nV/m,nV/Am)
Ephz
(ndarray, 1)
Electric field phase (unit. mrad)
Hmag
(ndarray, 1)
Magnetic field magnitude (Unit.pT,pT/A)
Hphz
(ndarray, 1)
Magnetic field phase (unit. mrad)
Resistivity
(ndarray, 1)
Cagnard apparent Resistivity magnitude (unit.ohm.m)
Phase
(ndarray, 1)
Impedance phase (unit. mrad)
Z
(ndarray, 1)
Impedance magnitude (unit. km/s)
pcEmag
(ndarray, 1)
relative |E| error (%)
pcHmag
(ndarray, 1)
relative |H| error (%)
sEphz
(ndarray, 1)
phase(E) error (unit.mrad)
sHphz
(ndarray, 1)
phase(H) error (unit.mrad)
sPhz
(ndarray, 1)
phase(Z) error (unit.mrad)
pcRho
(ndarray, 1)
relative apparent resistivity (rho) error (%)
added_astatic_data
(ndarray, 1)
static_corrected-apparent resistivity (unit.ohm.m)
set_to_degree
bool
phase angle value :if set to True , valueof phase will be on degree. make sure to converte the data on radian anglebefore not in mrad.
More attributes can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core import Avg >>> DATA=Data(data_array=avg_data ) >>> stn=DATA.Station.name >>> freq=DATA.Frequency.value
- 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))
- Parameters
**e_mag_array** (ndarray) – E_field magnitude Class
Attributes
Type
Explanation
value
nd.array
data of Emag column on avgfile
max
float
maximum E-Field magnitude unit :mV/km*Amp
loc
dict
location of E-Field magnitude value at the station lambda.e:g : loc[‘S00’] show the current E-mag data of station 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) >>> emag_obj =avg_obj.Data_section.Emag.loc['S02'] ... print(emag_obj)
- class pycsamt.ff.core.avg.Ephz(e_phz_array=None, number_of_frequencies=None, number_of_stations=None, **kwargs)[source]
E-field phase (milliRadians)
- Parameters
**e_phz_array** (ndarray) – E_phase data field
**to_deg** (bool) – put the Ephz value on degree .
Attributes
Type
Explanation
value
nd.array
data of Emag column unit - mrad
max
float
maximum E-Field magnitude unit -mV/km*Amp
loc
dict
location of E-phase value at the station lambda . e.g - loc[‘S46] show the current E-phase data at the station S46
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) >>> ephz_obj =avg_obj.Data_section.Ephz.loc['46'] >>> print(ephz_obj)
- 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
- Parameters
**freq_array** (arrya_like) – frequence data array
**normalize_freq_betw** (list) – must be on list of integer value If float value provided should be convert on list, same as tuple
Attributes
Type
Explanation
value
nd.array
frequency data columns components
max
float
Hight frequency
min
float
lower frequency
loc
dict
main attribute : location of station loc [‘S01’] show the frequency of station at that point.
normalize_freq_betw
list
must be a list of integer be sure that the numberprovided will be power to 10. eg .(start, end, nfreq) start - first number will be power by 10 0=1:10exp(0) end- last value to be interpolated : 4 –> 10(exp)4 nfreq- number of frequency : eg : 17 Default is None
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"], "data", "avg", "K1.AVG") >>> freq_obj=Avg(path) >>> freq_obj =avg_obj.Data_section.Frequency.loc['S07'] ... print(freq_obj)
- class pycsamt.ff.core.avg.Header(header_infos=None, **kwargs)[source]
Read the info Header of AVG file and rewrite Avgfile (main type, Type1) .
- Parameters
**data_fn** (str) – path to avgfile
Attributes
Type
Explanation
HardwareInfos
class
zonge Hardware
SurveyAnnotation
class
zonge project informations
SurveyConfiguration
class
zonge project/locations settings
Tx
class
special Transmitter properties
Rx
class
special receiver properties
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", "LC101.avg") >>> avg_obj= Avg(data_fn=path) >>> surv_area= avg_obj.Header.SurveyAnnotation.project_area >>> print(survey.area)
- 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_fn (*) – path to Avgfile
savepath (*) – 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)
- Parameters
**h_mag_array** (ndarray) – H/B_field magnitude Class .
Attributes
Type
Explanation
value
nd.array
data of Hmag column on avgfile maximum
max
float
H-mag magnitude unit - mV/km*Amp
loc
dict
location of H-mag magnitude value at the station lambda . e:g : loc[‘S05’] show the current H-mag data of station at S05.
More attributes can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core import Avg >>> path=os.path.join(os.environ["pyCSAMT"], ... 'pycsamt', "data", "K1.AVG") >>> avg_obj=Avg(path) >>> hmag_obj =avg_obj.Data_section.Hmag.loc['S05'] ... print(hmag_obj)
- class pycsamt.ff.core.avg.Hphz(h_phz_array=None, number_of_frequencies=None, number_of_stations=None, **kwargs)[source]
H-field phase (milliRadians)
- Parameters
**h_phz_array** (ndarray) –
E_phase data field to_degree : bool
put the Hphz value on degree .
Attributes
Type
Explanation
value
nd.array
data of Emag column unit : mrad
max
float
maximum E-Field magnitude unit :mV/km*Amp
loc
dict
location of E-phase value at the station lambda , e.g loc[‘S43] show the current E-phase data at the stationS43
More attributes can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core.avg import Data_section >>> path=os.path.join(os.environ["pyCSAMT"], 'pycsamt', "data", "K1.AVG") >>> avg_obj=Avg(path) >>> hphz_obj =avg_obj.Data_section.Ephz.loc['43'] ... print(hphz_obj)
- 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
- Parameters
**phase_array** (ndarray) –
array of phase values got on the field to_degree : bool
put the Phase value on degree .
Attributes
Type
Explanation
value
nd.array
data of phase column
max
float
maximum phase value (mrad)
min
float
minimum Phase (mrad)
loc
dict
location of H-phase value at the station lambda . e:g : loc[‘S00’] show the current phase data at the station S00
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) >>> phs_obj =avg_obj.Data_section.Phase.loc['S00'] ... print(phs.loc['S00'])
- class pycsamt.ff.core.avg.ReceiverProperties(Rx_data=None, **kwargs)[source]
Class for receiver properties.
- Parameters
**Rx_data** (list or str) – Filled automatically or path to your receiver properties file.
Attributes
Type
Explanation
rxGdpStn
str
receiver GDP station number (alias = Station)
rxStn
str
receiver client station number
rxHPR
int
EM component heading, pitch, roll (floats, Rx heading alias = RxBrg, ExAzm) (heading = x component azimuth in degrees east of north, pitch = x component orientation in degrees. up from horizontal, pitch = z cmp rotation about x cmp, 0=z+up, 180 = z+ down)
rxLength
str
E-field dipole length or loop widths( positive float(s),length units) (alias = aspace) (positive float, length units)
rxComps
str
EM component/impedance label(ExHx, ExHy, EyHx, EyHy, Zxx, Zxy, Zyx, Zyy, Zvec, Zdet)
sconfig_dict
dict
parameters dict config
More attributes can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core import Avg >>> path= os.path.join(os.environ['pyCSAMT'], 'pycsamt', data, 'LCS01.AVG') >>> avg_obj= Avg(data_fn=path) ... avg_obj.Header.Rx.txGdpStn ... avg_obj.Header.Rx.txStn ... avg_obj.Header.Rx.sconfig_dict['Tx.Length']
- 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
- Parameters
**res_array** (str) – data array of apparents resistivy calculation.
Attributes
Type
Explanation
value
nd.array
data of resistivity column - ohm.m
max
float
higher value of Resistivity
min
float
minimum value of resitivity on the area
mean
float
everage value of the rho
loc
dict
location of rho value at the station lambda e.g - loc[‘S13] show the current rho data at the station S13
Sres
ndarray
Astatic value corrected
More attributes can be added by inputing a key word dictionary
- Example
>>> from csammtpy.ff.core.avg import Avg >>> path=os.path.join(os.environ["pyCSAMT"], ... 'pycsamt', "data", "K1.AVG") >>> avg_obj=Avg(path) >>> rho_obj =avg_obj.Data_section.Resistivity.loc['S00'] >>> print(rho.loc['S00'])
- class pycsamt.ff.core.avg.Skip_flag(skip_flag=None, **kwargs)[source]
skip flag values
drop data
skip data
good quality of data
- Parameters
**skip_flag** (str or int ,) – skip_flag value set automatically . some astatic file doesnt mention the number of skip_flag .Default is ‘2’.
- Example
>>> from pycsamt.ff.core import Avg >>> path= os.path.join(os.environ['pyCSAMT'], ... 'pycsamt', data, 'LCS01.AVG') >>> avg_obj= Avg(data_fn=path) >>> avg_obj.Skip_flag.skip_flag >>> avg_obj.Skip_flag.get_skip_flag
- class pycsamt.ff.core.avg.Station(station_data_array=None, **kwargs)[source]
Stations informations
- Parameters
**norm_station_value** (bool) – If True, station will numbered starting by 0.*Default* is True
Attributes
Type
Explanation
value
nd.array
data of station columns components
max
float
maximum distance of survey lines
min
float
minimum distance strated recorded data
names
str
names of stations name filled automaticaly
end
str
last station name
lengh
float
lenght of the survey
unit
str
lines lenght units may be on [m, km , ft]
alldata
nd.array
ndarray of all data value from raw file
loc
dict
main attribute location of station: eg loc [‘S01’] show the distance of station at that point.
More attributes can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core.avg import Station >>> path=os.path.join(os.environ["pyCSAMT"], ... 'pycsamt', "data", "K1.AVG") >>> station=Station(path) >>> print(station.loc['S07'])
- class pycsamt.ff.core.avg.SurveyAnnotation(survey_annotations_data=None, **kwargs)[source]
Class for survey annotations.
- Parameters
**survey_annotations_data** (list , str) – path to your annotation file or Filled automatically
Attributes
Type
Explanation
project_name
str
project name
project_area
str
project area
custumer_name
str
company name
contractor_name
str
contractor name
projet_label
str
label or number
acqdate
str
data acquisition date
sconfig_dict
dict
survey annotation dictionnary
More attributes can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core.avg import Avg >>> avg_obj= Avg(data_fn=path) >>> surv_area= avg_obj.Header.SurveyAnnotation.project_area ... survey_area ... avg_obj.Header.SurveyAnnotation.sconfig_dict['Job.By']
- class pycsamt.ff.core.avg.SurveyConfiguration(survey_config_data=None, **kwargs)[source]
Class for survey Survey configuration.
- Parameters
**survey_config_data** (list) – configuration list
Attributes
Type
Explanation
surveyType
str
survey type (CSAMT, TEM, CR, TDIP)
surveyArray
str
array type(for CSAMT:Scalar, Vector, Tensor)
lineName
str
line label
lineNumber
float
line number
azimuth
str
line azimuth ( deg E of N)
stnGdpBeg
float
first GDP station number
StnGdpInc
float
GDP station number increment
stnBeg
float
possibly rescaled first station number
stnInc
float
possibly rescaled station number increment
stnLeft
float
rescaled station number on left edge of pseudosection plot
stnRight
float
rescaled station number on right edge of pseudosection plot
unitLength
float
length units (m,ft)
unitEmag
str
field units (nV/m,nV/Am)
unitHfield
str
field units (pT,pT/A
unitPhase
str
units (mrad,deg)
sconfig_dict
dict
surveyconfiguration dict elmts
More attributes can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core import Avg >>> avg_obj= Avg(data_fn=path) >>> surv_nameLine= avg_obj.Header.SurveyConfiguration.lineName ... surv_nameLine ... avg_obj.Header.SurveyConfiguration.sconfig_dict['Stn.Right']
- class pycsamt.ff.core.avg.TransmitterProperties(**kwargs)[source]
Class for transmitter properties.
- Parameters
**data_fn** (str) – path to avgfile
Attributes
Type
Explanation
txType
str
- source type (for NSAMT /CSAMT:Natural,
Bipole,Loop)
txGdpStn
str
transmitter ID from GDP Tx field (GDP stn #) (alias = XMTR)
txStn
str
rescaled Tx ID (rescaled client stn #)
txCenter
float
transmitter center-point easting, northing,elevation (float, length units) (aliases = TxCX, TxCY)
txHPR
int
transmitter orientation heading, pitch, roll (Tx heading alias = TxBrg) (heading = bipole azimuth, pitch=0, roll=0 for z+up or 180 for z positive down)
txLength
str
transmitter bipole length or square loop width (positive float, length units)
sconfig_dict
dict
params config dictionnary
More attributes can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core import Avg >>> path= os.path.join(os.environ['pyCSAMT'], ... 'pycsamt', data, 'LCS01.AVG') >>> avg_obj= Avg(data_fn=path) >>> avg_obj.Header.Tx.txGdpStn >>> avg_obj.Header.Tx.txStn >>> avg_obj.Header.Tx.sconfig_dict['Tx.Type']
- 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.
- Parameters
**data_fn** (str) – path to avg filename.
Attributes
Type
units
Explanation
Z
np.ndarray
V/m
Impedance tensor
real
dict
V/m
real part of Z
imag
dict
imaginary part of Z
complex
dict
complex
Z on complex type
rho
dict
ohm.m
Resistivity
loc
dict
location of Z value at the station lambda . e:g loc[‘S00] show the current Z data at station S00
Note
all dict-attributes can be loc with the station name .
More attributes can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core.avg impor Z_tensor >>> path=os.path.join(os.environ["pyCSAMT"], ... 'pycsamt', "data", "K1.AVG") >>> z_obj=Z_Tensor(path) >>> z_z=Zxy.Z >>> print(z_obj.real["S00"]) >>> print(z_obj.imag["S00"]) >>> print(z_obj.complex["S00"]) >>> print(z_obj.loc["S00"]) >>> print(z_obj.rho["S00"])
- 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_array (*) – resistivity value in ohm.m
phase_array (*) – phase angle value in mradians
z_error (*) – impedance Tensor error
freq (*) – frequency numbers in Hz
- Returns
resistivities error and phase errors values .
- Return type
ndarrays
- 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_array (*) – Impedance tensor complex_number The default is None.
freq (*) – 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.
- Parameters
**zonge_hardw_infos** (list or str ,) – filled automatically or path to your hardware setting file.
Attributes
Type
Explanation
version
str
version of AMTAVG software
dated
str
date of building Avg file
processed
str
date of data preprocessing
from_fld_file
str
parent of avg file
astactic_version
str
zonge astactic sofware version
updated_data
str
date were data were updated
numfilterfreq
int
number of point that TMA used to filter
freq_filter
float
value of TMA filter frequency
end_astatic_file
str
end file description.
More can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core import Avg >>> path= os.path.join(os.environ['pyCSAMT'], ... 'pycsamt', data, 'LCS01.AVG') >>> avg_obj= Avg(data_fn=path) >>> avg_obj.Header.HardwareInfos.freq_filter) >>> avg_obj.Header.HardwareInfos.sconfig_dict['AMTAVG'])
- 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)
- Parameters
**pcEmag** (ndarray) – data array of statistical variataion of Emag value on the field.
Attributes
Type
Explanation
value
nd.array
data of pcEmag column on avgfile
max
float
maximum % value of pc Emag
min
float
minimum % value of pcEmag
loc
dict
location of %Ephz magnitude value at the station lambda e:g .loc[‘S05’] show the current H-mag data of station at S05.
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) >>> pcemag_obj =avg_obj.Data_section.pcEmag.loc['S05'] >>> print(pcemag_obj)
- 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)
- Parameters
**pcRes** (ndarray) – statistical variation averaged rho.
Attributes
Type
Explanation
value
ndarray
data of pcRho column on avgfile
max
float
maximum % value of pcRho
min
float
minimu % value of pcRho
loc
dict
location of %Rho magnitude value at the station lambda . e:g : loc[‘S07’] show the current H-mag data of station at S07.
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) >>> pcrho_obj =avg_obj.Data_section.pcRho.loc['S00'] ... print(pcrho.loc['S00'])
- 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)
- Parameters
**sEphz** (ndarray,) – data array of statistical variation of Ephase value on the field.
Attributes
Type
Explanation
value
nd.array
data of sHphz column on avgfile
max
float
maximum % value of sHphz
min
float
minimum value of sHphz
loc
dict
location of sHphz magnitude value at the station lambda e.g : loc[‘S44’] show the current sHphz data of station at S44
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) >>> shphz_obj =avg_obj.Data_section.sHphz.loc['S44'] ... print(shphz_obj)
- class pycsamt.ff.core.avg.sHphz(shphz_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 Hphz values (milliradians)
- Parameters
**shphz** (ndarray) – data array of statistical variation of Emag value on the field.
Attributes
Type
Explanation
value
nd.array
data of sHphz column on avgfile
max
float
maximum % value of sHphz
min
float
minimum value of sHphz
loc
dict
location of sHphz magnitude value at the station lambda. e:g : loc[‘S43’] show the current sHphz data of station at S43.
More attributes can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core.avg impor Avg >>> path=os.path.join(os.environ["pyCSAMT"], ... 'pycsamt', "data", "K1.AVG") >>> avg_obj=Avg(path) >>> shphz_obj =avg_obj.Data_section.sHphz.loc['S43'] >>> print(shphz_obj)
- class pycsamt.ff.core.avg.sPhz(sPhase_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 Phase values (milliradians)
- Parameters
array** (**sphz) – coefficient of phase variation arrqy
avg** (**path to) – full path to filename
Holds the following informations:
Attributes
Type
Explanation
value
nd.array
data of sPhz column on avgfile
max
float
maximum % value of sHphz
min
float
minimu value of sHphz
loc
dict
location of sPhz magnitude value at the station lambda . e:g - loc[‘S07’] show the current sPhz data of station at S07.
More attributes can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core.avg impor Avg >>> path=os.path.join(os.environ["pyCSAMT"], ... 'pycsamt', "data", "K1.AVG") >>> avg_obj=Avg(path) >>> shphz_obj =avg_obj.Data_section.sHphz.loc['43'] ... print(shphz_obj)
Module CS
- class pycsamt.ff.core.cs.CSAMT(data_fn=None, profile_fn=None, **kwargs)[source]
CSAMT class is a 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 for specific uses. Objet CSAMT can recognize the typical input obj of file and set attributes for use .
- Parameters
**data_fn** (str) – full path to EDI, J or AVG file or files directory
**edipath** (str) – path to edifiles directory., where edifiles are located
**jpath** (str) – full path to AG.Jones file , directory where jfiles are located
**profile_fn** (str) – full path to Zonge station profile file “*.stn”
Note
to call multiple files , better to specify only the path.
Attributes
Type
Description
lat
float/ndarray,1
sation latitude
lon
float/ndarray,1
station longitude
elev
float/ndarray
station elevantion in m or ft
east
float/ndarray.1
station easting coordinate (m)
north
float/ndarray,1
station northing coordinate (m)
azim
float/ndarray,1
station azimuth in meter (m)
station
ndarray,1
sation id from survey
utm_zone
str
UTM location zone
resistivity
dict
resistivity value at each station (ohm.m)
resistivity_err
dict
res.error at each station
phase
dict
phase value at each station in degree
phase_err
dict
phase error at each station
zxy
dict
impedanceTensor at each station from xy
zxy_error
dict
imped. Tensor error at each station from yx
zyx
dict
- impedanceTensor at each station
from xy
zyx_err
dict
imped. Tensor error at each station from yx
freq
ndarray,1
frequency array from survey
verbose
int
control the level of verbosity. Higher more messages. Default is 0.
Methods
Description
_read_csamt_objs
read in CSAMT file [EDI|AVG|J]
_read_edi_obj
read_edi_obj and set attributes
_read_avg_obj
read Zonge Eng. Avg file and set attributes
_read_j_obj
read A.G. Jones file and set attributes.
avg2edi
convert AVG to EDI files
j2edi
convert J to EDI files
- Example
>>> from pycsamt.ff.core.cs import CSAMT >>> profile_stn='K1.stn' >>> for ii in ['csi000.dat', 'testemap3.edi', 'K1.AVG']: >>> path = os.path.join(os.environ["pyCSAMT"], ... 'pycsamt','data', ii) >>> csamt_obj = CSAMT(fn = path, ... profile_fn= os.path.join( ... os.path.dirname(path), file_stn)) ... print(csamt_obj.resistivity['S00']) ... print(csamt_obj.phase['S00']) ... print(csamt_obj.phase_err['S00'])
- avg2edi(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 an astatic file, user can apply filter by setting filter to “tma, ama, or flma”. Once apply, edifiles will exported by computing resistivities filtered
- Parameters
data_fn (*) – full path to avgfile
savepath (*) – outdir to store edifiles if None , is your current work directory
profile_fn (*) – full path to station _profile file
apply_filter (*) – 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
edi outputfiles or edi filtered file.
- Return type
obj, edi_obj
Holdings additionals parameters
Optional
Type
Description
reference_frequency
float
frequency at clean data.Default is computed automatically
number_of_points=7.
int
number of point to for weighted window,. Default is 7.
dipole_length
float
length of dipole in meter. For CSAMT, Default is 50.
number_of_skin_depth
float
number of skin_depth can be 1 to 10 when using filter AMA. Default is 3.
- 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 )
- 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.
- j2edi(data_fn=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
data_fn – 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)
Module EDI
- 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 .
- Parameters
defineMeas_list** (**param) – list for define measurement infos
- >=DEFINEMEAS
MAXCHAN=7
MAXRUN=999
MAXMEAS=9999
UNITS=M
REFTYPE=CART
REFLAT=-30:52:05.62
REFLONG=21:44:35.00
REFELEV=1166
- >!****CHANNELS USING ORIGINAL SITE LAYOUT. FOR ROTATIONS SEE ZROT****!
>HMEAS ID=1001.001 CHTYPE=HX X= 0.0 Y= 0.0 Z= 0.0 AZM= 0.0
>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
>EMEAS ID=1004.001 CHTYPE=EX X= -50.0 Y= 0.0 Z= 0.0 X2= 50.0 Y2= 0.0 AZM= 0.0
>EMEAS ID=1005.001 CHTYPE=EY X= 0.0 Y= -50.0 Z= 0.0 X2= 0.0 Y2= 50.0 AZM= 90.0
Attributes
Description
Default
Restriction
defineMeas_list
list of definemeasurment
None
no
maxchan
Maximum number of channels measured
None
yes
maxmeas
Maximum number of measurements
9999
yes
maxrun
Maximum number of measurement runs
999
yes
meas_####
Hmeasurement or EmEasurment object defining the measurement made
None
yes
refelev
Reference elevation (m)
None
yes
reflat
Reference latitude
None
yes
refloc
Reference location
None
yes
reflon
Reference longituted
None
yes
reftype
Reference coordinate system
‘cart’
yes
units
Units of length
m
yes
Note
To get the list for define measurement it’s better to call the classmethod <get_define_measurement_info> to full path to .edi file to read in. …
- 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, run 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, verbose=0, **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.
- Parameters
**edi_filename** (str) – full path to .edi file to be read default is None.
Attributes
Description
edifile
Full path to edifile
MTEMAP
MT section or EMAP DataSection class, contains basic information on the data collected . Can read MT and EMAP section
DefineMeasurement
DefineMeasurement class, contains information on how the data was collected.
Head
Head class, contains metadata on where, when, and who collected the data Information class.
Info
contains information on how the data was processed and how thetransfer functions where estimated.
Z
Z class, contains the impedance data
block_size
number of data in one line. Default is 7
data_header_com
header string for each of the data section. Default is ‘>!****{0}****!’
bloc_num_format
string format of data, Default is’ 16.6e’
_t_comps
components for tipper blocks
_z_comps
components for impedance blocks
_res_comps
resistivities components
_phs_comps
phase components
Methods
Description
read_edi
Reads in an edi file and populates the associated classes and attributes.
write_edifile
Writes an .edi file following the EDI format given the apporpriate attributes are filled. Writes out in impedance and Tipper format.
_fill_data_array
Fill the impedance blocks,Tipper blocks if exists, if the.edi file is in EMAP section, read_data compute data to impedance , rho and phase .
_write_components
Write MT or EMAP components blocks for data blocks
_blocks_mt
of the .edi file.
- Example
>>> import pycsamt.ff.core.edi as csedi >>> path = os.path.join(os.environ["pyCSAMT"], ... 'data','edi', csa000.edi) >>> edihead= csedi.Head.get_header_list_from_edi( ... edi_fn=path) >>> info_obj =csedi.Info.get_info_list_from_edi( ... edi_fn=path) >>> edi_obj =csedi.Edi(edi_filename=path ) >>> edi_obj.write_edifile(new_edifilename=None)
- 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 .
- list_of_edifileslist
list of edifiles
- edipathstr
path to edifiles. If no listis provided , provided
- survey_namelocation name where the date
where collected . if surveyname is None can chech on edifiles.
Attributes
Type
Description
edifiles
list
List of edifiles ,default is None
survey_name
str
location where edidata where collected
Edi
class
Ediclass for ediproperties
Location
class
Location class for location properties
longitude
ndarray, 1
array of longitude collected from edifiles
latitude
ndarray,1
array of latitude collected from edifiles
freq_array
nadarry,1
array of frequencies collected from edifiles
elevation
ndarray ,1
array of elevation collected from edifiles.
station_names
list
list of EDI dataId , Use station
id to work.
res_xy|res_yx
dict
dict :{stn: res_xy|res_yx} ndarray value of resivities from 2 comps xy|yx
phs_xy|phs_yx
dict
dict :{stn: res_phs|phs_yx} ndarray value of phase from 2 comps xy|yx
z_xy|res_yx
dict
dict :{stn: z_xy|z_yx} (in degree) ndarray value of impedance from 2 comps xy|yx
XX_err_xy|XX_err_yx
dict
dict of error values {stn: XX_err_xy|XX_err_yx} ndarray value of impedance from 2 comps xy|yx XX : res|phs|z stn : name of site eg stn :S00, S01 , .., Snn
- Example
>>> from pycsamt.ff.core.edi import Edi_collection >>> edilist = [os.path.join(path, edi)for edi in os.listdir (path) if edi.endswith('.edi')] ... edi_objs = Edi_collection(list_of_edifiles = edilist) ... print(edi_objs.res_xy['S01']) ... print(edi_objs.phs_err_xy['S00']) ... print(edi_objs.z_err_xy['S00'])
- 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.
- Parameters
**edi_fn** (str) – Full path to edi path
- > HEAD
DATAID=”kap012”
ACQBY=”Phoenix”
FILEBY=”EMTF FCU”
FILEDATE=01/02/18
LAT=-30:52:05.62
LONG=21:44:35.00
ELEV=1166
STDVERS=SEG 1.0
PROGVERS=”4.0”
PROGDATE=06/20/11
MAXSECT=999
EMPTY=1.0e+32
Attribute
Description
Restriction
Default
dataid
Identifier for data set
str
Required
acqby
Name of contractor or otherparty
str
Required
fileby
Name of contractor of other party
str
Required
acqdate
Date of (start of) data acquisition
date
Required
enddate
Date of end of data acq
date
“”
filedate
Date EDI was written
Date
Required
country
Name of country of acq.
str
“”
state
state(s) of province(s) of acquisition
str
“”
county
Name of country of acq.
str
“”
prospect
Name of associated prospect
str
“”
loc
Description of location
str
“”
lat
avg.(approx) latitude of acq.
str
“”
long
avg.(approx)longitude of avq.
str
“”
elev
avg.(approx)elevation of acq.
str
“”
units
Units for elevation
“m”|”ft”
“m”
stdvers
Version of EDI format for this file
str
Required
progvers
Version ID for prog. written
str
Required
progdate
Last revision of prog writing file
str
Required
coordsys
coordinate system [geographic|geomagnetic]
str
Geog.North
declination
geomagnetic declination
float
“10.”
maxsect
Maximum data section in EDI file
int>=1
“16”
bindata
if not “”, tag for binary data file
str of “”
“”
empty
Value which represents”nodata”
float
“1.0E32”
- 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
- 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'})
- 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 function validates 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
- 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
- Parameters
**j_fn** (str) – path to A.G. Jones Jfile .
Holds the following information:
Attributes
Type
Explanation
jazim
float
station azimuth in degree .
jlat
float
station latitude in degre decimal
jlon
float
station longitude in degree decimal
jelev
float
station elevation in meter.
jmode
str
polarization mode.Polarization mode will be use to compute jproperties.
jnperiod
int
number of period . User can provide.If none it will be computed automatically
jperiod
(ndarray,1)
array of periods (s-1) or(1/second)1
japp_rho
(ndarray,1)
array of apparent resistivities (ohm.m)
jphase
(ndarray,1)
array of phase in degree
jrhomax
(ndarray,1)
rho + 1 standard error
jrhomin
(ndarray,1)
rho - 1 standard error
jphamax
(ndarray,1)
pha + 1 standard error
jphamin
(ndarray,1)
pha - 1 standard error
jwrho
(ndarray,1)
weight for apparent_resistivity
jwpha
(ndarray,1)
weight for phase
jreal
(ndarray,1)
real part of the transfer function
jimag
(ndarray,1)
imaginary part of the transfer function
jerror
(ndarray ,1)
standard error
jweight
(ndarray,1)
weight (Note: some weights are in error!)
Method
Description
jname
staticmethod to generate A.G.Jones station codename
jMode
method for comformited H-Polarization and E-Polari- zation mode . if mode is provided , il will check conformities, if not provied, Default is ‘RXY’.
read_j
read the jfiles.
More attributes can be added by inputing a key word dictionary
- Example
>>> from pycsamt.ff.core import J >>> j=J() >>> jmode = j.jMode(polarization_type='RXY') >>> print(jmode)
- 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
- Parameters
**list_of_jfiles** (list) – list of Jfiles collection
**survey_name** (str) – path to A.G. Jones Jfiles
Holds the following information:
Attributes
Type
Explanation
azimuth
ndarray,1
array_of all stations azimuth (deg)
latitude
ndarray,1
stations latitudes in degre decimal
longitude
ndarray,1
stations longitudes in degree decimal
elevation
ndarray,1
stations elevations in meter.
period
list
- list of array of collection periods.
collect all periods from all stations .
app_rho
list
list of arrays of apparent resistivities (ohm.m)
phase
list
list of array of phases in degree from allstations.
rhomax
list
list of (rho + 1 standard error) arrays
rhomin
list
list of (rho - 1 standard error) arrays
phamax
list
list of (pha + 1 standard error )arrays
phamin
list
list of (pha - 1 standard error) arrays
wrho
list
list of (weight for apparent_resistivity) arrays
wpha
list
list of (weight for phase ) arrays
real
list
list of real part of the transfer function arrays
imag
list
list of imaginary part of the transfer function
error
list
list of standard error from alla stations
weight
list
list of weight (Note: some weights are in error!)
Method
Description
collect_jfiles
read collections jfiles and populates attributes
plot_Topo_Stn_Azim
method to plot Topograpy , station seperation and Azimuth .
rewrite_jfiles
rewrite jfiles.
- 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 objectand 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
- class pycsamt.ff.core.z.ResPhase(z_array=None, z_err_array=None, freq=None, **kwargs)[source]
resistivity and phase container .. module:: Z
- 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
- 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
- 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.
- Contains
z1
det
det_real
det_imag
trace
skew
norm
lambda_plus/minus,
sigma_plus/minus
- 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’)
Module Site
- class pycsamt.ff.site.Location(**kwargs)[source]
Details of station location. Class 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
- 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.site.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.site 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)
- 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 (*) – path to station profile file
split_type (*) – How data is separed . Default is “”.
easting (*) – easting coordinate (m),
northing (*) – northing coordinate value (m)
lat (*) – latitude coordinate in degree
lon (*) – longitude coordinate in degree
azim (*) – azimuth in degree If not provided can computed automatically
utm_zone (*) – 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 (*) – value for ajusting X coordinates _EASTING
y (*) – value for ajustig Y coordinates ._NORTHING
stn_file (*) – station profile file . it may be a STN file .
rewrite (*) – rewrite a new station file after reajust coordinates.
savepath (*) – 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)
* elevation (array_like) – evelation point at each station (m)
:Example :
>>> from pycsamt.ff.site 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
easting (*) – easting coordinates
northing (*) – northing coordinates
interpolate (*) – 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.site.Site(data_fn=None, **kwargs)[source]
Specific site object Easy pack data :lat, lon, elev, azim, east, north, into dictionnary for easy access .
- Parameters
**data_fn** (str) – path to site file , the same file as profile or X,Y coordinates values
- Example
>>> from pycsamt.ff.site import Site >>> site=Site(data_fn=path) >>> print(site.east['S07']) >>> print(site.north['S09'])
- 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