File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
libra_toolbox/neutron_detection/activation_foils Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ import numpy as np
2+ import os
13
24
35def get_channel (filename ):
@@ -23,4 +25,33 @@ def get_channel(filename):
2325 return int (filename .split ('@' )[0 ][7 :])
2426
2527
28+ def sort_compass_files (directory ):
29+ """ Gets Compass csv data filenames
30+ and sorts them according to channel and ending number.
31+ The filenames need to be sorted by ending number because only
32+ the first csv file for each channel contains a header.
33+
34+ Example of sorted filenames in directory:
35+ 1st file: Data_CH4@...22.CSV
36+ 2nd file: Data_CH4@...22_1.CSV
37+ 3rd file: Data_CH4@...22_2.CSV """
38+
39+ filenames = os .listdir (directory )
40+ data_filenames = {}
41+ for filename in filenames :
42+ if filename .lower ().endswith ('.csv' ):
43+ ch = get_channel (filename )
44+ # initialize filenames for each channel
45+ if ch not in data_filenames .keys ():
46+ data_filenames [ch ] = []
47+
48+ data_filenames [ch ] = filename
49+ # Sort filenames by number at end
50+ for ch in data_filenames .keys ():
51+ data_filenames [ch ] = np .sort (data_filenames [ch ])
52+
53+ return data_filenames
54+
55+
56+
2657
You can’t perform that action at this time.
0 commit comments