Skip to content

Commit 440f471

Browse files
cdunn314RemDelaporteMathurin
authored andcommitted
Added sort_compass_files function
Sort compass filenames and associated tests Using absolute path for compass_data Update libra_toolbox/neutron_detection/activation_foils/compass.py Co-authored-by: Rémi Delaporte-Mathurin <40028739+RemDelaporteMathurin@users.noreply.github.com> Update libra_toolbox/neutron_detection/activation_foils/compass.py Co-authored-by: Rémi Delaporte-Mathurin <40028739+RemDelaporteMathurin@users.noreply.github.com> Added full set of test files Reduced filesize Added new test cases to test_compass Reformatted with black Deleted old test files
1 parent 6b4edd2 commit 440f471

File tree

52 files changed

+2800417
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2800417
-7
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,8 @@ cython_debug/
161161
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
162162
#.idea/
163163

164-
**/_version.py
164+
**/_version.py
165+
166+
# Compass binary file
167+
*.DS_Store
168+
settings.xml

libra_toolbox/neutron_detection/activation_foils/compass.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import numpy as np
2+
import os
13

24

35
def 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: str) -> dict:
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].append(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

0 commit comments

Comments
 (0)