Package Visualization

Module Plot1D2D

This file is part of pyCSAMT.

pyCSAMT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

pyCSAMT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with pyCSAMT. If not, see <https://www.gnu.org/licenses/>.


Created on Mon Dec 28 14:28:06 2020

@author: KLaurent alias @Daniel03

class viewer.plot.Plot1d(**kwargs)[source]

plot 1d class Deal with all 1D plots.

Key Words

Description

fig_dpi

dots-per-inch resolution of the figure default is 300

fig_num

number of the figure instance default is ‘Mesh’

fig_size

size of figure in inches (width, height) default is [5, 5]

fs

size of font of axis tick labels, axis labels are fs+2. default is 6

ls

[ ‘-‘ | ‘.’ | ‘:’ ] line style of mesh lines default is ‘-‘

marker

marker of stations default is r”$lacktriangledown$”

ms

size of marker in points. default is 5

Methods

Description

plot_topo_sep_azim

plot_topography , station separation and azimuth profile can plot individually or grouped by.

penetrated1D

skindepth plot. penetration depth at different frequencies

plot_static_correction

plot rho and rho corrected by different filter defalut filter is TMA.

plot_freqVSRhoPhase

Resistivity and phase plot.

plot_curves

plot data curves : specific for Zonge Engineering AVG file.

plot_RhoPhase errors

plot errors bar of resistivities in ohm.m and phase in degree.

Methods

penetrated1D([fn, profile_fn, …])

Pentration1D depth : Show skin depth at selected frequencies .

plotRMS([fn, target, savefig])

Plot RMS .

plot_curves([fn, savefig, selected_stations])

Plot Zonge Engineering AVG file with different components E and H at differents frequencies.

plot_freqVSRhoPhase([fn, profile_fn, …])

Method to plot apparent resistivity |phase vs frequency .

plot_multiStations([X, Y, path, profile_lines])

Plot multisations of site sof survey area

plot_static_correction(data_fn[, …])

Plot corrected apparent resistivities at different stations to solve the problem of static shift by adding either Trimimg Moving average (TMA) filter or fixed-length-moving-average(FLMA) filter or Adaptative moving-average (AMA).

plot_station_profile([fn, straighten_type, …])

Method to plot original station profile and coordinate reajustment profiles.

plot_topo_sep_azim([fn, profile_fn, savefig])

Method to plot topographic , stations separation and azimuth profiles .

penetrated1D(fn=None, profile_fn=None, selected_frequency=None, **kwargs)[source]

Pentration1D depth : Show skin depth at selected frequencies . for multiples frequencies , put argument selected_frequency on list. If frequency provided is not on the frequency range , it will be interpolated.

Parameters
  • fn (str) – full path to [AVG|EDI|J] file

  • profile_fn (str) – full path to stn station file . If user used EDI or J files , Dont need to add profile_file

  • selected_frequency (list) – list , list of freauency want to see the penetration depth. must be on a list . i.e [8, 511,1024 ]

Params

Default

Description

rename_station

list

Bring the station name . Be sure the length of station name you provided match the size of the data station name .

rotate_station

int

rotation station name . Default is 90 degree.

fs

float

can change the size of marker. Default is .7 : eg ms =9*fs

lw

float

change the linewdth

plot_grid

bool

add grid on your plot . Default is False

Note

browse to see others plot config.

Example
>>> from viewer.plot import Plot1d
>>> path =  os.path.join(os.environ["pyCSAMT"],
...              'csamtpy','data', file_1)
>>> plot_1d_obj =Plot1d()
... plot1d_depth = plot_1d_obj.penetrated1D(fn =path ,
...                    profile_fn= os.path.join(
...                        os.path.dirname(path), 'K1.stn'),
...                    selected_frequency =511)
plotRMS(fn=None, target=1.0, savefig=None, **kwargs)[source]

Plot RMS . If occamlogfile is not available , set rms value , iteration value at each rms and|or roughness.

Parameters
* fnstr

