def load():
    """Read data from a text file on disk."""
    # Get the data file relative to this file's location...
    datadir = os.path.dirname(__file__)
    filename = os.path.join(datadir, 'angelier_data.txt')

    data = []
    with open(filename, 'r') as infile:
        for line in infile:
            # Skip comments
            if line.startswith('#'):
                continue

            # First column: strike, second: dip, third: rake.
            strike, dip, rake = line.strip().split()

            if rake[-1].isalpha():
                # If there's a directional letter on the rake column, parse it
                # normally.
                strike, dip, rake = mplstereonet.parse_rake(strike, dip, rake)
            else:
                # Otherwise, it's actually an azimuthal measurement of the
                # slickenslide directions, so we need to convert it to a rake.
                strike, dip = mplstereonet.parse_strike_dip(strike, dip)
                azimuth = float(rake)
                rake = mplstereonet.azimuth2rake(strike, dip, azimuth)

            data.append([strike, dip, rake])

    # Separate the columns back out
    strike, dip, rake = zip(*data)
    return strike, dip, rake
def load():
    """Read data from a text file on disk."""
    # Get the data file relative to this file's location...
    datadir = os.path.dirname(__file__)
    filename = os.path.join(datadir, 'angelier_data.txt')

    data = []
    with open(filename, 'r') as infile:
        for line in infile:
            # Skip comments
            if line.startswith('#'):
                continue

            # First column: strike, second: dip, third: rake.
            strike, dip, rake = line.strip().split()

            if rake[-1].isalpha():
                # If there's a directional letter on the rake column, parse it
                # normally.
                strike, dip, rake = mplstereonet.parse_rake(strike, dip, rake)
            else:
                # Otherwise, it's actually an azimuthal measurement of the
                # slickenslide directions, so we need to convert it to a rake.
                strike, dip = mplstereonet.parse_strike_dip(strike, dip)
                azimuth = float(rake)
                rake = mplstereonet.azimuth2rake(strike, dip, azimuth)

            data.append([strike, dip, rake])

    # Separate the columns back out
    strike, dip, rake = zip(*data)
    return strike, dip, rake
Exemple #3
0
 def test_parse_strike(self):
     data = [
         [('N30E', '45NW'), (210, 45)],
         [('210', '45'), (210, 45)],
         [('E10N', '20NW'), (260, 20)],
         [('350', '40W'), (170, 40)],
         [('280', '30SW'), (100, 30)],
         [('280', '30 SW'), (100, 30)],
     ]
     for test, correct in data:
         result = mplstereonet.parse_strike_dip(*test)
         assert np.allclose(result, correct)
 def test_parse_strike(self):
     data = [
             [('N30E', '45NW'), (210, 45)],
             [('210', '45'),    (210, 45)],
             [('E10N', '20NW'), (260, 20)],
             [('350', '40W'),   (170, 40)],
             [('280', '30SW'),  (100, 30)],
             [('280', '30 SW'),  (100, 30)],
            ]
     for test, correct in data:
         result = mplstereonet.parse_strike_dip(*test)
         assert np.allclose(result, correct)
