pygmi.mag package¶
Submodules¶
pygmi.mag.dataprep module¶
A set of Magnetic Data routines.
- class pygmi.mag.dataprep.RTP(parent=None)¶
Bases:
BasicModule
Perform Reduction to the Pole on Magnetic data.
- acceptall()¶
Accept option.
Updates self.outdata, which is used as input to other modules.
- 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.mag.dataprep.Tilt1(parent=None)¶
Bases:
BasicModule
Class used to gather information via a GUI, for function tilt1.
- azi¶
directional filter azimuth in degrees from East
- Type:
float
- smooth¶
size of smoothing matrix to use - must be odd input 0 for no smoothing
- Type:
int
- 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.
- pygmi.mag.dataprep.fft_getkxy(fftmod, xdim, ydim)¶
Get KX and KY.
- Parameters:
fftmod (numpy array) – FFT data.
xdim (float) – cell x dimension.
ydim (float) – cell y dimension.
- Returns:
KX (numpy array) – x sample frequencies.
KY (numpy array) – y sample frequencies.
- pygmi.mag.dataprep.fftprep(data)¶
FFT Preparation.
- Parameters:
data (numpy array) – Input dataset.
- Returns:
zfin (numpy array.) – Output prepared data.
rdiff (int) – rows divided by 2.
cdiff (int) – columns divided by 2.
datamedian (float) – Median of data.
- pygmi.mag.dataprep.nextpow2(n)¶
Next power of 2.
- Based on work by Gordon Cooper (School of Geosciences, University of the
Witwatersrand, Johannesburg, South Africa).
- Parameters:
n (float or numpy array) – Current value.
- Returns:
m_i – Output.
- Return type:
float or numpy array
- pygmi.mag.dataprep.rtp(data, I_deg, D_deg)¶
Reduction to the pole.
- Parameters:
data (PyGMI Data) – PyGMI raster data.
I_deg (float) – Magnetic inclination.
D_deg (float) – Magnetic declination.
- Returns:
dat – PyGMI raster data.
- Return type:
PyGMI Data
- pygmi.mag.dataprep.tilt1(data, azi, s, k=2)¶
Tilt angle calculations.
- Based on work by Gordon Cooper (School of Geosciences, University of the
Witwatersrand, Johannesburg, South Africa)
- Parameters:
data (numpy masked array) – matrix of double to be filtered
azi (float) – directional filter azimuth in degrees from East
s (int) – size of smoothing matrix to use - must be odd input 0 for no smoothing
k (int) – Factor for EHGA filter. Must be > 0. Optional.
- Returns:
t1 (numpy masked array) – Standard tilt angle
th (numpy masked array) – Hyperbolic tilt angle
t2 (numpy masked array) – Second order tilt angle
ta (numpy masked array) – Tilt Based Directional Derivative
tdx (numpy masked array) – Total Derivative
tahg (numpy masked array) – Tilt Angle of the Horizontal Gradient
ehga (numpy masked array) – Enhanced Horizontal Gradient Amplitude
- pygmi.mag.dataprep.vertical(data, npts=None, xint=1, order=1)¶
Vertical derivative.
- Based on work by Gordon Cooper (School of Geosciences, University of the
Witwatersrand, Johannesburg, South Africa).
- Parameters:
data (numpy array) – Input data.
npts (int, optional) – Number of points. The default is None.
xint (float, optional) – X interval. The default is 1.
order (int) – Order of derivative. The default is 1.
- Returns:
dz – Output data
- Return type:
numpy array
pygmi.mag.igrf module¶
IGRF calculations.
This code is based on the GEOMAG software, with information given below. It was translated into Python from the GEOMAG code.
- class pygmi.mag.igrf.IGRF(parent=None)¶
Bases:
BasicModule
IGRF field calculation.
This produces two datasets. The first is an IGRF dataset for the area of interest, defined by some input magnetic dataset. The second is the IGRF corrected form of that input magnetic dataset.
To do this, the input dataset must be reprojected from its local projection to degrees, where the IGRF correction will take place. This is done within this class.
- Parameters:
altmin (Double) – Minimum height of selected model.
altmax (Double array) – array of MAXMOD Maximum height of model.
maxalt (Double) – Maximum height of selected model.
d (float) – Declination of the field from the geographic north (deg).
sdate (float) – start date inputted
ddot (float) – annual rate of change of decl. (arc-min/yr)
alt (float) – altitude above WGS84 Ellipsoid
epoch (list) – list of MAXMOD epoch of model.
latitude (float) – Latitude.
longitude (float) – Longitude.
gh (numpy array) – Schmidt quasi-normal internal spherical harmonic coeff. Schmidt quasi-normal internal spherical harmonic coeff. Coefficients of resulting model. Coefficients of rate of change model.
i (float) – Inclination (deg).
idot (float) – Rate of change of i (arc-min/yr).
igdgc (int) – Flag for geodetic or geocentric coordinate choice.
irec_pos (int array) – array of MAXMOD Record counter for header
fileline (int) – Current line in file (for errors)
max1 (list, int) – array of MAXMOD Main field coefficient.
max2 (list, int) – array of MAXMOD Secular variation coefficient.
max3 (list, int) – array of MAXMOD Acceleration coefficient.
minyr (float) – Min year of all models
maxyr (float) – Max year of all models
yrmax (list, float) – array of MAXMOD Max year of model.
yrmin (list, float) – array of MAXMOD Min year of model.
- 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.
- pygmi.mag.igrf.calc_igrf(data, sdate, alt=100, wkt=None, igrfonly=True, piter=<built-in function iter>, showlog=<built-in function print>)¶
Calculate IGRF.
- Parameters:
data (PyGMI Data) – Input magnetic data.
sdate (Date) – Survey date.
alt (float, optional) – Sensor clearance. The default is 100.
wkt (str, optional) – WKT projection. The default is None.
igrfonly (bool, optional) – Output IGRF only. The default is True.
piter (function, optional) – Progress bar iterator. The default is iter.
showlog (function, optional) – Display information. The default is print.
- Returns:
outdata (list of PyGMI Data.) – Output PyGMI Data.
fmean (float) – Total intensity mean.
imean (float) – Inclination mean.
dmean (float) – Declination mean.
- pygmi.mag.igrf.dihf(x, y, z)¶
Compute the geomagnetic d, i, h, and f from x, y, and z.
This updates self.d, self.i, self.h and self.f (declination, inclination, horizontal intensity and total intensity).
FORTRAN : A. Zunde, USGS, MS 964, box 25046 Federal Center, Denver,CO. 80225C : C. H. Shaffer, Lockheed Missiles and Space Company, Sunnyvale CA- Parameters:
x (float) – northward component
y (float) – eastward component
z (float) – vertically-downward component
- Returns:
h (float) – Horizontal Intensity
f (float) – Total Intensity
i (float) – Inclination
d (float) – Declination
- pygmi.mag.igrf.extrapsh(date, dte1, nmax1, nmax2, igh, gh)¶
Extrapolate a spherical harmonic model.
Extrapolates linearly a spherical harmonic model with a rate-of-change model. Updates Schmidt quasi-normal internal spherical harmonic coefficients.
FORTRAN : A. Zunde, USGS, MS 964, box 25046 Federal Center, Denver,CO. 80225C : C. H. Shaffer, Lockheed Missiles and Space Company, Sunnyvale CA- Parameters:
date (float) – date of resulting model (in decimal year)
dte1 (float) – date of base model
nmax1 (int) – maximum degree and order of base model
nmax2 (int) – maximum degree and order of rate-of-change model
gh (numpy array) – Schmidt quasi-normal internal spherical harmonic coefficients of base model and rate-of-change model
- Returns:
nmax (int) – maximum degree and order of resulting model
gh (numpy array) – Schmidt quasi-normal internal spherical harmonic coefficients of base model and rate-of-change model
- pygmi.mag.igrf.getshc(file, iflag, strec, nmax_of_gh, igh, gh)¶
Read spherical harmonic coefficients from the specified model.
Reads spherical harmonic coefficients from the specified model into an array (Schmidt quasi-normal internal spherical harmonic coefficients).
FORTRAN: Bill Flanagan, NOAA CORPS, DESDIS, NGDC, 325 Broadway,Boulder CO. 80301C: C. H. Shaffer, Lockheed Missiles and Space Company, Sunnyvale CA- Parameters:
file (file) – reference to a file object
iflag – Flag for SV equal to 1 or not equal to 1 for designated read statements
strec (int) – Starting record number to read from model
nmax_of_gh (int) – Maximum degree and order of model
igh (int) – Index for Schmidt quasi-normal internal spherical harmonic coefficients.
gh (numpy array) – Schmidt quasi-normal internal spherical harmonic coefficients.
- Returns:
gh – Schmidt quasi-normal internal spherical harmonic coefficients.
- Return type:
numpy array
- pygmi.mag.igrf.interpsh(date, dte1, nmax1, dte2, nmax2, igh, gh)¶
Temporal Interpolation between two spherical harmonic models.
Interpolates linearly, in time, between two spherical harmonic models.
Updates Schmidt quasi-normal internal spherical harmonic coefficients.
FORTRAN : A. Zunde, USGS, MS 964, box 25046 Federal Center, Denver,CO. 80225C : C. H. Shaffer, Lockheed Missiles and Space Company, Sunnyvale CA- Parameters:
date (float) – date of resulting model (in decimal year)
dte1 (float) – date of earlier model
nmax1 (int) – maximum degree and order of earlier model
dte2 (float) – date of later model
nmax2 (int) – maximum degree and order of later model
gh (numpy array) – Schmidt quasi-normal internal spherical harmonic coefficients of earlier model and internal model
- Returns:
nmax (int) – maximum degree and order of resulting model
gh (numpy array) – Schmidt quasi-normal internal spherical harmonic coefficients of earlier model and internal model
- pygmi.mag.igrf.shval3(igdgc, flat, flon, elev, nmax, igh, gh)¶
Calculate field components from spherical harmonic (sh) models.
This routine updates self.x, self.y, self.z (Northward, Eastward and vertically downward components respectively NED)
Based on subroutine ‘igrf’ by D. R. Barraclough and S. R. C. Malin, report no. 71/1, institute of geological sciences, U.K.
FORTRAN : Norman W. Peddie, USGS, MS 964, box 25046 Federal Center,Denver, CO. 80225C : C. H. Shaffer, Lockheed Missiles and Space Company, Sunnyvale CA- Parameters:
igdgc (int) – indicates coordinate system used set equal to 1 if geodetic, 2 if geocentric
flat (float) – north latitude, in degrees
flon (float) – east longitude, in degrees
elev (float) – WGS84 altitude above ellipsoid (igdgc=1), or radial distance from earth’s center (igdgc=2)
nmax (int) – maximum degree and order of coefficients
gh (numpy array) – Schmidt quasi-normal internal spherical harmonic coefficients of earlier model and internal model
- Returns:
x (float) – Northward component (NED)
y (float) – Eastward component (NED)
z (float) – Vertically downward component (NED)
pygmi.mag.tiltdepth module¶
Tilt Depth Routine.
Based on work by EH Stettler
References
Salem et al., 2007, Leading Edge, Dec,p1502-5
- class pygmi.mag.tiltdepth.TiltDepth(parent=None)¶
Bases:
BasicModule
Primary class for the Tilt Depth.
- self.mmc¶
main canvas containing the image
- Type:
FigureCanvas
- calculate()¶
Routine which occurs when apply button is pressed.
- Return type:
None.
- change_cbar()¶
Change the colour map for the colour bar.
- Return type:
None.
- rtp_choice()¶
Check if RTP must be done.
- Return type:
None.
- save_depths()¶
Save depths.
- 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.
- tiltdepth(data)¶
Calculate tilt depth.
Output is stored in self.outdata.
- Parameters:
data (PyGMI Data.) – PyGMI raster dataset.
- Return type:
None.
- pygmi.mag.tiltdepth.distpc(dx, dy, dx0, dy0, dcnt)¶
Find closest distances.
- Parameters:
dx (numpy array) – X array.
dy (numpy array) – Y array.
dx0 (float) – X point to measure distance from.
dy0 (float) – Y point to measure distance from.
dcnt (int) – Starting index to measure distance from.
- Returns:
dcnt – Index of closest distance found in x and y arrays.
- Return type:
int
- pygmi.mag.tiltdepth.vgrad(cnt)¶
Get contour gradients at vertices.
- Parameters:
cnt (axes.contour) – Output from Matplotlib’s axes.contour.
- Returns:
gx (numpy array) – X gradients.
gy (numpy array) – Y gradients.
cgrad (numpy array) – Contour gradient.
cntid (numpy array) – Contour index.
Module contents¶
Magnetic Routines