mplstereonet Documentation

repository·master·Indexed 41 days ago

https://github.com/joferkington/mplstereonet

A Matplotlib extension for plotting and analyzing structural orientation data using lower-hemisphere equal-area and equal-angle stereonets. It provides tools for plotting planes, poles, lines, and rakes, generating orientation density contours, parsing structural measurements, and performing data analysis such as fitting planes to girdles and calculating flattening values for Flinn plots.

Tokens
1.2K
Snippets
5
Records
6
Agent score
3%

What's inside mplstereonet

  1. Perform orientation data analysis

    master

    Beyond plotting, mplstereonet provides analytical tools for structural data, including:

    • Fitting planes to girdles.
    • Fitting a pole to a set of points.
    • Identifying modes of conjugate fault sets (e.g., via K-means).
    • Calculating flattening values for Flinn plots using eigenvectors.
  2. Create a stereonet axes

    master

    To use mplstereonet, you must create axes with the projection='stereonet' argument. By default, this creates an equal-area stereonet. Alternatively, you can use mplstereonet.subplots(), which behaves like matplotlib.pyplot.subplots() but returns stereonet axes.

    import matplotlib.pyplot as plt
    import mplstereonet
    
    # Method 1: Using add_subplot
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='stereonet')
    
    # Method 2: Using mplstereonet.subplots
    fig, ax = mplstereonet.subplots()
  3. Install mplstereonet

    master

    You can install mplstereonet via PyPI using pip, or install from source locally. For development, use the develop mode to ensure changes are reflected immediately upon import.

    # Install from PyPI
    pip install mplstereonet
    
    # Install from source (from repository root)
    python setup.py install
    
    # Development installation
    python setup.py develop
  4. Plot planes, poles, lines, and rakes

    master

    Once you have a stereonet axes (ax), you can plot various structural elements. Note that all planar measurements must follow the right-hand rule (RHR) to indicate dip direction (e.g., 315/30S should be converted to 135/30).

    import matplotlib.pyplot as plt
    import mplstereonet
    
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='stereonet')
    
    strike, dip = 315, 30
    ax.plane(strike, dip, 'g-', linewidth=2)  # Plot a plane
    ax.pole(strike, dip, 'g^', markersize=18) # Plot a pole to the plane
    ax.rake(strike, dip, -25)                 # Plot a rake along the plane
    ax.line(plunge, bearing)                 # Plot a line
    ax.grid()
    
    plt.show()
  5. Generate orientation density contours

    master

    You can produce orientation density diagrams using ax.density_contour (lines) or ax.density_contourf (filled contours). To get the raw data, use mplstereonet.density_grid.

    Configuration:

    • measurement: Specifies the type of data (e.g., 'poles').
    • method: The estimation method. Defaults to a modified Kamb method with exponential smoothing. Other options include 'Kamb' and 'Schmidt' (also known as 1%).
    • sigma: Controls the expected count in standard deviations.
    import matplotlib.pyplot as plt
    import numpy as np
    import mplstereonet
    
    fig, ax = mplstereonet.subplots()
    
    strike, dip = 90, 80
    num = 10
    strikes = strike + 10 * np.random.randn(num)
    dips = dip + 10 * np.random.randn(num)
    
    # Create filled density contours
    cax = ax.density_contourf(strikes, dips, measurement='poles')
                                  
    ax.pole(strikes, dips)
    ax.grid(True)
    fig.colorbar(cax)
    
    plt.show()
  6. Parse structural measurements

    master

    The library includes utilities to parse structural measurements in quadrant or azimuth form and convert them to follow the right-hand rule (RHR). This includes parsing quadrant azimuths, strike/dip, and rake measurements.

    # Quadrant azimuth examples
    "N30E" --> 30.0
    "E30N" --> 60.0
    
    # Quadrant strike/dip (outputs RHR)
    "215/10" --> Strike: 215.0, Dip: 10.0
    "215/10E" --> Strike: 35.0, Dip: 10.0
    
    # Rake measurements
    "N30E/45NW 10NE" --> Strike: 210.0, Dip: 45.0, Rake: 170.0