scripts to analyse unit-cell size as a function of chip aperture
This commit is contained in:
64
cool_tools/uc_analysis.py
Normal file
64
cool_tools/uc_analysis.py
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# author J.Beale
|
||||
|
||||
"""
|
||||
# aim
|
||||
compile results from 3 chips to give mean and std.
|
||||
|
||||
# usage
|
||||
python uc_analysis.py <path to csv 1> <path to csv 2> <path to csv 3> output
|
||||
|
||||
# output
|
||||
compile csv of 3 chips and gives a per aperture output of the hits, mean uc and std. uc
|
||||
"""
|
||||
|
||||
# modules
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import sys
|
||||
|
||||
def compile_inputs( csv_lst, output ):
|
||||
|
||||
print( "compiling results" )
|
||||
# overall inputs
|
||||
compiled_df = pd.DataFrame()
|
||||
merged_df = pd.DataFrame()
|
||||
|
||||
count=1
|
||||
for csv in csv_lst:
|
||||
|
||||
uc_vol = "vol_{0}".format( count )
|
||||
hits = "hits_{0}".format( count )
|
||||
cols = [ uc_vol, hits ]
|
||||
csv_df = pd.read_csv( csv,
|
||||
skiprows=1,
|
||||
names=cols,
|
||||
index_col=0,
|
||||
sep=","
|
||||
)
|
||||
|
||||
compiled_df = pd.concat( ( compiled_df, csv_df ), axis=1 )
|
||||
|
||||
count = count +1
|
||||
|
||||
# merge hits
|
||||
merged_df[ "hits" ] = compiled_df[ [ "hits_1", "hits_2", "hits_3" ] ].sum(axis=1)
|
||||
merged_df[ "vol_mean" ] = compiled_df[ [ "vol_1", "vol_2", "vol_3" ] ].mean(axis=1)
|
||||
merged_df[ "vol_std" ] = compiled_df[ [ "vol_1", "vol_2", "vol_3" ] ].std(axis=1)
|
||||
|
||||
# output results
|
||||
file_name = "{0}_uc.csv".format( output )
|
||||
merged_df.to_csv( file_name, sep="," )
|
||||
print( "done" )
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
csv_lst = [ sys.argv[1],
|
||||
sys.argv[2],
|
||||
sys.argv[3]
|
||||
]
|
||||
|
||||
print( sys.argv[1] )
|
||||
|
||||
compile_inputs( csv_lst, sys.argv[4] )
|
||||
Reference in New Issue
Block a user