<jupyter_start><jupyter_text>Modeling Off-Axis Seamounts; Expediting insight into near-ridge mantle heterogeneity- Part Three - IN PROGRESS - - Workflow  By: <NAME>  I. Problem Statement  In an age where seeing the unseen is commonplace, scientists still have surprisingly few constraints on mantle dynamics beneath our feet. Studies performed at mid-ocean ridges attempt to address this gap in knowledge by examining chemistry of basalts produced at ridge axes where distance to the mantle is minimal (often less than 1 km). Ideally, those basalts are as close to representing the mantle as a geochemist can access. However, at fast-spreading ridges a continuous thermal barrier allows for efficient mixing of mantle material prior to eruption, so materials collected on-axis (the most common site for sampling) only represent an average composition. To probe any heterogeneities in the mantle, ~300 basalt samples were collected from a long seamount chain perpendicular to the fast-spreading East Pacific Rise in an attempt to by-pass homogenization mixing and see into the mantle.  To assess heterogeneity, fractional crystallization, source mixing, and mantle melting models are compared to the 300 basalt samples. However, the stages from inputing parameters into the melting program (alphaMELTs) to producing visualizations of the results are arduous and time-consuming. This results in week-long modeling sessions that are frequently inadequate and need adjusted and re-run. To expedite the melt model results, this study will incorporate the computing power of Python to read the alphaMELTs output results, process the data, feed it into a script which plots the results in real-time without all of the intermediate, time-consuming steps. This will effectively reduce the time required to visualize the results so I can immediately decide which parameters to adjust, quickly adjust those, and automate getting updated results.   II. Import libraries and Upload seamount data<jupyter_code>import pandas as pd # standard library for data analysis
import numpy as np # library for scientific computing
import matplotlib.pyplot as plt # library for plotting values and generating visualizations
import subprocess # library for executing an external program through Jupyter notebooks
from subprocess import call # use subprocess call to execute external program MELTs... 
#it seems that Jupyter already has this capability by just using an exclamation point
Elements = pd.read_csv('Documents/EPR/Code/MajorTrace.csv') #read in seamount data file and set variable Elements for table<jupyter_output><empty_output><jupyter_text>III. Choose melting parameters* Edit batch file to reflect melting parameters for the program MELTs* Set variables for specifying titles, etc in the plots later so that labels accurately reflect the parameters modelled<jupyter_code>%load C:\Users\Molly\Documents\bin\batch.txt #adjust batch file to appropriate composition txt file, temp, pressure conditions
%%write editedbatch.txt #save changes as the batch we apply later<jupyter_output><empty_output><jupyter_text>IV. Execute MELTs Program* Call batch file which executes MELTs and provides the right flags (f for environment, b for batch, p for output)    (tells MELTs which environment file, batch file (the one adjusted above), and output location)* Produce an output in the form of a txt file (ends in traceint)<jupyter_code>!C:/Users/Molly/Documents/bin/test.bat #exclamation point to call the batch which executes MELTs program

print('done') #since the program is finnicky and long, have Jupyter output 'done' when it is complete and successful<jupyter_output><empty_output><jupyter_text>V. Upload Output Results as CSV* Remove the upper header rows* Convert to csv * Upload csv into Jupyter notebooks<jupyter_code>Output_TE = pd.read('Documents/bin/Output.traceint') #read trace element file of MELTs output (an example for this part of the project)<jupyter_output><empty_output><jupyter_text>VI. Calculate Trace Element Ratios Normalized to Mantle --> create new columns* Use La/SmN formula and put calculated results for each row in an additional column in the table* Use Nb/La formula and put calculated results of each row in an additional column in the table<jupyter_code># did not get to this section because Anaconda crashed on my computer. Due to installation issues the project changed here<jupyter_output><empty_output><jupyter_text>VII. Plot Results of Model with Seamount Data for Visual Comparison* Plot La/SmN versus Nb/La showing 1. the seamount data as points, and 2. the model results in the form of a line * Include axes titles, labels, a figure title, and a legend<jupyter_code>LaSmN_Data = Elements['La.SmN'].values #set variables for columns of seamount data
NbLa_Data = Elements['Nb.La'].values
LaSmN_Model = Output_TE['La/Sm_1D'].values #set variables for columns of modelled data 
NbLa_Model = Output_TE['Nb/La_1D'].values
plt.plot(LaSmN_Data, NbLa_Data, 'ro', label = "Seamount Data") #plot the seamount data as red points, title for legend
plt.plot(LaSmN_Model, NbLa_Model, 'bl', label = "Model Results") #plot the model results as a blue line, title for legend
plt.title('Melting models') #title of the plot
plt.xlabel('La/SmN') #x-axis label
plt.ylabel('Nb/La') #y-axis label
plt.legend() #automatically produces a legend based on the two plotted series
plt.text(2,0.6, 'Depleted Depleted Mantle') #add text to the plot to describe the line and what model it represents<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.05510241073046946, 'fraction_numerical': 0.0025376110204821463, 'mean_word_length': 5.484136310223267, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '63502', 'license': 'MIT', 'n_tokens_mistral': 1485, 'n_tokens_neox': 1385, 'n_words': 732, 'path': 'SeamountGeochemistry_Workflow_Update.ipynb', 'repo_name': 'MollyKAnderson/Geos505_Research_Computing', 'size': '5525'}