|
| 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