コード例 #1
0
one of which being the Sulfur Content at Sulfur Saturation
(:func:`pyrolite.geochem.magma.SCCS`) function. This is an empirical relationship
derived by Li and Ripley (2009) [#ref_1]_ which enables a better understanding
of relative saturation sulfur saturation state (for both sulfide and sulfate)
and the prediction of sulfur saturation in evolving melts.

Here we use this function to predict sulfur saturation in a fractionally
crystallizing MORB melt with a range of sulfur contents. First we'll import a set of
example data tables:
"""
from pyrolite_meltsutil.util.general import get_data_example
from pyrolite_meltsutil.tables.load import import_tables, import_batch_config

# sphinx_gallery_thumbnail_number = 3
hsh = "363f3d0a0b"  # the hash index of our experiment
batchdir = get_data_example(
    "batch")  # let's use the example batch data for this
system, phases = import_tables(batchdir / hsh,
                               kelvin=False)  # let's import the tables
name, cfg, env = import_batch_config(batchdir)[
    hsh]  # and also the configuration

########################################################################################
# From this we extract only the liquid composition:
#
liquid = phases.loc[phases.phase == "liquid", :]
########################################################################################
# Now we can calcuate the sulfur saturation at sulfide saturation for this magma.
# This table also includes the relevant temperature and pressure data, noting
# that the temperature here is in degrees Celsius (:code:`kelvin = False`) and the
# pressure is in bars (wheras this function requires kbar, hence the division by 1000):
#
コード例 #2
0
As one of the main use cases for using pyrolite-meltsutil is executing, interrogating
and visualising multiple experiments, one of the core functionalities is importing
alphaMELTS results and integrating these. Of the key functions to do this is
:func:`~pyrolite_meltsutil.tables.load.aggregate_tables`. This enables you to load
in all the results from an array of experiments within a single folder, enabling
subsequent analysis and visualization.
"""
########################################################################################
# First let's find a folder with some results. In this case we'll use one of the
# pyrolite-meltsutil example folders which already contains some batch experiment
# results:
#
from pyrolite_meltsutil.util.general import get_data_example

experiment_dir = get_data_example("batch")
########################################################################################
# Now we can import the table files from each of the experiments. Note that in the
# same fashion as :func:`~pyrolite_meltsutil.tables.load.import_tables`,
# :func:`~pyrolite_meltsutil.tables.load.aggregate_tables` returns two tables
# - one for :code:`system` variables and one for :code:`phases`,
# which contains information pertaining to individual phases or aggregates (e.g.
# 'olivine_0', 'bulk', 'liquid' etc).
#
from pyrolite_meltsutil.tables.load import aggregate_tables

system, phases = aggregate_tables(experiment_dir)
########################################################################################
# In addition to the variables you'd expect from the tables, the returned dataframes
# also include an 'experiment' column which contains the hash-index of each experiment
# such that they can be easily distinguished:
コード例 #3
0
"""
Visualisation: Plot Templates
=====================================

pyrolite-meltsutil includes a few plot templates to quickly visualise some melts
experiment results.
"""
########################################################################################
# First let's get a folder with some data in it. Here we use one of the isobaric
# crystallisation experiments from the montecarlo tutorial, and import the tables:
from pyrolite_meltsutil.util.general import get_data_example
from pyrolite_meltsutil.tables import import_tables
# sphinx_gallery_thumbnail_number = 2

exp_dir = get_data_example("montecarlo/97ed8127d9")
system, phases = import_tables(exp_dir)
########################################################################################
# We can quickly visualise the phase volume relationships versus temperature:
#
import matplotlib.pyplot as plt
from pyrolite_meltsutil.vis.templates import plot_phasevolumes

ax = plot_phasevolumes(phases)
plt.show()
########################################################################################
# Similarly, for the phase mass relationships versus temperature:
#
from pyrolite_meltsutil.vis.templates import plot_phasemasses

ax = plot_phasemasses(phases, marker=None)
ax.set_yscale("log")
コード例 #4
0
 def setUp(self):
     self.fromdir = get_data_example("batch/363f3d0a0b/")
     self.system, self.phases = import_tables(self.fromdir)
     self.liquid = self.phases.loc[self.phases.phase == "liquid", :]
コード例 #5
0
 def setUp(self):
     self.fracdir = get_data_example("batch/363f3d0a0b/")
     self.nofracdir = get_data_example("montecarlo/97ed8127d9")
     self.fracsystem, self.fracphases = import_tables(self.fracdir)
     self.nofracsystem, self.nofracphases = import_tables(self.nofracdir)
コード例 #6
0
 def setUp(self):
     self.fromdir = get_data_example("batch/363f3d0a0b/")
     self.system, self.phases = import_tables(self.fromdir)
コード例 #7
0
 def setUp(self):
     self.fromdir = get_data_example("batch/")
コード例 #8
0
"""
Visualising Cumulate Compositions
====================================
"""
########################################################################################
# First we'll import a set of example data tables:
#
from pyrolite_meltsutil.util.general import get_data_example
from pyrolite_meltsutil.tables.load import import_tables

# sphinx_gallery_thumbnail_number = 2
hsh = "0cc4d1315d"  # the hash index of our experiment
batchdir = get_data_example(
    "montecarlo")  # let's use the example batch data for this
system, phases = import_tables(batchdir / hsh)  # let's import the tables
########################################################################################
# The cumulate composition is automatically calculated and added to the phase table:
#
phases.loc[phases.phase == "cumulate", :].head(3).T
########################################################################################
# We can also manually calculate the phase mass proportions for the cumulate pile:
#
from pyrolite_meltsutil.util.tables import integrate_solid_proportions

cumulate_phases = integrate_solid_proportions(phases, frac=False)
cumulate_phases.tail(3).T
########################################################################################
# Ternary diagrams can be useful to visualise how the overal/fractional cumulates
# change during the experiment:
#
import matplotlib.pyplot as plt
コード例 #9
0
 def setUp(self):
     self.fromdir = get_data_example("batch/363f3d0a0b/")
コード例 #10
0
 def setUp(self):
     self.file = get_data_example("batch/363f3d0a0b/Phase_main_tbl.txt")
コード例 #11
0
 def setUp(self):
     self.file = get_data_example("batch/363f3d0a0b/alphaMELTS_tbl.txt")
コード例 #12
0
 def setUp(self):
     self.exps = {
         n: c
         for (k, (n, c, e)) in import_batch_config(
             get_data_example("montecarlo")).items()
     }
コード例 #13
0
# Now we can setup an environment for isobaric fractional crystallisation:
#
from pyrolite_meltsutil.env import MELTS_Env

env = MELTS_Env()
env.VERSION = "MELTS"  # crustal processes, < 1GPa/10kbar
env.MODE = "isobaric"
env.DELTAT = -5
env.MINP = 0
env.MAXP = 10000
########################################################################################
# Let's create a directory to run this experiment in - here we use an example folder:
#
from pyrolite_meltsutil.util.general import get_data_example

experiment_dir = get_data_example("montecarlo")
########################################################################################
# Let's also set up logging we can see the progression:
from pyrolite.util.meta import stream_log
import logging

logger = logging.Logger(__name__)
stream_log(logger)
########################################################################################
# Next we setup the alphaMELTS configuration for each of the inputs:
#
from pyrolite_meltsutil.automation import MeltsBatch

batch = MeltsBatch(
    df,
    default_config={