add HB in fun

This commit is contained in:
Pritimay Sarkar
2023-12-10 13:44:34 +05:30
parent fb93e8fa87
commit b0292aa757

View File

@@ -135,6 +135,13 @@ def performance(request):
"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'
@@ -142,14 +149,19 @@ def performance(request):
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:
@@ -250,7 +262,7 @@ def performance(request):
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):
@@ -270,8 +282,8 @@ def performance(request):
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
@@ -299,7 +311,6 @@ def performance(request):
writer.close()
else:
# If df is empty, create an empty Excel file
output_filename = f'/tmp/empty_excel_{datetime.today().strftime("%d_%m_%Y_%H_%M")}.xlsx'
pd.DataFrame().to_excel(output_filename, engine='xlsxwriter', index=False)