예제 #1
0
 def test_non_mineral(self):
     for get in ["andychristyite", "Not quite a formula"]:
         with self.subTest(get=get):
             out = get_mineral(get)
             self.assertIsInstance(out, pd.Series)
예제 #2
0
                         molecular=True)
ed
########################################################################################
# Equally, if you knew the likely endmembers beforehand, you could specify a list of
# endmembers:
#
ed = endmember_decompose(pd.DataFrame(comp).T,
                         endmembers=["forsterite", "fayalite"],
                         ord=1,
                         molecular=True)
ed
########################################################################################
# We can check this by recombining the components with these proportions. We can first
# lookup the compositions for our endmembers:
#
em = pd.DataFrame([get_mineral("forsterite"), get_mineral("fayalite")])
em.loc[:, ~(em == 0).all(axis=0)]  # columns not full of zeros
########################################################################################
# First we have to convert these element-based compositions to oxide-based compositions:
#
emvalues = (em.loc[:, ["Mg", "Si", "Fe"]].pyrochem.to_molecular().fillna(
    0).pyrochem.convert_chemistry(
        to=["MgO", "SiO2",
            "FeO"], molecular=True).fillna(0).pyrocomp.renormalise(scale=1))
emvalues
########################################################################################
# These can now be used with our endmember proportions to regenerate a composition:
#
recombined = pd.DataFrame(
    ed.values.flatten() @ emvalues).T.pyrochem.to_weight()
recombined
예제 #3
0
 def test_get_mineral(self):
     for get in ["forsterite", "enstatite"]:
         with self.subTest(get=get):
             out = get_mineral(get)
             self.assertIsInstance(out, pd.Series)
예제 #4
0
pyrolite includes a limited mineral database which is useful for
for looking up endmember compositions. This part of the package is being actively
developed, so expect expansions and improvements soon.
"""
import pandas as pd
from pyrolite.mineral.mindb import (
    list_groups,
    list_minerals,
    list_formulae,
    get_mineral,
    get_mineral_group,
)

pd.set_option("precision", 3)  # smaller outputs
########################################################################################
# From the database, you can get the list of its contents using a few utility
# functions:
list_groups()
########################################################################################
list_minerals()
########################################################################################
list_formulae()
########################################################################################
# You can also directly get the composition of specific minerals by name:
#
get_mineral("forsterite")
########################################################################################
# If you want to get compositions for all minerals within a specific group, you can
# use :func:`~pyrolite.mineral.mindb.get_mineral_group`:
get_mineral_group("olivine")