mtwaffle quickstart tutorial


In [1]:
import mtwaffle
!git describe


v0.6

Load a response function from an Electrical Data Interchange (EDI) file:


In [2]:
site = mtwaffle.read_edi('bwa2890.edi')

When data is read in like this it will be loaded into an mtwaffle.mt.Site object. This is a dict-like object with attribute access.

The fundamental data that make up the response function are stored as numpy.ndarrays and can be changed by the user:


In [3]:
site.name


Out[3]:
'bwa2890'

In [4]:
site.freqs


Out[4]:
array([  3.05180000e-02,   4.57760000e-02,   6.10350000e-02,
         2.44140000e-01,   4.88280000e-01,   7.32420000e-01,
         1.46480000e+00,   1.95310000e+00,   2.92970000e+00,
         3.90620000e+00,   5.85940000e+00,   7.81250000e+00,
         1.17190000e+01,   1.56250000e+01,   2.34380000e+01,
         3.12500000e+01,   4.68750000e+01,   6.25000000e+01,
         9.37500000e+01,   1.25000000e+02])

And the impedance tensors:


In [5]:
site.zs


Out[5]:
array([[[ -2.65220 -7.93610000e-01j,   3.88170 +3.11400000e+00j],
        [ -4.35530 -2.89100000e+00j,   2.36610 +5.98250000e-01j]],

       [[ -3.41790 -9.43450000e-01j,   5.60120 +3.07000000e+00j],
        [ -5.70650 -3.17900000e+00j,   2.65310 +7.51900000e-01j]],

       [[ -3.41980 -4.85940000e-01j,   7.18780 +3.00080000e+00j],
        [ -6.82150 -3.17030000e+00j,   2.26560 +9.14630000e-01j]],

       [[ -3.12760 +6.84620000e-02j,  10.28200 +3.05620000e+00j],
        [ -9.20030 -2.94890000e+00j,   2.97610 +2.78910000e-01j]],

       [[ -3.63390 -4.36250000e-01j,  11.35300 +2.62070000e+00j],
        [-10.21700 -2.76610000e+00j,   3.23880 +3.39670000e-01j]],

       [[ -3.65310 -3.70740000e-01j,  11.62500 +2.23880000e+00j],
        [-10.62500 -2.76940000e+00j,   3.33570 +4.11020000e-01j]],

       [[ -3.96470 -5.06570000e-01j,  12.42100 +2.66420000e+00j],
        [-11.68100 -3.31960000e+00j,   3.71790 +1.01220000e-01j]],

       [[ -4.01280 -4.82180000e-01j,  12.71400 +2.76330000e+00j],
        [-12.23000 -3.53420000e+00j,   3.69970 -1.16210000e-02j]],

       [[ -4.21030 -3.76450000e-01j,  13.43900 +3.14200000e+00j],
        [-13.42000 -4.03170000e+00j,   3.71480 -1.32300000e-01j]],

       [[ -4.36360 -2.91860000e-01j,  14.21400 +3.38170000e+00j],
        [-14.34500 -4.11050000e+00j,   3.62930 -3.15410000e-01j]],

       [[ -4.65650 -2.08420000e-01j,  15.30700 +3.82480000e+00j],
        [-15.98200 -4.35620000e+00j,   3.72380 -4.93620000e-01j]],

       [[ -4.72140 +2.77860000e-01j,  15.65300 +4.02700000e+00j],
        [-16.42600 -4.41240000e+00j,   3.66580 -9.93650000e-02j]],

       [[ -4.72170 +3.47040000e-01j,  17.06100 +4.37430000e+00j],
        [-17.75300 -4.56480000e+00j,   3.59650 -1.12400000e+00j]],

       [[ -4.40210 +6.35220000e-01j,  17.16200 +4.95270000e+00j],
        [-17.46200 -5.03490000e+00j,   3.23340 -8.70510000e-01j]],

       [[ -4.22560 +9.59350000e-01j,  18.21800 +5.65410000e+00j],
        [-18.55600 -5.65960000e+00j,   3.00660 -1.19500000e+00j]],

       [[ -3.87020 +1.20040000e+00j,  19.14000 +6.36200000e+00j],
        [-19.44800 -6.24590000e+00j,   2.69070 -1.37230000e+00j]],

       [[ -3.37160 +1.27710000e+00j,  20.22100 +7.57110000e+00j],
        [-20.34000 -7.55140000e+00j,   2.22630 -1.62440000e+00j]],

       [[ -2.97520 +1.22270000e+00j,  21.31100 +8.90530000e+00j],
        [-21.28600 -8.99570000e+00j,   1.83110 -1.73950000e+00j]],

       [[ -2.40590 +9.77800000e-01j,  23.01900 +1.09240000e+01j],
        [-22.89600 -1.15340000e+01j,   1.23920 -1.70480000e+00j]],

       [[ -2.35290 +2.74900000e-01j,  24.17900 +1.46800000e+01j],
        [-23.80700 -1.51410000e+01j,   0.93289 -1.78430000e+00j]]])

Other properties are lazy i.e. they are calculated when they are accessed:


In [6]:
site.res_xy


Out[6]:
array([ 162.29497929,  178.25210346,  198.80157116,   94.25729699,
         55.60689665,   38.27116967,   22.03429856,   17.33466007,
         13.00330307,   10.92999288,    8.49688856,    6.68756833,
          5.29417564,    4.08401256,    3.10490973,    2.60361372,
          1.98916436,    1.70708189,    1.38497736,    1.28020231])

Attributes are also available through item-style access, as mtwaffle.mt.Site is inherited from attrdict.AttrDict (more info):


