pygmi.pfmod package

Submodules

pygmi.pfmod.datatypes module

Class for data types.

class pygmi.pfmod.datatypes.LithModel

Bases: object

Lithological Model Data.

This is the main data structure for the modelling program

mlut

colour table for lithologies

Type:

dictionary

numx

number of columns per layer in model

Type:

int

numy

number of rows per layer in model

Type:

int):

numz

number of layers in model

Type:

int

dxy

dimension of cubes in the x and y directions

Type:

float

d_z

dimension of cubes in the z direction

Type:

float

lith_index

3D array of lithological indices.

Type:

numpy array

xrange

minimum and maximum x coordinates

Type:

list

yrange

minimum and maximum y coordinates

Type:

list

zrange

minimum and maximum z coordinates

Type:

list

griddata

dictionary of Data classes with raster data

Type:

dictionary

custprofx

custom profile x coordinates

Type:

dictionary

custprofy

custom profile y coordinates

Type:

dictionary

profpics

profile pictures

Type:

dictionary

lith_list

list of lithologies

Type:

dictionary

lith_list_reverse

reverse lookup for lith_list

Type:

dictionary

mht

height of magnetic sensor

Type:

float

ght

height of gravity sensor

Type:

float

gregional

gravity regional correction

Type:

float

dtm_to_lith(pbar=None)

Assign the DTM to the model.

This means creating nodata values in areas above the DTM. These values are assigned a lithology of -1.

Parameters:

pbar (pygmi.misc.ProgressBar, optional) – Progressbar. The default is None.

Return type:

None.

init_calc_grids()

Initialize mag and gravity from the model.

Return type:

None.

init_grid(data)

Initialize raster variables in the Data class.

Parameters:

data (numpy array) – Masked array containing raster data.

Returns:

grid – PyGMI raster dataset.

Return type:

PyGMI Data

is_modified(modified=True)

Update modified flag.

Parameters:

modified (bool, optional) – Flag for whether the lithology has been modified. The default is True.

Return type:

None.

lithold_to_lith(nodtm=False, pbar=None)

Transfers an old lithology to the new one, using update parameters.

Parameters:
  • nodtm (bool, optional) – Flag for a DTM. The default is False.

  • pbar (pygmi.misc.ProgressBar, optional) – Progressbar. The default is None.

Return type:

None.

update(cols, rows, layers, utlx, utly, utlz, dxy, d_z, mht=-1, ght=-1, usedtm=True, pbar=None)

Update the local variables for the LithModel class.

Parameters:
  • cols (int) – Number of columns per layer in model.

  • rows (int) – Number of rows per layer in model.

  • layers (int) – Number of layers in model.

  • utlx (float) – Upper top left (NW) x coordinate.

  • utly (float) – Upper top left (NW) y coordinate.

  • utlz (float) – Upper top left (NW) z coordinate.

  • dxy (float) – Dimension of cubes in the x and y directions.

  • d_z (float) – Dimension of cubes in the z direction.

  • mht (float, optional) – Height of magnetic sensor. The default is -1.

  • ght (float, optional) – Height of gravity sensor. The default is -1.

  • usedtm (bool, optional) – Flag to use a DTM. The default is True.

  • pbar (pygmi.misc.ProgressBar, optional) – Progressbar. The default is None.

Return type:

None.

update_lith_list_reverse()

Update the lith_list reverse lookup.

It must be run at least once before using lith_list_reverse.

Return type:

None.

update_lithlist()

Update lith_list from local variables.

Return type:

None.

pygmi.pfmod.grvmag3d module

Gravity and magnetic field calculations.

This uses the following algorithms:

References

Singh, B., Guptasarma, D., 2001. New method for fast computation of gravity and magnetic anomalies from arbitrary polyhedral. Geophysics 66, 521-526.

Blakely, R.J., 1996. Potential Theory in Gravity and Magnetic Applications, 1st edn. Cambridge University Press, Cambridge, UK, 441 pp. 200-201

class pygmi.pfmod.grvmag3d.GeoData(parent, ncols=10, nrows=10, numz=10, dxy=10.0, d_z=10.0, mht=80.0, ght=0.0)

Bases: object

Data layer class.

This class defines each geological type and calculates the field for one cube from the standard definitions.

The is a class which contains the geophysical information for a single lithology. This includes the final calculated field for that lithology only.

calc_origin_grav(hcor=None)

Calculate the field values for the lithologies.

Parameters:

hcor (numpy array or None, optional) – Height corrections. The default is None.

Return type:

None.

calc_origin_mag(hcor=None, demag=False)

Calculate the field values for the lithologies.

Parameters:

hcor (numpy array or None, optional) – Height corrections. The default is None.

Return type:

None.

gboxmain(xobs, yobs, zobs, hcor)

Gbox routine by Blakely.

Note: xobs, yobs and zobs must be floats or there will be problems later.

Subroutine GBOX computes the vertical attraction of a rectangular prism. Sides of prism are parallel to x,y,z axes, and z axis is vertical down.

Input parameters: | Observation point is (x0,y0,z0). The prism extends from x1 | to x2, from y1 to y2, and from z1 to z2 in the x, y, and z | directions, respectively. Density of prism is rho. All | distance parameters in units of m;

Output parameters: | Vertical attraction of gravity, g, in mGal/rho. | Must still be multiplied by rho outside routine. | Done this way for speed.

Parameters:
  • xobs (numpy array) – Observation X coordinates.

  • yobs (numpy array) – Observation Y coordinates.

  • zobs (numpy array) – Observation Z coordinates.

  • hcor (numpy array) – Height corrections.

Return type:

None.

mboxmain(xobs, yobs, zobs, hcor, demag=False)

Mbox routine by Blakely.

Note: xobs, yobs and zobs must be floats or there will be problems later.

