Mercurial > repos > jay > gaiac_precision
annotate gaiac_precision_calculation/gaiac_precision_calculation.py @ 0:287d6cc86582 draft
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
| author | jay | 
|---|---|
| date | Thu, 15 May 2025 14:45:45 +0000 | 
| parents | |
| children | 
| rev | line source | 
|---|---|
| 
0
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
1 import scipy | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
2 import argparse | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
3 from scipy.stats.distributions import chi2 | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
4 import pandas as pd | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
5 import numpy as np | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
6 | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
7 def Precision(infile, clm1, clm2, Out): | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
8 | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
9 df = pd.read_csv(infile, sep="\t") | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
10 lOc = int(df.shape[0]) | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
11 | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
12 cl = df.columns.tolist() | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
13 | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
14 df['PM10_OPC_DIFF']=(((df[cl[int(clm1)-1]])-(df[cl[int(clm2)-1]]))/(((df[cl[int(clm1)-1]])+(df[cl[int(clm2)-1]]))/2)*100) | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
15 df['PM10_OPC_DIFFs']=(df['PM10_OPC_DIFF'])*(df['PM10_OPC_DIFF']) | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
16 d10=df.PM10_OPC_DIFF.sum() | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
17 d10_2=df.PM10_OPC_DIFFs.sum() | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
18 CV_10= (np.sqrt((lOc*(d10_2)-(d10)**2)/(2*lOc*(lOc-1))))*(np.sqrt((lOc-1)/(chi2.ppf(0.1, df=lOc)))) | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
19 df1 = pd.DataFrame([CV_10], columns=['Percent Precision']) | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
20 df1.round(4).to_csv(Out,sep='\t') | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
21 | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
22 if __name__=="__main__": | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
23 | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
24 parser = argparse.ArgumentParser() | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
25 | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
26 parser.add_argument("-I", "--infile", required=True, default=None, help="Input file") | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
27 parser.add_argument("-c1", "--column_1", required=True, default=None, help="First column") | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
28 parser.add_argument("-c2", "--column_2", required=True, default=None, help="Second column") | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
29 parser.add_argument("-o", "--out", required=True, default=None, help="OutFile") | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
30 args = parser.parse_args() | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
31 | 
| 
 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 
jay 
parents:  
diff
changeset
 | 
32 Precision(args.infile, args.column_1, args.column_2, args.out) | 
