OCCAMTools: an interface to Scripp’s Occam inversion program

Created on Tue Aug 23 11:54:38 2011

@author: a1185872

class MTpy.core.OCCAMTools.Occam2DData(datafn=None)[source]
__init__(datafn=None)[source]
__module__ = 'MTpy.core.OCCAMTools'
make2DdataFile(edipath, mmode='both', savepath=None, stationlst=None, title=None, thetar=0, resxyerr=10, resyxerr=10, phasexyerr=5, phaseyxerr=5, ss=' ', fmt='%2.6f', freqstep=1, plotyn='y', lineori='ew', tippererr=None, ftol=0.05)[source]

make2DdataFile will make a data file for occam2D.

Input:

edipath = path to edifiles mmode = modes to invert for. Can be:

‘both’ -> will model both TE and TM modes ‘TM’ -> will model just TM mode ‘TE’ -> will model just TE mode
savepath = path to save the data file to, this can include the name of
the data file, if not the file will be named:
savepathData.dat or edipathData.dat if savepath=None
stationlst = list of stations to put in the data file, doesn’t need to
be in order, the relative distance will be calculated internally. If stationlst=None, it will be assumed all the files in edipath will be input into the data file

title = title input into the data file thetar = rotation angle (deg) of the edifiles if you want to align the

components with the profile. Angle is on the unit circle with an orientation that north is 0 degree, east -90.
resxyerr = percent error in the res_xy component (TE),
can be entered as ‘data’ where the errors from the data are used.
resyxerr = percent error in the res_yx component (TM),
can be entered as ‘data’ where the errors from the data are used.
phasexyerr = percent error in the phase_xy component (TE),
can be entered as ‘data’ where the errors from the data are used.
phaseyxerr = percent error in the phase_yx component (TM),
can be entered as ‘data’ where the errors from the data are used.

ss = is the spacing parameter for the data file fmt = format of the numbers for the data file, see string formats for

a full description
freqstep = take frequencies at this step, so if you want to take every
third frequency enter 3. Can input as a list of specific frequencies. Note that the frequencies must match the frequencies in the EDI files, otherwise they will not be input.

plotyn = y or n to plot the stations on the profile line. lineori = predominant line orientation with respect to geographic north

ew for east-west line-> will orientate so first station is
farthest to the west
ns for north-south line-> will orientate so first station is
farthest to the south
tippererr = error for tipper in percent. If this value is entered than
the tipper will be included in the inversion, if the value is None than the tipper will not be included.
Output:
datfilename = full path of data file
maskPoints()[source]

maskPoints will take in points found from plotMaskPoints and rewrite the data file to nameRW.dat. Be sure to run plotMaskPoints first

plot2DResponses(respfn=None, wlfn=None, maxcol=8, plottype='1', ms=2, fs=10, phaselimits=(-5, 95), colormode='color', reslimits=None, plotnum=1, **kwargs)[source]

plotResponse will plot the responses modeled from winglink against the observed data.

Inputs:

respfn = full path to response file datafn = full path to data file wlfn = full path to a winglink data file used for a similar

inversion. This will be plotted on the response plots for comparison of fits.

maxcol = maximum number of columns for the plot plottype = ‘all’ to plot all on the same plot

‘1’ to plot each respones in a different figure station to plot a single station or enter as a list of stations to plot a few stations [station1,station2]. Does not have to be verbatim but should have similar unique characters input pb01 for pb01cs in outputfile

ms = marker size phaselimits = limits of phase in degrees (min,max) colormode = ‘color’ for color plots

‘bw’ for black and white plots
reslimits = resistivity limits on a log scale (
log10(min),log10(max))
plotnum = 1 to plot both TE and TM in the same plot
2 to plot TE and TM in separate subplots
plotAllResponses(station, fignum=1)[source]

Plot all the responses of occam inversion from data file. This assumes the response curves are in the same folder as the datafile.

Input:
datafile = full path to occam data file
Output:
Plot
plotMaskPoints(plottype=None, reserrinc=0.2, phaseerrinc=5, marker='o', colormode='color', dpi=300, ms=2, reslimits=None, phaselimits=(-5, 95))[source]