full path to occam2D logfile

  • savefigstr

    full directory to save fig

  • targetfloat

    target supposed RMS to reach . Default is 1.

Returns
obj , plot_RMS obj

Note

If occam2d logfile is availbale , dont need other parameters , except the path “fn” and as possible the “target”.

plot_curves(fn=None, savefig=None, selected_stations=1, **kws)[source]

Plot Zonge Engineering AVG file with different components E and H at differents frequencies.

Parameters
  • fn (str) – full path to Zonge Engineering file

  • profile_fn (str) – full path to profile file .

  • savefig (str) – path to figure plot

Params

Default

Description

fs

float

can change the size of marker. *Default is .7 : eg ms =9*fs

lw

float

change the linewdth

error_bar

bool

set to false to let invisible. Default is True

:Example :

>>> from viewer.plot import Plot1d
>>>path =  os.path.join(os.environ["pyCSAMT"],
...          'csamtpy','data', file_1)
>>> plot_1d_obj =Plot1d()
>>> plotcurves = plot_1d_obj .plot_curves(fn = path,
                                        selected_stations=[1,10, 20],
                                          error_bar=True)
plot_freqVSRhoPhase(fn=None, profile_fn=None, station_id=1, rename_stations=None, **kwargs)[source]

Method to plot apparent resistivity |phase vs frequency .

Parameters
  • fn (str) – full path to [AVG|EDI|J] file

  • profile_fn (str) – full path to station profile .

Note

if user use drectly AVG data must provide station profile ‘.stn’

Others params

Default

Description

station_id

str or int

plot the name of station if string is povided make be sure that the station name is on the station list eg : station_id = 1 means plot S00 station =[1,13] means plot >S00,S12station [S05, 7, 8] – [ S05, S06, S07]

rename_stations

list

bring the station name . Be sure the length of station name you provided match the data station name

show_error

bool

if True , see errobar plot. Default is False.

plot_multiStations(X=None, Y=None, path=None, profile_lines=None, **kwargs)[source]

Plot multisations of site sof survey area

Parameters
* pathstr

full path to station profile path . In the case where Zonge avg file is provided , use stn profile files. Group all stn file on a folder will call automatically

  • profile_lineslist

    name of profile lines . if profile lines is NOne will tale all stn profiles in the path directory

  • Xlist
    list of arrays array of X coordinates values for each

    survey line. Can be easting or Northing

  • Y: list
    list of arrays of Y coordinates valuescan be easting

    or northing

.. note:: `X` and `Y` MUST be the same length
plot_static_correction(data_fn, profile_fn=None, dipole_length=50.0, frequency_id=1, ADD_FILTER='tma', **kwargs)[source]

Plot corrected apparent resistivities at different stations to solve the problem of static shift by adding either Trimimg Moving average (TMA) filter or fixed-length-moving-average(FLMA) filter or Adaptative moving-average (AMA). Actually FLMA and TMA filter are available and default filTer is TMA. To plot all filter into one figure add the joker * to arguments ADD_FILER.

Parameters
  • data_fn (str) – full path to file , can be [AVG|EDI|J] files

  • profile_fn (str) – pathLike full path to Zonge Engeneering *.station file .

  • dipole_length (float, int) – length of dipole in meters when user applied for FLMA

Holding others informations

Params

Default

Description

frequency_id

str,int

plot the filtered frequency, eg frequency_id = 1023 means plot uncorrected rho and static rho at that frequency . set on list to plot multiple frequency [8,1101 ].

ADD_FILTER

str

name of filter to apply . TMA Trimming moving average AMA Adaptative moving average FLMA Fixed Length moving average

Note

Profile file (*.stn) is compolsory when provide raw Zonge AVG otherwise no need to profile for EDI or J file. In addition when FLMA filter is used m, provided dipole_length and number_of_points for window width are necessaries.

