Package Processing
Module Dispatcher
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 Nov 26 20:55:39 2020
@author: @Daniel03
- pycsamt.ff.processing.callffunc.agso_data()[source]
Geological data codes processing
Deprecated since version function: will later deprecated
- pycsamt.ff.processing.callffunc.dipole_center_position(dipole_position=None)[source]
Generaly positions are taken at each electrode of dipole to that to easy correct data for ploting and for noise correction , we adjust coordinate by taking the center position that means , the number of points will be substract to one.
- Parameters
dipole_position (array_like) – postion array at each electrodes.
- Returns
centered position value array
- Return type
array_like
- pycsamt.ff.processing.callffunc.get_array_from_reffreq(array_loc, freq_array, reffreq_value, stnNames=None)[source]
Get array value at special frequency :param * array_loc: dictionnary of stations , array_value e.g: S00:(ndarray,1) rho_values :type * array_loc: dict , :param * freq_array: frequency array for CSAMT survey :type * freq_array: (ndarray,1) :param * reffreq_value: the value of frequency user want to get the value :type * reffreq_value: int or float :param * stnNames: list of stations names . :type * stnNames: list
- Returns
- array_like
an array of all station with reffreq_value . e.g reffreq_value =1024. it return all value of the array at 1024Hz frequency .
- pycsamt.ff.processing.callffunc.get_matrix_from_dict(dict_array, flip_freq=False, freq_array=None, transpose=False)[source]
Function to collect dictionnary station data with values as array and build matrix along the line, The rowlines is assumed to be frequency and colums as stations names. If freq_array is provided , flip_freq is not usefull.
- Parameters
- dict_arraydict
stations dictionnary array, keys are stations names and values are stations values on array_like.
- transposebool, optional
transpose matrix , if true wwill transpose data and stations should be read as rowlines and frequency as columns. The default is False.
- freq_arrayarray , optional
array of frequency, if provided will check if frequency are range from highest to lowest .Defalut is True
- flip_freq :bool, optional
- set to false if you want frequency to be lowest to highest otherwise
frequency are sorted Highest to lowest. Default is False
- Returns
- ndarray(len(stations,), len(frequency))
matrix of dictionnary values
- bool,
flip_freq, ascertain if frequency array is flipped or not.
- pycsamt.ff.processing.callffunc.plot_reference_frequency(reference_array, frequency_array, data_array, station_names=None, **kwargs)[source]
Function to plot reference frequency
- Parameters
- reference_arrayarray_like,
array_of average_impedance Z_avg.
- frequency_array: array_like
array of frequency on sites
- data_arrayndarray,
nadarray of sounding curve, ndarray(len(frequency), len(number_ofstaions).
- Returns
- viewer
- pycsamt.ff.processing.callffunc.relocate_on_dict_arrays(data_array, number_of_frequency, station_names=None)[source]
Put data arrays on dictionnary where keys is each station and value the array of that station. if station_names is None , program will create name of station. if station_names is given , function will sorted stations names . please make sure to provide correctly station according the disposal you want .
- Parameters
number_of_frequency (array_like) – array of frequency during survey
station_names (list of array_like) – list of station
- Returns
infos at data stations
- Return type
dict
- pycsamt.ff.processing.callffunc.set_stratum_on_dict()[source]
Process to put geocodes_strata and geocodes_structures into dictionnaries better way to go on metaclasses merely. Thus each keys of dictionary will be its own object.
- Returns
- strata_dictdict
Disctionnary of geostrata
- structures_dictdict
Dictionnary of geostructures.
- pycsamt.ff.processing.callffunc.straighten_cac2CSfile(data_array, component_column_section=None)[source]
Sometimes head_sections of file _F2(CAC2CSAMT) provided is little different colunms section name according to different version . it ‘s better to filter and to check before returning the correct informations we need.
- Parameters
- * data_arrayndarray
data from AVG astatic file
- component_column_sectionlist
astactic file column comps provided
- Returns
- array_we_need :ndarray
same infos present in the plainty /1 Avg file
- array_other_comppd.Core.DataFrame
infos include through Astatic softwares very usefull therefore we keep it .
- pycsamt.ff.processing.callffunc.truncated_data(data, number_of_reccurence, **kwargs)[source]
Function to truncate all data according to number of frequency.
- Parameters
- * datalist, or nd.array
data must be truncate.
- number_of_freqint
number of frequency imaged.
- Returns
- list
loc_list , data truncated on list.
- pycsamt.ff.processing.callffunc.zstar_array_to_nan(zstar_array, nan_value=nan, keep_str=False)[source]
- Parameters
- * zstar_arrayndarray
array contain unfloat converter value. the unconverter value can be a ‘*’
- nan_valuefloat or np.nan type
the nan_value could be any value either int, float or str. The default is np.nan.
- keep_strbool, optional
keep the str item on your array. f keep_str is set to false and the type nan_value is str , the program will force ‘keep_str_’ to True to allow converter . The default is False.
- Returns
- ndarray
zstrar_array converted .
Module Shifting
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 Sat Dec 12 13:55:47 2020
@author: @Daniel03
- pycsamt.ff.processing.corr.buildBlock_freqRhoOrPhase(dictRhoOrPhase)[source]
From a dictionnary, build matrix like ndarray (nfreq, Rho|Phase)
- Parameters
dictRhoOrPhase – dictionnary of station and values. We assume stations is sorted to first station to the last
- Returns
Block matrix of rho or phase
- pycsamt.ff.processing.corr.interp_to_reference_freq(freq_array, rho_array, reference_freq, plot=False)[source]
Interpolate frequencies to the reference frequencies.
- Parameters
freq_array (array_like) – frequency array
reference_freq (float) – frequency at clean data
- class pycsamt.ff.processing.corr.shifting(data_fn=None, freq_array=None, res_array=None, phase_array=None, **kwargs)[source]
- processing classshifting processing workflow correction class
deal with AVG Zonge station file “*.stn” or SEG-EDI file.
- Attributes
- app_rho
- frequency
- phase
- referencefreq
Methods
AMA([data_fn, dipole_length, ...])Adapative moving average AMA to correct apparent resistivities. AMA filter estimates static-corrected apparent resistivities at a single reference frequency by calculating a profile of average impedances along the length of the line. Sounding curves are then shifted so that they intersect the averaged profile. The highest frequency with clean data should be selected as the static-correction reference frequency.
FLMA([data_fn, dipole_length, ...])Fixed length-dipole moving average FLMA to correct apparent resistivities.The FLMA filter estimates static-corrected apparent resistivities at a single reference frequency by calculating a profile of average impedances along the length of the line.
TMA([data_fn, reference_freq, ...])Corrected apparent resistivities with Trimmed-moving-average filter(TMA) .TMA estimates average apparent resistivities at a single static-correction-reference frequency.
Can use this fonction to compute at the same time FLMA and AMA by setting only the filter func argument .
read_processing_file([data_fn, profile_fn, ...])Mehod read processing files and load attributes for use.
write_corrected_edi([data_fn, ...])Method to rewrite edifiles with corrected resistivities by applying filters either tma (triming moving average) or flma fixed-length dipole moving average.
- AMA(data_fn=None, dipole_length=50.0, number_of_skin_depth=3.0, freq_array=None, reference_freq=None, **kwargs)[source]
Adapative moving average AMA to correct apparent resistivities. AMA filter estimates static-corrected apparent resistivities at a single reference frequency by calculating a profile of average
impedances along the length of the line. Sounding curves are then
shifted so that they intersect the averaged profile. The highest frequency with clean data should be selected as the static-correction reference frequency.
- Parameters
number_of_skin_depths – skin depth for filter length
:type number_of_skin_depths : int, float, default is 3.
- Returns
resistivities corrected with ama filter
:rtype:dict ,
See also
for other parameters explanations see the docstring of FlMA
read from edipath or jpath
- Example
>>> from pycsamt.ff.processing.corr import shifting >>> edipath =os.path.join(os.environ['pyCSAMT'], 'data', 'edi') >>> corr_obj= shifting(data_fn =edipath) >>> corrapp = corr_obj.AMA(number_of_points=7, ... reference_freq=1024.) >>> corr_obj._rj >>> corrapp
read Zonge avg file
- Example
>>> from pycsamt.ff.processing.corr import shifting >>> avg_path = os.path.join(os.environ['pyCSAMT'], 'data', 'avg') >>> csamt_obj =CSAMT(data_fn =os.path.join(avg_path, 'K2.AVG'), ... profile_fn=os.path.join(avg_path, 'K2.stn')) >>> corr_obj= shifting(data_fn =os.path.join(avg_path, 'K2.AVG'), ... profile_fn=os.path.join(avg_path, 'K2.stn')) >>> corrapp = corr_obj.AMA(number_of_points=5, reference_freq=8000.) >>> print(corr_obj._rj) >>> print(corrapp)
- FLMA(data_fn=None, dipole_length=50.0, number_of_dipole=5.0, reference_freq=None, **kwargs)[source]
Fixed length-dipole moving average FLMA to correct apparent resistivities.The FLMA filter estimates static-corrected apparent resistivities at a single reference frequency by calculating a profile of average impedances along the length of the line. Sounding curves are then shifted so that they intersect the averaged profile. The highest frequency with clean data should be selected as the static-correction reference frequency.
- Parameters
data_fn (str) – full path to data file , could be[AVG|EDI|J]
dipole_length (float, default is 50.) – value of dipole length in meters
number_of_dipole – number of dipole to cover hanning window width
:type number_of_dipole : int, float, default is 5.
- Parameters
reference_freq (int, float) – reference frequency at clean data , if not provided reference will be compute automaticcally
freq_array (array_like) – array of survey frequency of the field
res_dict_arrays (ndarray_array, dict , optional) – resistivity array of data collected on the field, could be a ndarray of resistivites at each frequency of each sites or a dictionnary of array
phase_dict_arrays (ndarray, optional) – phase values of data at each stations could be an ndarray of phase with ndarray(len(freq), len(nstaions)) or dictionnary of phase values at each stations.
- Returns
rho corrected at each survey sites
- Type
dict
Note
skin depth param is not to used for FLMA filter application. It is not necessary to provide when apply for FLMA filter.
read from edipath or jpath
- Example
>>> from pycsamt.ff.processing.corr import shifting >>> edipath =os.path.join(os.environ['pyCSAMT'], 'data', 'edi') >>> corr_obj= shifting(data_fn =edipath) >>> corrapp = corr_obj.FLMA(number_of_dipole=7, ... reference_freq=1024.) >>> corr_obj._rj >>> corrapp
read Zonge avg file
- Example
>>> from pycsamt.ff.processing.corr import shifting >>> avg_path = os.path.join(os.environ['pyCSAMT'], 'data', 'avg') >>> csamt_obj =CSAMT(data_fn =os.path.join(avg_path, 'K2.AVG'), ... profile_fn=os.path.join(avg_path, 'K2.stn')) >>> corr_obj= shifting(data_fn =os.path.join(avg_path, 'K2.AVG'), ... profile_fn=os.path.join(avg_path, 'K2.stn')) >>> corrapp = corr_obj.FLMA(number_of_dipole=7, reference_freq=8000.) >>> print(corr_obj._rj) >>> print(corrapp)
- TMA(data_fn=None, reference_freq=None, number_of_TMA_points=5.0, **kwargs)[source]
Corrected apparent resistivities with Trimmed-moving-average filter(TMA) .TMA estimates average apparent resistivities at a single static-correction-reference frequency. if reference frequency is not provided , will find automatically.
- Parameters
- * data_fnstr
path to avg file or edi file .
- freq_arrayarray_like (ndarray,1)
frequency array of at normalization frequency (reference value)of all stations.
station j to n .( units = Hz )
- res_arraydict of array_like (ndarra,1)
dict of array of app.resistivity at reffreq. from station j to n.
- phase_arraydict of array_lie(ndarray,1), dict of array
- of phase at reffreq.from station j to n.
(unit=rad)value of frequency with clean data . (unit=Hz)
- stnVSrho_locdict
set of dictionnary of all app.resistivity data from station j to n . (optional)
- num_of_TMA_point :int
window to apply filter .
- Returns
- dict
rho_corrected , value corrected with TMA filter from station j to n.
corrected data from [AVG] ..
- Example
>>> from pycsamt.ff.processing.corr import Shifting >>> path = os.path.join(os.environ["pyCSAMT"], ... 'pycsamt','data', LCS01.AVG) ... static_cor =shifting().TMA (data_fn=path, ... reference_freq=1024., number_of_TMA_points =5 )
- corrected from edifiles [EDI]
- Example
>>> from pycsamt.ff.core.cs import CSAMT >>> from pycsamt.ff.processing.corr import Shifting >>> edipath = r'C:/Users\Administrator\Desktop est\edirewrite' >>> csamt_obj =CSAMT(edipath =edipath) >>> static_cor =shifting().TMA( reference_freq =256. , ... freq_array = csamt_obj.freq , ... res_array = csamt_obj.resistivity , ... phase_array =csamt_obj.phase , ... number_of_TMA_points=5) ... print(static_cor)
- compute_fixed_and_adaptative_moving_average(filterfunc, data_fn=None, profile_fn=None, dipole_length=50.0, reference_freq=None, **kwargs)[source]
Can use this fonction to compute at the same time FLMA and AMA by setting only the filter func argument . If the function is used set the param filterfunc to the filter we need. Avoid repetition in the code Later.
- Parameters
filterfunc (obj) – filter fonction , can be filter-AMA or filter-FLMA
data_fn (str) – full path to data file , could be[AVG|EDI|J]
dipole_length (float, default is 50.) – value of dipole length in meters
number_of_skin_depths – skin depth for filter length
:type number_of_skin_depths : int, float, default is 5.
- Parameters
reference_freq (int, float) – reference frequency at clean data , if not provided reference will be compute automaticcally
compute fixed length dipole moving average FLMA
- Example
>>> from pycsamt.ff.processing.corr import shifting >>> edipath =os.path.join(os.environ['pyCSAMT'], 'data', 'edi') >>> corr_obj= shifting(data_fn =edipath) >>> res_flma_obj = corr_obj.compute_fixed_and_adaptative_moving_average( filterfunc=Zcc.compute_FLMA, number_of_points=7, ... reference_freq=8192.) >>> corr_obj._rj >>> res_flma_obj
compute adaptative moving-average AMA
- Example
>>> from pycsamt.ff.processing.corr import shifting >>> edipath =os.path.join(os.environ['pyCSAMT'], 'data', 'edi') >>> corr_obj= shifting(data_fn =edipath) >>> res_ama_obj = corr_obj.compute_fixed_and_adaptative_moving_average( filterfunc=Zcc.compute_FLMA, number_of_skin_depth=7, ... reference_freq=8192.) >>> corr_obj._rj >>> res_ama_obj
- read_processing_file(data_fn=None, profile_fn=None, reference_freq=None, **kwargs)[source]
Mehod read processing files and load attributes for use.
- Parameters
data_fn (str) – full path to data file , coulb be avg of Zonge International Engineering or edi of Society of Exploration Geophysics or j|dat format of AG.Jones MT.
profile_fn (str) – full path to station profile file. It’s compulsory to provide this file when read avgfile.
- write_corrected_edi(data_fn=None, reference_frequency=None, FILTER='tma', **kwargs)[source]
Method to rewrite edifiles with corrected resistivities by applying filters either tma (triming moving average) or flma fixed-length dipole moving average. ama adaptative moving average is not available yet for Electromagnetic Array Profilin(EMAP). To apply filter for MT data , set FILTER arguments to ss for static shift removal and dist for distortion removal. It’s possible to apply EMPA filters MT data by setting datatype argument to “mt”.
- Parameters
data_fn (str) – full path to edifiles
FILTER (str, default is`tma`) – type of filter to write, can be tma or flma for EMAP data or ss (remove static schift) or dist (remove distortion)for MT data . Default is tma assume data provided are EMAP data.
- Reference_frequency
refrequency at clean data, optional when apply for filter ss and dist.
Holds others parameters:
Params
Type
Description
filename
str
name of output edifiles
number_of_points
int
weighted window. Default is 7. if one edifile is provided , change weigthed point to 1.
dipole_length
float
length of dipole. Default is 50.m
reduce_res_factor_x
float
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
static shift factor to be applied to y components (ie z[:, 1, :]). This is assumed to be in resistivity scale
distortion_tensor
ndarray
real distortion tensor as a 2x2, np.ndarray(2, 2, dtype=real)
distortion_err_tensor
ndarray
real distortion tensor error as a 2x2 np.ndarray(2, 2, dtype=real)
datatype
str
type of data provided . Could be mt or emap. Detect automatically if None.
savepath
str
full path to save outputfile.
corrected single edifile
- Example
>>> from pycsamt.ff.processing import shifting >>> edifile =os.path.join(os.environ['pyCSAMT'], 'data', ... 'edi', 'new_csa000.edi' ) >>> corr_obj= shifting() >>> corr_obj.write_corrected_edi(data_fn = edifile, ... number_of_points =1., ... dipole_length =50., FILTER='ss')
corrected multi edifiles EMAP
- Example
>>> from pycsamt.ff.processing import shifting >>> edipath =os.path.join(os.environ['pyCSAMT'], 'data', 'edi') >>> corr_obj= shifting() >>> corr_obj.write_corrected_edi(data_fn = edipath, ... number_of_points =7., ... dipole_length =50., ... FILTER='flma')
Module ZCalculator
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 16:44:29 2020
@author: @Daniel03
- pycsamt.ff.processing.zcalculator.comp_phz(comphz_array, units='deg')[source]
PHZc are from each data block, units in rad
- Parameters
comphz_array (float) – average parameters phase for data blocs.
- Returns
component phase averaged.
- Return type
component phase averaged.
- Example
>>> path = os.path.join(os.environ["pyCSAMT"], ... 'csamtpy','data', 'K1.AVG') >>> from pycsamt.core import avg >>> phs_obj =avg.Phase(path) >>> phs_obj.loc['S00'] >>> value, ss = comp_phz(comphz_array=phs_obj.loc[ ... 'S00'], to_degree=True) ... print(value)
- pycsamt.ff.processing.zcalculator.comp_rho(mag_E_field, mag_H_field, freq_array, A_spacing, Txcurr)[source]
Function to compute component average unit in in ohm.m
- Parameters
mag_E_field (np.ndarray(ndarray,1)) – magnitude of E-filed , averaged
mag_H_field (np.ndarray(ndarray,1)) – magnitude of H-Field , averaged
freq_array (np.ndarray(ndarray,1)) – frequency of station field
A_spacing (np.float) – step_between station
Txcurr (np.float,) – distance of coil in meter
- Returns
comp_rho , component averaged rho.
- Return type
np.ndarray
- pycsamt.ff.processing.zcalculator.compute_AMA(reference_freq=None, z_array=None, number_of_skin_depth=1.0, dipole_length=50.0, **kwargs)[source]
Use an adaptive-moving-average filter to estimate average apparent resistivities at a single static-correction-reference frequency. Adaptive filtering is based on ideas presented inTorres-Verdin and Bostick, 1992, Principles of spatial surface electric field filtering in magnetotellurics -electromagnetic array profiling (EMAP), Geophysics, v57, p603-622.
- Parameters
reference_frequency (float) – frequency with clean data in Hertz
z_array (arry_like, complex) – array of uncorrected impedance values.
dipole_length (float) – length of dipole on survey
number_of_skin_depth (int , default is 1.) – arbitrary real constant, can be changed to any value between 1 and 10 skin depths, by experiency, value shoulb be 1<= c <= 4
weighted_window (array_like) – bandwidth of hanning window filter lengths, skin_depth arrays at each station.
app_rho (array_like) – array of apparent resistivities in ohm.m , if not provided will use impedance zrho to compute app_rho with reference_frequency
- Returns
windowed hanning , filtered window.
- Return type
array_like
Note
If resistivities array is provided, provided also uncorrected phase array to compute impedance array.
- Example
>>> from pycsamt.ff.core.processing import zcalculator as Zcc >>> z1= np.array([2.46073791 +3.00162006j , ... 9.74193019 +1.82209497j, ... 15.68879141 + 12.91164264j , ... 5.84384925 +3.6899018j, ... 2.4430065 +0.57175607j]) ... >>> reference_frequency = 8192. >>> znew= compute_AMA(reference_frequency=8192., ... number_of_skin_depth= 1., dipole_length =50., ... z_array=z1) ... print(znew)
- pycsamt.ff.processing.zcalculator.compute_FLMA(z_array=None, weighted_window=None, dipole_length=50.0, number_of_points=5.0, **kwargs)[source]
Use a fixed-length-moving-average filter to estimate average apparent resistivities at a single static-correction-reference frequency
- Parameters
z_array (arry_like, complex) – array of uncorrected impedance values.
dipole_length (float) – length of dipole on survey
number_of_points (int) – survey point or number point to apply.
weighted_window (array_like) – bandwidth of hanning window filter lengths, skin_depth arrays at each station.
app_rho (array_like) – array of apparent resistivities in ohm.m , if not provided will use impedance zrho to compute app_rho with reference_frequency
- Returns
windowed hanning , filtered window.
- Return type
array_like
- Example
>>> from pycsamt.ff.core.processing import zcalculator as Zcc >>> z1= np.array([2.46073791 +3.00162006j , ... 9.74193019 +1.82209497j, ... 15.68879141 + 12.91164264j , ... 5.84384925 +3.6899018j, ... 2.4430065 +0.57175607j]) >>> flma= compute_FLMA(z_array=z1, dipole_length=50. , number_of_points=4) >>> print(flma)
- pycsamt.ff.processing.zcalculator.compute_TMA(data_array=None, number_of_TMApoints=5.0)[source]
function to compute a trimmed-moving-average filter to estimate average apparent resistivities.
- Parameters
data_array (array_like(ndarray,1)) – content of value to be trimmed
points (number_of_TMA) – number of filter points .
- Returns
value corrected with TMA
- Return type
array_like (ndarray, 1)
- Example
>>> from pycsamt.ff.core.processing import zcalculator as Zcc >>> z2 = np.array([2.46073791 , 3.00162006 , ... 9.74193019 ])# 1.82209497, ... # 15.68879141 , 12.91164264 , ... # 5.84384925 , 3.6899018, ... # 2.4430065 ,0.57175607]) >>> tma= Zcc.compute_TMA(data_array=z2, ... number_of_TMApoints= 7) ... print(tma)
- pycsamt.ff.processing.zcalculator.compute_adaptative_moving_average(z_array=None, weighted_window=None, dipole_length=None, number_of_points=None)[source]
Note
see compute_AMA !
- pycsamt.ff.processing.zcalculator.compute_components_Z_Phz(magn_E_field, magn_H_field, phz_E_field, phz_H_field, freq_value, **kwargs)[source]
Function to compute all components derived from Impedance Z. user can enter specifik units in kwargs arguments . program will compute and converts value automatically.
- Parameters
- * magn_E_fieldnp.ndarray
E_.field magnitude (ndarray,1) in microV/KM*A
- magn_H_fieldnp.ndarray
H_.field magnitude (ndarray,1)in mGammas/A or picoTesla/A
- phz_E_fieldnp.ndarray
E_field phase (ndarray, 1) in mrad
- phz_H_fieldnp.ndarray
H_field phase (ndarray,1) in mrad.
- freq_valuenp.ndarray
Frequency at which data was measured(ndarray,1)in Hz
- kwargsstr
units conversion.
- Returns
- rho: ndarray
Cagnard resistivity calculation. ohm.m
- phz: ndarray
Impedance phase value.
- Zij: ndarray
Impedance Tensor value.
- Zreal: ndarray
Value of Real part of impedance Tensor.
- Zimag: float
Value of Imaginary part of impedance Tensor.
- Zreal_imag: ndarray , complex
Complex value of impedance Tensor.
- Example
>>> from pycsamt.core import avg >>> path = os.path.join(os.environ["pyCSAMT"], ... data', 'avg', 'K1.AVG') >>> emag_ob = avg.Emag(path) >>> hmag_obj = avg.Hmag(path) >>> ephz_obj = avg.Ephz(path) >>> hphz_obj = avg.Hphz(path) >>> freq_obj =avg.Frequency(path) >>> station_name ='S00' >>> rho, phz, Z, real, imag, comp =compute_components_Z_Phz( ... magn_E_field=emag_ob.loc[station_name], ... magn_H_field =hmag_obj.loc[station_name], ... phz_E_field =ephz_obj.loc[station_name], ... phz_H_field=hphz_obj.loc[station_name], ... freq_value=freq_obj.loc[station_name]) ... rho
- Raises
- CSex.pyCSAMTError_z(),
Exceptions if units entered by the user doesnt match or are messy.
- pycsamt.ff.processing.zcalculator.compute_sigmas_e_h_and_sigma_rho(pc_emag, pc_hmag, pc_app_rho, app_rho, emag, hmag)[source]
function to compute Standard Deviation for E-field (sigma_e), Standard Deviation for H-Field (sigma_h) , & Standard Deviation for Component RHO (sigma_rho)
- Parameters
- * pc_emagfloat
Statistical variation of magnitude values from averaged data blocks. Standard Deviation/Average Emag (%)
- pc_hmag :float
Statistical variation of magnitude values from averaged data blocks. Standard Deviation / Average Hmag (%)
- pc_app_rho: float
Statistical variation of magnitude values from averaged data blocks. Standard Deviation / Average Rho (%)
- app_rho :float
resistivity calculated from averaged component (ohm.m)
- Emagfloat
average E - field magnitude(microVolt/Km *amp )
- Hmagfloat
average H - field magnitude(pTesta/amp) or (milliGammas/Amp)
- Returns
- sigma_rhofloat
srhoC (Standard Deviation for Component RHO)
- c_var_Rhofloat
C-varrhoC( Coefficient of Variation for Component RHO)
- pycsamt.ff.processing.zcalculator.compute_trimming_moving_average(data_array=None, number_of_TMApoints=5.0)[source]
function to compute a trimmed-moving-average filter to estimate average apparent resistivities.
- Parameters
data_array (array_like(ndarray,1)) – content of value to be trimmed
points (number_of_TMA) – number of filter points .
- Returns
value corrected with TMA
- Return type
array_like (ndarray, 1)
- Example
>>> from pycsamt.ff.core.processing import zcalculator as Zcc >>> z2 = np.array([2.46073791 , 3.00162006 , ... 9.74193019 ])# 1.82209497, ... # 15.68879141 , 12.91164264 , ... # 5.84384925 , 3.6899018, ... # 2.4430065 ,0.57175607]) >>> tma= Zcc.compute_TMA(data_array=z2, ... number_of_TMApoints= 7) ... print(tma)
- pycsamt.ff.processing.zcalculator.compute_weight_factor_betaj(Xpos, dipole_length=50.0, number_of_points=5.0, window_width=None)[source]
- weight Beta is computed following the paper of Torres-verdfn, C., and F. X. Bostick, 1992,
Principles of spatial surface electric field filtering in magnetotellurics - Electromagnetic
array profiling ( EMAP )- Geophysics, 57(4), 25–34.
- Parameters
Xpos (str) – reference position on the field
dipole_length (float) – length of dipole measurement
number_of_points (int) – point to stand filters , windowed width
- pycsamt.ff.processing.zcalculator.compute_zxy_xk_omega(z_imp, coeffs_bj)[source]
Compute adaptative impedance with variable length Hanning window :param z_imp: impedance value to be filtered :type z_imp: complex
- Parameters
coeff_bj – list coefficients of weighted window at each stations
:type coeffs_bj : list
- Returns
array of new impedance filtered
- Return type
complex
- Example
>>> from pycsamt.ff.processing import z_calculator as Zcc >>> z1= np.array([2.46073791 +3.00162006j , ... 9.74193019 +1.82209497j, ... 15.68879141 + 12.91164264j , ... 5.84384925 +3.6899018j, ... 2.4430065 +0.57175607j]) >>> weight_betaj = [array([0.18169011, 0.81830989]), ... array([0.02492092, 0.25, 0.47507908, 0.25]), ... array([0.00224272, 0.02771308, 0.09220631, 0.16554531, 0.21341394, ... 0.21341394, 0.16554531, 0.09220631, 0.02771308]), ... array([0.05766889, 0.47116556, 0.47116556]), ... array([1.])] >>> Zcc.compute_zxy_xk_omega(coeffs_bj=weight_betaj , z_imp=z1) ... [2.01364616+2.45625537j 9.16556955+4.84395488j 6.83942027+4.21606008j ... 4.80923612+2.75254645j 2.4430065 +0.57175607j]
- pycsamt.ff.processing.zcalculator.find_reference_frequency(freq_array=None, reffreq_value=None, sharp=False, etching=True)[source]
Method to find and interpolate reference value if it is not present on the frequency range.
- Parameters
freq_array (array_like) – array_like frequency range
reffreq_value (float or int) – reference frequency value
sharp (bool) – if set to True , it forces the program to find mainly a value closest inside the frequency range.
etching (bool) – bool , if set to True , it will print in your stdout.
- Returns
reference frequency
- Return type
float
- pycsamt.ff.processing.zcalculator.get_data_from_reference_frequency(array_loc, freq_array, reffreq_value)[source]
Function to get reference frequency without call especially stations array. The function is profitable but . It’s less expensive However if something wrong happened by using the first step to get a reference array , it will try the traditionnally function to get it. If none value is found , an Error will occurs.
- Parameters
array_loc (dict) – assume to be a dictionnary of stations_data_values.
freq_array (array_like) – frequency array
reffreq_value (float or int) – reffrence value, If the reference value is not in frequency array , function will force to interpolate value and find the correlative array.
- Returns
an array of reference value at specific index
- Return type
array_like
- Example
>>> get_data_from_reference_frequency(array_loc=rho,freq_array=freq_array, ... reffreq_value=1023.) ... Input reference frequency has been interpolated to < 1024.0 > Hz
- pycsamt.ff.processing.zcalculator.get_reffreq_index(freq_array, reffreq_value)[source]
Get the index of reference index. From this index ,All array will filter data at this reffreq value . :param freq_array: array of frequency values :type freq_array: array_like
- Parameters
reffreq_value (float, int) – value of frequency at clean data
- pycsamt.ff.processing.zcalculator.hanning(dipole_length=50.0, number_of_points=7, large_band=False)[source]
Function to compute hanning window .
- Parameters
dipole_length (float) – the length of dipole , xk is centered between dipole
number_of_points (int) – number of filter points
- Returns
windowed hanning
- Return type
array_like
- pycsamt.ff.processing.zcalculator.hanning_x(x_point_value, dipole_length=50.0, number_of_points=7, bandwidth_values=False, on_half=True)[source]
Function to compute point on window width . Use discrete computing . Function show the value at center point of window assume that the point is center locate on the window width . It intergrates value between dipole length. User can use see_extraband to see the values on the total bandwith. If half is False the value of greater than center point will be computed and not be 0 as the normal definition of Hanning window filter.
- Parameters
x_point_value (float) – value to intergrate.
dipole_length (float) – length of dipole on survey
number_of_point (int) – survey point or number point to apply.
bandwidth_values – see all value on the bandwith , value greater than x_center point will be computed .
:type bandwidth_values:bool
- Parameters
on_half (bool) – value on the bandwith; value greater that x_center point = 0.
- Returns
hannx integrated X_point_value or array of window bandwidth .
- Return type
array_like
- pycsamt.ff.processing.zcalculator.hanning_xk(dipole_length=50.0, number_of_points=7)[source]
- compute _hanning window on a wtdth of number of point :
integrate value on all the window_bandwidth discrete and continue. if value is greater than Hald of the width value == 0 .
- Parameters
dipole_length (float) – length of dipole
number_of_points (int) – value of points or survey stations .
- Returns
han_xk , continue value on half bandwidth x0– xk (center point)
- Return type
array_like
- Returns
windowed hanning, discrete _value ,SUM(han(x0, xk))
- Return type
array_like
- pycsamt.ff.processing.zcalculator.interpolate_sets(array_to, fill_value=None, array_size=None)[source]
Function to interpolate data contain of multiple nan values.
- pycsamt.ff.processing.zcalculator.mag_avg(mag_array, A_spacing, Txcur)[source]
- RAW, E-, or H-field magnitude values)for each frequency
units : mV/Km*
- Parameters
mag_array (np.array (ndarray, 1),) – magnnitude value for each data block
a_spacing (float) – dipole length
txcur – curv coil, transmitter length
- Returns
averaged data of magnitude data Block
- Rtype mag_avg
np.ndarray
- pycsamt.ff.processing.zcalculator.param_phz(pphz_array, to_degree=False)[source]
PHZn are from each data block , units in mrad
- Parameters
pphz_array (array_like) – average parameters phase for data blocs.
to_degree (bool) – ascertain convertion to degree
- pycsamt.ff.processing.zcalculator.param_rho(rho_array)[source]
Parameter Average RHO (RHOp), RHO are from each data block, unit ( ohm.m)
- Parameters
rho_array (array_like) – array of resistivity values
- pycsamt.ff.processing.zcalculator.perforce_reference_freq(dataset, frequency_array=None)[source]
Function to get automatically the reference frequency. If user doesnt provide the value , function will find automatically value .
- Parameters
data (array_like) – array of avg DATA, ndim>1
frequency_array (array_like) – array of frequency
- Returns
reffreq_value float , reference frequency value
- Return type
float
- Returns
uncover_index, index of reference value on frequency array
- Return type
int
- Returns
nan_ratio , the ratio or the prevalence of nan in the data_set
- Return type
float
- pycsamt.ff.processing.zcalculator.phz_avg(phz_array, to_degree)[source]
E-, H-field, or Impedance Phase values unit in mrad
- Parameters
phz_array (array_like) – array of phase values in mrad
to_degree (bool) – ascertain convertion to degree
- pycsamt.ff.processing.zcalculator.rhophi2z(phase, freq, resistivity=None, z_array=None)[source]
Function to compute z , real part and imag part .
- Parameters
phase (ndarray) – phase angles array in radians
freq (array_like) – frequencies array in Hz
resistivity (array_like) – rho array in ohm.m
z_array (array_like) – impedance z array in V/m
- Returns
z_abs , absolute value of zz
- Return type
float
- Returns
z_real, real part of complex number
- Return type
float
- Returns
z_imag, imaginary part of zz
- Return type
complex
- Returns
ndarray
- Return type
zz, array of z_abs, z_imag, z_real
- pycsamt.ff.processing.zcalculator.wbetaX2(Xpos, dipole_length=50.0, number_of_points=5)[source]
weight Beta is computed following the paper of Torres-verdfn, C., and F. X. Bostick, 1992, Principles of spatial surface electric field filtering in magnetotellurics - Electromagnetic array profiling ( EMAP )- Geophysics, 57(4), 25–34.
- Parameters
Xpos (str) – reference position on the field
dipole_length (float) – length of dipole measurement
number_of_points (int) – point to stand filters , window width
- pycsamt.ff.processing.zcalculator.weight_beta(dipole_length=50.0, number_of_points=7, window_width=None)[source]
WeightBeta function is weight Hanning window . if window width is not provide , function will compute the width of window.
See also
Torres-Verdin and Bostick, 1992, Principles of spatial surface electric field filtering in magnetotellurics: electromagnetic array profiling (EMAP), Geophysics, v57, p603-622. …
- Parameters
dipole_length (float) – length of dipole in meter (m)
number_of_points (int) – number of station points to filter
window_width (float) – the width of window filter
- Returns
beta_array at each station
- Return type
array_like
- pycsamt.ff.processing.zcalculator.z_error2r_phi_error(z_real, z_imag, error)[source]
Error estimation from rectangular to polar coordinates. By standard error propagation, relative error in resistivity is 2*relative error in z amplitude. Uncertainty in phase (in degrees) is computed by defining a circle around the z vector in the complex plane. The uncertainty is the absolute angle between the vector to (x,y) and the vector between the origin and the tangent to the circle.
- Parameters
z_real (float) – real component of z (real number or array)
z_imag (complex) – imaginary component of z (real number or array)
error (float) – absolute error in z (real number or array)
- Returns
containers of relative error in resistivity, absolute error in phase
- Rtupe
tuple