def test_fit_girdle(self): for strike in range(0, 370, 10): for dip in range(0, 100, 10): lon, lat = mplstereonet.plane(strike, dip) strikes, dips = mplstereonet.geographic2pole(lon, lat) s, d = mplstereonet.fit_girdle(strikes, dips) self.compare_strikedip(strike, dip, s, d)
def fisher_rvs(kappa, data_size, resultant_orien, form='azimuth'): """ randomly sampling vectors :param kappa: float -fisher constant :param data_size: int -the length of simulated vectors :param resultant_orien: (float, float) -the strike and dip of resultant orientation :param form:'azimuth' or 'geographic' -'azimuth' generate samples in the format of (strike, dip) -'geographic' generate samples in the format of (lon, lat) :return: """ y = np.random.uniform(0, 1, data_size) sampling_lat = (np.pi / 2 - inverse_fisher_cdf(y, kappa)) sampling_lon = np.random.uniform(-np.pi, np.pi, 100) rotate_back_lon, rotate_back_lat = rotate_points_back( sampling_lon, sampling_lat, resultant_orien) sampling_strike, sampling_dip = mplstereonet.geographic2pole( rotate_back_lon, rotate_back_lat) if form is 'azimuth': return sampling_strike, sampling_dip elif form is 'geographic': return rotate_back_lon, rotate_back_lat else: raise ValueError("Error format!")
def test_fit_pole_noisy(self): np.random.seed(1) for strike in range(0, 370, 10): for dip in range(0, 100, 10): lon, lat = mplstereonet.pole(strike, dip) lon = lon + np.radians(np.random.normal(0, 1, 100)) lat = lat + np.radians(np.random.normal(0, 1, 100)) s_noisy, d_noisy = mplstereonet.geographic2pole(lon, lat) s, d = mplstereonet.fit_pole(s_noisy, d_noisy) ang_dist = self.cos_distance(strike, dip, s, d) assert ang_dist < 2 or (180 - ang_dist) < 2
""" import numpy as np import matplotlib.pyplot as plt import mplstereonet np.random.seed(1) # Generate a random girdle distribution from the plunge/bearing of a fold hinge # In the end, we'll have strikes and dips as measured from bedding in the fold. # *strike* and *dip* below would normally be your input. num_points = 200 real_bearing, real_plunge = 300, 5 s, d = mplstereonet.plunge_bearing2pole(real_plunge, real_bearing) lon, lat = mplstereonet.plane(s, d, segments=num_points) lon += np.random.normal(0, np.radians(15), lon.shape) lat += np.random.normal(0, np.radians(15), lat.shape) strike, dip = mplstereonet.geographic2pole(lon, lat) # Plot the raw data and contour it: fig, ax = mplstereonet.subplots() ax.density_contourf(strike, dip, cmap='gist_earth') ax.density_contour(strike, dip, colors='black') ax.pole(strike, dip, marker='.', color='black') # Fit a plane to the girdle of the distribution and display it. fit_strike, fit_dip = mplstereonet.fit_girdle(strike, dip) ax.plane(fit_strike, fit_dip, color='red', lw=2) ax.pole(fit_strike, fit_dip, marker='o', color='red', markersize=14) # Add some annotation of the result lon, lat = mplstereonet.pole(fit_strike, fit_dip) (plunge, ), (bearing, ) = mplstereonet.pole2plunge_bearing(fit_strike, fit_dip)
# Plot the raw data and contour it: fig, ax = mplstereonet.subplots() #ax.density_contourf(strike, dip, rake, measurement='rakes', cmap='gist_earth', # sigma=1.5) ax.density_contour(strike, dip, rake, measurement='rakes', cmap='gist_earth', sigma=1.5) ax.rake(strike, dip, rake, marker='.', color='black') # Find the two modes centers = mplstereonet.kmeans(strike, dip, rake, num=2, measurement='rakes') strike_cent, dip_cent = mplstereonet.geographic2pole(*zip(*centers)) ax.pole(strike_cent, dip_cent, 'ro', ms=12) # Label the modes for (x0, y0) in centers: s, d = mplstereonet.geographic2pole(x0, y0) x, y = mplstereonet.pole(s, d) # Otherwise, we may get the antipode... if x > 0: kwargs = dict(xytext=(40, -40), ha='left') else: kwargs = dict(xytext=(-40, 40), ha='right') ax.annotate('{:03.0f}/{:03.0f}'.format(s[0], d[0]), xy=(x, y), xycoords='data',
import mplstereonet import parse_angelier_data # Load data from Angelier, 1979 strike, dip, rake = parse_angelier_data.load() # Plot the raw data and contour it: fig, ax = mplstereonet.subplots() ax.density_contour(strike, dip, rake, measurement='rakes', cmap='gist_earth', sigma=1.5) ax.rake(strike, dip, rake, marker='.', color='black') # Find the two modes centers = mplstereonet.kmeans(strike, dip, rake, num=2, measurement='rakes') strike_cent, dip_cent = mplstereonet.geographic2pole(*zip(*centers)) ax.pole(strike_cent, dip_cent, 'ro', ms=12) # Fit a girdle to the two modes # The pole of this plane will be the plunge of the fold axis axis_s, axis_d = mplstereonet.fit_girdle(*zip(*centers), measurement='radians') ax.plane(axis_s, axis_d, color='green') ax.pole(axis_s, axis_d, color='green', marker='o', ms=15) # Now we'll find the midpoint. We could project the centers as rakes on the # plane we just fit, but it's easier to get their mean vector instead. mid, _ = mplstereonet.find_mean_vector(*zip(*centers), measurement='radians') midx, midy = mplstereonet.line(*mid) # Now let's find the axial plane by fitting another girdle to the midpoint # and the pole of the plunge axis.
""" import numpy as np import matplotlib.pyplot as plt import mplstereonet np.random.seed(1) # Generate a random girdle distribution from the plunge/bearing of a fold hinge # In the end, we'll have strikes and dips as measured from bedding in the fold. # *strike* and *dip* below would normally be your input. num_points = 200 real_bearing, real_plunge = 300, 5 s, d = mplstereonet.plunge_bearing2pole(real_plunge, real_bearing) lon, lat = mplstereonet.plane(s, d, segments=num_points) lon += np.random.normal(0, np.radians(15), lon.shape) lat += np.random.normal(0, np.radians(15), lat.shape) strike, dip = mplstereonet.geographic2pole(lon, lat) # Plot the raw data and contour it: fig, ax = mplstereonet.subplots() ax.density_contourf(strike, dip, cmap='gist_earth') ax.density_contour(strike, dip, colors='black') ax.pole(strike, dip, marker='.', color='black') # Fit a plane to the girdle of the distribution and display it. fit_strike, fit_dip = mplstereonet.fit_girdle(strike, dip) ax.plane(fit_strike, fit_dip, color='red', lw=2) ax.pole(fit_strike, fit_dip, marker='o', color='red', markersize=14) # Add some annotation of the result lon, lat = mplstereonet.pole(fit_strike, fit_dip) (plunge,), (bearing,) = mplstereonet.pole2plunge_bearing(fit_strike, fit_dip)