Example
>>> from from viewer.plot import Plot1d
>>> path =  os.path.join(os.environ["pyCSAMT"],
...              'csamtpy','data', file_1)
>>> plot_1d_obj =Plot1d()
... plot_1d_obj.plot_static_correction(data_fn =path ,
...                                   profile_fn= os.path.join(
...                                    os.path.dirname(path), 'K1.stn'),
...                                   frequency_id =1023)
plot_station_profile(fn=None, straighten_type='classic', reajust_coordinates=(0, 0), savefig=None, **kwargs)[source]

Method to plot original station profile and coordinate reajustment profiles. Deal with Zonge AVG file .

Parameters
* fnstr

full path to profile station file of Zonge Engineering station profile file . format egal to *.stn

  • straighten_typestr

    type of straingther profile it may be classic, equisistant or distord Default is ‘classic’

  • reajust_coordinateslist

    list of float x, y values

:Example:
>>> path =  os.path.join(os.environ["pyCSAMT"],
...          'csamtpy','data', 'avg', 'K1.stn')
>>> plot_1d_obj= Plot1d()
>>> plot_1d_obj.plot_station_profile(fn = path)
plot_topo_sep_azim(fn=None, profile_fn=None, savefig=None, **kwargs)[source]

Method to plot topographic , stations separation and azimuth profiles . User can add station_names and and set _it to let the program to plot on the corresponding figure. He can alse force the program to plot its dipole length otherwise the program will compute it automatically. If “set_station_name” is False , No Name of station will be visible. User has the possibility to plot one by one figure or all by using a “*” symbol or 123. To polt one figure , it may use keyword argument “plot” following the king [‘topo’, azimuth’, ‘sep’] or integer 1|2|3.Method is flexible .User can customize the plot , marker and line as he wants by putting on list the matplotlib labels properties . The program uses the label properties on order to set configuration lines and other properties . Topography plot correspond to index 0 , stations-separation to index 1 and azimuth to index 2.To plot individually , User doesnt need to put properties on list. Programm will recognize and set the poperties provided according the figure He wants.

Parameters
* fnstr

full path to [EDI|J|AVG] file.

  • profile_fnstr

    path to file may Zonge Engineering *.stn file

  • plotstr

    type of plot , default is ‘*’ mean of three profile.

  • Station_Names: list

    list of station names , User could provide. Default is None compute automatically

  • set_station_namesbool

    display the station name on figure axis . Default is False.

  • elevation(ndarray,1)

    Array_like of elevation

  • station_pkarray_like,

    array_like station dipole center value.

  • savefigstr

    path to save figure.

Returns
obj,

plot_obj azim- topo and station separation.

Example
>>> import os
>>> file_stn='K6.stn'
>>> path =  os.path.join(os.environ["pyCSAMT"],
...                          'csamtpy','data', file_stn)
...  plot_1d_obj= Plot1d()
.... plot_1d_obj.plot_topo_sep_azim(profile_fn= path , plot='*',
                                    set_station_names=True,
                                   dipole_length_curve=False)
class viewer.plot.Plot2d(**kws)[source]

class to plot 2D map Deal with all 2D plots

keywords

Description

cb_pad

padding between axes edge and color bar

cb_shrink

percentage to shrink the color bar

climits

limits of the color scale for resistivity in log scale (min, max)

cmap

name of color map for resistivity values

fig_aspect

aspect ratio between width and height of resistivity image. 1 for equal axes

fig_dpi

resolution of figure in dots-per-inch

fig_num

number of figure instance

fig_size

size of figure in inches (width, height)

font_size

size of axes tick labels, axes labels is +2

grid

[ ‘both’ | ‘major’ |’minor’ | None ] string to tell the program to make a grid on the specified axes.

ms

size of station marker

plot_yn

[ ‘y’ | ‘n’] ‘y’ –> to plot on instantiation ‘n’ –> to not plot on instantiation

station_color

color of station marker

station_font_color

color station label

station_font_pad

padding between station label and marker

station_font_rotation

angle of station label in degrees 0 is horizontal

station_font_size

font size of station label

station_font_weight

font weight of station label

station_id

index to take station label from station name

station_marker

station marker. if inputing a LaTex marker be sure to input as r”LaTexMarker” otherwise might not plot properly

