-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculation.py
74 lines (69 loc) · 3.39 KB
/
calculation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# -*- coding: UTF-8 -*-
import pandas as pd
from Napture import Napture
import math
class Hf():
def __init__(self, file, hf180):
self.filename = file
# Read .exp data into Pandas DataFrame.
machine_type = Napture()
machine_type.open(self.filename, encoding='ascii')
self.df = machine_type.getdata()
self.df = self.df[self.df.iloc[:, -1] > hf180]
self.datanumber = len(self.df)
def cal(self):
self.df['beta2/3'] = (self.df['172Yb']/self.df['173Yb']).apply(lambda x:math.log(1.35274/x))/math.log(171.936378/172.938208)
self.df['beta7/9'] = (self.df['177Hf']/self.df['179Hf']).apply(lambda x:math.log(1/0.7325/x))/math.log(176.943217/178.945812)
self.df['176Yb'] = self.df['172Yb'] * math.pow(171.936378/175.942564, self.df['beta2/3'].mean())*0.588596
self.df['176Lu'] = self.df['175Lu'] * math.pow(174.94077/175.942679, self.df['beta2/3'].mean())*0.02658
self.df['176Hf*'] = self.df['176Hf'] - self.df['176Yb'] - self.df['176Lu']
self.df['176Yb/177Hf'] = self.df['176Yb']/self.df['177Hf'] * self.df['beta7/9'].apply(lambda x:math.pow(175.942564/176.943217,x))
self.df['176Lu/177Hf'] = self.df['176Lu']/self.df['177Hf'] * self.df['beta7/9'].apply(lambda x:math.pow(175.946279/176.943217,x))
self.df['176Hf*/177Hf'] = self.df['176Hf*']/self.df['177Hf'] * math.pow(175.941406/176.943217,self.df['beta7/9'].mean())
# Add some data statistics
mean = self.df.mean()
sd = self.df.std()
rsd = sd/mean
count = self.df.count()
count.astype(float)
count_sqrt = count.apply(math.sqrt)
se = 2 * sd / count_sqrt
rse = se / mean
self.df = self.df.append(pd.DataFrame(data = mean).rename(columns = {0:'Mean'}).T)
self.df = self.df.append(pd.DataFrame(data = sd).rename(columns = {0:'SD'}).T)
self.df = self.df.append(pd.DataFrame(data = rsd).rename(columns = {0:'RSD'}).T)
self.df = self.df.append(pd.DataFrame(data = se).rename(columns = {0:'2SE'}).T)
self.df = self.df.append(pd.DataFrame(data = rse).rename(columns = {0:'2RSE'}).T)
return self.df
# Return the final report, no calculations here.
def report(self,filename):