Mercurial > repos > jay > gaiac_box_plot
annotate gaiac_precision_calculation/gaiac_precision_calculation.py @ 2:f4bde1be9ed0 draft
planemo upload for repository https://github.com/jaidevjoshi83/gaiac commit c31ef5726cd1d2659da9aeb956c22fb834b177ff
author | jay |
---|---|
date | Fri, 23 May 2025 17:53:36 +0000 |
parents | 0763bb545f98 |
children |
rev | line source |
---|---|
0
0763bb545f98
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
1 import scipy |
0763bb545f98
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
2 import argparse |
0763bb545f98
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
3 from scipy.stats.distributions import chi2 |
0763bb545f98
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
4 import pandas as pd |
0763bb545f98
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
5 import numpy as np |
0763bb545f98
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
6 |
0763bb545f98
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
7 def Precision(infile, clm1, clm2, Out): |
0763bb545f98
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
8 |
0763bb545f98
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") |
0763bb545f98
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
10 lOc = int(df.shape[0]) |
0763bb545f98
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
11 |
0763bb545f98
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
12 cl = df.columns.tolist() |
0763bb545f98
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
13 |
0763bb545f98
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) |
0763bb545f98
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']) |
0763bb545f98
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
16 d10=df.PM10_OPC_DIFF.sum() |
0763bb545f98
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() |
0763bb545f98
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)))) |
0763bb545f98
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']) |
0763bb545f98
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') |
0763bb545f98
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
21 |
0763bb545f98
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
22 if __name__=="__main__": |
0763bb545f98
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
23 |
0763bb545f98
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
24 parser = argparse.ArgumentParser() |
0763bb545f98
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
25 |
0763bb545f98
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") |
0763bb545f98
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") |
0763bb545f98
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") |
0763bb545f98
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") |
0763bb545f98
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
30 args = parser.parse_args() |
0763bb545f98
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
jay
parents:
diff
changeset
|
31 |
0763bb545f98
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) |