Skip to content

Commit 12003d0

Browse files
authored
Merge pull request #15165 from rmcdermo/master
Python: add converted NIST_deposition_gauge.py
2 parents 2b3203d + fda5e66 commit 12003d0

File tree

2 files changed

+71
-2
lines changed

2 files changed

+71
-2
lines changed

Utilities/Python/FDS_validation_script.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
# Scripts to run prior to dataplot
99

10-
#print("catchpole_spread_rates..."); subprocess.run(["python","./scripts/catchpole_spread_rates.py"])
10+
# print("catchpole_spread_rates..."); subprocess.run(["python","./scripts/catchpole_spread_rates.py"])
11+
# print("NIST_deposition_gauge..."); subprocess.run(["python","./scripts/NIST_deposition_gauge.py"])
1112

1213
# Dataplot and scatplot options
1314

@@ -25,7 +26,7 @@
2526

2627
# Special cases
2728

28-
#print("Sandia_Pools..."); subprocess.run(["python","./scripts/Sandia_Pools.py"])
29+
# print("Sandia_Pools..."); subprocess.run(["python","./scripts/Sandia_Pools.py"])
2930
print("TUS_Facade..."); subprocess.run(["python","./scripts/TUS_Facade_contours.py"])
3031
print("Wu_Bakar_Tunnels..."); subprocess.run(["python","./scripts/Wu_Bakar_Tunnels.py"])
3132

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env python3
2+
3+
# Converted from
4+
# Overholt
5+
# 10-30-2012
6+
# NIST_deposition_gauge.m
7+
8+
import os
9+
import pandas as pd
10+
11+
# Equivalent to Matlab script
12+
def main():
13+
outdir = os.path.normpath('../../../out/NIST_Deposition_Gauge/') + os.sep
14+
15+
filenames = [
16+
'NIST_SDG-2p5-100-p39a_devc.csv', 'NIST_SDG-2p5-100-p39b_devc.csv', 'NIST_SDG-2p5-100-p39c_devc.csv', 'NIST_SDG-2p5-100-p39d_devc.csv',
17+
'NIST_SDG-5p0-100-p39a_devc.csv', 'NIST_SDG-5p0-100-p39b_devc.csv', 'NIST_SDG-5p0-100-p39c_devc.csv', 'NIST_SDG-5p0-100-p39d_devc.csv',
18+
'NIST_SDG-10p0-100-p39a_devc.csv', 'NIST_SDG-10p0-100-p39b_devc.csv', 'NIST_SDG-10p0-100-p39c_devc.csv',
19+
'NIST_SDG-2p5-200-p39a_devc.csv', 'NIST_SDG-2p5-200-p39b_devc.csv', 'NIST_SDG-2p5-200-p39c_devc.csv', 'NIST_SDG-2p5-200-p39d_devc.csv',
20+
'NIST_SDG-5p0-200-p39a_devc.csv', 'NIST_SDG-5p0-200-p39b_devc.csv', 'NIST_SDG-5p0-200-p39c_devc.csv', 'NIST_SDG-5p0-200-p39d_devc.csv',
21+
'NIST_SDG-10p0-200-p39a_devc.csv', 'NIST_SDG-10p0-200-p39b_devc.csv', 'NIST_SDG-10p0-200-p39c_devc.csv'
22+
]
23+
24+
# Check for missing files
25+
skip_case = False
26+
for fn in filenames:
27+
fullpath = os.path.join(outdir, fn)
28+
if not os.path.isfile(fullpath):
29+
print(f"Error: File {fullpath} does not exist. Skipping case.")
30+
skip_case = True
31+
if skip_case:
32+
return
33+
34+
# SLPM values
35+
slpm = [2.5,2.5,2.5,2.5,5,5,5,5,10,10,10,2.5,2.5,2.5,2.5,5,5,5,5,10,10,10]
36+
37+
# Preallocate “cell arrays”
38+
sensor1 = [None]*len(filenames)
39+
sensor2 = [None]*len(filenames)
40+
sensor3 = [None]*len(filenames)
41+
sensor4 = [None]*len(filenames)
42+
43+
# Equivalent of for i=1:22
44+
for i in range(len(filenames)):
45+
fullpath = os.path.join(outdir, filenames[i])
46+
df = pd.read_csv(fullpath, skiprows=2)
47+
last_row = df.iloc[-1]
48+
sensor1[i] = last_row.iloc[2] # Matlab data(end,3)
49+
sensor2[i] = last_row.iloc[3]
50+
sensor3[i] = last_row.iloc[4]
51+
sensor4[i] = last_row.iloc[5]
52+
53+
# Write out results file (100)
54+
out100 = os.path.join(outdir, 'SDG_All_Tests_100.csv')
55+
with open(out100, 'w') as f:
56+
f.write('SLPM,Sensor1,Sensor2,Sensor3,Sensor4\n')
57+
for i in range(11): # Matlab for i=1:11
58+
f.write(f'{slpm[i]:5.3e},{sensor1[i]:5.3e},{sensor2[i]:5.3e},{sensor3[i]:5.3e},{sensor4[i]:5.3e}\n')
59+
60+
# Write out results file (200)
61+
out200 = os.path.join(outdir, 'SDG_All_Tests_200.csv')
62+
with open(out200, 'w') as f:
63+
f.write('SLPM,Sensor1,Sensor2,Sensor3,Sensor4\n')
64+
for i in range(11, 22): # Matlab for i=1:11 for the second block
65+
f.write(f'{slpm[i]:5.3e},{sensor1[i]:5.3e},{sensor2[i]:5.3e},{sensor3[i]:5.3e},{sensor4[i]:5.3e}\n')
66+
67+
if __name__ == '__main__':
68+
main()

0 commit comments

Comments
 (0)