def create_model(n_euler_rotations, use_tpw):
    if n_euler_rotations < 0:
        raise Exception(
            "Number of plate Euler rotations must be greater than or equal to zero"
        )
    if use_tpw != False and use_tpw != True:
        raise Exception("Must enter 'true' or 'false' for whether to use TPW")
    if n_euler_rotations == 0 and use_tpw == False:
        raise Exception(
            "Must use either TPW or plate Euler rotations, or both")

    print("Fitting Keweenawan APW track with"\
            +("out TPW and " if use_tpw == False else " TPW and ")\
            +str(n_euler_rotations)+" Euler rotation"\
            + ("" if n_euler_rotations == 1 else "s") )

    data = pd.read_csv("pole_means.csv")
    # Give unnamed column an appropriate name
    data.rename(columns={'Unnamed: 0': 'Name',\
                         'Unnamed: 14': 'GaussianOrUniform'},\
                inplace=True)
    data = data[data.Name !=
                'Osler_N']  #Huge error, does not contribute much to the model
    data = data[data.PoleName !=
                'Abitibi']  # Standstill at the beginning, not realistic to fit
    data = data[data.PoleName !=
                'Haliburton']  #Much younger, far away pole, difficutlt to fit
    data.sort_values('AgeNominal', ascending=False, inplace=True)

    poles = []
    pole_names = []
    pole_colors = []
    for i, row in data.iterrows():
        pole_lat = row['PLat']
        pole_lon = row['PLon'] - lon_shift
        a95 = row['A95']
        age = row['AgeNominal']

        if row['GaussianOrUniform'] == 'gaussian':
            sigma_age = row['Gaussian_2sigma'] / 2.
        elif row['GaussianOrUniform'] == 'uniform':
            sigma_age = (row['AgeLower'], row['AgeUpper'])
        else:
            raise Exception("Unrecognized age error type")

        pole = mcplates.PaleomagneticPole(pole_lon,
                                          pole_lat,
                                          angular_error=a95,
                                          age=age,
                                          sigma_age=sigma_age)
        poles.append(pole)
        pole_names.append(row['PoleName'])
        pole_colors.append(row['color'])

    tpw_str = 'true' if use_tpw else 'false'
    prefix = 'keweenawan_' + str(n_euler_rotations) + '_' + tpw_str
    path = mcplates.APWPath(prefix, poles, n_euler_rotations)
    tpw_rate_scale = 2.5 if use_tpw else None
    path.create_model(site_lon_lat=(slon, slat), watson_concentration=0.0,\
            rate_scale=2.5, tpw_rate_scale=tpw_rate_scale)
    return path, poles, pole_names, pole_colors
Beispiel #2
0
#Make a dummy APW path to create the synthetic data
dummy_pole_position_fn = mcplates.APWPath.generate_pole_position_fn(
    n_euler_poles, start_age)
pole_list = []
for a in ages:
    lon_lat = dummy_pole_position_fn(hidden_start_pole, a, 0.0, 0.0,
                                     hidden_euler_pole, hidden_euler_rate)
    pole_list.append(
        mcplates.PaleomagneticPole(lon_lat[0],
                                   lon_lat[1],
                                   angular_error=10.,
                                   age=a,
                                   sigma_age=0.01))

path = mcplates.APWPath(dbname, pole_list, n_euler_poles)
path.create_model(watson_concentration=0.0, rate_scale=2.5)


def plot_result():

    fig = plt.figure(figsize=(8, 4))
    ax = fig.add_subplot(1, 2, 1, projection=ccrs.Orthographic(0., 15.))
    ax.gridlines()
    ax.set_global()

    colors = itertools.cycle([cmap_red, cmap_green])
    direction_samples = path.euler_directions()
    for directions in direction_samples:
        mcplates.plot.plot_distribution(ax,
                                        directions[:, 0],
# Add pole with low error for present day pole
poles.append(
    mcplates.PaleomagneticPole(0.,
                               90.,
                               angular_error=1.,
                               age=0.,
                               sigma_age=0.01))

# Reference position on the Australian continent
slat = -25.3  # Uluru lat
slon = 131.0 - lon_shift  # Uluru lon
uluru = mcplates.PlateCentroid(slon, slat)
prefix = 'australia_' + str(n_euler_rotations) + '_' + sys.argv[2]

path = mcplates.APWPath(prefix, poles, n_euler_rotations)
tpw_rate_scale = 2.5 if use_tpw else None
path.create_model(site_lon_lat=(slon, slat), watson_concentration=0.0,\
        rate_scale=2.5, tpw_rate_scale=tpw_rate_scale)


def plot_synthetic_paths(ax=None, title=''):
    if ax is None:
        if proj_type == 'M':
            myax = plt.axes(projection=ccrs.Mollweide(200. - lon_shift))
        elif proj_type == 'O':
            myax = plt.axes(
                projection=ccrs.Orthographic(200. - lon_shift, 30.))
    else:
        myax = ax
Beispiel #4
0
import mcplates

dbname = 'pickles/apw.pickle'

# Generate a synthetic data set
ages =[0.,10.,20.,30.,40]
sigma_ages = [2., 2., 2., 2., [38.,43.]]

lon_lats = [ [300., -20.], [340.,0.], [0.,30.], [20., 0.], [60.,-20.]]

poles = []
for a, s, ll in zip(ages, sigma_ages, lon_lats):
    pole = mcplates.PaleomagneticPole( ll[0], ll[1], angular_error=10., age=a, sigma_age=s)
    poles.append(pole)

path = mcplates.APWPath( 'apw', poles, 2 )
path.create_model()

def plot_result():

    ax = plt.axes(projection = ccrs.Orthographic(0.,-30.))
    #ax = plt.axes(projection = ccrs.Mollweide(0.))
    ax.gridlines()
    ax.set_global()

    direction_samples = path.euler_directions()
    for directions in direction_samples:
        mcplates.plot.plot_distribution( ax, directions[:,0], directions[:,1])

    pathlons, pathlats = path.compute_synthetic_paths(n=100)
    for pathlon,pathlat in zip(pathlons,pathlats):