Subroutine MBOX computes the total field anomaly of an infinitely extended rectangular prism. Sides of prism are parallel to x,y,z axes, and z is vertical down. Bottom of prism extends to infinity. Two calls to mbox can provide the anomaly of a prism with finite thickness; e.g.,

call mbox(x0,y0,z0,x1,y1,z1,x2,y2,mi,md,fi,fd,m,theta,t1)
call mbox(x0,y0,z0,x1,y1,z2,x2,y2,mi,md,fi,fd,m,theta,t2)
t=t1-t2

Requires subroutine DIRCOS. Method from Bhattacharyya (1964).

Input parameters: | Observation point is (x0,y0,z0). Prism extends from x1 to | x2, y1 to y2, and z1 to infinity in x, y, and z directions, | respectively. Magnetization defined by inclination mi, | declination md, intensity m. Ambient field defined by | inclination fi and declination fd. X axis has declination | theta. Distance units are irrelevant but must be consistent. | Angles are in degrees, with inclinations positive below | horizontal and declinations positive east of true north. | Magnetization in A/m.

Output parameters: | Total field anomaly t, in nT.

Parameters:
  • xobs (numpy array) – Observation X coordinates.

  • yobs (numpy array) – Observation Y coordinates.

  • zobs (numpy array) – Observation Z coordinates.

  • hcor (numpy array) – Height corrections.

Return type:

None.

rho()

Return the density contrast.

Returns:

Density contrast.

Return type:

float

set_xyz(ncols, nrows, numz, g_dxy, mht, ght, d_z, dxy=None, modified=True)

Sets/updates xyz parameters.

Parameters:
  • ncols (int) – Number of columns.

  • nrows (int) – Number of rows.

  • numz (int) – Number of layers.

  • g_dxy (float) – Grid spacing in x and y direction.

  • mht (float) – Magnetic sensor height.

  • ght (float) – Gravity sensor height.

  • d_z (float) – Model spacing in z direction.

  • dxy (float, optional) – Model spacing in x and y direction. The default is None.

  • modified (bool, optional) – Whether the model was modified. The default is True.

Return type:

None.

set_xyz12()

Set x12, y12, z12.

This is the limits of the cubes for the model

Return type:

None.

class pygmi.pfmod.grvmag3d.GravMag(parent=None)

Bases: object

The GravMag class holds generic magnetic and gravity modelling routines.

Routine that will calculate the final versions of the field. Other, related code is here as well, such as the inversion routines.

calc_field2(showreports=False, magcalc=False)

Calculate magnetic and gravity field.

Parameters:
  • showreports (bool, optional) – Flag for showing reports. The default is False.

  • magcalc (bool, optional) – Flag for choosing the magnetic calculation. The default is False.

Return type:

None.

calc_field_grav()

Pre field-calculation routine.

Return type:

None.

calc_field_grav_changes()

Calculate only gravity field changes.

Return type:

None.

calc_field_mag()

Pre field-calculation routine.

Return type:

None.

calc_field_mag_changes()

Calculate only magnetic field changes.

Return type:

None.

calc_regional()

Calculate magnetic and gravity regional.

Calculates a gravity and magnetic regional value based on a single solid lithology model. The principle is that the maximum value for a solid model with fixed extents and depth, using the most COMMON lithology, would be the MAXIMUM AVERAGE value for any model which we would do. Therefore the regional is simply:

REGIONAL = OBS GRAVITY MEAN - CALC GRAVITY MAX

This routine calculates the last term.

Return type:

None.

setupui()

Set up UI.

Return type:

None.

test_pattern()

Displays a test pattern of the data.

This is an indication of the edge of model field decay. It gives an idea about how reliable the calculated field on the edge of the model is.

Return type:

None.

update_graph(grvval, magval, modind)

Update the graph.

Parameters:
  • grvval (numpy array) – Array of gravity values.

  • magval (numpy array) – Array of magnetic values.

  • modind (numpy array) – Model indices.

Return type:

None.

pygmi.pfmod.grvmag3d.calc_demag(mvec, k, dxy, dz)

Calculate demagnetisation correction.

Parameters:
  • mvec (numpy array) – Body Magnetisation.

  • k (float) – susceptibility.

  • dxy (float) – cell width.

  • dz (float) – cell height.

Returns:

outvec – Corrected magnetisation.

Return type:

numpy array

pygmi.pfmod.grvmag3d.calc_field(lmod, pbars=None, showtext=None, parent=None, showreports=False, magcalc=False, demag=False)

Calculate magnetic and gravity field.

This function calculates the magnetic and gravity field. It has two different modes of operation, by using the magcalc switch. If magcalc=True then magnetic fields are calculated, otherwise only gravity is calculated.

Parameters:
  • lmod (LithModel) – PyGMI lithological model

  • pbars (module) – progress bar routine if available. (internal use)

  • showtext (module) – showtext routine if available. (internal use)

  • showreports (bool) – show extra reports

  • magcalc (bool) – if True, calculates magnetic data, otherwise only gravity.

Returns:

lmod.griddata – dictionary of items of type Data.

Return type:

dictionary

pygmi.pfmod.grvmag3d.dat_extent(dat, axes)

Get the extent of the dat variable.

Parameters:
  • dat (PyGMI Data) – PyGMI raster dataset.

  • axes (matplotlib.axes._subplots.AxesSubplot) – Matplotlib axes.

Returns:

  • left (float) – Left coordinate.

  • right (float) – Right coordinate.

  • bottom (float) – Bottom coordinate.

  • top (float) – Top coordinate.

pygmi.pfmod.grvmag3d.dircos(incl, decl, azim)

DIRCOS computes direction cosines from inclination and declination.

Parameters:
  • incl (float) – inclination in degrees positive below horizontal.

  • decl (float) – declination in degrees positive east of true north.

  • azim (float) – azimuth of x axis in degrees positive east of north.

