ax = figure.add_subplot(3, 3, reorder[i] + 1) # plt.subplots_adjust(left=0, bottom=None, right=0, top=None, # wspace=None, hspace=None) plt.subplots_adjust(wspace=0, hspace=0.2) plt.plot(seis_p / 1.e9, seis_vs / 1.e3, linestyle="-", color='k', linewidth=2.0, label='PREM') plt.plot(seis_p / 1.e9, base_vs / 1.e3, color=colors.color(3), dashes=dashstyle2, linewidth=1.5, markersize=6, markerfacecolor='None', label='pv') plt.plot(seis_p / 1.e9, vsmin / 1.e3, color=colors.color(3), linestyle="-", linewidth=.5, markersize=6, markerfacecolor='None', label='min') plt.plot(seis_p / 1.e9,
# speed up computation for the automatic tests: if "RUNNING_TESTS" in globals(): xx = np.linspace(0.0, 1.0, 10) errs = np.array([material_error(x) for x in xx]) yy_vs = errs[:, 0] yy_vphi = errs[:, 1] vs_average_prem = sum(seis_vs) / len(seis_vs) vphi_average_prem = sum(seis_vphi) / len(seis_vphi) print(vs_average_prem, vphi_average_prem) yy_vs /= vs_average_prem yy_vphi /= vphi_average_prem yy_sum = (yy_vs + yy_vphi) # we scale by a factor so it fits in the plot # plt.figure(dpi=100,figsize=figsize) plt.subplot(2, 2, 1) plt.plot(xx * 100, yy_vs, "-", color=colors.color(1), label=("$V_s$ error"), linewidth=1.5, dashes=dashstyle2) plt.plot(xx * 100, yy_vphi, "-", color=colors.color(3), label=("$V_\phi$ error"), linewidth=1.5) # plt.plot (xx*100,yy_vs+yy_vphi,"g--",label=("sum"),linewidth=1.5) plt.plot(xx * 100, yy_sum, "-", color=colors.color(4), label=("weighted sum"), linewidth=1.5, dashes=dashstyle3) ymin = 1e-2 ymax = 1e2 plt.ylim([ymin, ymax]) print(xx[np.argmin(yy_vs)], xx[np.argmin(yy_vphi)], xx[np.argmin(yy_sum)]) B = np.around(xx[np.argmin(yy_vs)], decimals=3) A = np.around(xx[np.argmin(yy_vphi)], decimals=3)
uncertain = np.ones(len) uncertain[i] += spread[i] * x _, vs, vphi, _ = eval(uncertain) vsmin = np.minimum(vs,vsmin) vsmax = np.maximum(vs,vsmax) vphimin = np.minimum(vphi,vphimin) vphimax = np.maximum(vphi,vphimax) ax = figure.add_subplot(3,3,reorder[i]+1) #plt.subplots_adjust(left=0, bottom=None, right=0, top=None, wspace=None, hspace=None) plt.subplots_adjust(wspace=0, hspace=0.2) plt.plot(seis_p/1.e9,seis_vs/1.e3,linestyle="-",color='k',linewidth=2.0,label='PREM') plt.plot(seis_p/1.e9,base_vs/1.e3,color=colors.color(3),dashes=dashstyle2,linewidth=1.5, markersize=6,markerfacecolor='None',label='pv') plt.plot(seis_p/1.e9,vsmin/1.e3,color=colors.color(3),linestyle="-",linewidth=.5, markersize=6,markerfacecolor='None',label='min') plt.plot(seis_p/1.e9,vsmax/1.e3,color=colors.color(3),linestyle="-",linewidth=.5, markersize=6,markerfacecolor='None',label='max') plt.fill_between(seis_p/1.e9,vsmax/1.e3, vsmin/1.e3, facecolor='#ffbbbb', lw=0, label='asdf',interpolate=False) plt.title('Vs %s +/- %d\\%% '%(names[i], spread[i]*100) ) plt.ylim([6.2,7.6]) if (reorder[i]%3==0): plt.ylabel('Wave speed (km/s)') else: ax.yaxis.set_ticklabels([]) if (reorder[i]>5):
((0.834 * mat_vs_1 + 0.166 * mat_vs_2) + np.ones_like(mat_vs_1) / (0.834 / mat_vs_1 + 0.166 / mat_vs_2)) mat_vs_4_wr = 0.5 * \ ((0.92 * mat_vs_1 + 0.08 * mat_vs_2) + np.ones_like(mat_vs_1) / (0.92 / mat_vs_1 + 0.08 / mat_vs_2)) plt.subplot(1, 2, 2) plt.ylim(5.2, 7.4) plt.xlim(25, 135) # fig1 = mpimg.imread('input_figures/murakami_book_chapter.png') # plt.imshow(fig1, extent=[25,135,5.0,7.6], aspect='auto') plt.plot( seis_p / 1.e9, seis_vs / 1.e3, color='k', linestyle='-', marker='None', markerfacecolor='w', markersize=4, label='PREM', linewidth=3.0, mew=1.5) plt.plot( seis_p / 1.e9, mat_vs_1 / 1.e3, color=colors.color(3), marker='v', markerfacecolor=colors.color(3), markersize=4, markeredgecolor=colors.color(3), markevery=2, linewidth=1.5, label='perovskite') plt.plot( seis_p / 1.e9, mat_vs_2 / 1.e3, color=colors.color(1), linestyle='-', linewidth=1.5, marker='^', markerfacecolor=colors.color(1), markersize=4, markeredgecolor=colors.color(1), markevery=2, label='periclase') plt.plot( seis_p / 1.e9, mat_vs_4_wr / 1.e3, color=colors.color(4), dashes=dashstyle3, linewidth=1.5, marker='o', markerfacecolor=colors.color(4), markersize=4, markeredgecolor=colors.color(4), markevery=2, label='92\% pv') plt.plot( seis_p / 1.e9, mat_vs_3_wr / 1.e3, color='g', linestyle='-', dashes=dashstyle2, linewidth=1.5, marker='o', markerfacecolor='w', markersize=4, markeredgecolor='g', markevery=2, label='83\% pv') plt.legend(loc='lower right', prop={'size': 12}) plt.title("Phase average on velocities")
uncertain = np.ones(len) uncertain[i] += spread[i] * x _, vs, vphi, _ = eval(uncertain) vsmin = np.minimum(vs, vsmin) vsmax = np.maximum(vs, vsmax) vphimin = np.minimum(vphi, vphimin) vphimax = np.maximum(vphi, vphimax) ax = figure.add_subplot(3, 3, order_idx + 1) plt.subplots_adjust(wspace=0, hspace=0.2) ax.plot(seis_p / 1.e9, seis_vs / 1.e3, linestyle="-", color='k', linewidth=2.0, label='PREM') ax.plot( seis_p / 1.e9, base_vs / 1.e3, color=colors.color(3), dashes=dashstyle2, linewidth=1.5, markersize=6, markerfacecolor='None', label='$V_S$') ax.plot( seis_p / 1.e9, vsmin / 1.e3, color=colors.color(3), linestyle="-", linewidth=.5, markersize=6, markerfacecolor='None') ax.plot( seis_p / 1.e9, vsmax / 1.e3, color=colors.color(3), linestyle="-", linewidth=.5, markersize=6, markerfacecolor='None') ax.fill_between(seis_p / 1.e9, vsmax / 1.e3, vsmin / 1.e3, facecolor='#ffbbbb', lw=0, interpolate=False) if (reorder[i] % 3 == 0): ax.set_ylabel('Wave speed (km/s)') else:
errs = np.array([material_error(x) for x in xx]) yy_vs = errs[:, 0] yy_vphi = errs[:, 1] vs_average_prem = sum(seis_vs) / len(seis_vs) vphi_average_prem = sum(seis_vphi) / len(seis_vphi) print(vs_average_prem, vphi_average_prem) yy_vs /= vs_average_prem yy_vphi /= vphi_average_prem yy_sum = (yy_vs + yy_vphi) # we scale by a factor so it fits in the plot # plt.figure(dpi=100,figsize=figsize) plt.subplot(2, 2, 1) plt.plot(xx * 100, yy_vs, "-", color=colors.color(1), label=("$V_s$ error"), linewidth=1.5, dashes=dashstyle2) plt.plot(xx * 100, yy_vphi, "-", color=colors.color(3), label=("$V_\phi$ error"), linewidth=1.5) # plt.plot (xx*100,yy_vs+yy_vphi,"g--",label=("sum"),linewidth=1.5) plt.plot(xx * 100, yy_sum, "-", color=colors.color(4), label=("weighted sum"),
# Lower bound for Hashin-Shtrikman averaging rock.set_averaging_scheme(burnman.averaging_schemes.HashinShtrikmanLower()) rho_hsl, vp_hsl, vs_hsl, vphi_hsl, K_hsl, G_hsl = \ rock.evaluate( ['rho', 'v_p', 'v_s', 'v_phi', 'K_S', 'G'], pressures, temperatures) # linear fit vs_lin = vs_pv * amount_perovskite + vs_fp * (1.0 - amount_perovskite) # PLOTTING # plot vs ax = figure.add_subplot(1, 1, 1) ax.plot(pressures / 1.e9, vs_v / 1.e3, color=colors.color(0), linewidth=2, linestyle='-', marker='^', markersize=4, label='Voigt') ax.plot(pressures / 1.e9, vs_r / 1.e3, color=colors.color(5), linewidth=2, linestyle='-', marker='v', markersize=4, label='Reuss') ax.plot(pressures / 1.e9, vs_vrh / 1.e3,
model_vs_2nd_order_incorrect = calc_shear_velocities( sol[0], sol[1], mg_perovskite_test, pressures) # now do third-order fit mg_perovskite_test.set_method("bm3") func = lambda x: error(x, mg_perovskite_test, obs_pressures, obs_vs) sol = opt.fmin(func, guess) print("3rd order fit: G = ", sol[0] / 1.e9, "GPa\tG' = ", sol[1]) model_vs_3rd_order_correct = calc_shear_velocities( sol[0], sol[1], mg_perovskite_test, pressures) mg_perovskite_test.set_method("bm2") model_vs_3rd_order_incorrect = calc_shear_velocities( sol[0], sol[1], mg_perovskite_test, pressures) plt.plot( pressures / 1.e9, model_vs_2nd_order_correct / 1000., color=colors.color(3), linestyle='-', marker='x', markevery=7, linewidth=1.5, label="Correct 2nd order extrapolation") plt.plot( pressures / 1.e9, model_vs_2nd_order_incorrect / 1000., color=colors.color(3), linestyle='--', marker='x', markevery=7, linewidth=1.5, label="2nd order fit, 3rd order extrapolation") plt.plot( pressures / 1.e9, model_vs_3rd_order_correct / 1000., color=colors.color(1), linestyle='-', linewidth=1.5, label="Correct 3rd order extrapolation") plt.plot( pressures / 1.e9, model_vs_3rd_order_incorrect / 1000., color=colors.color(1), linestyle='--', linewidth=1.5, label="3rd order fit, 2nd order extrapolation") plt.scatter(obs_pressures / 1.e9, obs_vs / 1000., zorder=1000, marker='o', c='w') plt.ylim([6.7, 8]) plt.xlim([25., 135.]) if "RUNNING_TESTS" not in globals():
# Lower bound for Hashin-Shtrikman averaging rock.set_averaging_scheme(burnman.averaging_schemes.HashinShtrikmanLower()) rho_hsl, vp_hsl, vs_hsl, vphi_hsl, K_hsl, G_hsl = \ rock.evaluate( ['rho', 'v_p', 'v_s', 'v_phi', 'K_S', 'G'], pressures, temperatures) # linear fit vs_lin = vs_pv * amount_perovskite + vs_fp * (1.0 - amount_perovskite) # PLOTTING # plot vs ax = figure.add_subplot(1, 1, 1) plt.plot( pressures / 1.e9, vs_v / 1.e3, color=colors.color(0), linewidth=2, linestyle='-', marker='^', markersize=4, label='Voigt') plt.plot( pressures / 1.e9, vs_r / 1.e3, color=colors.color(5), linewidth=2, linestyle='-', marker='v', markersize=4, label='Reuss') plt.plot( pressures / 1.e9, vs_vrh / 1.e3, color=colors.color(1), linestyle='-', marker='*', markersize=6, label='Voigt-Reuss-Hill') plt.fill_between(pressures / 1.e9, vs_hsu / 1.e3, vs_hsl / 1.e3, facecolor='red', lw=0, label='asdf', interpolate=False) # plt.plot(pressures/1.e9,vs_hsu/1.e3,color='r',linestyle='-',\ # markersize=4,label='Hashin-Shtrikman') # plt.plot(pressures/1.e9,vs_hsl/1.e3,color='r',linestyle='-',marker='x',\ # markersize=4) plt.plot(
sol = opt.fmin(func, guess) print("2nd order fit: G = ", sol[0]/1.e9, "GPa\tG' = ", sol[1]) model_vs_2nd_order_correct = calc_shear_velocities(sol[0], sol[1], mg_perovskite_test, pressures) mg_perovskite_test.set_method("bm3") model_vs_2nd_order_incorrect = calc_shear_velocities(sol[0], sol[1], mg_perovskite_test, pressures) #now do third-order fit mg_perovskite_test.set_method("bm3") func = lambda x : error( x, mg_perovskite_test, obs_pressures, obs_vs) sol = opt.fmin(func, guess) print("3rd order fit: G = ", sol[0]/1.e9, "GPa\tG' = ", sol[1]) model_vs_3rd_order_correct = calc_shear_velocities(sol[0], sol[1], mg_perovskite_test, pressures) mg_perovskite_test.set_method("bm2") model_vs_3rd_order_incorrect = calc_shear_velocities(sol[0], sol[1], mg_perovskite_test, pressures) plt.plot(pressures/1.e9,model_vs_2nd_order_correct/1000.,color=colors.color(3), linestyle='-', marker='x',markevery=7,linewidth=1.5, label = "Correct 2nd order extrapolation") plt.plot(pressures/1.e9,model_vs_2nd_order_incorrect/1000.,color=colors.color(3), linestyle='--', marker='x',markevery=7, linewidth=1.5, label = "2nd order fit, 3rd order extrapolation") plt.plot(pressures/1.e9,model_vs_3rd_order_correct/1000.,color=colors.color(1), linestyle='-', linewidth=1.5, label = "Correct 3rd order extrapolation") plt.plot(pressures/1.e9,model_vs_3rd_order_incorrect/1000.,color=colors.color(1), linestyle='--', linewidth=1.5, label = "3rd order fit, 2nd order extrapolation") plt.scatter(obs_pressures/1.e9, obs_vs/1000., zorder=1000, marker='o',c='w') plt.ylim([6.7, 8]) plt.xlim([25., 135.]) if "RUNNING_TESTS" not in globals(): plt.ylabel(r'Shear velocity ${V}_{\mathlarger{\mathlarger{\mathlarger{s}}}}$ (km/s)') plt.xlabel("Pressure (GPa)") plt.legend(loc = "lower right",prop=prop) if "RUNNING_TESTS" not in globals(): plt.savefig("example_fit_data.pdf", bbox_inches='tight') plt.show()