add HB in auto analysis

This commit is contained in:
Pritimay Sarkar
2023-12-08 21:47:38 +05:30
parent 9b7000db4f
commit 988ad4c621

View File

@@ -61,6 +61,13 @@ denovix_reference_values = {
"1450": 0.447634285,
"1550": 0.478220085,
},
"HB": {
"2": 0.187191676,
"4": 0.187191676,
"5": 0.187191676,
"6": 0.187191676,
"8": 0.077846397,
},
}
df_reference_device = pd.DataFrame(denovix_reference_values).T
df_reference_device.index.name = 'Solution'
@@ -70,14 +77,19 @@ df = pd.read_excel(curdir + path_delim + "data" + path_delim + "data_06_12_2023_
if not df.empty:
conditions = [df['name'].str.contains('Tar', case=False, na=False),
df['name'].str.contains('KM', case=False, na=False)]
df['name'].str.contains('KM', case=False, na=False),
df['name'].str.contains('HB', case=False, na=False)]
choices = ['Tartrazine', 'KMnO4']
choices = ['Tartrazine', 'KMnO4', "HB"]
df['solution'] = np.select(conditions, choices, default=None)
def extract_numbers(s):
match = re.search(r'-(\d+)', s) or re.search(r'(\d+)', s)
if "HB" in s:
match = re.search(r'-(\d+)$', s)
else:
match = re.search(r'-(\d+)', s) or re.search(r'(\d+)', s)
if match:
return int(match.group(1))
else:
@@ -178,7 +190,7 @@ if not df.empty:
fig, ax = plt.subplots()
filtered_df = df[df['solution'].isin(['KMnO4', 'Tartrazine'])]
filtered_df = df[df['solution'].isin(['KMnO4', 'Tartrazine', 'HB'])]
for solution in filtered_df['solution'].unique():
if pd.notna(solution):
@@ -199,8 +211,8 @@ if not df.empty:
ax.text(concentration_means.index[-1] + 5, np.polyval(coefficients, concentration_means.index[-1]), annotation_text, fontsize=10, verticalalignment='center')
wks1.write(row, 0, solution)
wks1.write(row, 1, coefficients[0])
wks1.write(row, 2, coefficients[1])
wks1.write(row, 1, str(coefficients[0]))
wks1.write(row, 2, str(coefficients[1]))
row += 1
@@ -227,6 +239,5 @@ if not df.empty:
writer.close()
else:
# If df is empty, create an empty Excel file
empty_output_filename = f'data/empty_excel_{datetime.today().strftime("%d_%m_%Y_%H_%M")}.xlsx'
pd.DataFrame().to_excel(empty_output_filename, engine='xlsxwriter', index=False)