예제 #1
0
 def test_LambdaTransformer(self):
     """Test the LambdaTransformer transfomer."""
     df = normal_frame(columns=REE()).apply(close, axis=1)
     tmr = LambdaTransformer()
     for ree in [REE(), [i for i in REE() if i not in ["Eu"]]]:
         with self.subTest(ree=ree):
             out = tmr.transform(df.loc[:, ree])
예제 #2
0
    def setUp(self):
        self.cols = ["MgO", "SiO2", "CaO"]

        # can run into interesting singular matrix errors with bivariate random data
        self.tridf = normal_frame(columns=self.cols, size=100)
        self.bidf = self.tridf.loc[:, self.cols[:2]]
        self.multidf = normal_frame(columns=REE(), size=100)
예제 #3
0
    def setUp(self):
        self.cols = ["MgO", "SiO2", "CaO"]

        # can run into interesting singular matrix errors with bivariate random data
        self.tridf = test_df(cols=self.cols, index_length=100)
        self.bidf = self.tridf.loc[:, self.cols[:2]]
        self.multidf = test_df(cols=REE(), index_length=100)
예제 #4
0
 def test_LambdaTransformer(self):
     """Test the LambdaTransformer transfomer."""
     df = test_df(cols=REE()).apply(close, axis=1)
     tmr = LambdaTransformer()
     for input in [df]:
         with self.subTest(input=input):
             out = tmr.transform(input)
예제 #5
0
    def setUp(self):
        self.C = get_reference_composition("PM_PON")
        self.C.set_units("ppm")
        els = [i for i in REE() if not i == "Pm"]
        vals = self.C[els]
        self.df = pd.DataFrame({k: v for (k, v) in zip(els, vals)}, index=[0])

        self.df = self.df.pyrochem.normalize_to("Chondrite_PON", units="ppm")
        self.df.loc[1, :] = self.df.loc[0, :]
        self.default_degree = 3
예제 #6
0
 def setUp(self):
     elements = [i for i in REE(dropPm=True) if i != "Eu"]  # drop Pm, Eu
     self.xs = np.array(get_ionic_radii(elements, coordination=8, charge=3))
     self.default_degree = 5
     self.expect = [
         (),
         (1.05477,),
         (1.00533, 1.12824),
         (0.99141, 1.06055, 1.14552),
         (0.98482, 1.03052, 1.10441, 1.15343),
     ]
예제 #7
0
 def test_params(self):
     # the first three all have the same result - defaulting to ONeill 2016
     # the two following use a full REE set for the OP basis function definition
     # the last illustrates that custom parameters could be used
     degree = self.default_degree
     for params in [
             None,
             "ONeill2016",
             "O'Neill (2016)",
             "full",
             "Full",
             orthogonal_polynomial_constants(
                 get_ionic_radii(REE(), charge=3, coordination=8),  # xs
                 degree=self.default_degree,
             ),
     ]:
         with self.subTest(params=params):
             ret = calc_lambdas(self.df, params=params, degree=degree)
             self.assertTrue(ret.columns.size == self.default_degree)
예제 #8
0
Cu_radii = get_ionic_radii("Cu")
print(Cu_radii)
########################################################################################
# Note that this function returned a series of the possible radii, given specific
# charges and coordinations of the Cu ion. If we completely specify these, we'll get
# a single number back:
#
Cu2plus6fold_radii = get_ionic_radii("Cu", coordination=6, charge=2)
print(Cu2plus6fold_radii)
########################################################################################
# You can also pass lists to the function. For example, if you wanted to get the Shannon
# ionic radii of Rare Earth Elements (REE) in eight-fold coordination with a valence of
# +3, you should use the following:
#
shannon_ionic_radii = get_ionic_radii(REE(), coordination=8, charge=3)
print(shannon_ionic_radii)
########################################################################################
# The function defaults to using the Shannon ionic radii consistent with [Pauling1960]_,
# but you can adjust to use the set you like with the `pauling` boolean argument
# (:code:`pauling=False` to use Shannon's 'Crystal Radii') or the `source` argument
# (:code:`source='Whittaker'` to use the [WhittakerMuntus1970]_ dataset):
#
shannon_crystal_radii = get_ionic_radii(REE(),
                                        coordination=8,
                                        charge=3,
                                        pauling=False)