In [7]:
site['phase_yx']


Out[7]:
array([ 33.57576734,  29.12148116,  24.92670354,  17.77180592,
        15.1488215 ,  14.60906321,  15.86451347,  16.11812646,
        16.72156801,  15.98943468,  15.2466853 ,  15.03600958,
        14.4199947 ,  16.08410546,  16.96176239,  17.80488821,
        20.36787694,  22.90945926,  26.73695999,  32.45592854])

A complete list of the attributes available for an mtwaffle.Site object can be produced using the site.help() method:


In [8]:
site.help()


Attributes of mtwaffle.mtsite.Site are calculated using functions from the mtwaffle.mt module:

 mtsite.Site         mtwaffle.mt function
  attribute       (args are Site attributes)                  Function description
--------------  ------------------------------  ----------------------------------------------
appres          appres(zs, freqs)               Convert imp. tensor(s) (mV/km/nT) to apparent resistivity(s) (ohm.m).
bostick         bostick(freqs, appres, phases)  Bostick transform of imp. tensor(s) - returns tuple (depths, resistivities).
inv_imag_sign   inv_imag_sign(zs)               Invert sign of imaginary parts of imp. tensor(s).
mV_km_nT2ohms   mV_km_nT2ohms(zs)               Convert imp. tensor(s) from mV/km/nT to ohms
normfreqs       normfreqs(zs, freqs)            Normalise imp. tensor(s) magnitude by multiplying by sqrt(period).
ohms2mV_km_nT   ohms2mV_km_nT(zs)               Convert imp. tensor(s) from ohms to mV/km/nT.
phase           phase(zs)                       Phase of imp. tensor(s) - calculated in the first quadrant.
phase2          phase2(zs)                      Phase of imp. tensor(s) - calculated with quadrant information preserved.
phase_abs       phase_abs(zs)                   Phase of imp. tensor(s) - forced into the first quadrant.
ptens_alpha     ptens_alpha(ptensors)           Phase tensor(s) alpha angle (Caldwell 2004).
ptens_azimuth   ptens_azimuth(zs)               Rotation azimuth of phase tensor(s) such that diags are max-ed & Pxx > Pyy.
ptens_beta      ptens_beta(ptensors)            Phase tensor(s) beta angle (Caldwell 2004).
ptens_max       ptens_max(ptensors)             Maximum angle of phase tensor(s) (Caldwell 2004, A9).
ptens_min       ptens_min(ptensors)             Minimum angle of phase tensor(s) (Caldwell 2004, A8).
ptens_normskew  ptens_normskew(zs)              Normalised phase tensor skew(s) of Booker (2012).
ptens_skew      ptens_skew(ptensors)            Skew angle of phase tensor(s) (Caldwell 2004).
ptens_vectors   ptens_vectors(ptensors)         Return n_theta vectors for phase tensor/s around the unit circle.
ptensors        ptensors(zs)                    Calculate phase tensor(s) for imp. tensor(s) (Caldwell 2004).
theta_es        theta_es(zs)                    Electric strike of impedance tensors (Lilley 1998).
theta_hs        theta_hs(zs)                    Magnetic strike of impedance tensors (Lilley 1998).

In case it is not clear, here is an example. For this site we can apply the Bostick transform to obtain a list of the depths from the transform, and the resistivities:


In [9]:
depths, res = site.bostick

And now check the xy values:


In [10]:
depths[:, 0, 1]


Out[10]:
array([ 25917.42983956,  22177.66581258,  20283.26455507,   6983.21549348,
         3792.68945959,   2569.05376823,   1378.40827824,   1058.7973563 ,
          748.74285369,    594.49762655,    427.97737552,    328.81871257,
          238.8753404 ,    181.6983339 ,    129.35452853,    102.5842502 ,
           73.21197411,     58.73603037,     43.19695382,     35.96679334])

In [11]:
res[:, 0, 1]


Out[11]:
array([ 214.77084608,  380.2023934 ,  590.79819084,  418.19922404,
        329.41400781,  277.70555103,  141.77586806,  109.89628032,
         75.93052208,   62.57584196,   46.01172905,   35.03032577,
         27.83959644,   18.74966943,   13.10204006,   10.14087511,
          6.7323757 ,    5.06744107,    3.52487843,    2.40519142])

This is actually calculated behind the scenes using a stand-alone function from mtwaffle.mt, as described in the list just above. We can do the same manually to illustrate the process:


In [12]:
depths_xy, res_xy = mtwaffle.bostick(site.freqs, site.res_xy, site.phase_xy)

In [13]:
depths_xy


Out[13]:
array([ 25917.42983956,  22177.66581258,  20283.26455507,   6983.21549348,
         3792.68945959,   2569.05376823,   1378.40827824,   1058.7973563 ,
          748.74285369,    594.49762655,    427.97737552,    328.81871257,
          238.8753404 ,    181.6983339 ,    129.35452853,    102.5842502 ,
           73.21197411,     58.73603037,     43.19695382,     35.96679334])

There are many more functions in mtwaffle.mt, but they are often only intermediary properties which are not often of interest. You can use them all manually, check the documention for more information by running help(mtwaffle.mt).

Canned graphs


In [14]:
%matplotlib nbagg

Graphing functions are also wrapped from mtwaffle.graphs:


In [15]:
site.plot_impedance_tensors()



In [16]:
axreal, aximag = site.plot_mohr_imp()



In [17]:
site.plot_ptensell()



In [18]:
site.plot_ptensell_filled(site.ptens_max)



In [19]:
site.plot_mohr_ptensor()



In [20]:


In [20]: