conc_true = np.genfromtxt("conc_true.txt")
conc_meas = np.genfromtxt("conc_meas.txt")
conc_meas_err = n.measurement_error(conc_meas)
ms = np.genfromtxt("ms.txt")
misfits = np.genfromtxt("misfits.txt")
constraints = util.unpickle("constraints.dat")
con = constraints
p = util.unpickle("production_rate.dat")
dof = con["n_gl"]

# denormalize the models
ms *= con["max_dz"] / con["rho"] / 100.0

dz_true_m = con["dz_true_m"]
# get data for plotting a depth vs time curve
t_true, z_true = sim.glacial_depth_v_time(con["t_gl"], con["t_int"], con["t_postgl"], dz_true_m, n_gl=con["n_gl"])
dvt_len = 2 * (con["n_gl"] + 1)
fit_t = np.zeros((misfits.size, dvt_len))
fit_z = np.empty((misfits.size, dvt_len))
for i in range(misfits.size):
    fit_t[i, :], fit_z[i, :] = sim.glacial_depth_v_time(
        con["t_gl"], con["t_int"], con["t_postgl"], ms[i], n_gl=con["n_gl"]
    )

#############################
# PLOTTING                  #
#############################

# input zoft plot (just input depth vs time)
zoft_fig = plt.figure(1)
zoft_ax = zoft_fig.add_subplot(111)
Example #2
0
ms = np.atleast_2d(np.genfromtxt('ms.txt'))
misfits = np.atleast_1d(np.genfromtxt('misfits.txt'))
con = util.unpickle('con.dat')
p = util.unpickle('production_rate.dat')

ms_denorm = ms * (con['max_dz'] - con['min_dz']) + con['min_dz']
# denormalize the models
ms_m = ms_denorm / con['rho'] / 100.0

dvt_len = 2 * (con['n_gl'] + 1)
fit_t = np.zeros((misfits.size, dvt_len))
fit_z = np.empty((misfits.size, dvt_len))
for i in range(misfits.size):
    fit_t[i, :], fit_z[i, :] = sim.glacial_depth_v_time(con['t_gl'],
                                                        con['t_int'],
                                                        con['t_postgl'],
                                                        ms_m[i],
                                                        n_gl=con['n_gl'])

#############################
# PLOTTING                  #
#############################

# zoft plot including all the close exposure histories
many_zoft_fig = plt.figure()
many_zoft_ax = many_zoft_fig.add_subplot(111)
# make the brightness of each curve dependent on how low its error was
alphas = 1 - (misfits / con['dof'])
#alpha = 0.5
for i in range(misfits.size):
    plt.plot(fit_t[i] / 1e6, fit_z[i], 'k', alpha=alphas[i])
Example #3
0
conc_meas_err = n.measurement_error(conc_meas)
ms = np.genfromtxt('ms.txt')
misfits = np.genfromtxt('misfits.txt')
constraints = util.unpickle('constraints.dat')
con = constraints
p = util.unpickle('production_rate.dat')
dof = con['n_gl']

# denormalize the models
ms *= con['max_dz'] / con['rho'] / 100.0

dz_true_m = con['dz_true_m']
# get data for plotting a depth vs time curve
t_true, z_true = sim.glacial_depth_v_time(con['t_gl'],
                                          con['t_int'],
                                          con['t_postgl'],
                                          dz_true_m,
                                          n_gl=con['n_gl'])
dvt_len = 2 * (con['n_gl'] + 1)
fit_t = np.zeros((misfits.size, dvt_len))
fit_z = np.empty((misfits.size, dvt_len))
for i in range(misfits.size):
    fit_t[i, :], fit_z[i, :] = sim.glacial_depth_v_time(con['t_gl'],
                                                        con['t_int'],
                                                        con['t_postgl'],
                                                        ms[i],
                                                        n_gl=con['n_gl'])

#############################
# PLOTTING                  #
#############################
Example #4
0
# logarithmically place our sample depths
con['sample_depths_m'] = np.logspace(
    0, np.log(con['bottom_depth_m'] + 1), con['n_samples'], base=np.e) - 1
con['sample_depths'] = con['sample_depths_m'] * 100 * con['rho']

# Construct the target erosion history
con['dz_m'] = np.array([
    4.5, 3.5, 2.5, 1.5, 1, 1.2, 0.5, 0.3, 0.7, 0.5, 0.4, 1, 1.2, 0.2, 0.3, 0.4,
    0.25, 0.75, 1.2, 0.8
])
con['dz'] = con['dz_m'] * 100 * con['rho']

# create points for the true erosion history model
con['t'], con['z_true'] = sim.glacial_depth_v_time(con['t_gl'],
                                                   con['t_int'],
                                                   con['t_postgl'],
                                                   con['dz_m'],
                                                   n_gl=con['n_gl'])