whittaker_ionic_radii = get_ionic_radii(REE(),
                                        coordination=8,
                                        charge=3,
                                        source="Whittaker")
예제 #9
0
#
from pyrolite.util.synthetic import example_patterns_from_parameters

ls = np.array([
    [2, 5, -30, 100, -600, 0, 0, 0, 0],  # lambda-only
    [3, 15, 30, 300, 1500, 0, 0, 0, 0],  # lambda-only
    [1, 5, -50, 0, -1000, -0.3, -0.7, -1.4, -0.2],  # W-pattern tetrad
    [5, 15, 50, 400, 2000, 0.6, 1.1, 1.5, 0.3],  # M-pattern tetrad
])
# now we use these parameters to generate some synthetic log-scaled normalised REE
# patterns and add a bit of noise
pattern_df = pd.DataFrame(
    np.vstack([
        example_patterns_from_parameters(l, includes_tetrads=True) for l in ls
    ]),
    columns=REE(),
)
# We can now fit these patterns and see what the effect of fitting and not-Fitting
# tetrads might look like in these (slightly extreme) cases:
fit_ls_only = pattern_df.pyrochem.lambda_lnREE(norm_to=None,
                                               degree=5,
                                               fit_tetrads=False)
fit_ts = pattern_df.pyrochem.lambda_lnREE(norm_to=None,
                                          degree=5,
                                          fit_tetrads=True)
########################################################################################
# We can now examine what the differences between the fits are. Below we plot the four
# sets of synthetic REE patterns (lambda-only above and lamba+tetrad below) and examine
# the relative accuracy of fitting some of the higher order lambda parameters where
# tetrads are also fit:
#
예제 #10
0
"""
Ionic Radii
==============

:mod:`pyrolite` incldues a few sets of reference tables for ionic radii in aangstroms
(Å) from [Shannon1976]_ and [WhittakerMuntus1970]_, each with tables indexed
by element, ionic charge and coordination. The easiset way to access these is via
the :func:`~pyrolite.geochem.ind.get_ionic_radii` function. The function can be used
to get radii for individual elements, using a :code:`source` keyword argument to swap
between the datasets:
"""
import pandas as pd
import matplotlib.pyplot as plt
from pyrolite.geochem.ind import get_ionic_radii, REE

REE_radii = pd.Series(get_ionic_radii(REE(),
                                      coordination=8,
                                      charge=3,
                                      source="Whittaker"),
                      index=REE())
REE_radii
########################################################################################
REE_radii.pyroplot.spider(color="k", logy=False)
plt.show()
########################################################################################
# References
# ----------
# .. [Shannon1976] Shannon RD (1976). Revised effective ionic radii and systematic
#         studies of interatomic distances in halides and chalcogenides.
#         Acta Crystallographica Section A 32:751–767.
#         `doi: 10.1107/S0567739476001551 <https://doi.org/10.1107/S0567739476001551>`__.
예제 #11
0
df.pyrochem.list_elements

########################################################################################

df.pyrochem.list_REE

########################################################################################

df.pyrochem.list_compositional

########################################################################################
# All elements (up to U):
#
from pyrolite.geochem.ind import common_elements, common_oxides, REE

common_elements()  # string return

########################################################################################
# All elements, returned as a list of `~periodictable.core.Formula`:
#
common_elements(output="formula")  # periodictable.core.Formula return

########################################################################################
# Oxides for elements with positive charges (up to U):
#
common_oxides()

########################################################################################

REE()
예제 #12
0
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from pyrolite.plot import pyroplot
from pyrolite.plot.spider import REE_v_radii
from pyrolite.geochem.ind import REE, get_ionic_radii
# sphinx_gallery_thumbnail_number = 4

########################################################################################
# Where data is not specified, it will return a formatted axis which can be used for
# subsequent plotting:
ax = REE_v_radii(
    index='radii')  # radii mode will put ionic radii on the x axis

# create some example data
ree = REE()
xs = get_ionic_radii(ree, coordination=8, charge=3)
ys = np.linspace(1, 20, len(xs))
ax.plot(xs, ys, marker='D', color='k')
plt.show()
########################################################################################
# Here we generate some example data:
#
no_analyses = 10