An interactive plotting tool to mask points an add errorbars

plotPseudoSection(respfn=None, fignum=1, rcmap='jet_r', pcmap='jet', rlim=((0, 4), (0, 4)), plim=((0, 90), (0, 90)), ml=2, stationid=[0, 4])[source]

plots a pseudo section of the data

datafn = full path to data file respfn = full path to response file

read2DRespFile(respfn)[source]

read2DRespFile will read in a response file and combine the data with info from the data file.

Input:
respfn = full path to the response file datafn = full path to data file
Outputs:
for each data array, the rows are ordered as:
0 -> input data 1 -> input error 2 -> model output 3 -> relative error (data-model)/(input error)
rplst = list of dictionaries for each station with keywords:

‘station’ = station name ‘offset’ = relative offset, ‘resxy’ = TE resistivity ‘resyx’= TM resistivity ‘phasexy’= TE phase ‘phaseyx’= TM phase a ‘realtip’= Real Tipper ‘imagtip’= Imaginary Tipper

Note: that the resistivity will be in log10 space. Also, there are 2 extra rows in the data arrays, this is to put the response from the inversion.

stationlst = list of stations in order from one side of the profile
to the other.

freq = list of frequencies used in the inversion title = title, could be useful for plotting.

read2DdataFile()[source]
read2DdataFile will read in data from a 2D occam data file.
Only supports the first 6 data types of occam2D
Input:
datafn = full path to data file
Output:
rplst = list of dictionaries for each station with keywords:

‘station’ = station name ‘offset’ = relative offset, ‘resxy’ = TE resistivity and error as row 0 and 1 ressectively, ‘resyx’= TM resistivity and error as row 0 and 1 respectively, ‘phasexy’= TE phase and error as row 0 and 1 respectively, ‘phaseyx’= Tm phase and error as row 0 and 1 respectively, ‘realtip’= Real Tipper and error as row 0 and 1 respectively, ‘imagtip’= Imaginary Tipper and error as row 0 and 1 respectively

Note: that the resistivity will be in log10 space. Also, there are 2 extra rows in the data arrays, this is to put the response from the inversion.

stationlst = list of stations in order from one side of the profile
to the other.

freq = list of frequencies used in the inversion title = title, could be useful for plotting.

rewrite2DdataFile(edipath=None, thetar=0, resxyerr='prev', resyxerr='prev', phasexyerr='prev', phaseyxerr='prev', tippererr=None, mmode='both', flst=None, removestation=None)[source]

rewrite2DDataFile will rewrite an existing data file so you can redefine some of the parameters, such as rotation angle, or errors for the different components or only invert for one mode or add one or add tipper or remove tipper.

Inputs:

datafn = full path to data file to rewrite

rotz = rotation angle with positive clockwise

resxyerr = error for TE mode resistivity (percent) or ‘data’ for data
or prev to take errors from data file.
resyxerr = error for TM mode resistivity (percent) or ‘data’ for data
or prev to take errors from data file.
phasexyerr = error for TE mode phase (percent) or ‘data’ for data
or prev to take errors from data file.
phaseyxerr = error for TM mode phase (percent) or ‘data’ for data
or prev to take errors from data file.
tippererr = error for tipper (percent) input only if you want to invert
for the tipper or ‘data’ for data errors or prev to take errors from data file.
mmodes = ‘both’ for both TE and TM
‘TE’ for TE ‘TM’ for TM
flst = frequency list in Hz to rewrite, needs to be similar to the
datafile, cannot add frequencies

removestation = list of stations to remove if desired

class MTpy.core.OCCAMTools.Occam2DModel(iterfn, meshfn=None, inmodelfn=None)[source]

Bases: MTpy.core.OCCAMTools.Occam2DData

This class deals with the model side of Occam inversions, including plotting the model, the L-curve, depth profiles. It will also be able to build a mesh and regularization grid at some point.

It inherits Occam2DData and the data can be extracted from the method get2DData(). After this call you can use all the methods of Occam2DData, such as plotting the model responses and pseudo sections.

__init__(iterfn, meshfn=None, inmodelfn=None)[source]
__module__ = 'MTpy.core.OCCAMTools'
get2DData()[source]
get2DModel()[source]

