def run_model(src, dst, clinopyroxene=False): with app.app_context(): data = sample_ree(normalized=True, mode='whole_rock') colors = sample_colors() model = DepletionModel(src) depleted = model.fit_HREE(data) trace = model.tables['Solid Trace'] fig, ax = subplots(1, 1, figsize=(3.5, 3.5)) ax.plot(trace.Temperature, trace.Pressure / 1e4, 'k') ax.set_ylabel(r'Pressure (GPa)') ax.set_xlabel("Temperature (\u00b0C)") df = concat([depleted, colors], axis=1) ax.scatter(df.Temperature, df.Pressure / 1e4, color="white", s=50, zorder=8) ax.scatter(df.Temperature, df.Pressure / 1e4, color=df.color, s=20, zorder=10) for i, row in df.iterrows(): y = 0 x = 5 if i in ['CK-3', 'CK-7']: x -= 28 y -= 5 ax.annotate(i, xy=(row.Temperature, row.Pressure / 1e4), color=row.color, xytext=(x, y), textcoords='offset points') ax.set_ylim([2.5, 0]) ax.set_xlim([1230, 1350]) ax.annotate("garnet out", xy=(1345, 2.05), xytext=(-28, 2), textcoords='offset points', size=7, style='italic') ax.annotate("start: DMM at 3.0 GPa, 1350ºC", xy=(1340, 2.5), xytext=(-15, 2), textcoords='offset points', ha='right', va='bottom', size=7) ax.annotate("↓", xy=(1340, 2.5), rotation=25, xytext=(-7, 2), textcoords='offset points', ha='right', va='bottom', size=10) update_axes(ax) fig.savefig(dst, bbox_inches='tight')
plots = ('bkn','ca_opx_corr') for thermometer,ax in zip(plots,axes[1:]): ids = ('ta98',thermometer) names = [thermometers[th]["name"] for th in ids] for sample in data: name = sample["id"] for a_loc in ["core", "rim"]: values = [sample[a_loc][i]["sep"] for i in ids] popts = scatter_options(sample['color'],a_loc) ax.scatter( [i.n for i in values[0]], [i.n for i in values[1]], **popts) ax.set_ylabel(label(names[1])) ax.autoscale(False) ax.set_xlim([900,1125]) if thermometer == 'ca_opx_corr': ax.set_ylim([950,1125]) else: ax.set_ylim([975,1200]) ax.plot([0,1800],[0,1800],color="#cccccc", zorder=-20) update_axes(ax) axes[-1].set_xlabel(label(names[0])) axis_labels(*axes, fontsize=16, pad=0.2) path = os.path.join("build", "temp-comparisons.pdf") fig.savefig(path, bbox_inches="tight")
ax.set_xlabel("MgO (molar %)") ax.set_ylabel("FeO (molar %)") ax.text(32, 11.6, "Mg #", rotation=-20, color="#aaaaaa", size=5) props = dict(color='#aaaaaa', size=8, horizontalalignment='center', verticalalignment='center') ax.text(43, 3.2, "Orthopyroxene", **props) ax.text(22, 1.4, "Clinopyroxene", **props) ax.text(60, 4.8, "Olivine", **props) ax.text(42, 11.2, "Spinel", **props) ax.text(53, 21, "Phenocryst olivine", **props) update_axes(ax) def process_data(): for m in xeno_query.all(): ox = lambda x: m.oxide(x).molar_percent color = m.sample.color ec = edge_color(color) yield ox('SiO2'), m.mg_number, ec, color data = list(process_data()) x, y, colors, edgecolors = zip(*data) ax2 = fig.add_subplot(gs[1, 0]) ax2.scatter(x, y, c=colors, edgecolors=edgecolors, alpha=0.5) ax2.set_xlim(32, 34.5)
def run_model(src, dst, clinopyroxene=False): with app.app_context(): data = sample_ree(normalized=True, mode='cpx' if clinopyroxene else 'whole_rock') colors = sample_colors() model = DepletionModel(src) if clinopyroxene: depleted = model.fit_HREE(data, table='clinopyroxene_0 trace') else: depleted = model.fit_HREE(data) enrichment, multiplier = model.enrichment(data, depleted) # Create primitive-mantle normalized dataset Sun_PM = get_melts_data('literature/Sun_McDonough_PM.melts') PM_trace = Sun_PM.trace.ix[:, 0] # Add NMORB NMORB = get_melts_data('literature/NMORB_trace.melts') NMORB_trace = ree_only(NMORB.trace.transpose() / PM_trace) # Alkali basalt alkali = read_table('literature/Farmer_1995-Alkali-basalt.txt', comment="#", index_col=0) alkali /= PM_trace alkali_trace = ree_only(alkali) vals = [element(i) for i in data.columns] d = ree_only(depleted) grid = dict(height_ratios=(4.5, 1), hspace=0.1, right=0.99, left=0.16) fig, (ax1, ax2) = subplots(2, 1, figsize=(3.5, 6), gridspec_kw=grid) def create_main_axis(ax): for i, row in d.iterrows(): c = colors.ix[row.name][0] # Plot real data series = data.ix[row.name] u = series.map(lambda x: x.n) s = series.map(lambda x: x.s) ax.fill_between(vals, u - s, u + s, facecolor=c, edgecolor='none', alpha=0.2) def plot(name, x, y, **kwargs): if i == 'CK-3': kwargs['label'] = name else: kwargs['label'] = "" p = ax.plot(x, y, color=c, **kwargs) if clinopyroxene: s = 'clinopyroxene' else: s = 'whole-rock' plot('Measured ' + s, vals, u) # Plot calculated best fit plot("Modeled depleted", d.columns, row, linestyle='--', linewidth=1) v = enrichment.ix[row.name] if i == 'CK-2': # Don't include CK-2 because it isn't depleted, so results are spurious. continue plot("Enriching melt", d.columns, v, linestyle=':', linewidth=1) # Plot NMORB ax.fill_between(NMORB_trace.columns, NMORB_trace.ix[0, :], NMORB_trace.ix[0, :] - 0.5, color='#bbbbbb', linewidth=1.5, zorder=-5, label="") ax.fill_between(alkali_trace.columns, alkali_trace.min(), alkali_trace.max(), facecolor='#dddddd', edgecolor='none', zorder=-10, label="") ax.set_ylim(.01, 100) ax.set_xlim(element('La') - 0.1, element('Lu')) ax.yaxis.set_ticklabels( ["{:g}".format(v) for v in ax.yaxis.get_ticklocs()]) ax.set_ylabel("Rare-earth element abundance / Primitive Mantle") ax.xaxis.set_ticks(vals) ax.xaxis.set_ticklabels(data.columns) ax.set_yscale('log') ax.text(element('Ce') - 0.5, 40, "Alkali basalt", rotation=-28, color='#888888') ax.text(element('La'), 5, "NMORB", rotation=15, color='#888888') legend = ax.legend(loc="upper right") fr = legend.get_frame() fr.set_lw(0.5) create_main_axis(ax1) update_axes(ax1) fig.subplots_adjust(top=0.99, right=0.99) ree_scatter(ax2, model, data, colors) ax2.set_ylim([0, 1.2]) ax2.set_xlabel(r'HREE depletion degrees (%)') ax2.set_ylabel("Enriching fluid\nassimilated (%)") ax2.yaxis.set_label_coords(-0.1, 0.22) update_axes(ax2) axis_labels(ax1, ax2, pad=.16, fontsize=14) fig.savefig(dst, bbox_inches='tight')