data_ree = REE(dropPm=True)
data_radii = np.array(get_ionic_radii(data_ree, coordination=8, charge=3))
data_radii = np.tile(data_radii,
                     (1, no_analyses)).reshape(no_analyses,
                                               data_radii.shape[0])
예제 #13
0
"""
Shannon Radii
=============
"""
import matplotlib.pyplot as plt
from pyrolite.geochem.ind import get_ionic_radii, REE

REE_radii = get_ionic_radii(REE(), coordination=8, charge=3)

fig, ax = plt.subplots(1)
ax.plot(REE_radii, c='k', marker='D')
ax.set_xticks(range(len(REE())))
ax.set_xticklabels(REE())
ax.set_ylabel('Ionic Radius ($\AA$)')
ax.set_title('Rare Earth Element Shannon Ionic Radii')
########################################################################################
# .. seealso:: `Pandas Lambda Ln(REE) Function <../lambdas/pandaslambdas.html>`__,
#              `Lambdas for Dimensional Reduction <../lambdas/lambdadimreduction.html>`__,
#              `REE Radii Plot <../plotting/REE_radii_plot.html>`__
예제 #14
0
Cu_radii = get_ionic_radii("Cu")
print(Cu_radii)
########################################################################################
# Note that this function returned a series of the possible radii, given specific
# charges and coordinations of the Cu ion. If we completely specify these, we'll get
# a single number back:
#
Cu2plus6fold_radii = get_ionic_radii("Cu", coordination=6, charge=2)
print(Cu2plus6fold_radii)
########################################################################################
# You can also pass lists to the function. For example, if you wanted to get the Shannon
# ionic radii of Rare Earth Elements (REE) in eight-fold coordination with a valence of
# +3, you should use the following:
#
shannon_ionic_radii = get_ionic_radii(REE(), coordination=8, charge=3)
print(shannon_ionic_radii)
########################################################################################
# The function defaults to using the Shannon ionic radii consistent with [Pauling1960]_,
# but you can adjust to use the set you like with the `pauling` boolean argument
# (:code:`pauling=False` to use Shannon's 'Crystal Radii') or the `source` argument
# (:code:`source='Whittaker'` to use the [WhittakerMuntus1970]_ dataset):
#
shannon_crystal_radii = get_ionic_radii(REE(), coordination=8, charge=3, pauling=False)
whittaker_ionic_radii = get_ionic_radii(
    REE(), coordination=8, charge=3, source="Whittaker"
)
########################################################################################
# We can see what the differences between these look like across the REE:
#
import matplotlib.pyplot as plt
예제 #15
0
 def setUp(self):
     self.xs = np.array(get_ionic_radii(REE(), coordination=8, charge=3))
     self.default_degree = 4
예제 #16
0
 def setUp(self):
     self.ree = REE()
예제 #17
0
                va="bottom",
                fontsize=fontsize)
fig
########################################################################################
# When it comes to estimating the partitioning of :math:`X^{3+}` cations, we'll need a reference
# point - here we'll use :math:`D_{La}` to calculate relative partitioning of the other
# Rare Earth Elements, although you may have noticed it is not defined above.
# Through a handy relationship, we can estimate :math:`D_{La}`
# based on the easier measured :math:`D_{Ca}`, :math:`D_{Na}` and temperature [#ref_2]_:
#
D_La = (D_Ca**2 / D_Na) * np.exp((529 / Tk) - 3.705)
D_La  # 0.48085
########################################################################################
# Now :math:`D_{La}` is defined, we can use it as a reference for the other REE:
#
site3labels = REE(dropPm=True)
# get the Shannon ionic radii for the elements in the 3+ site
site3radii = [
    get_ionic_radii(x, charge=3, coordination=8) for x in REE(dropPm=True)
]
site3Ds = D_La * np.array(
    [strain_coefficient(rLa, rx, r0=r03, E=E_3, T=Tk) for rx in site3radii])
# plot the relative paritioning curve for cations in the 3+ site
ax.scatter(site3radii, site3Ds, color="purple", label="$X^{3+}$ Cations")
# plot the relative paritioning curve for the site
curve3Ds = D_La * strain_coefficient(rLa, xs, r0=r03, E=E_3, T=Tk)
ax.plot(xs, curve3Ds, color="0.5", ls="--")
# add the element labels next to the points
for l, r, d in zip(site3labels, site3radii, site3Ds):
    ax.annotate(l,
                xy=(r, d),