Exemple #5
0
    def dirToAz(self, table, dipazimut=False, rule='right_hand_rule'):
        """Converte Direction of linear structure in Strike according to a right hand rule
        Input: (table,dipazimut,rule)
            table: tabular data like csv, excel, it may contain direction, dip and plunge of structure
            dipazimut: default False, does the structure data contain plunge to calculate dipazimut
            rule: default right_hand_rule, the methode to determinate strike of linear structure
        Output: tabular data with correct linear structutre
        """
        if table.endswith('.csv') or table.endswith('.txt'):
            pts = pd.read_csv(table)  # Import csv data
        else:
            print 'Error, tabular data structure not reconized, Please import csv or excel file'

        aztxt = np.char.array(
            pts['az'].values)  # converte azimut to text like 50 to 'N50'
        diptxt = np.char.array(
            pts['dip'].values)  # converte dip to text like 50 to '50'
        pts['txt'] = aztxt + ',' + diptxt + pts.plg
        strikes, dips = zip(*[
            mste.parse_strike_dip(*s.strip().split(',')) for s in pts.txt if s
        ])
        pts['stk'] = strikes
        if True == dipazimut:
            # Calculate dipazimut according to the value of strike
            mask = pts.stk > 270
            pts.loc[
                mask,
                'dipaz'] = pts.stk - 270  # Where strike>270, dipaz = strike+90-360
            pts.loc[
                ~mask,
                'dipaz'] = pts.stk + 90  # Where strike<270, dipaz = strike+90-360
        self.pts = pts
        try:
            pts['ln'] = 5 * pts['thn']  #calculate the length of polyline
            pts['lnc'] = -1 * pts[
                'ln']  #calculate the opposite length of polyline
            pts['dipln'] = 0.01 + pts['ln'] * (90 - pts['dip']) * (0.5 / 90)
        except Exception as e:
            raise e
        # Export pts tabular data to csv file
        try:
            pts.to_csv('geospatiale/Input/DirazCalculated.csv')
            print "Your linear structure file is succesfully created"
            print "At  Input/DirazCalculated.csv' as tabular data"
            print 'Please check it and make change as you like'
        except Exception as e:
            raise e
        return self.pts
def parse_sd(original, seperator):
    strike, dip = mplstereonet.parse_strike_dip(*original.split(seperator))
    print('"{}" --> Strike: {:.1f}, Dip: {:.1f}'.format(original, strike, dip))
Exemple #7
0
        label='Intersection %02d/%03d' % (plunge, bearing))
ax.legend()
# we can also ad the grid
ax.grid()
fig

# -- Fold
fold_mesurements = '''
  N 88 E, 16 N
  N 66 E, 30 NW
  N 60 E, 45 NW
  N 41 E, 50 SE
  N 35 E, 35 SE
  N 20 E, 20 E
'''
strikes, dips = zip(*[mplstereonet.parse_strike_dip(*s.strip().split(','))
for s in fold_mesurements.split('\n') if s])
strikes, dips

from collections import OrderedDict
fig = plt.figure(figsize=(10,8))

# Method 1
ax = fig.add_subplot(121, projection='stereonet')
ax.plane(strikes, dips, c='k', label='Planes (Fold Limbs)')
strike, dip = mplstereonet.fit_girdle(strikes,dips)
ax.pole(strike, dip, c='r', label='Beta axis (Intersection of Planes)')

# Method 2
ax = fig.add_subplot(122, projection='stereonet')
ax.pole(strikes, dips, c='k', label='Planes (Fold Limbs)')
Exemple #8
0
import mplstereonet
import matplotlib.pyplot as plt

#Transforme fault to dip/trende data
#
#strikes, dips = zip(*[mplstereonet.parse_strike_dip(*s.strip().split(','))
#for s in faults.split('\n') if s])

#strikes, dips = zip(*[mplstereonet.parse_strike_dip(*s.strip().split(','))
#for s in bdk_faults.split('\n') if s])

#strikes, dips = zip(*[mplstereonet.parse_strike_dip(*s.strip().split(','))
#for s in bdk_fault_mine.split('\n') if s])

strikes, dips = zip(*[
    mplstereonet.parse_strike_dip(*s.strip().split(','))
    for s in trik.split('\n') if s
])

strikes, dips

fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111, projection='stereonet')
ax.plane(strikes, dips, c='k', label='Fault system')
strike, dip = mplstereonet.fit_girdle(strikes, dips)
ax.pole(strike, dip, c='r', label='Pole of Fault plane')

# Calculate the number of directions (strikes) every 10° using numpy.histogram
bin_edges = np.arange(-5, 366, 10)
number_of_strikes, bin_edges = np.histogram(strikes, bin_edges)