get2DModel will create an array based on the FE mesh and fill the values found from the regularization grid. This way the array can be manipulated as a 2D object and plotted as an image or a mesh.

Outputs:
self.2Dmodel -> model array with log resistivity values self.plotx -> horizontal distance of FE mesh (m) blocks self.ploty -> depth of vertical nodes of FE mesh (m)
plot2DModel(datafn=None, xpad=1.0, ypad=1.0, mpad=0.5, spad=1.0, ms=60, stationid=None, fdict={'rotation': 60, 'weight': 'normal', 'size': 8}, dpi=300, ylimits=None, xminorticks=5, yminorticks=1, climits=(0, 4), cmap='jet_r', fs=8, femesh='off', regmesh='off', aspect='auto', title='on', meshnum='off', blocknum='off', blkfdict={'size': 3}, fignum=1, plotdimensions=(10, 10), grid='off', yscale='km')[source]

plotModel will plot the model output by occam in the iteration file.

Inputs:

datafn = full path to data file. If none is input it will use the
data file found in the iteration file.

xpad = padding in the horizontal direction of model

ypad = padding the in the vertical direction of the top of the model
to fit the station names and markers
mpad = marker pad to fit right at the surface, haven’t found a better
way of doing this automatically yet
spad = padding of station names away from the top of the model, this
is kind of awkward at the moment especially if you zoom into the model, it usually looks retarded and doesn’t fit

ms = marker size in ambiguous points

stationid = index of station names to plot -> ex. pb01sdr would be
stationid=(0,4) to plot pb01
fdict = font dictionary for the station names, can have keys:
‘size’ = font size ‘rotation’ = angle of rotation (deg) of font ‘weight’ = weight of font ‘color’ = color of font ‘style’ = style of font ex. ‘italics’

plotdimensions = x-y dimensions of the figure (10,10) in inches

dpi = dot per inch of figure, should be 300 for publications

ylimits = limits of depth scale (km). ex, ylimits=(0,30)

xminorticks = location of minor tick marks for the horizontal axis

yminorticks = location of minor tick marks for vertical axis

climits = limits of log10(resistivity). ex. climits=(0,4)

cmap = color map to plot the model image

fs = font size of axis labels

femesh = ‘on’ to plot finite element forward modeling mesh (black)

regmesh = ‘on’ to plot regularization mesh (blue)

aspect = aspect ratio of the figure, depends on your line length and
the depth you want to investigate
title = ‘on’ to put the RMS and Roughness as the title, or input a
string that will be added to the RMS and roughness, or put None to not put a title on the plot and print out RMS and roughness

meshnum = ‘on’ to plot FE mesh block numbers

fignum = figure number to plot to

blocknum = ‘on’ to plot numbers on the regularization blocks

blkfdict = font dictionary for the numbering of regularization blocks

grid = major for major ticks grid
minor for a grid of the minor ticks both for a grid with major and minor ticks

yscale = ‘km’ for depth in km or ‘m’ for depth in meters

plotDepthModel(dpi=300, depth=10000, plottype='1', yscale='log', plotdimensions=(3, 6), plotnum=1, fignum=1)[source]

will plot a depth section profile for a given set of stations.

Inputs:

plotnum = 1 to plot in different figures, ‘all’ to plot in all into
one figure.

dpi = dpi of figure

depth = max depth to estimate the profile

stationnames = list of station names corresponding to the starting
block numbers

yscale = ‘log’ for logarithmic or ‘linear’ for linear

plotL2Curve(fnstem=None, fignum=1, dpi=300)[source]

PlotL2Curve will plot the RMS vs iteration number for the given inversion folder and roughness vs iteration number

Inputs:
fnstem = filename stem to look for in case multiple inversions were
run in the same folder. If none then searches for anything ending in .iter

fignum = figure number dpi = dpi of the figure

read2DInmodel()[source]

read an INMODEL file for occam 2D

Input:
inmodelfn = full path to INMODEL file
Output:
rows = list of combined data blocks where first number of each list
represents the number of combined mesh layers for this regularization block. The second number is the number of columns in the regularization block layer
cols = list of combined mesh columns for the regularization layer.
The sum of this list must be equal to the number of mesh columns.
headerdict = dictionary of all the header information including the
binding offset
read2DIter()[source]

