Skip to content

Commit

Permalink
Update LambdaLnREE to accept normalised data
Browse files Browse the repository at this point in the history
  • Loading branch information
morganjwilliams committed Nov 1, 2018
1 parent 36a6498 commit 20c4ac3
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions pyrolite/geochem.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def REE(output='string',
if output == 'formula':
elements = [getattr(pt, el) for el in elements]
return elements


def common_oxides(elements: list=[], output='string',
addition: list=['FeOT', 'Fe2O3T', 'LOI'],
Expand Down Expand Up @@ -407,22 +407,27 @@ def lambda_lnREE(df,
col_indexes = [i for i in df.columns if i in ree
or i in map(str, ree)]

if isinstance(norm_to, str):
norm = ReferenceCompositions()[norm_to]
norm_abund = np.array([norm[str(el)].value for el in ree])
elif isinstance(norm_to, RefComp):
norm_abund = np.array([getattr(norm_to, str(e)) for e in col_indexes])
else: # list, iterable, pd.Index etc
norm_abund = np.array([i for i in norm_abund])

assert len(norm_abund) == len(ree)
norm_df = df.loc[:, col_indexes] # initialize normdf

labels = [chr(955) + str(d) for d in range(degree)]

norm_df = df.loc[:, col_indexes]
norm_df.loc[:, col_indexes] = np.divide(norm_df.loc[:, col_indexes].values,
norm_abund)
if norm_to is not None: # None = already normalised data
if isinstance(norm_to, str):
norm = ReferenceCompositions()[norm_to]
norm_abund = np.array([norm[str(el)].value for el in ree])
elif isinstance(norm_to, RefComp):
norm_abund = np.array([getattr(norm_to, str(e)) for e in col_indexes])
else: # list, iterable, pd.Index etc
norm_abund = np.array([i for i in norm_abund])

assert len(norm_abund) == len(ree)


norm_df.loc[:, col_indexes] = np.divide(norm_df.loc[:,
col_indexes].values,
norm_abund)
norm_df = norm_df.applymap(np.log)

lambda_partial = functools.partial(lambdas,
xs=radii,
params=params,
Expand Down

0 comments on commit 20c4ac3

Please sign in to comment.