title

title of plot. If None then the name of the iteration file and containing folder will be the title with RMS and Roughness.

xlimits

limits of plot in x-direction in (km)

xminorticks

increment of minor ticks in x direction

xpad

padding in x-direction in km

ylimits

depth limits of plot positive down (km)

yminorticks

increment of minor ticks in y-direction

ypad

padding in negative y-direction (km)

yscale

[ ‘km’ | ‘m’ ] scale of plot, if ‘m’ everything will be scaled accordingly.

Methods

penetration2D([fn, profile_fn, savefig, doi])

Plot penetration 2D.

plot_Pseudolog([station_id, iter_fn, …])

Build pseudodrill from the model resistivity .

plot_Response([data_fn, response_fn, mode])

Function to plot forward value , and residual value from Occam 2D

plot_occam2dModel([model_fn, iter_fn, …])

Plotoccam Model form Occam Model class

pseudocrossResPhase(fn[, profile_fn, …])

Plot Pseudocrossection of resistivity and phase.

penetration2D(fn=None, profile_fn=None, savefig=None, doi='2km', **kwargs)[source]

Plot penetration 2D.

Parameters
* fnstr

full path to [EDI|AVG|J] files.

  • doifloat

    depth assumed to be imaged , default is 2000m For CSAMT , 2km is enought to have more info about near surface.

    • Default* unit is “m”.

  • profile_fnstr

    full path to profile *stn file

  • savefigstr

    outdir

Returns
obj ,

plot penetration obj.

Example
>>> path =  os.path.join(os.environ["pyCSAMT"],
...      'csamtpy','data', K1.AVG)
>>> plot2d_obj = plot2d()
>>> plot2d_obj.penetration2D(fn = path,
...                        profile_fn=os.path.join(
...                            os.path.dirname(path),'K1.stn'),
...                         plot_style='imshow',  doi='10000m')
plot_Pseudolog(station_id='S00', iter_fn=None, mesh_fn=None, data_fn=None, iter2dat_fn=None, bln_fn=None, model_fn=None, **kwargs)[source]

Build pseudodrill from the model resistivity .

Deal with true value of ressitivity obtained during survey .In fact , How to input these values into our model to produce an accuracy underground map is the chalenge.Building pseudolog allow to know how layers are disposal in underground so to emphasize the large conductive zone in the case of groundwater exploration. It is combinaison with geophysic data especially inversion data with geological data. Actually the program deal with Occam 2D inverison file or Bo Yang (x,y,z) file. We will extend this program later with other external softares files extension. If user have a golder software installed on its computer , can use the files generated by the software and to produce 2D map so to compare both . Model map and detail-sequences map to see the difference Details sequences map is most closest to the reality . When step descent parameter is small ,the detail sequences trend to model map . So More geological values are, more the accuracy of detail sequences logs becomes. Geological data allow to harmonize the value of resistivity produced by our model so to force the pogramm to make a correlation between data from true layers and the model values.

Parameters

station_id (str, int) – Number or the site id of the survey area number starts from 1 to the end .

Note

User caneither use Occam 2D inversions files to plot or BoYang (x, y, file)+ station location file (*bln) to plot if the two types of files are provided , program with give priority to Occam 2D inversion files.

Params

Type

Description

model_fn

str

full path to Occam model file .

iter_fn

str

full path to occam iteration file

data_fn

str

full path to occam_data file

doi

str

depth of investigation might be float or str like “1km” =1000

depth_scale

str

scale of imaging depth can be “km” or “m”. Default is”m”

step_descent

float

step to enforce the model resistivities to keep truth layers values as reference data . if step descentis egal to doi max, data looks like model at 99.99%.Step decent is function of depth and rho.

lc_AD_curves

tuple

customize line color of average curve and details sequneces logs eg : ((0.5, 0.8, 0.),’blue’)

default_unknow_lcolor

str

In the case the name of layer is notin our data base , customize the layer color . default is “(1.0, 1.0, 1.0)”.

default_unknow_lpatter