read2DIter will read an iteration file and combine that info from the datafn and return a dictionary of variables.

Inputs:
iterfn = full path to iteration file if iterpath=None. If
iterpath is input then iterfn is just the name of the file without the full path.
Outputs:
idict = dictionary of parameters, keys are verbatim from the file,
except for the key ‘model’ which is the contains the model numbers in a 1D array.
read2DMesh()[source]

read a 2D meshfn

Input:
meshfn = full path to mesh file
Output:
hnodes = array of horizontal nodes (column locations (m)) vnodes = array of vertical nodes (row locations(m)) mdata = free parameters
Things to do:
incorporate fixed values
class MTpy.core.OCCAMTools.OccamPointPicker(axlst, linelst, errlst, reserrinc=0.05, phaseerrinc=0.02, marker='h')[source]

Bases: object

This class will help the user interactively pick points to mask and add error bars.

To mask just a single point right click over the point and a gray point will appear indicating it has been masked

To mask both the apparent resistivity and phase left click over the point. Gray points will appear over both the apparent resistivity and phase. Sometimes the points don’t exactly matchup, haven’t quite worked that bug out yet, but not to worry it picks out the correct points

To add error bars to a point click the middle or scroll bar button. This only adds error bars to the point and does not reduce them so start out with reasonable errorbars. You can change the increment that the error bars are increased with reserrinc and phaseerrinc.

Inputs:
axlst = list of the resistivity and phase axis that have been plotted
as [axrte,axrtm,axpte,axptm]

linelst = list of lines used to plot the responses, not the error bars

errlst = list of the errorcaps and errorbar lines as
[[cap1,cap2,bar],...]

reserrinc = percent increment to increase the errorbars

phaseerrinc = percent increment to increase the errorbars

__call__(event)[source]

When the function is called the mouse events will be recorder for picking points to mask or change error bars.

Left mouse button will mask both resistivity and phase point

Right mouse button will mask just the point selected

middle mouse button will increase the error bars

q will close the figure.

__dict__ = <dictproxy object at 0x0A93DD50>
__init__(axlst, linelst, errlst, reserrinc=0.05, phaseerrinc=0.02, marker='h')[source]
__module__ = 'MTpy.core.OCCAMTools'
__weakref__

list of weak references to the object (if defined)

inAxes(event)[source]
inFigure(event)[source]
on_close(event)[source]
MTpy.core.OCCAMTools.blocks_elements_setup(parameter_dict)[source]
MTpy.core.OCCAMTools.compareIter(iterfn1, iterfn2, savepath=None)[source]

compareIter will take the difference between two iteration and make a difference iter file

Inputs:

iterfn1 = full path to iteration file 1 iterfn2 = full path to iteration file 2 savepath = path to save the difference iteration file, can be full or

just a directory
Outputs:
diterfn = file name of iteration difference either:
savepath/iterdiff##and##.iter or os.path.dirname(iterfn1,iterdiff##and##.iter) or savepath
MTpy.core.OCCAMTools.get_model_setup(parameter_dict)[source]
MTpy.core.OCCAMTools.getdatetime()[source]
MTpy.core.OCCAMTools.make1DInputFile(savepath, modelfile=None, datafile=None, roughtype=1, maxiter=100, targetrms=1.0, rhostart=100, description='1dInv', lagrange=5.0, roughness=10000000.0, debuglevel=1, iteration=0, misfit=100.0)[source]

Make a 1D input file for occam

Input:
savepath = full path to save input file to, if just path then saved as
savepath/input.input
modelfile = full path to model file, if None then assumed to be in
savepath/model.mod
datafile = full path to data file, if None then assumed to be in
savepath/data.data

roughtype = roughness type maxiter = maximum number of iterations targetrms = target rms value rhostart = starting resistivity value on linear scale paramcount =

MTpy.core.OCCAMTools.make1DModelFile(savepath, nlayers=100, bottomlayer=10000, basestep=10, z1layer=50, airlayerheight=10000)[source]

Makes a 1D model file

Input:

savepath =path to save file to, if just path saved as savepathmodel.mod nlayers = number of layers bottomlayer = depth of bottom layer in meters basestep = numerical base of logarithmic depth step 10 or 2 or 1 for

linear

z1layer = depth of first layer in meters airlayerheight = height of air layers in meters

Output:
modelfilename = full path to model file
MTpy.core.OCCAMTools.make1DdataFile(station, edipath=None, savepath=None, polarization='both', reserr='data', phaseerr='data', fmt='%.6e', ss=' ', thetar=0)[source]

make1Ddatafile will write a data file for Occam1D

Input:

station = the station name and path if edipath=None edipath = path to the edi files to be written into a data file,

useful for multile data files

savepath = path to save the file thetar = rotation angle to rotate Z

#=============================================================================== # Input parameters #===============================================================================

edipath=r”C:PeacockMy DropboxParalanaEDIFilesBaseSurveySS” #path to edi’s station=’pb01’ #station to create data file for savepath=r”C:PeacockPHDOCCAMDInversionBase” #path to save the data file polarization=’both’ #choose component either xy or yx or both reserr=’data’ #either data or set as a percentage phaseerr=’data’ #either data or set as percentage -> 10 for 10 percent error ss=’ ‘ fmt=’%.6e’ #=============================================================================== # open up edi file and write data file #===============================================================================

MTpy.core.OCCAMTools.make2DdataFile(edipath, mmode='both', savepath=None, stationlst=None, title=None, thetar=0, resxyerr=10, resyxerr=10, phasexyerr=10, phaseyxerr=10, ss=' ', fmt='%2.6f', freqstep=1, plotyn='y', lineori='ew', tippererr=None, ftol=0.05)[source]

make2DdataFile will make a data file for occam2D.

Input:

edipath = path to edifiles mmode = modes to invert for. Can be:

‘both’ -> will model both TE and TM modes ‘TM’ -> will model just TM mode ‘TE’ -> will model just TE mode
savepath = path to save the data file to, this can include the name of
the data file, if not the file will be named:
savepathData.dat or edipathData.dat if savepath=None
stationlst = list of stations to put in the data file, doesn’t need to
be in order, the relative distance will be calculated internally. If stationlst=None, it will be assumed all the files in edipath will be input into the data file

title = title input into the data file thetar = rotation angle (deg) of the edifiles if you want to align the

components with the profile. Angle is on the unit circle with an orientation that north is 0 degree, east -90.
resxyerr = percent error in the res_xy component (TE),
can be entered as ‘data’ where the errors from the data are used.
resyxerr = percent error in the res_yx component (TM),
can be entered as ‘data’ where the errors from the data are used.
phasexyerr = percent error in the phase_xy component (TE),
can be entered as ‘data’ where the errors from the data are used.
phaseyxerr = percent error in the phase_yx component (TM),
can be entered as ‘data’ where the errors from the data are used.

ss = is the spacing parameter for the data file fmt = format of the numbers for the data file, see string formats for

a full description
freqstep = take frequencies at this step, so if you want to take every
third frequency enter 3. Can input as a list of specific frequencies. Note that the frequencies must match the frequencies in the EDI files, otherwise they will not be input.

plotyn = y or n to plot the stations on the profile line. lineori = predominant line orientation with respect to geographic north

ew for east-west line-> will orientate so first station is
farthest to the west
ns for north-south line-> will orientate so first station is
farthest to the south
tippererr = error for tipper in percent. If this value is entered than
the tipper will be included in the inversion, if the value is None than the tipper will not be included.
Output:
datfilename = full path of data file
MTpy.core.OCCAMTools.makeModel(datafilename, niter=20, targetrms=1.0, nlayers=100, nlperdec=30, z1layer=50, bwidth=200, trigger=0.75, cwd='.', rhostart=100, makemodelexe=None, modelname='', use_existing_startup=False, existing_startup_file=None)[source]

makeModel will make an the input files for occam using Steve Constable’s MakeModel2DMT.f code.

