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
Beispiel #3
0
 def test_parse_rake(self):
     data = [
         [('N30E', '45NW', '10NE'), (210, 45, 170)],
         [('N30E', '45NW', '10SW'), (210, 45, 10)],
         [('210', '45', '10'), (210, 45, 10)],
         [('210', '45', '-10'), (210, 45, 170)],
         [('210', '45', '170'), (210, 45, 170)],
         [('E10N', '20NW', '80E'), (260, 20, 100)],
         [('E10N', '20NW', '100'), (260, 20, 100)],
         [('E10N', '20NW', '80W'), (260, 20, 80)],
         [('E10N', '20NW', '-80'), (260, 20, 100)],
         [('350', '40W', '45N'), (170, 40, 135)],
         [('350', '40W', '45S'), (170, 40, 45)],
         [('280', '30SW', '30E'), (100, 30, 30)],
         [('280', '30SW', '30W'), (100, 30, 150)],
     ]
     for test, correct in data:
         result = mplstereonet.parse_rake(*test)
         assert np.allclose(result, correct)
 def test_parse_rake(self):
     data = [
             [('N30E', '45NW', '10NE'),  (210, 45, 170)],
             [('N30E', '45NW', '10SW'),  (210, 45, 10)],
             [('210', '45', '10'),       (210, 45, 10)],
             [('210', '45', '-10'),      (210, 45, 170)],
             [('210', '45', '170'),      (210, 45, 170)],
             [('E10N', '20NW', '80E'),   (260, 20, 100)],
             [('E10N', '20NW', '100'),   (260, 20, 100)],
             [('E10N', '20NW', '80W'),   (260, 20, 80)],
             [('E10N', '20NW', '-80'),   (260, 20, 100)],
             [('350', '40W', '45N'),     (170, 40, 135)],
             [('350', '40W', '45S'),     (170, 40, 45)],
             [('280', '30SW', '30E'),    (100, 30, 30)],
             [('280', '30SW', '30W'),    (100, 30, 150)],
            ]
     for test, correct in data:
         result = mplstereonet.parse_rake(*test)
         assert np.allclose(result, correct)
def display_rake(original, sep1, sep2=None):
    components = split_rake(original, sep1, sep2)
    strike, dip, rake = mplstereonet.parse_rake(*components)
    template = '"{}" --> Strike: {:.1f}, Dip: {:.1f}, Rake: {:.1f}'
    print(template.format(original, strike, dip, rake))