Ejemplo n.º 1
0
 def test_default(self):
     logger = stream_log(self.key)
     # check that the logger has a single stream handler
     handlers = [
         i for i in logger.handlers if isinstance(i, logging.StreamHandler)
     ]
     self.assertTrue(len(handlers) == 1)
Ejemplo n.º 2
0
 def test_WARNING(self):
     level = "WARNING"
     logger = stream_log(self.key, level=level)
     # check that the logger has a single stream handler
     handlers = [i for i in logger.handlers if isinstance(i, logging.StreamHandler)]
     self.assertTrue(len(handlers) == 1)
     self.assertTrue(handlers[0].level == getattr(logging, level))
Ejemplo n.º 3
0
 def test_ouptut(self):
     level = "WARNING"
     logger = stream_log(self.key, level=level)
     logger.warning('Test Warning')
Ejemplo n.º 4
0
from pathlib import Path
from pyrolite_meltsutil.tables import get_experiments_summary
from pyrolite_meltsutil.plottemplates import table_by_phase
from pyrolite.util.meta import stream_log
logger = stream_log('pyrolite_meltsutil.tables', level='DEBUG')
tempdir = Path("./_auto") / "montecarlo"
summary = get_experiments_summary(tempdir / "isobar5kbar1300-800CFMQ",
                                  kelvin=False)
# %%
import matplotlib.pyplot as plt
import pyrolite.plot
from pyrolite.util.plot import add_colorbar

otpt = summary["MORB_Gale2013-2"]["output"]

otpt.liquidcomp
cmap = plt.cm.magma
norm = plt.Normalize(vmin=otpt.liquidcomp.Temperature.min(),
                     vmax=otpt.liquidcomp.Temperature.max())

ax = otpt.liquidcomp.loc[:, ["CaO", "MgO", "Al2O3"]].pyroplot.scatter(
    color=otpt.liquidcomp.Temperature.values, cmap=cmap, figsize=(8, 8))
add_colorbar(ax.collections[-1], cmap=cmap, norm=norm)

# %%
import numpy as np
import pandas as pd
from pyrolite.comp.codata import clr, inverse_clr, alr, inverse_alr

# cpx olivine plag
# CaMgSi2O6 Mg2Si2O4 CaAl2Si2O8
Ejemplo n.º 5
0
----------------------------------

pyrolite can download and manage its own version of alphaMELTS (without any real
'installation', *per-se*), and use this for :mod:`~pyrolite_meltsutil.automation`
purposes.

"""
from pyrolite.util.meta import stream_log
from pyrolite_meltsutil.download import install_melts
from pyrolite_meltsutil.util.general import pyrolite_meltsutil_datafolder

########################################################################################
# Here we can do a conditonal install - only downloading alphamelts if it doesnt exist:
#
if not (pyrolite_meltsutil_datafolder(subfolder="localinstall")).exists():
    stream_log("pyrolite-meltsutil", level="INFO")  # logger for output info
    install_melts(
        local=True)  # install a copy of melts to pyrolite data folder

########################################################################################
# .. warning:: This 'local install' method still requires that you have Perl installed,
#           as it uses the Perl :code:`run_alphamelts.command` script. If you're on
#           Windows, you can use `Strawberry Perl <http://strawberryperl.com/>`__
#           for this purpose.
#
# .. seealso::
#
#   Examples:
#     `alphaMELTS Environment Configuration <environment.html>`__,
#     `Automating alphaMELTS Runs <automation.html>`__,
#     `Handling Outputs from Melts: Tables <tables.html>`__,
Ejemplo n.º 6
0
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={
        "Initial Pressure": 5000,
        "Initial Temperature": 1300,
        "Final Temperature": 800,
        "modes": ["isobaric"],
    },
    config_grid={
        # "Initial Pressure": [3000, 7000],