Inputs:
datafn = full path to data file niter = maximum number of iterations targetrms = target root mean square error nlayers = total number of layers in mesh nlperdec = number of layers per decade z1layer = thickness of the first layer in meters bwidth = maximum block width for regularization grid in meters trigger = triger point to amalgamate blocks cwd = working directory, files are saved here rhostart = starting resistivity for homogeneous half space in ohm-m use_existing_startup: set True, if an old iteration step output is provided as startup existing_startup_file: absolute path for old itereation output to be used as startup
Outputs:

meshfn = mesh file for finite element grid saved ats MESH inmodelfn = input model, starting model with rhostart as starting value

saved as INMODEL

startupfn = start up filepath, saved as startup

MTpy.core.OCCAMTools.makestartfiles(parameter_dict)[source]
MTpy.core.OCCAMTools.plot1D(respfile, iterfile, modelfile, fignum=1, ms=4, dpi=150)[source]
MTpy.core.OCCAMTools.plot2DModel(iterfile, meshfile=None, inmodelfile=None, datafile=None, xpad=1.0, ypad=6.0, mpad=0.5, spad=3.0, ms=60, stationid=None, fdict={'rotation': 60, 'weight': 'normal', 'size': 8}, dpi=300, ylimits=None, xminorticks=5, yminorticks=1, climits=(0, 4), cmap='jet_r', fs=8, femesh='off', regmesh='off', aspect='auto', title='on', meshnum='off', blocknum='off', blkfdict={'size': 3}, fignum=1, plotdimensions=(10, 10), grid='off', yscale='km')[source]

plotModel will plot the model output by occam in the iteration file.

Inputs:

iterfile = full path to the iteration file that you want to plot

meshfile = full path to mesh file (the forward modeling mesh). If
none it will look for a file with mesh in the name.
inmodelfile = full path to the INMODEL file (regularization mesh).
If none it will look for a file with inmodel in the name.
datafile = full path to data file. If none is input it will use the
data file found in the iteration file.

xpad = padding in the horizontal direction of model

ypad = padding the in the vertical direction of the top of the model
to fit the station names and markers
mpad = marker pad to fit right at the surface, haven’t found a better
way of doing this automatically yet
spad = padding of station names away from the top of the model, this
is kind of awkward at the moment especially if you zoom into the model, it usually looks retarded and doesn’t fit

ms = marker size in ambiguous points

stationid = index of station names to plot -> ex. pb01sdr would be
stationid=(0,4) to plot pb01
fdict = font dictionary for the station names, can have keys:
‘size’ = font size ‘rotation’ = angle of rotation (deg) of font ‘weight’ = weight of font ‘color’ = color of font ‘style’ = style of font ex. ‘italics’

plotdimensions = x-y dimensions of the figure (10,10) in inches

dpi = dot per inch of figure, should be 300 for publications

ylimits = limits of depth scale (km). ex, ylimits=(0,30)

xminorticks = location of minor tick marks for the horizontal axis

yminorticks = location of minor tick marks for vertical axis

climits = limits of log10(resistivity). ex. climits=(0,4)

cmap = color map to plot the model image

fs = font size of axis labels

femesh = ‘on’ to plot finite element forward modeling mesh (black)

regmesh = ‘on’ to plot regularization mesh (blue)

aspect = aspect ratio of the figure, depends on your line length and
the depth you want to investigate
title = ‘on’ to put the RMS and Roughness as the title, or input a
string that will be added to the RMS and roughness, or put None to not put a title on the plot and print out RMS and roughness

meshnum = ‘on’ to plot FE mesh block numbers

fignum = figure number to plot to

blocknum = ‘on’ to plot numbers on the regularization blocks

blkfdict = font dictionary for the numbering of regularization blocks

grid = major for major ticks grid
minor for a grid of the minor ticks both for a grid with major and minor ticks

yscale = ‘km’ for depth in km or ‘m’ for depth in meters

MTpy.core.OCCAMTools.plot2DResponses(datafn, respfn=None, wlfn=None, maxcol=8, plottype='1', ms=4, phaselimits=(-5, 95), colormode='color', reslimits=None, **kwargs)[source]

plotResponse will plot the responses modeled from winglink against the observed data.

Inputs:

respfn = full path to response file datafn = full path to data file wlfn = full path to a winglink data file used for a similar

inversion. This will be plotted on the response plots for comparison of fits.

