Read EDI file and plot response

import modules


In [9]:
%matplotlib inline

In [2]:
import mtpy.core.mt as mt

In [3]:
edi_fn = r"c:\Users\jpeacock\Documents\GitHub\mtpy\examples\data\edi_files\pb40c.edi"
mt_obj = mt.MT(edi_fn)


 ...nulled all attributes of current MTedi.Edi instance.
reading in Edi file: c:\Users\jpeacock\Documents\GitHub\mtpy\examples\data\edi_files\pb40c.edi
C:\Python27\lib\site-packages\mtpy\analysis\zinvariants.py:214: RuntimeWarning: invalid value encountered in arcsin
  strikeangerr = abs(.5*np.arcsin(inv7))*(180/np.pi)

If you need help


In [5]:
help(mt_obj)


Help on MT in module mtpy.core.mt object:

class MT(__builtin__.object)
 |  Basic object containing all information necessary for a single MT station
 |  including:
 |  
 |  ===================== =====================================================
 |  **Attribute**         Description
 |  ===================== =====================================================
 |  name                  station name
 |  lat                   station latitude in decimal degrees
 |  lon                   station longitude in decimal degrees
 |  elev                  station elevation in meters
 |  Z                     mtpy.core.z.Z object for impedance tensor
 |  Tipper                mtpy.core.z.Tipper object for tipper
 |  date                  date collected
 |  east                  station location in UTM coordinates assuming WGS-84
 |  north                 station location in UTM coordinates assuming WGS-84 
 |  utm_zone              zone of UTM coordinates assuming WGS-84
 |  ===================== =====================================================
 |      
 |  .. note:: 
 |      * can change the utm grid by changing _utm_ellipsoid.  See 
 |        mtpy.utils.latlongutmconversion for details on reference 
 |        ellipsoids
 |      
 |      * currently the information is assumed to come from an edi file
 |        but can be extended later to .j files or something else or can
 |        be input by hand
 |            
 |      * if you set the coordinates east, north or utm_zone, be sure to 
 |        run _get_ll() to recalculate the latitude and longitude.
 |        
 |      * can input the following key words to fill values in Z and Tipper:
 |          - z_object        --> mtpy.core.z.Z object
 |          - z_array         --> np.ndarray(n_freq, 2, 2, dtype='complex')
 |          - zerr_array      --> np.ndarray(n_freq, 2, 2)
 |          - freq            --> np.ndarray(n_freq)
 |          - resistivity     --> np.ndarray(n_freq, 2, 2) (linear scale)
 |          - resistivity_err --> np.ndarray(n_freq, 2, 2) 
 |          - phase           --> np.ndarray(n_freq, 2, 2)           
 |          - phase_err       --> np.ndarray(n_freq, 2, 2) 
 |          - tipper_object   --> mtpy.core.z.Tipper object
 |          - tipper          --> np.ndarray(n_freq, 1, 2, dtype='complex') 
 |          - tippererr       --> np.ndarray(n_freq, 1, 2)
 |      
 |  ===================== =====================================================
 |  **methods**           Description
 |  ===================== =====================================================
 |  write_edi_file        write an edi_file from the MT data
 |  remove_distortion     remove distortion from the data following 
 |                        Bibby et al. [2005]
 |  interpolate           interpolates the impedance tensor and induction
 |                        vectors onto a specified frequency array.
 |  plot_mt_response      plots the MT response using mtpy.imaging.plotresponse
 |  ===================== =====================================================
 |  
 |  
 |  Examples
 |  -------------------
 |  
 |  * Plot MT response:
 |  
 |      >>> import mtpy.core.mt as mt
 |      >>> mt_obj = mt.MT(r"/home/edi_files/s01.edi")
 |      >>> # plot all components of mt response and phase tensor
 |      >>> plot_obj = mt_obj.plot_mt_response(plot_num=2, plot_pt='y')        
 |      >>> # plot the tipper as well
 |      >>> plot_obj.plot_tipper = 'yri'
 |      >>> plot_obj.redraw_plot()
 |    
 |   * Remove Distortion:
 |       
 |      >>> import mtpy.core.mt as mt
 |      >>> mt_obj = mt.MT(r"/home/edi_files/s01.edi")
 |      >>> D, new_z = mt_obj.remove_distortion()
 |      >>> print D
 |      np.array([[0.1, .9],
 |                [0.98, .43]])
 |      >>> # write a new edi file
 |      >>> mt_obj.write_edi_file(new_Z=new_z)
 |      wrote file to: /home/edi_files/s01_RW.edi
 |      
 |   * Interpolate:
 |   
 |      >>> import mtpy.core.mt as mt
 |      >>> mt_obj = mt.MT(r"/home/edi_files/s01.edi")
 |      >>> new_freq = np.logspace(-3, 3, num=24)
 |      >>> new_z_obj, new_tipper_obj = mt_obj.interpolate(new_freq)
 |      >>> mt_obj.write_edi_file(new_Z=new_z_obj, new_Tipper=new_tipper_obj)
 |      wrote file to: /home/edi_files/s01_RW.edi
 |  
 |  Methods defined here:
 |  
 |  __init__(self, fn=None, **kwargs)
 |  
 |  interpolate(self, new_freq_array)
 |      interpolate the impedance tensor onto different frequencies.
 |      
 |      **Arguments**
 |      
 |          *new_freq_array* : np.ndarray 
 |                             a 1-d array of frequencies to interpolate on
 |                             to.  Must be with in the bounds of the existing
 |                             frequency range, anything outside and an error
 |                             will occur.
 |                             
 |      **Returns** :
 |          *new_z_object* : mtpy.core.z.Z object
 |                           a new impedance object with the corresponding
 |                           frequencies and components.
 |                           
 |          *new_tipper_object* : mtpy.core.z.Tipper object
 |                           a new tipper object with the corresponding
 |                           frequencies and components.
 |                           
 |      
 |      :Example: ::
 |          >>> # make a new edi file for interpolated frequencies 
 |          >>> import mtpy.core.mt as mt
 |          >>> edi_fn = r"/home/edi_files/mt_01.edi"
 |          >>> mt_obj = mt.MT(edi_fn)
 |          >>> # create a new frequency range to interpolate onto
 |          >>> new_freq = np.logspace(-3, 3, 24)
 |          >>> new_z_object, new_tipper_obj = mt_obj.interpolate(new_freq)
 |          >>> mt_obj.write_edi_file(new_fn=r"/home/edi_files/mt_01_interp.edi",
 |          >>>                       new_Z=new_z_object,
 |          >>>                       new_Tipper=new_tipper_object)
 |  
 |  plot_mt_response(self, **kwargs)
 |      returns a mtpy.imaging.plotresponse.PlotResponse object
 |      
 |      :Example: ::
 |          >>> mt_obj = mt.MT(edi_file)
 |          >>> pr = mt.plot_mt_response()
 |          >>> # if you need more infor on plot_mt_response 
 |          >>> help(pr)
 |  
 |  remove_distortion(self)
 |      remove distortion following Bibby et al. [2005].
 |      
 |      if you want to write a new edi file with distortion removed you can 
 |      do this by:
 |      
 |          >>> import mtpy.core.mt as mt
 |          >>> mt1 = mt.MT(fn=r"/home/mt/edi_files/mt01.edi")
 |          >>> D, new_z = mt1.remove_distortion()
 |          >>> mt1.write_edi_file(new_fn=r"/home/mt/edi_files/mt01_dr.edi",                                   new_Z=new_z)
 |  
 |  write_edi_file(self, new_fn=None, new_Z=None, new_Tipper=None)
 |      write a new edi file if things have changed.  Note if new_Z or
 |      new_Tipper are not None, they are not changed in MT object, you
 |      need to change them manually if you want them to be changed.
 |      Similarly, the new function name does not change the MT objecte fn
 |      attribute but does change MT.edi_object.fn attribute.
 |      
 |      **Arguments**:
 |          
 |          *new_fn* : string
 |                     full path to new file name
 |                     
 |          *new_Z* : mtpy.core.Z object
 |                    a new impedance tensor object to be written
 |                    
 |          *new_Tipper* : mtpy.core.Z.Tipper object
 |                         a new Tipper object to be written
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  
 |  Tipper
 |      Tipper object
 |  
 |  Z
 |      impedence tensor object
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)
 |  
 |  east
 |      easting in meters of station location on UTM grid
 |  
 |  elev
 |      elevation in meters
 |  
 |  fn
 |      name of file containing MT info
 |  
 |  lat
 |      latitude of station in decimal degrees
 |  
 |  lon
 |      longitude of station in decimal degrees
 |  
 |  north
 |      northing in meters of station location on UTM grid
 |  
 |  rotation_angle
 |      rotation angle of Z and Tipper
 |  
 |  utm_zone
 |      UTM zone

plot mt response


In [10]:
mt_plot = mt_obj.plot_mt_response()


 ...nulled all attributes of current MTedi.Edi instance.
reading in Edi file: c:\Users\jpeacock\Documents\GitHub\mtpy\examples\data\edi_files\pb40c.edi

plot phase tensors


In [11]:
mt_plot.plot_pt = 'y'
mt_plot.redraw_plot()


plot strike angle


In [12]:
mt_plot.plot_strike = 'ytip'
mt_plot.redraw_plot()