find max of 427, 555 in df
This commit is contained in:
@@ -68,7 +68,7 @@ def consolidate_and_perform_calculations(curdir, rootdir, path_delim, validation
|
||||
|
||||
# 427 nm range
|
||||
df1 = df[ (df['Wavelength'] > (midpoint1-bandwidth1)) & (df['Wavelength'] < (midpoint1+bandwidth1)) ]
|
||||
|
||||
|
||||
# 555 nm range
|
||||
df2 = df[ (df['Wavelength'] > (midpoint2-bandwidth2)) & (df['Wavelength'] < (midpoint2+bandwidth2)) ]
|
||||
|
||||
@@ -89,11 +89,38 @@ def consolidate_and_perform_calculations(curdir, rootdir, path_delim, validation
|
||||
writer.close()
|
||||
|
||||
|
||||
def device_calculations(device_dir):
|
||||
csv_files = glob.glob(device_dir + path_delim + '/*.{}'.format('csv'))
|
||||
if len(csv_files) == 0:
|
||||
print("no csv files in the sub folder")
|
||||
|
||||
for file in csv_files:
|
||||
df = pd.read_csv(file)
|
||||
|
||||
print(file)
|
||||
|
||||
midpoint1 = 427
|
||||
midpoint2 = 555
|
||||
bandwidth1 = 1
|
||||
bandwidth2 = 1
|
||||
|
||||
df.rename(columns = {"tv":"Wavelength","ca":"Absorbance"}, inplace = True)
|
||||
|
||||
df1 = df[ (df['Wavelength'] > (midpoint1)) & (df['Wavelength'] < (midpoint1+bandwidth1)) ]
|
||||
df2 = df[ (df['Wavelength'] > (midpoint2)) & (df['Wavelength'] < (midpoint2+bandwidth2)) ]
|
||||
print("df", df1.iloc[0]['Wavelength'])
|
||||
start_wavlength_427 = df1.iloc[0]['Wavelength']
|
||||
print(df1.loc[df1['Wavelength'] == start_wavlength_427])
|
||||
|
||||
print("max_427", round(df1["Absorbance"].max(), 5))
|
||||
print("wvmax_427", round(df1.at[df1["Absorbance"].idxmax(),"Wavelength"], 5))
|
||||
print("max_555", round(df2["Absorbance"].max(), 5))
|
||||
print("wvmax_555", round(df2.at[df2["Absorbance"].idxmax(),"Wavelength"], 5))
|
||||
|
||||
sampleID = 1
|
||||
allDF = pd.DataFrame()
|
||||
procData = []
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
environment = "dev" # dev, QC
|
||||
rootdir = os.getcwd()
|
||||
@@ -107,15 +134,16 @@ if __name__ == "__main__":
|
||||
choose_validation_file = QFileDialog.getOpenFileName(None, "Select validation excel")
|
||||
validation_file = choose_validation_file[0]
|
||||
|
||||
path_delim = ''
|
||||
if platform.system() == 'Darwin':
|
||||
path_delim = '/'
|
||||
else:
|
||||
path_delim = '\\'
|
||||
|
||||
for file in tqdm(os.listdir(rootdir)):
|
||||
curdir = os.path.join(rootdir, file)
|
||||
if os.path.isdir(curdir):
|
||||
device_dir = os.path.join(rootdir, file)
|
||||
if os.path.isdir(device_dir):
|
||||
# os.chdir(d)
|
||||
consolidate_and_perform_calculations(curdir, rootdir, path_delim, validation_file)
|
||||
# consolidate_and_perform_calculations(curdir, rootdir, path_delim, validation_file)
|
||||
device_calculations(device_dir)
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user