maxcol = maximum number of columns for the plot plottype = ‘all’ to plot all on the same plot

‘1’ to plot each respones in a different figure station to plot a single station or enter as a list of stations to plot a few stations [station1,station2]. Does not have to be verbatim but should have similar unique characters input pb01 for pb01cs in outputfile
Outputs:
used for interactive masking of points axlst = list of axes plotted errlst = list of errors that were plotted linelst = list of lines plotted
MTpy.core.OCCAMTools.plotAllResponses(datafile, station, fignum=1)[source]

Plot all the responses of occam inversion from data file. This assumes the response curves are in the same folder as the datafile.

Input:
datafile = full path to occam data file
Output:
Plot
MTpy.core.OCCAMTools.plotDepthModel(iterfn, meshfn, slst, lm, fignum=1, dpi=300, depth=10000, stations=None, yscale='log')[source]

will plot a depth section as a line for the block numbers given by slst and the layer multiplier lm

MTpy.core.OCCAMTools.plotL2Curve(invpath, fnstem=None, fignum=1, dpi=300)[source]

PlotL2Curve will plot the RMS vs iteration number for the given inversion folder and roughness vs iteration number

Inputs:

invpath = full path to the inversion folder where .iter files are fnstem = filename stem to look for in case multiple inversions were

run in the same folder. If none then searches for anything ending in .iter
Outputs:
rmsiter = array(3x#iterations) of rms, iteration and roughness
MTpy.core.OCCAMTools.plotPseudoSection(datafn, respfn=None, fignum=1, rcmap='jet_r', pcmap='jet', rlim=((0, 4), (0, 4)), plim=((0, 90), (0, 90)), ml=2, stationid=[0, 4])[source]

plots a pseudo section of the data

datafn = full path to data file respfn = full path to response file

MTpy.core.OCCAMTools.plotTipper(datafile)[source]
MTpy.core.OCCAMTools.read1DInputFile(inputfile)[source]

reads in a 1D input file

MTpy.core.OCCAMTools.read1DIterFile(iterfile, modelfile)[source]

read an iteration file

Input:
iterfile = full path to iteration file modelfile = full path to model file
Output:
idict = dictionary with keys:

depth = depth of model in m modelres = resistivity of model, any fixed parameters will be put in

correct place.
MTpy.core.OCCAMTools.read1DModelFile(modelfile)[source]

will read in model file

Inputs:
modelfile = full path to model file
Outputs:
mdict = dictionary of values with keys:
depth = depth of model in meters res = value of resisitivity pen = penalty pre = preference prefpen = preference penalty
MTpy.core.OCCAMTools.read1DRespFile(respfile)[source]

read response file

Input:
repsfile = full path to response file
Outputs:
rpdict = dictionary with keys:

freq = frequency array resxy,resyx,phasexy,phaseyx = array for corresponding component with

index as:
0 = input data 1 = input error 2 = model data 3 = model error
MTpy.core.OCCAMTools.read1DdataFile(datafile)[source]

reads a 1D data file

Iputs:
datafile = full path to data file
MTpy.core.OCCAMTools.read2DInmodel(inmodelfn)[source]

read an INMODEL file for occam 2D

Input:
inmodelfn = full path to INMODEL file
Output:
rows = list of combined data blocks where first number of each list
represents the number of combined mesh layers for this regularization block. The second number is the number of columns in the regularization block layer
cols = list of combined mesh columns for the regularization layer.
The sum of this list must be equal to the number of mesh columns.
headerdict = dictionary of all the header information including the
binding offset
MTpy.core.OCCAMTools.read2DIterFile(iterfn, iterpath=None)[source]

read2DIterFile will read an iteration file and combine that info from the datafn and return a dictionary of variables.

Inputs:
iterfn = full path to iteration file if iterpath=None. If
iterpath is input then iterfn is just the name of the file without the full path.
Outputs:
idict = dictionary of parameters, keys are verbatim from the file,
except for the key ‘model’ which is the contains the model numbers in a 1D array.
MTpy.core.OCCAMTools.read2DRespFile(respfn, datafn)[source]

read2DRespFile will read in a response file and combine the data with info from the data file.

Input:
respfn = full path to the response file datafn = full path to data file
Outputs:
for each data array, the rows are ordered as:
0 -> input data 1 -> input error 2 -> model output 3 -> relative error (data-model)/(input error)
rplst = list of dictionaries for each station with keywords:

‘station’ = station name ‘offset’ = relative offset, ‘resxy’ = TE resistivity ‘resyx’= TM resistivity ‘phasexy’= TE phase ‘phaseyx’= TM phase a ‘realtip’= Real Tipper ‘imagtip’= Imaginary Tipper

Note: that the resistivity will be in log10 space. Also, there are 2 extra rows in the data arrays, this is to put the response from the inversion.

stationlst = list of stations in order from one side of the profile
to the other.

freq = list of frequencies used in the inversion title = title, could be useful for plotting.

MTpy.core.OCCAMTools.read2DdataFile(datafn)[source]

read2DdataFile will read in data from a 2D occam data file. Only supports the first 6 data types of occam2D

Input:
datafn = full path to data file
Output:
rplst = list of dictionaries for each station with keywords:

‘station’ = station name ‘offset’ = relative offset, ‘resxy’ = TE resistivity and error as row 0 and 1 ressectively, ‘resyx’= TM resistivity and error as row 0 and 1 respectively, ‘phasexy’= TE phase and error as row 0 and 1 respectively, ‘phaseyx’= Tm phase and error as row 0 and 1 respectively, ‘realtip’= Real Tipper and error as row 0 and 1 respectively, ‘imagtip’= Imaginary Tipper and error as row 0 and 1 respectively

Note: that the resistivity will be in log10 space. Also, there are 2 extra rows in the data arrays, this is to put the response from the inversion.

stationlst = list of stations in order from one side of the profile
to the other.

freq = list of frequencies used in the inversion title = title, could be useful for plotting.

MTpy.core.OCCAMTools.read2Dmesh(meshfn)[source]

read a 2D meshfn

Input:
meshfn = full path to mesh file
Output:
hnodes = array of horizontal nodes (column locations (m)) vnodes = array of vertical nodes (row locations(m)) mdata = free parameters
Things to do:
incorporate fixed values
MTpy.core.OCCAMTools.read_datafile(parameter_dict)[source]
MTpy.core.OCCAMTools.rewrite2DdataFile(datafn, edipath=None, thetar=0, resxyerr='prev', resyxerr='prev', phasexyerr='prev', phaseyxerr='prev', tippererr=None, mmode='both', flst=None, removestation=None)[source]

rewrite2DDataFile will rewrite an existing data file so you can redefine some of the parameters, such as rotation angle, or errors for the different components or only invert for one mode or add one or add tipper or remove tipper.

Inputs:

datafn = full path to data file to rewrite

rotz = rotation angle with positive clockwise

resxyerr = error for TE mode resistivity (percent) or ‘data’ for data
or prev to take errors from data file.
resyxerr = error for TM mode resistivity (percent) or ‘data’ for data
or prev to take errors from data file.
phasexyerr = error for TE mode phase (percent) or ‘data’ for data
or prev to take errors from data file.
phaseyxerr = error for TM mode phase (percent) or ‘data’ for data
or prev to take errors from data file.
tippererr = error for tipper (percent) input only if you want to invert
for the tipper or ‘data’ for data errors or prev to take errors from data file.
mmodes = ‘both’ for both TE and TM
‘TE’ for TE ‘TM’ for TM
flst = frequency list in Hz to rewrite, needs to be similar to the
datafile, cannot add frequencies

removestation = list of stations to remove if desired

MTpy.core.OCCAMTools.rewriteMesh(meshfn)[source]

checkMesh will check to see if the number of lines are correct and the length of the line is correct

MTpy.core.OCCAMTools.writemeshfile(parameter_dict)[source]
MTpy.core.OCCAMTools.writemodelfile(parameter_dict)[source]

needed : filename,binding_offset,startcolumn, n_layers,layer_thickness,block_width

MTpy.core.OCCAMTools.writestartupfile(parameter_dict)[source]

Previous topic

Z: calculate properties of impedance tensors

Next topic

WS3DTools: working with WS3DMTINV

This Page