Returns:

  • aaa (float) – First direction cosine.

  • bbb (float) – Second direction cosine.

  • ccc (float) – Third direction cosine.

pygmi.pfmod.grvmag3d.gridmatch(lmod, ctxt, rtxt)

Match the rows and columns of the second grid to the first grid.

Parameters:
  • lmod (LithModel) – Lithology Model.

  • ctxt (str) – First grid text label.

  • rtxt (str) – Second grid text label.

Returns:

dat – Numpy array of data.

Return type:

numpy array

pygmi.pfmod.grvmag3d.quick_model(numx=50, numy=40, numz=5, dxy=100.0, d_z=100.0, tlx=0.0, tly=0.0, tlz=0.0, mht=100.0, ght=0.0, finc=-67, fdec=-17, inputliths=None, susc=None, dens=None, minc=None, mdec=None, mstrength=None, hintn=30000.0)

Quick model function.

Parameters:
  • numx (int, optional) – Number of x elements. The default is 50.

  • numy (int, optional) – Number of y elements. The default is 40.

  • numz (int, optional) – number of z elements (layers). The default is 5.

  • dxy (float, optional) – Cell size in x and y direction. The default is 100..

  • d_z (float, optional) – Layer thickness. The default is 100..

  • tlx (float, optional) – Top left x coordinate. The default is 0..

  • tly (float, optional) – Top left y coordinate. The default is 0..

  • tlz (float, optional) – Top left z coordinate. The default is 0..

  • mht (float, optional) – Magnetic sensor height. The default is 100..

  • ght (float, optional) – Gravity sensor height. The default is 0..

  • finc (float, optional) – Magnetic field inclination (degrees). The default is -67.

  • fdec (float, optional) – Magnetic field declination (degrees). The default is -17.

  • inputliths (list or None, optional) – List of input lithologies. The default is None.

  • susc (list or None, optional) – List of susceptibilities. The default is None.

  • dens (list or None, optional) – List of densities. The default is None.

  • minc (list or None, optional) – List of remanent inclinations (degrees). The default is None.

  • mdec (list or None, optional) – List of remanent declinations (degrees). The default is None.

  • mstrength (list or None, optional) – List of remanent magnetisations (A/m). The default is None.

  • hintn (float, optional) – Magnetic field strength (nT). The default is 30000.

Returns:

lmod – Output model.

Return type:

LithModel

pygmi.pfmod.grvmag3d.save_layer(mlist)

Routine to save the mlayer and glayer to a file.

Parameters:

mlist (list) – List with 2 elements - lithology name and LithModel.

Returns:

outfile – Link to a temporary file.

Return type:

TemporaryFile

pygmi.pfmod.grvmag3d.sum_fields(k, mgval, numx, numy, modind, aaa0, aaa1, mlayers, hcorflat, mijk)

Sum magnetic and gravity field datasets to produce final model field.

Parameters:
  • k (int) – k index.

  • mgval (numpy array) – Magnetic or gravity data being summed.

  • numx (int) – Number of x elements.

  • numy (int) – Number of y elements.

  • modind (numpy array) – model with indices representing lithologies.

  • aaa0 (numpy array) – x indices for offsets.

  • aaa1 (numpy array) – y indices for offsets.

  • mlayers (numpy array) – Layer fields for summation.

  • hcorflat (numpy array) – Height correction.

  • mijk (int) – Current lithology index.

Returns:

mgval – Output summed data.

Return type:

numpy array

pygmi.pfmod.iodefs module

Import Potential field model data.

class pygmi.pfmod.iodefs.ExportMod3D(parent=None)

Bases: ContextModule

Export Data.

lmod2dict(outdict, pre='')

Convert LithModel to a dictionary.

Parameters:
  • outdict (dictionary) – Output dictionary.

  • pre (str, optional) – Text. The default is ‘’.

Returns:

outdict – Output dictionary.

Return type:

dictionary

mod3dtocsv()

Save the 3D model in a csv file.

Return type:

None.

mod3dtokmz()

Save the 3D model and grids in a kmz file.

Only the boundary of the area is in degrees. The actual coordinates are still in meters.

Return type:

None.

mod3dtoshp(nodialog=False)

Save the 3D model and grids in a shapefile file.

Only the boundary of the area is in degrees. The actual coordinates are still in meters.

Return type:

None.

run()

Run.

Return type:

None.

savemodel()

Save model.

Return type:

None.

class pygmi.pfmod.iodefs.Exportkmz(wkt, parent=None)

Bases: QDialog

Export kmz dialog.

setupui()

Set up UI.

Return type:

None.

class pygmi.pfmod.iodefs.ImportMod3D(parent=None)

Bases: BasicModule

Import Data.

dict2lmod(indict, pre='')

Convert a dictionary to a LithModel.

Parameters:
  • indict (dictionary) – Imported dictionary.

  • pre (str, optional) – Text. The default is ‘’.

Return type:

None.

import_ascii_xyz_model(filename)

Use to import ASCII XYZ Models of the form x,y,z,label.

Parameters:

filename (str) – Input filename.

Return type:

None.

import_leapfrog_csv(filename)

Import leapfrog csv block models.

Parameters:

filename (str) – Input filename.

Return type:

None.

saveproj()

Save project data from class.

Return type:

None.

settings(nodialog=False)

Entry point into item.

Parameters:

nodialog (bool, optional) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

class pygmi.pfmod.iodefs.MessageCombo(combotext, parent=None)

Bases: QDialog

Message combo box.

parent

reference to the parent routine

Type:

parent

acceptall()

Accept option.

Returns:

Returns current text.

Return type:

str

setupui()

Set up UI.

Return type:

None.

pygmi.pfmod.menu module

Potential Field Modelling menus.