# plot the true model erosion history
#true_hist_fig = plt.figure()
#ax = true_hist_fig.add_subplot(111)
#plt.title('True Model Erosion History')
#var_line, = plt.plot(con['t'] * 1e-6, con['z_true'], 'k', lw=2)
#ax.invert_xaxis()
#ax.invert_yaxis()
#plt.xlabel('Time Before Present (Myr)')
#plt.ylabel('Depth (m)')
#plt.grid(linestyle='-', color='0.75')
#plt.xlim(left=2)
#plt.ylim(bottom=75)
# logarithmically place our samples
con['sample_depths_m'] = np.logspace(0, np.log(con['bottom_depth_m'] + 1), con['n_samples'], base=np.e) - 1
con['sample_depths'] = con['sample_depths_m'] * 100 * con['rho']

# Construct the target erosion history
# made using sim.rand_erosion_hist(6, 3, 20)

con['dz_m'] = np.array([  9,   2,   4,  2,
        0.2,   0.3,   0.1,   0.3,
        0.2,   3.4,   8 ,   7,
        2,   3.6,   8.3,   6,
        5 ,   1.8,  7.5,   4])
con['dz'] = con['dz_m'] * 100 * con['rho']
avg_dz_m = con['dz_m'].mean()

con['t'], con['z_targ'] = sim.glacial_depth_v_time(con['t_gl'], con['t_int'], con['t_postgl'], 
                             con['dz_m'], n_gl=con['n_gl'])
_, z_const = sim.glacial_depth_v_time(con['t_gl'], con['t_int'], con['t_postgl'], 
                              avg_dz_m, n_gl=con['n_gl'])

fig_height = 3.5 # in.
fig_width = 5 # in.

fig = Figure(figsize=(fig_width, fig_height))
canvas = FigureCanvas(fig)
ax = fig.add_subplot(111)
ax.set_title('Varied Erosion History', fontsize=12)
ax.invert_xaxis()
ax.invert_yaxis()
var_line, = ax.plot(con['t'] * 1e-6, con['z_targ'], 'r')
ax.set_xlabel('Time Before Present (Myr)', fontsize=10)
ax.set_ylabel('Depth (m)', fontsize=10)
Example #6
0
assert con['max_dz'] > dz_true[0]
mtrue = dz_true / con['max_dz']

# Interpolate the production rate
max_possible_depth = con['n_gl'] * con['max_dz'] + con['bottom_depth']
npts = 500 # points to interpolate through
zs = np.unique(np.logspace(0, np.log2(max_possible_depth + 1), npts, base=2)) - 1
prod_rates = production.P_tot(zs, con['alt'], con['lat'], con['nuclide'])
#p = interp1d(zs, prod_rates, kind=3)
# interp1d used as above gives crazy negative dives around z = 82000, do not
# want that! UnivariateSpline seems to work much much better
p = UnivariateSpline(zs, prod_rates, k=3, s=0)
util.pickle(p, 'production_rate.dat')

# get data for plotting a depth vs time curve, meters and years
t_true, z_true = sim.glacial_depth_v_time(con['t_gl'], con['t_int'], con['t_postgl'], 
                                  con['dz_true_m'], n_gl=con['n_gl'])

conc_true = sim.multiglaciate(dz_true, con['t_gl'], con['t_int'],
                              con['t_postgl'], con['sample_depths'], 
                              con['nuclide'], p, con['n_gl'])

sigma_true = con['nuclide'].measurement_error(conc_true)
conc_meas = np.random.normal(loc=conc_true, scale=sigma_true)

# we need a way to measure error between models
def chi2(a, b, sigma):
    """ Chi squared of two vectors """
    return (((a - b) / sigma)**2).sum()

# degrees of freedom in our problem
dof = dz_true.size
Example #7
0
# logarithmically place our samples
con['sample_depths_m'] = np.logspace(0, np.log(con['bottom_depth_m'] + 1), con['n_samples'], base=np.e) - 1
con['sample_depths'] = con['sample_depths_m'] * 100 * con['rho']

# Construct the target erosion history
# made using sim.rand_erosion_hist(6, 3, 20)

con['dz_m'] = np.array([  9,   2,   4,  2,
        0.2,   0.3,   0.1,   0.3,
        0.2,   3.4,   8 ,   7,
        2,   3.6,   8.3,   6,
        5 ,   1.8,  7.5,   4])
con['dz'] = con['dz_m'] * 100 * con['rho']
avg_dz_m = con['dz_m'].mean()

t, z_targ = sim.glacial_depth_v_time(con['t_gl'], con['t_int'], con['t_postgl'], 
                             con['dz_m'], n_gl=con['n_gl'])
_, z_const = sim.glacial_depth_v_time(con['t_gl'], con['t_int'], con['t_postgl'], 
                              avg_dz_m, n_gl=con['n_gl'])

fig_height = 3.5 # in.
fig_width = 5 # in.

