Package Utils
Module Agso
Created on Sat Sep 26 20:30:41 2020
@author: KouaoLaurent alias @Daniel03
- Class :
- **Agso ** .
Data of Geological Welllogs
Module Decorator
- class pycsamt.utils.decorator.deprecated(reason)[source]
- Description:
used to mark functions, methods and classes deprecated, and prints warning message when it called decorators based on https://stackoverflow.com/a/40301488
- Usage:
todo: write usage
Author: YingzhiGou Date: 20/06/2017
Methods
__call__(cls_or_func)Call self as a function.
Module Func-utils
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 Sun Sep 13 09:24:00 2020 @author: @Daniel03
- utils
averageData
concat_array_from_list
sort_array_data
transfer_array_ (deprecated)
interpol_scipy
_set_depth_to_coeff
_OlDFUNCNOUSEsearch_fill_data (deprecated)
_search_ToFill_Data
straighten_out_list
take_firstValue_offDepth
dump_comma
build_wellData
compute_azimuth
build_geochemistry_sample
_nonelist_checker
_order_well
intell_index
_nonevalue_checker
_clean_space
*_cross_eraser * _remove_str_word * stn_check_split_type * minimum_parser_to_write_edi
- pycsamt.utils.func_utils.averageData(np_array, filter_order=0, axis_average=0, astype='float32')[source]
- Parameters
- * np_arraynumpy array
must be an array data
- filter_orderint
must be the index of the column you want to sort
- axis averageint
axis you want to see data averaged, also , it is the concatenate axis default is axis=0
- astype*: str ,
is the ndarray dtype array . change to have an outup arry dtype , you want .
- Returns
- numpy array
Data averaged array
- :Example :
>>> import numpy as np >>> list8=[[4,2,0.1],[8,2,0.7],[10,1,0.18],[4,3,0.1], ... [7,2,1.2],[10,3,0.5],[10,1,0.5],[8.2,0,1.9], ... [10,7,0.5],[10,1,0.5], ... [2,0,1.4],[5,4,0.5],[10,2,0.7],[7,2,1.078], ... [10,2,3.5],[10,8,1.9]] >>> np_test=np.array(list8) >>> ss=averageData(np_array=np_test,filter_order=1, ... axis_average=0, astype="int") >>> ss
- pycsamt.utils.func_utils.broke_array_to_(arrayData, keyIndex=0, broken_type='dict')[source]
broke data array into different value with their same key
- Parameters
- * arrayData :np.array
data array .
- keyIndexint
index of column to create dict key
- Returns
- dict
dico_brok ,dictionnary of array.
- pycsamt.utils.func_utils.build_geochemistry_sample()[source]
Build geochemistry_sample_data
- Returns
- np.ndarray
Sample ,Geochemistry sample Data.
- Example
>>> geoch=build_geochemistry_sample() >>> print(geoch) ... sampleData ... [['S0X4' '0' '254.0' 'PUP'] ... ['S0X4' '254' '521.0' 'mg'] ... ['S0X4' '521' '625.0' 'tut'] ... ['S0X4' '625' '984.0' 'suj'] ... ['S0X2' '0' '19.0' 'pup'] ... ['S0X2' '19' '425.0' 'hut'] ... ['S0X2' '425' '510.0' 'mgt'] ... ['S0X2' '510' '923.2' 'pyt']]
- Raises
- Process to build geochemistry sample data manually .
- pycsamt.utils.func_utils.build_wellData(add_azimuth=False, utm_zone='49N', report_path=None, add_geochemistry_sample=False)[source]
- Parameters
- * add_azimuthBool, optional
compute azimuth if add_azimut is set to True. The default is False.
- utm_zoneStr, optional
WGS84 utm_projection. set your zone if add_azimuth is turn to True. The default is “49N”.
- report_pathstr, optional
path to save your _well_report. The default is None. its match the current work directory
- add_geochemistry_sample: bool
add_sample_data.Set to True if you want to add_mannually Geochimistry data. default is False.
- Returns
- str
name of location of well .
- np.ndarray
WellData , data of build Wells .
- np.ndarray
GeolData , data of build geology.
- Example
>>> import numpy as np >>> import os, shutil >>> import warnings, >>> form _utils.avgpylog import AvgPyLog >>> well=build_wellData (add_azimuth=True, utm_zone="49N") >>> print("nameof locations
- :”,well[0])
>>> print("CollarData
- :”,well[1])
>>> print("GeolData
- :”, well[2])
… nameof locations … Shimen … CollarData … [[‘S01’ ‘477205.6935’ ‘2830978.218’ ‘987.25’ ‘-90’ ‘0.0’ ‘Shi01’ … ‘Wdanxl0’] … [‘S18’ ‘477915.4355’ ‘2830555.927’ ‘974.4’ ‘-90’ ‘2.111’ ‘Shi18’ … ‘Wdanxl0’]] … GeolData … [[‘S01’ ‘0.0’ ‘240.2’ ‘granite’] … [‘S01’ ‘240.2’ ‘256.4’ ‘ basalte’] … [‘S01’ ‘256.4’ ‘580.0’ ‘ granite’] … [‘S01’ ‘580.0’ ‘987.25’ ‘rock’] … [‘S18’ ‘0.0’ ‘110.3’ ‘sand’] … [‘S18’ ‘110.3’ ‘520.2’ ‘agrilite’] … [‘S18’ ‘520.2’ ‘631.3’ ‘ granite’] … [‘S18’ ‘631.3’ ‘974.4’ ‘ rock’]] … Shimen_wellReports_
- Raises
- Exception
manage the dimentionaly of ndarrays .
- OSError
when report_path is not found in your O.S.
- pycsamt.utils.func_utils.compute_azimuth(easting, northing, utm_zone='49N', extrapolate=False)[source]
- Parameters
- * eastingnp.ndarray
Easting value of coordinates _UTM_WGS84
- northingnp.ndarray
Northing value of coordinates._UTM_WGS84
- utm_zonestr, optional
the utm_zone . if None try to get is through gis.get_utm_zone(latitude, longitude). latitude and longitude must be on degree decimals. The default is “49N”.
- extrapolatebool ,
for other purpose , user can extrapolate azimuth value , in order to get the sizesize as the easting and northing size. The the value will repositionate at each point data were collected.
Default is False as originally azimuth computation .
- Returns
- np.ndarray
azimuth.
- Example
>>> import numpy as np >>> import gis_tools as gis >>> easting=[477205.6935,477261.7258,477336.4355,477373.7903,477448.5, ... 477532.5484,477588.5806,477616.5968] >>> northing=[2830978.218, 2830944.879,2830900.427, 2830878.202,2830833.75, ... 2830783.742,2830750.403,2830733.734] >>> test=compute_azimuth(easting=np.array(easting), ... northing=np.array(northing), utm_zone="49N") >>> print(test)
- pycsamt.utils.func_utils.concat_array_from_list(list_of_array, concat_axis=0)[source]
Small function to concatenate a list with array contents
- Parameters
- * list_of_arraylist
contains a list for array data. the concatenation is possible if an index array have the same size
- Returns
- array_like
numpy concatenated data
- Example
>>> import numpy as np >>> np.random.seed(0) >>> ass=np.random.randn(10) >>> ass2=np.linspace(0,15,12) >>> ass=ass.reshape((ass.shape[0],1)) >>> ass2=ass2.reshape((ass2.shape[0],1)) >>> or_list=[ass,ass2] >>> ss_check_error=concat_array_from_list(list_of_array=or_list, ... concat_axis=0) >>> secont test : >>> ass=np.linspace(0,15,14) >>> ass2=np.random.randn(14) >>> ass=ass.reshape((ass.shape[0],1)) >>> ass2=ass2.reshape((ass2.shape[0],1)) >>> or_list=[ass,ass2] >>> ss=concat_array_from_list(list_of_array=or_list, concat_axis=0) >>> ss=concat_array_from_list(list_of_array=or_list, concat_axis=1) >>> ss >>> ss.shape
- pycsamt.utils.func_utils.dump_comma(input_car, max_value=2, carType='mixed')[source]
- Parameters
- * input_carstr,
Input character.
- max_valueint, optional
The default is 2.
- carType: str
Type of character , you want to entry
- Returns
- Tuple of input character
must be return tuple of float value, or string value
Note
carType may be as arguments parameters like [‘value’,’val’,”numeric”, “num”, “num”,”float”,”int”] or for pure character like
[“car”,”character”,”ch”,”char”,”str”, “mix”, “mixed”,”merge”,”mer”, “both”,”num&val”,”val&num&”] if not , can not possible to convert to float or integer. the defaut is mixed
- Example
>>> import numpy as np >>> ss=dump_comma(input_car=",car,box", max_value=3, ... carType="str") >>> print(ss) ... ('0', 'car', 'box')
- pycsamt.utils.func_utils.intell_index(datalist, assembly_dials=False)[source]
function to search index to differency value to string element like geological rocks and geologicals samples. It check that value are sorted in ascending order.
- Parameters
- * datalistlist
list of element : may contain value and rocks or sample .
- assembly_dialslist, optional
separate on two list : values and rocks or samples. The default is False.
- Returns
- index: int
index of breaking up.
- first_dial: list ,
first sclice of value part
- secund_dial: list ,
second slice of rocks or sample part.
- assemblylist
list of first_dial and second_dial
- Example
>>> import numpy as np >>> listtest =[['DH_Hole', 'Thick01', 'Thick02', 'Thick03', ... 'Thick04','Rock01', 'Rock02', 'Rock03', 'Rock04'], ... ['S01', '0.0', '98.62776918', '204.7500461','420.0266651','520', 'GRT', ... 'ATRK', 'GRT', 'ROCK','GRANODIORITE'], ... ['S02', '174.4293956', '313.9043882','974.8945704', 'GRT', 'ATRK', 'GRT']] >>> listtest2=[listtest[1][1:],listtest[2][1:]] >>> for ii in listtest2 : >>> op=intell_index(datalist=ii) >>> print("index:
- “,op [0])
>>> print('firstDials :
- ‘,op [1])
>>> print('secondDials:
- ‘,op [2])
- pycsamt.utils.func_utils.interpol_scipy(x_value, y_value, x_new, kind='linear', plot=False, fill='extrapolate')[source]
function to interpolate data
- Parameters
- * x_valuenp.ndarray
value on array data : original absciss
- y_valuenp.ndarray
value on array data : original coordinates (slope)
- x_newnp.ndarray
new value of absciss you want to interpolate data
- kindstr
- projection kind :
maybe : “linear”, “cubic”
- fillstr
kind of extraolation, if None , *spi will use constraint interpolation can be “extrapolate” to fill_value.
- plotBoolean
Set to True to see a wiewer graph
- Returns
- np.ndarray
y_new ,new function interplolate values .
- Example
>>> import numpy as np >>> fill="extrapolate" >>> x=np.linspace(0,15,10) >>> y=np.random.randn(10) >>> x_=np.linspace(0,20,15) >>> ss=interpol_Scipy(x_value=x, y_value=y, x_new=x_, kind="linear") >>> ss
- pycsamt.utils.func_utils.minimum_parser_to_write_edi(edilines, parser='=')[source]
This fonction validates edifile for writing , string with egal.we assume that dictionnary in list will be for definemeasurment E and H fied.
- Parameters
edilines (list) – list of item to parse
parser (str) – the egal is use to parser edifile . can be changed, default is =
- pycsamt.utils.func_utils.parse_wellData(filename=None, include_azimuth=False, utm_zone='49N')[source]
Function to parse well information in*csv file
- Parameters
- * filenamestr, optional
full path to parser file, The default is None.
- include_azimuth: bool ,
Way to compute azimuth automatically
- utm_zonestr,
set coordinate _utm_WGS84. Defaut is 49N
- Returns
- location: str
Name of location .
- WellDatanp.ndarray
Specificy the collar Data .
- GeoDatanp.ndarray
specify the geology data .
- SampleDataTYPE
geochemistry sample Data.
- Example
>>> import numpy as np >>> dir_=r"F:\OneDrive\Python\CodesExercices\ex_avgfiles\modules" >>> parse_=parse_wellData(filename='Drill&GeologydataT.csv') >>> print("NameOflocation:
- “,parse_[0])
>>> print("WellData:
- “,parse_[1])
>>> print("GeoData:
- “,parse_[2])
>>> print("Sample:
- “,parse_[3])
- Raises
- FileNotFoundError
if typical file deoesnt match the *csv file.
- pycsamt.utils.func_utils.round_dipole_length(value, round_value=5.0)[source]
small function to graduate dipole length 5 to 5. Goes to be reality and simple computation .
- Parameters
value (float) – value of dipole length
- Returns
value of dipole length rounded 5 to 5
- Return type
float
- pycsamt.utils.func_utils.sort_array_data(data, sort_order=0, concatenate=False, concat_axis_order=0)[source]
Function to sort array data and concatenate numpy.ndarray
- Parameters
- * datanumpy.ndarray
must be in simple array , list of array and dictionary whom the value is numpy.ndarray
- sort_orderint, optional
index of colum to sort data. The default is 0.
- concatenateBoolean , optional
concatenate all array in the object. Must be the same dimentional if concatenate is set to True. The default is False.
- concat_axis_orderint, optional
must the axis of concatenation . The default is axis=0.
- Returns
- numpy.ndarray
data , Either the simple sort data or array sorted and concatenated .
- pycsamt.utils.func_utils.stn_check_split_type(data_lines)[source]
Read data_line and check for data line the presence of split_type < ‘,’ or ‘ ‘, or any other marks.> Threshold is assume to be third of total data length.
- Params data_lines
list of data to parse .
- Returns
The split _type
- Return type
str
- Example
>>> from pycsamt.utils import func_utils as func >>> path = os.path.join(os.environ["pyCSAMT"], 'csamtpy','data', K6.stn) >>> with open (path, 'r', encoding='utf8') as f : ... data= f.readlines() >>> print(func.stn_check_split_type(data_lines=data))
- pycsamt.utils.func_utils.straighten_out_list(main_list, list_to_straigh)[source]
- Parameters
- * main_listlist
list of which the data must absolutely appear into the straighen list. in our case , it is the station list : a list of offset
- list_to_straighlist
list contain the data (offset calculated , the depth and the resistivity (log10)),
- Returns
- list
the straighen list. some offset have been replaced by the offsets which are not in the main_list whithout change the lengh of the straighen list.
- Example
>>> import numpy as np >>> np.random.seed(14) >>> ss=np.random.randn(10)*12 >>> ss=ss.tolist() >>> ss=[round(float(jj),4) for jj in ss] >>> ss.sort() >>> red=np.random.randn(7)*12 >>> red=red.tolist() >>> test=[19, 15.012, 5.5821, 0.7234,3.1, ... 0.7919, 3.445, 4.7398, 5.1, 10.8, 15.51,21] >>> main=[20., 0.7234, 5, 3.445, 15.51,10.7, 3,5.1] >>> test.sort() >>> main.sort() >>> red=[round(float(ss),1) for ss in red] >>> print(test) >>> print(main) >>> sos=straighten_out_list (main_list=main , ... list_to_straigh=test) >>> print("sos:
- “,sos)
- pycsamt.utils.func_utils.take_firstValue_offDepth(data_array, filter_order=1)[source]
- Parameters
- * data_arraynp.array
array of the data .
- filter_orderint , optional
the column you want to filter. The default is 1.
- Returns
- array_like
return array of the data filtered.
- Example
>>> import numpy as np >>> list8=[[4,2,0.1],[8,2,0.7],[10,1,0.18],[4,3,0.1], ... [7,2,1.2],[10,3,0.5],[10,1,0.5],[8.2,0,1.9], ... [10,7,0.5],[10,1,0.5],[2,0,1.4],[5,4,0.5], ... [10,2,0.7],[7,2,1.078],[10,2,3.5],[10,8,1.9]] >>> test=np.array(list8) >>> print(np_test) >>> ss=take_firstValue_offDepth(data_array =np_test, filter_order=1) >>> ss=averageData(np_array=np_test,filter_order=1, >>> axis_average=0, astype="int") >>> print(ss)
- pycsamt.utils.func_utils.transfer_array_(data, index_key, start_value_depth, end_value_depth, column_order_selection=0, axis=0)[source]
- Parameters
- * datadict
Dictionnary of numpy ndarray .
- index_keyfloat
key of the dictionnary . Must be a number of the first column of offset .
- start_value_depthfloat
If the depth is not reach must add depth of the closest point. give the start value which match to the maxi depth of the data : The default is -214.
- end_value_depthfloat
Maximum depth of the survey. The default is -904.
- column_order_selectionint,
the index of depth column. The default is 0.
- axisint , optional
numpy.ndarray axis . The default is 0.
- Returns
- numpy.ndarray
return the array data we want to top to .
- Example
>>> import numpy as np >>> sos=abs(np.random.randn(4,3)*4) >>> sos2=abs(np.random.randn(4,3)*10.8) >>> print(sos2) >>> sis1=sort_array_data(data=sos,sort_order =1, ... concatenate=False, concat_axis_order=0) >>> sis2=sort_array_data(data=sos2,sort_order =1, ... concatenate=False, concat_axis_order=0) >>> dico={"18.4":sis1, ... "21.4":sis2} >>> test=transfer_array_(data=dico, index_key=11.4, ... start_value_depth=-14, end_value_depth=23, ... column_order_selection=1) >>> print("sis1:",sis1) >>> print("sis2:",sis2) >>> print("Finaltest", test)
Module Gis-tools
Module Infos
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/>.
- synopsis
Module contains various parameters of files handling and glossary of some technical words.
Created on Sat Dec 12 16:21:10 2020
@author:KouaoLaurent alias @Daniel03
- class pycsamt.etc.infos._sensitive[source]
Note
sensitive class . Please keep carefully the indices like it’s ranged. Better Ways to avoid redundancy in code during the program design. Core of parser of each files except files from module-geodrill. Aims are: 1. to check file . it is was the right file provided or not 2. to write file . to Zonge Avg_format or J-Format or EDI -format and else. 3. to compute value . Indice are used for computation , set and get specific value.
Methods
validate_avg(avg_data_lines)Core function to validate avg file .
which_file([filename, deep])Which file is class method .
- static validate_avg(avg_data_lines)[source]
Core function to validate avg file .
- Parameters
avg_data_lines (list) – list of avgfile
- Returns
‘yesAST’ or ‘yes’ where ‘yesAST’ is Astatic file and ‘yes’ is plainty avg file (the main file)
- Return type
str
- Returns
item, spliting the headAvg components strutured by file.
- Return type
list
- Example
>>> from csamtpy.etc.infos.Infos inmport _sensistive as SB >>> path = os.path.join(os.environ["pyCSAMT"], ... 'csamtpy','data', LCS01_2_to_1.avg) ... with open (path, 'r', encoding ='utf8') as f : ... datalines = f.readlines() ... ss =SB._sensitive.validate_avg(avg_data_lines=datalines)
- classmethod which_file(filename=None, deep=True)[source]
Which file is class method . List of files are the typical files able to read by pyCSAMT softwares. Sensitive class method.
- Parameters
- **filename :str**
corresponding file to read , pathLike
- deepbool ,
control reading : False for just control the extension file , not opening file . True control in deeper file and
find which file were inputted.
- Returns
- str
- FileType could be [avg | j | edi | resp | mesh | occamdat |
stn | model | iter | logfile | startup]
- List of files read by pyCSAMT :
- Example
>>> files = ['K1_exp.bln','LCS01.avg' ,'LCS01_2_to_1.avg', 'K1.stn', ... 'csi000.dat','csa250.edi','LogFile.logfile', ... 'Occam2DMesh','Occam2DModel', 'OccamDataFile.dat', ... 'S00_ss.edi', 'Startup','RESP13.resp', ... 'ITER02.iter'] >>> for ii in files : >>> path = os.path.join(os.environ["pyCSAMT"], ... 'csamtpy','data', ii) ... try : ... print(_sensitive.which_file(path,deep=True)) ... except :pass
- class pycsamt.etc.infos.notion[source]
Singular class to explain CSAMT technical word in details. Also usefull for user to have info about any scientific context is does Know. Just call the word directly in warnings to give an overview of why error occurs. It like a short documentation using pyCSAMT software. Used everywhere in the script .
Module Plot-utils
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 Tue Dec 29 19:18:44 2020
@author: @Daniel03
- pycsamt.utils.plot_utils.annotate_tip(layer_thickness, layer_names)[source]
A tip to group text with the same resistivities one layer when the layer are successively the same .
- Parameters
layer_thickness (array_like |list) – thickness of layer
layer_names (list or array_like) – names of layers , geological structures names
- Returns
v , layer thickness in depth
- Return type
array_like
- Returns
ni , list : name of layer
- Return type
array_like
- Example
>>> from pycsamt.utils import plot_utils as punc >>> rocks = ['Massive sulfide', 'Igneous rocks', 'Igneous rocks', 'Igneous rocks', 'Igneous rocks', 'Igneous rocks', 'Igneous rocks', 'Igneous rocks', 'Massive sulfide', 'Igneous rocks', 'Igneous rocks', 'Igneous rocks'] >>> resprops = [0.0, 49.0,69.0,89.0,109.0,129.0, 149.0,179.0,249.0,699.0,799.0,899.0] >>> thickness, lnames = punc.annotate_tip(layer_thickness=resprops, layer_names=rocks) >>>print(thickness) >>> print(lnames) >>> v, ni ... [24.5, 149.0, 474.0, 799.0] ... ['Massive sulfide', 'Igneous rocks', 'Massive sulfide', 'Igneous rocks']
- pycsamt.utils.plot_utils.average_rho_in_deep(dep_array, rho_array, step_descent)[source]
function to average rho in deep according to the value provided . In fact averaged rho in shorter depth distance allow us to understand the conductive zone. in approximately. The most conductive zone is detected as the zone with lower resistivities values . But fixing values as averaged rho , can build a specific strata that could match this zone .
- Parameters
- * dep_arrayarray_like
the imaged depth (doi)
- rho_array: array_like
resistivity array
- step_descentfloat
value to step descent
- Returns
- array_like
rho average for each station # dep_averaged for each station
- Example
>>> import numpy as np >>> from pycsamt.utils import plot_utils as punc >>> pseudo_depth=np.array([ 0. , 6. , 13. , 20. ,29. , 39., 49. , ... 59. , 69. , 89., 109. ,129., 149. ,179., ... 209. ,249. ,289., 339., 399., 459. ,529. ,609., ... 699., 799., 899., 999.]) >>> pseudo_depth = np.arange(0, 1220, 20) >>> rho = np.random.randn(len(pseudo_depth)) >>> rho_aver, dep_aver= average_rho_in_deep(dep_array=pseudo_depth, ... rho_array=rho, ... step_descent=20.) >>> rho_2,dep_2 = average_rho_in_deeper (dep_array= pseudo_depth, ... rho_array=rho, ... step_descent=1000) >>> print(pseudo_depth)
- pycsamt.utils.plot_utils.average_rho_in_deeper(dep_array, rho_array, step_descent)[source]
function to average rho in deep according to the value provided . In fact averaged rho in shorter depth distance allow us to understand the conductive zone. in approximately. The most conductive zone is detected as the zone with lower resistivities values . But fixing values as averaged rho , can build a specific strata that could match this zone .
- Parameters
- * dep_arrayarray_like
the imaged depth (doi)
- rho_array: array_like
resistivity array
- step_descentfloat
value to step descent
- Returns
- array_like
rho average for each station # dep_averaged for each station
- Example
>>> import numpy as np >>> from pycsamt.utils import plot_utils as punc >>> pseudo_depth=np.array([ 0. , 6. , 13. , 20. ,29. , 39., 49. , ... 59. , 69. , 89., 109. ,129., 149. ,179., ... 209. ,249. ,289., 339., 399., 459. ,529. ,609., ... 699., 799., 899., 999.]) >>> pseudo_depth = np.arange(0, 1220, 20) >>> rho = np.random.randn(len(pseudo_depth)) >>> rho_aver, dep_aver= average_rho_in_deep(dep_array=pseudo_depth, ... rho_array=rho, ... step_descent=20.) >>> rho_2,dep_2 = average_rho_in_deeper (dep_array= pseudo_depth, ... rho_array=rho, ... step_descent=1000) >>> print(pseudo_depth)
- pycsamt.utils.plot_utils.average_rho_with_locals_minmax(array)[source]
How to compute mean value between local maxima and local minima and keep locals minima and maxima value on the final data
- Parameters
array (array_like) – data to compute the local minima and local maxima
- Returns
array mean with data local value averaged
- Return type
array_like
- Example
>>> from pycsamt.utils import plot_utils as punc >>> mean1= punc.average_rho_with_locals_minmax(tth[0]) >>> mean2= punc.average_rho_with_locals_minmax(tth[1]) >>> print(mean1) >>> print(mean2)
- pycsamt.utils.plot_utils.build_new_station_id(station_id, new_station_name)[source]
Fonction to build new station id including station name provided , if the length provided
doesnt match the length of station id
- Parameters
id (station) – new sites names
mess (str) – message for debugging, Default is None
- Example
>>> from pycsamt.utils import plot_utils as punc >>> ts =[ 28., 200., 400., 600., 800., 1000., 1200., 1400., 1600., 1800., 1807.] >>> sto = ['S{0}'.format(i) for i in range(7)] >>> print(sto) >>> stn, fu =punc.build_new_station_id(station_id = sto, new_station_name =ts) >>> print(stn, fu)
- pycsamt.utils.plot_utils.build_resistivity_barplot(depth_values, res_values)[source]
Allow to build bar plot resistivity function of investigation depth .
- Parameters
- * depth_valuesaray_like
model investigation depth
- res_valuesarray_like
model_resistivities at each depth values
- Returns
- darray_like
resistivity barplot depth .
- rarray_like
specific structure resistivities
- sumdfloat
checker number that cover in fact the total depth. this numbe must absolutely match the total depth .
- pycsamt.utils.plot_utils.controle_delineate_curve(res_deline=None, phase_deline=None)[source]
fonction to controle delineate value given and return value ceilling .
- Parameters
res_deline (float|int|list) – resistivity value todelineate. unit of Res in ohm.m
phase_deline (float|int|list) – phase value to delineate , unit of phase in degree
- Returns
delineate resistivity or phase values
- Return type
array_like
- pycsamt.utils.plot_utils.delineate_curve(dict_loc, value, atol=0.2, replace_value=nan)[source]
function to delineate value of rho and phase .
- Parameters
dict_loc (dict) – dictionnary composed of keys = stations id and values
value (float |list) – value to delineate curve . for single value.
atol (float) – tolerance parameter <=1 . Most the param is closest to 0 , most the selected data become severe.default is 0.2
replace_value (float or else) – could be None or np.nan , Default is np.nan
- Returns
dict of delineate data
- Return type
dict
- Example
>>> from pycsamt.utils import plot_utils as punc >>> ts = np.array([0.1, 0.7, 2, 3, 8, 1000, 58,55, 85, 18]) >>> to =np.array([51, 78, 0.25, 188, 256, 7]) >>> tt ={'S00': ts, 'S01':to, 'S02': np.array([0, 5, 125, 789])} >>> print(punc.delineate_curve(dict_loc = tt, value=[50,70], atol = 0.1))
- pycsamt.utils.plot_utils.delineate_sparseMatrix(dict_loc, delineate_dict, replace_value=nan)[source]
Build from delineate dict a matrix according to frequency length . value doesnt exist in the delineate dict will be repalce by replacevalue . Default is nan.
- Parameters
delineate_dict (dict) – delineation value
dict_loc (dict) – dictionnary composed of keys = stations id and values
replace_value (float) – value to replece other value like build a sparse matrix
- Returns
dit of sparse matrix
- Return type
dict
- pycsamt.utils.plot_utils.depth_of_investigation(doi)[source]
Depth of investigation converter
- Parameters
doi (str|float) – depth of investigation if value float is provided , it will considered as default units in meter
:returns doi:value in meter :rtype: float
- pycsamt.utils.plot_utils.find_closest_station(offset_indice, model_offsets, site_offsets)[source]
Get the indice of the closest offset
- Parameters
- * offset_indice: int
if the indix of the offset at the selected resistivity point.
- model_offset: array_like
is a large band of x_nodes resistivities gnerated by mesh files
- sites_offsets: array_like
the data set offset from Occam Data file
- Returns
- indexoffint
index of data offset
- get_offsfloat
value of the offset at that index
- pycsamt.utils.plot_utils.find_local_maxima_minima(array)[source]
function to find minimum local and maximum local on array
- Parameters
data (array_like) – value of array to find minima , maxima
- Returns
tuple of index of minima and maxima local index and array of minima maxima value
- Return type
array_like
- Example
>>> from pycsamt.utils import func_utils as func >>> from pycsamt.utils import plot_utils as punc >>> ts =np.array([2, 3, 4, 7, 9, 0.25, 18, 28, 86, 10, 5]) >>> te=np.array([0.2, .3, 18, 1.6, 0.2, 0.6, 0.7, 0.8, 0.9, 1., 23.]) >>> th =func.concat_array_from_list([ts, te], concat_axis=1) .. tth =th.T ... print(tth) ... print(punc.find_local_maxima_minima(tth[0]))
- pycsamt.utils.plot_utils.find_path(path=None, ptol=0.7)[source]
check path and return filepath , edipath or jpath .
- Parameters
path (str) – full path to edi, avag or j file or directory
ptol (float) – tolerance that given by the program to judge if the number of typical file [EDI|J] to declare as path found is either “edipath” or “jpath” if none ,return None . less or equal to 1.
- Returns
specific path
- Return type
str
- pycsamt.utils.plot_utils.fmt_text(data_text, fmt='~', leftspace=3, return_to_line=77)[source]
Allow to format report with data text , fm and leftspace
- Parameters
data_text (str) – a long text
fmt (str) – type of underline text
leftspae (int) – How many space do you want before starting wrinting report .
return_to_line (int) – number of character to return to line
- pycsamt.utils.plot_utils.get_conductive_and_resistive_zone(data, site_names, purpose='groundwater', **kws)[source]
function to get the probability of conductive and resistive zone . It is not absolutely True but give an overview of decison .
It is not sufficient to declare that the zone is
favorable for any drill , but just work with probability
- Parameters
data (ndarray) – resistivity datata of survey area
site_name (list) – list of sites names
purpose (str) – type of exploration , default is groundwater
- Returns
report of exploration area
- Return type
str
- pycsamt.utils.plot_utils.get_frequency_id(freq_array, frequency_id)[source]
function to get id of frequency . Frequency to plot
- Parameters
freq_array (nd.array,1) – array of frequency
frequency_id (list or float) – frequency to plot .
- Returns
new close frequency id
- Return type
float|list
- pycsamt.utils.plot_utils.get_station_id_input_resistivities(station_rho_value, number_of_layer=None)[source]
Get a special station input resistivities is much benefit and more close to reality of plot . Indeeed , it take only the maximum value of resistivities below the site and the minimum , then cut out 7 Considering all the model data and choose the max resistivities and the
minim resistivities to build automatic resistivities whom COULD match the deth is less sure .Geeting a input resitivities to aplom the site , give a merly and better interpretation.
- Parameters
station_rho_value (array_like) – value of resistivities under the site thin the maximum depth
number_of_layer (int) – number of layer to top to bottom.
- pycsamt.utils.plot_utils.get_stationid(stations, station_id)[source]
Tip to get station id from user by input either integer or station name .
- Parameters
stations (list) – list of stations known
station_id (list, str, or int) – staion expect to plot.
- Returns
constructed list for plotting
- Return type
array_like
- Example
>>> from pycsamt.utils import plot_utils as punc >>> teslist = ['S{0:02}'.format(ii) for ii in range(23)] >>> ss = punc.get_stationid (stations=teslist , station_id=('S04',13)) >>> print(ss)
- pycsamt.utils.plot_utils.getcloser_frequency(freq_array, frequency_id)[source]
chek whether the frequency value given is in frequency range if not found the closest value
- pycsamt.utils.plot_utils.plot_errorbar(ax, x_array, y_array, y_error=None, x_error=None, color='k', marker='x', ms=2, ls=':', lw=1, e_capsize=2, e_capthick=0.5, picker=None, **kws)[source]
convinience function to make an error bar instance @author: jpeacock-pr
- pycsamt.utils.plot_utils.resetting_colorbar_bound(cbmax, cbmin, number_of_ticks=5, logscale=False)[source]
Function to reset colorbar ticks more easy to read
- Parameters
cbmax (float) – value maximum of colorbar
cbmin (float minimum data value) – minimum data value
number_of_ticks (int) – number of ticks should be located on the color bar . Default is 5.
logscale (bool) – set to True if your data are lograith data .
- Returns
array of color bar ticks value.
- Return type
array_like
- pycsamt.utils.plot_utils.resetting_ticks(get_xyticks, number_of_ticks=None)[source]
resetting xyticks modulo , 100
- Parameters
get_xyticks (list) – xyticks list , use to ax.get_x|yticks()
number_of_ticks (int) – maybe the number of ticks on x or y axis
- Returns
a new_list or ndarray
- Return type
list or array_like
Function to set properties for each plot. Easy to customize line and markers. Function can add other properties which are not in kwargs.keys(). It will set according the number of subplotsplots we assume subplot are define on one columns
- Parameters
number_of_plot (int) – number of subsplot you want show.
- Returns
dictionarry of labels and properties.
- Return type
dict
- pycsamt.utils.plot_utils.slice_csamt_matrix(block_matrix, station_offsets, depth_offsets, offset_MinMax=(0, 1000), doi='2000m')[source]
Using Wannamaker FE elements mesh to define rho matrix blocks , need after inversion to slice the model resistivity according the offset and depth we need . This function is easy tool to slice matrix and to keep the part we need . station offset , depth and model resistivity
- Parameters
- * block_matrixndarray(station_offsets.shape[0],
matrix of station depth Resistivity model depth_offsets.shape[0])
- depth_offsetarray_like
depth of investigation after generating by mesh file :>z_nodes .
- station_offsetsarray_like
station _offsets : offset generate by mesh_file :>x_nodes .
- offset_MinMaxtuple
- the interval of data to keep . eg if station location start by 0 :
off[0] = min and off[-1]=max (min, max):–> index 0 : minimum value of station location –>index 1 :
maximum value of station location
default is (0,1000)
- doistr , float
investigation depth , migth be [m|km]. If value is provided is float number , it might take value as a default unit ‘meter’. i.e : 1000=”1000m”
- Returns
- tuple
new sliced station offset , new sliced depth offset , new_matrix block ,
- pycsamt.utils.plot_utils.slice_matrix(base_matrix, freq_array, doi=2000)[source]
Function get a matrix and give new matrice slice from limit value
- Parameters
base_matrix (ndarray) – arrays (yaxis lenghth, station_length)
freq_array (ndarray,1) – frequency array range
doi – expect to be the depth of investigation from which data muts be selected in m or km
:type doi:float
- Returns
matrix sliced according to doi
- Return type
ndarray
- pycsamt.utils.plot_utils.station_id(id_)[source]
From id get the station name as input and return index id. Index starts at 0.
- Parameters
id – name of the station or index . Be sure to hve the station name containing the letter S which mean site.
- Returns
station index. If the list id_ is given will return the tuple.