class pygmi.pfmod.menu.MenuWidget(parent=None)

Bases: object

Widget class to call the main interface.

This widget class creates the modelling menus to be found on the main interface. Normal as well as context menus are defined here.

parent

Reference to MainWidget class found in main.py

Type:

pygmi.main.MainWidget

export_mod3d()

Export 3D Model.

import_mod3d()

Import data.

maginv()

Voxel inversion of data.

merge_mod3d()

Merge models.

mod3d()

3D display of data.

pfmod()

Voxel modelling of data.

stat3d()

3D display of data.

pygmi.pfmod.misc module

These are miscellaneous functions for the program.

class pygmi.pfmod.misc.MergeMod3D(parent=None)

Bases: BasicModule

Perform Merge of two models.

acceptall()

Accept option.

Updates self.outdata, which is used as input to other modules.

Returns:

True if successful, False otherwise

Return type:

bool

saveproj()

Save project data from class.

Return type:

None.

settings(nodialog=False)

Entry point into item.

Parameters:

nodialog (bool, optional) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

setupui()

Set up UI.

Return type:

None.

class pygmi.pfmod.misc.ProgressBar(pbar, pbarmain)

Bases: object

Wrapper for a progress bar. It consists of two progress bars.

busysub()

Busy.

Return type:

None.

incr()

Increase value by one.

Return type:

None.

incrmain(i=1)

Increase value by i.

Parameters:

i (int, optional) – Iteration step. The default is 1.

Return type:

None.

iter(iterable)

Iterate routine.

Parameters:

iterable (iterable) – Iterable.

Yields:

obj (object) – Object in iterable.

maxall()

Set all progress bars to maximum value.

Return type:

None.

resetall(maximum=1, mmax=1)

Set min and max and resets all bars to 0.

Parameters:
  • maximum (int, optional) – Maximum value. The default is 1.

  • mmax (int, optional) – Maximum value. The default is 1.

Return type:

None.

resetsub(maximum=1)

Set min and max and resets sub bar to 0.

Parameters:

maximum (int, optional) – Maximum value. The default is 1.

Return type:

None.

pygmi.pfmod.misc.gmerge(master, slave, xrange=None, yrange=None)

Routine used to merge two grids.

Parameters:
  • master (PyGMI Data) – PyGMI raster dataset.

  • slave (PyGMI Data) – PyGMI raster dataset.

  • xrange (list, optional) – List containing range of minimum and maximum X. The default is None.

  • yrange (list, optional) – List containing range of minimum and maximum Y. The default is None.

Returns:

PyGMI raster dataset.

Return type:

PyGMI Data

pygmi.pfmod.misc.update_lith_lw(lmod, lwidget)

Update the lithology list widget.

Parameters:
  • lmod (LithModel) – 3D model.

  • lwidget (QListWidget) – List widget.

Return type:

None.

pygmi.pfmod.mvis3d module

Code for the 3d model creation.

class pygmi.pfmod.mvis3d.GLWidget(parent=None)

Bases: QGLWidget

OpenGL Widget.

draw_with_axis()

Draw with a set of axes.

Return type:

None.

initGeometry()

Initialise geometry.

Return type:

None.

init_object()

Initialise VBO.

Return type:

None.

init_projection()

Initialise the projection.

Return type:

None.

initializeGL()

Initialise OpenGL.

Return type:

None.

minimumSizeHint()

Minimum size hint.

Returns:

Returns a size of (50, 50)

Return type:

QtCore.QSize

mouseMoveEvent(event)

Mouse move event.

Parameters:

event (QMouseEvent) – Mouse event.

Return type:

None.

mousePressEvent(event)

Mouse press event.

Parameters:

event (QMouseEvent) – Mouse event.

Return type:

None.

normalizeAngle(angle)

Corrects an angle to between 0 and 360*16.

Parameters:

angle (float) – Input angle.

Returns:

angle – Output angle.

Return type:

float

paintGL()

Paint OpenGL.

Return type:

None.

print_string(x, y, z, text)

Print a 2D text string.

Parameters:
  • x (float) – X coordinate.

  • y (float) – Y coordinate.

  • z (float) – Z coordinate.

  • text (str) – Text string.

Return type:

None.

readPixels()

Read pixels from the window.

Returns:

data – Returned pixel data.

Return type:

numpy array

resizeGL(width, height)

Resize OpenGL.

Parameters:
  • width (float) – Width of side.

  • height (float) – Height of side.

Return type:

None.

setXRotation(angle)

Set X rotation.

Parameters:

angle (float) – X angle of rotation.

Return type:

None.

setYRotation(angle)

Set Y Rotation.

Parameters:

angle (float) – Y angle of rotation.

Return type:

None.

setZRotation(angle)

Set Z rotation.

Parameters:

angle (float) – Z angle of rotation.

Return type:

None.

setlightdir(x, y, z)

Set light direction.

Parameters:
  • x (float) – X light position.

  • y (float) – Y light position.

  • z (float) – Z light position.

Return type:

None.

sizeHint()

Size hint.

Returns:

Returns a size of (400, 400)

Return type:

QtCore.QSize

wheelEvent(event)

Mouse wheel event.

Parameters:

event (QWheelEvent) – Mouse wheel event.

Return type:

None.

pygmi.pfmod.mvis3d.GetTables()

Get tables.

Returns:

A list with edgetable and tritable.

Return type:

list

pygmi.pfmod.mvis3d.InterpolateVertices(isolevel, p1x, p1y, p1z, p2x, p2y, p2z, valp1, valp2)

Interpolate vertices.

Parameters:
  • isolevel (float) – ISO level.

  • p1x (numpy array) – p1 x coordinate.

  • p1y (numpy array) – p1 y coordinate.

  • p1z (numpy array) – p1 z coordinate.

  • p2x (numpy array) – p2 x coordinate.

  • p2y (numpy array) – p2 y coordinate.

  • p2z (numpy array) – p2 z coordinate.

  • valp1 (numpy array) – p1 value.

  • valp2 (numpy array) – p2 value.