fig = Figure(figsize=(fig_width, fig_height))
canvas = FigureCanvas(fig)
ax = fig.add_subplot(111)
ax.set_title('Varied Erosion History', fontsize=12)
ax.invert_xaxis()
ax.invert_yaxis()
var_line, = ax.plot(t * 1e-6, z_targ, 'r')
ax.set_xlabel('Time Before Present (Myr)', fontsize=10)
ax.set_ylabel('Depth (m)', fontsize=10)
Example #8
0
con['min_dz'] = con['min_dz_m'] * 100 * con['rho']

# logarithmically place our sample depths
con['sample_depths_m'] = np.logspace(0, np.log(con['bottom_depth_m'] + 1), con['n_samples'], base=np.e) - 1
con['sample_depths'] = con['sample_depths_m'] * 100 * con['rho']

# Construct the target erosion history
con['dz_m'] = np.array([  4.5,   3.5,   2.5,  1.5,
        1,   1.2,   0.5,   0.3,
        0.7,   0.5,   0.4 ,   1,
        1.2,   0.2,   0.3,   0.4,
        0.25 ,   0.75,  1.2,   0.8])
con['dz'] = con['dz_m'] * 100 * con['rho']

# create points for the true erosion history model
con['t'], con['z_true'] = sim.glacial_depth_v_time(con['t_gl'], con['t_int'], con['t_postgl'], 
                             con['dz_m'], n_gl=con['n_gl'])

# plot the true model erosion history
#true_hist_fig = plt.figure()
#ax = true_hist_fig.add_subplot(111)
#plt.title('True Model Erosion History')
#var_line, = plt.plot(con['t'] * 1e-6, con['z_true'], 'k', lw=2)
#ax.invert_xaxis()
#ax.invert_yaxis()
#plt.xlabel('Time Before Present (Myr)')
#plt.ylabel('Depth (m)')
#plt.grid(linestyle='-', color='0.75')
#plt.xlim(left=2)
#plt.ylim(bottom=75)
#plt.savefig('true_hist.png')
Example #9
0
models = np.genfromtxt('models.txt')
ms = np.atleast_2d(np.genfromtxt('ms.txt'))
misfits = np.atleast_1d(np.genfromtxt('misfits.txt'))
con = util.unpickle('con.dat')
p = util.unpickle('production_rate.dat')

ms_denorm = ms * (con['max_dz'] - con['min_dz']) + con['min_dz']
# denormalize the models
ms_m = ms_denorm / con['rho'] / 100.0

dvt_len = 2 * (con['n_gl'] + 1)
fit_t = np.zeros((misfits.size, dvt_len))
fit_z = np.empty((misfits.size, dvt_len))
for i in range(misfits.size):
    fit_t[i, :], fit_z[i, :] = sim.glacial_depth_v_time(con['t_gl'], con['t_int'],
                                                con['t_postgl'], ms_m[i], 
                                                n_gl=con['n_gl'])

#############################
# PLOTTING                  #
#############################

# zoft plot including all the close exposure histories
many_zoft_fig = plt.figure()
many_zoft_ax = many_zoft_fig.add_subplot(111)
# make the brightness of each curve dependent on how low its error was
alphas = 1 - (misfits / con['dof'])
#alpha = 0.5
for i in range(misfits.size):
    plt.plot(fit_t[i] / 1e6, fit_z[i], 'k', alpha=alphas[i])
var_line, = many_zoft_ax.plot(con['t'] * 1e-6, con['z_targ'], 'r')
Example #10
0
# Interpolate the production rate
max_possible_depth = con['n_gl'] * con['max_dz'] + con['bottom_depth']
npts = 500  # points to interpolate through
zs = np.unique(np.logspace(0, np.log2(max_possible_depth + 1), npts,
                           base=2)) - 1
prod_rates = production.P_tot(zs, con['alt'], con['lat'], con['nuclide'])
#p = interp1d(zs, prod_rates, kind=3)
# interp1d used as above gives crazy negative dives around z = 82000, do not
# want that! UnivariateSpline seems to work much much better
p = UnivariateSpline(zs, prod_rates, k=3, s=0)
util.pickle(p, 'production_rate.dat')

# get data for plotting a depth vs time curve, meters and years
t_true, z_true = sim.glacial_depth_v_time(con['t_gl'],
                                          con['t_int'],
                                          con['t_postgl'],
                                          con['dz_true_m'],
                                          n_gl=con['n_gl'])

conc_true = sim.multiglaciate(dz_true, con['t_gl'], con['t_int'],
                              con['t_postgl'], con['sample_depths'],
                              con['nuclide'], p, con['n_gl'])

sigma_true = con['nuclide'].measurement_error(conc_true)
conc_meas = np.random.normal(loc=conc_true, scale=sigma_true)


# we need a way to measure error between models
def chi2(a, b, sigma):
    """ Chi squared of two vectors """
    return (((a - b) / sigma)**2).sum()