str

In the case the name of layer is not in our data base , customize the layer pattern default is “+.+.+.”

Note

constrained_electrical _properties_of_rocks param keeps the Truth layers resistivities as reference resistivities. If value is false will check in our data base to find the resistivities that match better the given resistivities of

the layers. Default is True.

Customize your plot using matplotlib properties.

Example
>>> from viewer.plot import Plot2d
>>> path =os.path.join(os.environ ['pyCSAMT'],
...                       'csamtpy', 'data', 'occam2D')
>>> plot2d_obj = Plot2d(station_label_rotation=None,
...                    show_grid=True,
...                    font_size =8,
...                    lc='r',
...                    fig_size=[5,8],
...                    markerfacecolor='k',
...                    markeredgecolor='k')
>>> plot2d_obj.plot_Pseudolog( station_id=[43],
...                          input_resistivities=[300, 500,
...                                             1000, 2000,
...                                             4000, 6000],
...                          input_layers =['alluvium',
...                                         'amphibolite',
...                                         'altered rock',
...                                          'augen gneiss',
...                                          'granite'],
...                            mesh_fn=os.path.join(path,
...                                                 'Occam2DMesh')
...                            iter_fn = os.path.join(path,
...                                                   'ITER17.iter'),
...                            model_fn =os.path.join(path,
...                                                   'Occam2DModel') ,
...                            data_fn =os.path.join(path,
...                                                  'OccamDataFile.dat'),
...                            doi='1km',
...                            step_descent=200.,
...                            plot_style= 'pcolormesh')
plot_Response(data_fn=None, response_fn=None, mode=None, **kws)[source]

Function to plot forward value , and residual value from Occam 2D

list of params are below :

Params

Type

Description

response_fn

str

full path to occam iteration file

data_fn

str

full path to occam_data file

doi

str

depth of investigation might be float or str like “1km” =1000

show_station_id

str

show station names

Example
>>> from viewer.plot import Plot2d
>>> pathresp =os.path.join(os.environ ['pyCSAMT'],
...                           'csamtpy', 'data', 'occam2D','RESP17.resp')
>>> path_data =os.path.join(os.environ ['pyCSAMT'],
...                            'csamtpy', 'data', 'occam2D','OccamDataFile.dat' )
>>> plot2d_obj = plot2d()
... plot2d_obj.plot_Response(data_fn =path_data , response_fn=  pathresp )
plot_occam2dModel(model_fn=None, iter_fn=None, mesh_fn=None, data_fn=None, doi=1000, **kwargs)[source]

Plotoccam Model form Occam Model class

Parameters

model_fn (str) – full path to Occam 2Dmodel file

Params

Type

Description

iter_fn

str

full path to occam iteration file

mesh_fn

str

full path to mesh_fn file

data_fn

str

full path to occam_data file

doi

str

depth of investigation might be float or str like “1km” =1000

depth_scale

str

scale of imaging depth can be “km” or “m”. Default is”m”

Example
>>> data='OccamDataFile.dat'
>>> mesh = 'Occam2DMesh'
>>> model = 'Occam2DModel'
>>> iter_='ITER17.iter'
>>> path =os.path.join(os.environ ['pyCSAMT'],
...                       'data', 'occam2D', mesh)
>>> plot2d_obj = plot2d()
>>> plot2d_obj.plot_occam2dModel(mesh_fn=path,
...                            iter_fn = os.path.join(
...                                os.path.dirname(path), iter_),
...                            model_fn =os.path.join(
...                                os.path.dirname(path), model) ,
...                            data_fn =os.path.join(
...                                os.path.dirname(path), data ), doi='1km')
pseudocrossResPhase(fn, profile_fn=None, savefig=None, plot_style=None, **kws)[source]

Plot Pseudocrossection of resistivity and phase.

Parameters
  • fn (str) – full path to [‘AVG’, ‘EDI’, ‘J’] file .

  • profile_fn (str) – full path to profile station file in the case fn is *AVG.

  • savefig (str) – path to save figure