Returns:

p – Interpolated vertices.

Return type:

numpy array

pygmi.pfmod.mvis3d.MarchingCubes(x, y, z, c, iso, showlog=<built-in function print>)

Marching cubes.

Use marching cubes algorithm to compute a triangulated mesh of the isosurface within the 3D matrix of scalar values C at isosurface value ISO. The 3D matrices (X,Y,Z) represent a Cartesian, axis-aligned grid specifying the points at which the data C is given. These coordinate arrays must be in the format produced by Matlab’s meshgrid function. Output arguments F and V are the face list and vertex list of the resulting triangulated mesh. The orientation of the triangles is chosen such that the normals point from the higher values to the lower values. Optional arguments COLORS ans COLS can be used to produce interpolated mesh face colours. For usage, see Matlab’s isosurface.m. To avoid Out of Memory errors when matrix C is large, convert matrices X,Y,Z and C from doubles (Matlab default) to singles (32-bit floats).

Originally Adapted for Matlab by Peter Hammer in 2011 based on an Octave function written by Martin Helm <martin@mhelm.de> in 2009 http://www.mhelm.de/octave/m/marching_cube.m

Revised 30 September, 2011 to add code by Oliver Woodford for removing duplicate vertices.

Parameters:
  • x (numpy array) – X coordinates.

  • y (numpy array) – Y coordinates.

  • z (numpy array) – Z coordinates.

  • c (numpy array) – Data.

  • iso (float) – Isosurface level.

  • showlog (function, optional) – Display information. The default is print.

Returns:

  • F (numpy array) – Face list.

  • V (numpy array) – Vertex list.

class pygmi.pfmod.mvis3d.Mod3dDisplay(parent=None)

Bases: ContextModule

Widget class to call the main interface.

change_defs()

List box routine.

Return type:

None.

data_init()

Initialise data.

Return type:

None.

mod3d_vs()

Vertical slider used to scale 3d view.

resetlight()

Reset light to the current model position.

Return type:

None.

run()

Run.

Returns:

True if successful, False otherwise.

Return type:

bool

save()

Save a jpg.

Return type:

None.

set_selected_liths()

Set the selected lithologies.

Return type:

None.

setupui()

Set up UI.

Return type:

None.

sunclick(event)

Sunclick event is used to track changes to the sunshading.

Parameters:

event (event - matplotlib button press) – event returned by matplotlib when a button is pressed

update_color()

Update colour only.

Return type:

None.

update_for_kmz()

Update for the kmz file.

Return type:

None.

update_model(issmooth=None)

Update the 3d model.

Faces, nodes and face normals are calculated here, from the voxel model.

Parameters:

issmooth (bool, optional) – Flag to indicate a smooth model. The default is None.

Return type:

None.

update_model2()

Update the 3d model part 2.

Return type:

None.

update_plot()

Update 3D model.

Return type:

None.

class pygmi.pfmod.mvis3d.MySunCanvas(parent=None)

Bases: FigureCanvasQTAgg

Canvas for the sunshading tool.

sun

plot of a circle ‘o’ showing where the sun is

Type:

matplotlib plot instance

axes

axes on which the sun is drawn

Type:

matplotlib axes instance

init_graph()

Initialise graph.

Return type:

None.

pygmi.pfmod.mvis3d.bitget(byteval, idx)

Bit get.

Parameters:
  • byteval (int) – Input value to get bit from.

  • idx (int) – Position of bit to get.

Returns:

True if not 0, False otherwise.

Return type:

bool

pygmi.pfmod.mvis3d.bitset(byteval, idx)

Bit set.

Parameters:
  • byteval (int) – Input value to get bit from.

  • idx (int) – Position of bit to get.

Returns:

Output value with bit set.

Return type:

int

pygmi.pfmod.mvis3d.calc_norms(faces, vtx)

Calculate normals.

Parameters:
  • faces (numpy array) – Array of faces.

  • vtx (numpy array.) – Array of vertices.

Return type:

None.

pygmi.pfmod.mvis3d.fancyindex(out, var1, ii, jj, kk)

Fancy index.

Parameters:
  • out (numpy array) – Input data.

  • var1 (numpy array) – Input data.

  • ii (numpy array) – i indices.

  • jj (numpy array) – j indices.

  • kk (numpy array) – k indices.

Returns:

out – Output data with new values.

Return type:

numpy array

pygmi.pfmod.mvis3d.ind2sub(msize, idx)

Index to sub.

Parameters:
  • msize (tuple) – Tuple with number of rows and columns as first two elements.

  • idx (numpy array) – Array of indices.

Returns:

  • row (int) – Row.

  • col (int) – Column.

  • layer (numpy array) – Layer.

pygmi.pfmod.mvis3d.normalize_v3(arr)

Normalize a numpy array of 3 component vectors shape=(n,3).

Parameters:

arr (numpy array) – Array of 3 component vectors.

Returns:

arr – Output array of 3 component vectors.

Return type:

numpy array

pygmi.pfmod.mvis3d.sub2ind(msize, row, col, layer)

Sub to index.

Parameters:
  • msize (tuple) – Tuple with number of rows and columns as first two elements.

  • row (int) – Row.

  • col (int) – Column.

  • layer (numpy array) – Layer.

Returns:

tmp – Index returned.

Return type:

numpy array

pygmi.pfmod.pfinvert module

Magnetic inversion using the SimPEG inversion library.

class pygmi.pfmod.pfinvert.MagInvert(parent=None)

Bases: BasicModule

MextDisplay - Widget class to call the main interface.

acceptall()

Accept All.

Based on the SimPEG example.

Return type:

None.

apply_changes()

Apply changes.

Return type:

None.

choose_combo(combo, dtxt)

Combo box choice routine.

Parameters:
  • combo (QComboBox) – Combo box.

  • dtxt (str) – Text to describe new raster data entry.

Return type:

None.

choose_dtm()

Combo box to choose current DTM.

Return type:

None.

choose_model()

Choose model file.

Return type:

None.

extgrid(gdata)

Extrapolates the grid to get rid of nulls.

Uses a masked grid.

Parameters:

gdata (numpy array) – Raster dataset.

Returns:

Output dataset.

Return type:

numpy masked array

get_area()

Get current grid extents and parameters.

Return type:

None.

init()

Initialise parameters.

Return type:

None.

saveproj()

Save project data from class.

Return type:

None.

settings(nodialog=False)

Entry point.

Return type:

None.

setupui()

Set up UI.

Return type:

None.

upd_layers()

Update layers.

Return type:

None.

update_combos()

Update combos.

Return type:

None.

update_model_combos()

Update model combos.

Return type:

None.

update_vals()

Update the visible model extent parameters.

Return type:

None.

xycell(dxy)

Adjust XY dimensions when cell size changes.

Parameters:

dxy (float) – Cell dimension.

Return type:

None.

zcell(d_z)

Adjust Z dimension when cell size changes.

Parameters:

d_z (float) – Layer thickness.

Return type:

None.

pygmi.pfmod.pfmod module

The main program for the modelling package.

class pygmi.pfmod.pfmod.MainWidget(parent=None)

Bases: QMainWindow

MainWidget - Widget class to call the main interface.

data_reset()

Reset the data.

Return type:

None.

help_docs()

Help documentation.

Return type:

None.

savemodel()

Save model.

Return type:

None.

saveproj()

Save project data from class.

Return type:

None.

settings(nodialog=False)

Entry point into item.

Parameters:

nodialog (bool, optional) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

setupui()

GUI setup.

Return type:

None.

showtext(txt, replacelast=False)

Show text on the text panel of the main user interface.

Parameters:
  • txt (str) – Text to display.

  • replacelast (bool, optional) – Whether to replace the last text written. The default is False.

Return type:

None.

pygmi.pfmod.show_table module

Routine which displays a table graphically with various stats.

class pygmi.pfmod.show_table.BasicStats3D(parent=None)

Bases: ContextModule

Show a summary of basic stats.

combo()

Combo.

Return type:

None.

run()

Run.

Return type:

None.

save()

Save Table.

Returns:

True if successful, False otherwise.

Return type:

bool

setupui()

Set up UI.

Return type:

None.

pygmi.pfmod.show_table.basicstats3d_calc(lmod)

Calculate statistics.

Parameters:

lmod (PyGMI LithModel.) – PyGMI lithology model.

Returns:

  • bands (list) – Band list, currently only ‘Data Column’

  • cols (list) – Columns for the table

  • dattmp (list) – List of arrays containing statistics.

pygmi.pfmod.show_table.savetable(ofile, bands, cols, data)

Save tabular data.

Parameters:
  • ofile (str) – Output file name.

  • bands (list) – List of bands.

  • cols (list) – List of column headings.

  • data (list) – List of arrays containing statistics.

Return type:

None.

pygmi.pfmod.tab_mext module

Model Extents Display Routines.

class pygmi.pfmod.tab_mext.MextDisplay(parent=None)

Bases: QDialog

MextDisplay - Widget class to call the main interface.

apply_changes()

Apply changes.

Return type:

None.

choose_combo(combo, dtxt)

Combo box choice routine.

Parameters:
  • combo (QComboBox) – Combo box.

  • dtxt (str) – Text to describe new raster data entry.

Return type:

None.

choose_dtm()

Combo box to choose current DTM.

Return type:

None.

choose_model()

Choose model file.

Return type:

None.

extgrid(gdata)

Extrapolates the grid to get rid of nulls.

Uses a masked grid.

Parameters:

gdata (numpy array) – Raster dataset.

Returns:

Output dataset.

Return type:

numpy masked array

get_area()

Get current grid extents and parameters.

Return type:

None.

init()

Initialise parameters.

Return type:

None.

setupui()

Set up UI.

Return type:

None.

tab_activate()

Entry point.

Return type:

None.

upd_layers()

Update layers.

Return type:

None.

update_combos()

Update combos.

Return type:

None.

update_model_combos()

Update model combos.

Return type:

None.

update_vals()

Update the visible model extent parameters.

Return type:

None.

xycell(dxy)

Adjust XY dimensions when cell size changes.

Parameters:

dxy (float) – Cell dimension.

Return type:

None.

zcell(d_z)

Adjust Z dimension when cell size changes.

Parameters:

d_z (float) – Layer thickness.

Return type:

None.

pygmi.pfmod.tab_param module

Parameter Display Tab Routines.

class pygmi.pfmod.tab_param.LithNotes(parent=None)

Bases: QDialog

Class to call up a dialog for lithology descriptions.

apply_changes()

Apply changes.

Return type:

None.

lw_index_change()

List box in parameter tab for definitions.

Return type:

None.

setupui()

Set up UI.

Return type:

None.

tab_activate()

Entry point.

Return type:

None.

class pygmi.pfmod.tab_param.MergeLith(parent=None)

Bases: QDialog

Class to call up a dialog for ranged copying.

setupui()

Set up UI.

Return type:

None.

class pygmi.pfmod.tab_param.ParamDisplay(parent=None)

Bases: QDialog

Widget class to call the main interface.

add_def()

Add geophysical definition.

Return type:

None.

add_defs(deftxt='', getcol=False, lmod=None)

Add geophysical definitions and make them editable.

Parameters:
  • deftxt (str, optional) – Definition text. The default is ‘’.

  • getcol (bool, optional) – Get column. The default is False.

  • lmod (LithModel, optional) – 3D model. The default is None.

Return type:

None.

apply_changes()

Apply geophysical properties.

Return type:

None.

apply_lith()

Apply lithological changes.

Return type:

None.

change_defs(item)

Change geophysical definitions.

Parameters:

item (QListWidget item) – Parameter definition QListWidget item.

Return type:

None.

change_magnetization()

Update spinboxes when magnetization is changed.

Return type:

None.

change_qratio()

Update spinboxes when qratio is changed.

Return type:

None.

change_rmi()

Update spinboxes when rmi is changed.

Return type:

None.

connect_spin()

Connect spin boxes.

Return type:

None.

disconnect_spin()

Disconnect spin boxes.

Return type:

None.

get_lith()

Get parameter definitions.

Returns:

lith – Lithology data.

Return type:

GeoData

init()

Initialize parameters.

Return type:

None.

lw_color_change()

Routine to allow lithologies to have their colors changed.

Return type:

None.

lw_index_change()

List widget in parameter tab for definitions.

Return type:

None.

merge_defs()

Merge geophysical definitions.

Return type:

None.

rem_defs()

Remove geophysical definition.

Return type:

None.

rename_defs()

Rename a definition.

Return type:

None.

set_lw_colors(lwidget, lmod=None)

Set list widget colors.

Parameters:
  • lwidget (QListWidget) – Lithology list widget..

  • lmod (LithModel, optional) – 3D Model. The default is None.

Return type:

None.

setupui()

Set up UI.

Return type:

None.

tab_activate()

Entry point.

Return type:

None.

pygmi.pfmod.tab_prof module

Profile Display Tab Routines.

class pygmi.pfmod.tab_prof.GaugeWidget(*args, **kwargs)

Bases: QDial

Gauge widget.

paintEvent(event)

Paint event.

Parameters:

event (event) – Event variable.

Return type:

None.

class pygmi.pfmod.tab_prof.ImportPicture(parent=None)

Bases: BasicModule

Import Picture dialog.

get_filename()

Get filename of picture.

Return type:

None.

getcoords()

Get coordinates.

Return type:

None.

saveproj()

Save project data from class.

Return type:

None.

settings(nodialog=False)

Entry point into item.

Parameters:

nodialog (bool, optional) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

setupui()

Set up UI.

Return type:

None.

class pygmi.pfmod.tab_prof.LithBound(lmod)

Bases: QDialog

Class to call up a dialog for lithological boundary.

get_lith()

Get lithology.

Returns:

  • lithlower (int) – Lower lithology index.

  • lithupper (int) – Upper lithology index.

setupui()

Set up UI.

Return type:

None.

class pygmi.pfmod.tab_prof.MyMplCanvas(parent=None)

Bases: FigureCanvasQTAgg

Matplotlib Canvas.

button_press(event)

Button press event.

Parameters:

event (event) – Event variable.

Return type:

None.

button_release(event)

Button release event.

Parameters:

event (event) – Unused.

Return type:

None.

init_grid(dat, dat2=None, opac=0.0)

Initialise grid.

Parameters:
  • dat (numpy array) – Raster dataset.

  • dat2 (PyGMI Data, optional) – PyGMI raster dataset. The default is None.

  • opac (float, optional) – Opacity between 0 and 100. The default is 0.0.

Return type:

None.

init_grid_top(dat2=None, opac=100.0)

Initialise top grid.

Parameters:
  • dat2 (str, optional) – Combobox text. The default is None.

  • opac (float, optional) – Opacity between 0 and 100. The default is 100.0.

Return type:

None.

init_plot(xdat, dat, extent, xdat2=None, dat2=None)

Initialise plot.

Parameters:
  • xdat (numpy array) – X coordinates.

  • dat (numpy array) – Data values.

  • extent (list) – Extent list.

  • xdat2 (numpy array, optional) – X coordinates. The default is None.

  • dat2 (numpy array, optional) – Data values. The default is None.

Return type:

None.

luttodat(dat)

LUT to dat grid.

Parameters:

dat (numpy array) – Input data.

Returns:

tmp – dat grid.

Return type:

numpy array

move(event)

Mouse move event.

Parameters:

event (event) – Event variable.

Return type:

None.

on_resize(event)

Resize event.

Used to make sure tight_layout happens on startup.

Parameters:

event (event) – Unused.

Return type:

None.

set_mdata(xdata, ydata, mdata)

Routine to ‘draw’ the line on mdata.

xdata and ydata are the cursor centre coordinates.

Parameters:
  • xdata (float) – X data.

  • ydata (float) – Y data.

  • mdata (numpy array) – Model array.

Return type:

None.

slide_grid(dat, dat2=None, opac=None)

Slide grid.

Parameters:
  • dat (numpy array.) – Raster data array.

  • dat2 (numpy array, optional) – Raster data array. The default is None.

  • opac (float, optional) – Opacity between 0 and 100. The default is None.

Return type:

None.

slide_grid_top(opac=None)

Slide top grid.

Parameters:

opac (float, optional) – Opacity between 0 and 100. The default is None.

Return type:

None.

slide_plot(xdat, dat, xdat2=None, dat2=None)

Slide plot.

Parameters:
  • xdat (numpy array) – X coordinates.

  • dat (numpy array) – Data values.

  • xdat2 (numpy array, optional) – X coordinates. The default is None.

  • dat2 (numpy array, optional) – Data values. The default is None.

Return type:

None.

update_line()

Update the line position.

Return type:

None.

update_line_top()

Update the top line position.

Return type:

None.

class pygmi.pfmod.tab_prof.MySlider(parent=None)

Bases: QSlider

My Slider.

Custom class which allows clicking on a horizontal slider bar with slider moving to click in a single step.

mouseMoveEvent(event)

Mouse move event.

Jump to pointer position while moving.

Parameters:

event (event) – Event variable.

Return type:

None.

mousePressEvent(event)

Mouse press event.

Parameters:

event (event) – Event variable.

Return type:

None.

class pygmi.pfmod.tab_prof.MyToolbar(parent=None)

Bases: NavigationToolbar2QT

Custom Matplotlib toolbar.

axis_scale()

Axis scale.

Return type:

None.

b_logs()

Borehole logs.

Return type:

None.

grv_profile()

View gravity profile.

Return type:

None.

mag_profile()

View magnetic profile.

Return type:

None.

toolitems = [('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous view', 'back', 'back'), ('Forward', 'Forward to next view', 'forward', 'forward'), (None, None, None, None), ('Pan', 'Left button pans, Right button zooms\nx/y fixes axis, CTRL fixes aspect', 'move', 'pan'), ('Zoom', 'Zoom to rectangle\nx/y fixes axis', 'zoom_to_rect', 'zoom'), ('Subplots', 'Configure subplots', 'subplots', 'configure_subplots'), ('Customize', 'Edit axis, curve and image parameters', 'qt4_editor_options', 'edit_parameters'), (None, None, None, None), ('Save', 'Save the figure', 'filesave', 'save_figure'), (None, None, None, None), ('Field\nDisplay\nLimits', 'Axis Scale', 'Axis Scale', 'axis_scale'), ('View\nMagnetic\nProfile', 'Magnetic Profile', 'Magnetic Profile', 'mag_profile'), ('View\nGravity\nProfile', 'Gravity Profile', 'Gravity Profile', 'grv_profile'), ('Import\nBorehole\nLogs', 'Borehole Logs', 'Borehole Logs', 'b_logs')]
class pygmi.pfmod.tab_prof.PlotScale(parent, lmod)

Bases: QDialog

Class to call up a dialog for plot axis scale.

custom()

Set custom radiobutton when limits are changed.

Return type:

None.

setupui()

Set up UI.

Return type:

None.

class pygmi.pfmod.tab_prof.ProfileDisplay(parent=None)

Bases: QWidget

Widget class to call the main interface.

borehole_import()

Import borehole data.

Return type:

None.

calc_prof_limits(curprof=None)

Calculate profile limits.

Parameters:

curprof (int or None, optional) – Current profile. The default is None.

Return type:

None.

change_defs()

Change definitions.

Return type:

None.

cprof_add()

Add new custom profile.

Return type:

None.

cprof_del()

Delete current custom profile.

Return type:

None.

custom_prof_limits(curprof=None)

Calculate custom profile limits.

Parameters:

curprof (int or str, optional) – Current profile. The default is None.

Return type:

None.

export_csv()

Export profile to csv.

Return type:

None.

get_model()

Get model slice.

Return type:

None.

hcprofnum()

Change a profile from a horizontal slider.

Return type:

None.

hlayer()

Horizontal slider to change the layer.

Return type:

None.

hprofnum()

Change a profile from a horizontal slider.

Return type:

None.

lbound()

Insert a lithological boundary.

Return type:

None.

pic_overview()

Horizontal slider to change picture opacity.

Return type:

None.

pic_overview2()

Horizontal slider to change picture opacity.

Return type:

None.

pic_sideview()

Horizontal slider for picture opacity.

Change the opacity of profile and overlain picture.

Return type:

None.

plot_scale()

Plot scale.

Return type:

None.

prof_dir(slide=True)

Profile direction.

Parameters:

slide (bool, optional) – Flag to redraw entire plot, or just update. The default is True.

Return type:

None.

proftype_changed()

Profile type changed.

Return type:

None.

rcopy()

Do a ranged copy on a profile.

Return type:

None.

rcopy_layer(rcopy)

Do a ranged copy on a layer.

Parameters:

rcopy (RangedCopy) – Handle of ranged copy GUI.

Return type:

None.

rcopy_prof(rcopy)

Ranged copy on a profile.

Parameters:

rcopy (RangedCopy) – Handle to RangedCopy GUI.

Return type:

None.

scprofnum()

Change a profile from a spinbox.

Return type:

None.

setupui()

Set up UI.

Return type:

None.

setwidth(width)

Set the width of the edits on the profile view.

Parameters:

width (int) – Edit width.

Return type:

None.

slayer()

Change model layer.

Return type:

None.

sprofdir()

Profile direction spinbox.

Return type:

None.

sprofnum()

Routine to change a profile from spinbox.

Return type:

None.

tab_activate()

Entry point.

Return type:

None.

update_plot(slide=False)

Update the profile on the model view.

Parameters:

slide (bool, optional) – Flag to redraw entire plot, or just update. The default is False.

Return type:

None.

class pygmi.pfmod.tab_prof.RangedCopy(parent=None)

Bases: QDialog

Class to call up a dialog for ranged copying.

setupui()

Set up UI.

Return type:

None.

target_update()

Update target.

Return type:

None.

pygmi.pfmod.tab_prof.gridmatch2(cgrv, rgrv)

Grid match.

Matches the rows and columns of the second grid to the first grid.

Parameters:
  • cgrv (PyGMI Data.) – Raster dataset.

  • rgrv (PyGMI Data) – Raster dataset.

Returns:

Output data.

Return type:

numpy array

pygmi.pfmod.tab_prof.rotate2d(pts, cntr, ang=0.7853981633974483)

Rotate 2D.

Rotates points(nx2) about center cntr(2) by angle ang(1) in radians.

Parameters:
  • pts (numpy array) – Points to rotate.

  • cntr (numpy array) – Center of rotation.

  • ang (float, optional) – Angle to rotate in radians. The default is np.pi/4.

Returns:

pts2 – Rotated points.

Return type:

numpy array

Module contents

Potential Field Routines.