Files
hpos-data/scripts/recompute.py
Pritimay Sarkar b55a6115e1 recompute
2023-11-08 14:01:36 +05:30

34 lines
1.2 KiB
Python

import pandas as pd
import os
import numpy as np
import re
import math
curdir = os.getcwd()
path_delim = '/'
df = pd.read_excel(curdir + path_delim + "data/tests_30_10_2023_10_19.xlsx", sheet_name="data")
def parse(resultData, idx):
result = [line.strip() for line in resultData.split("\n") if "RESULT" in line and "REND" in line]
# print(result[-1].split(' '))
return result[-1].split(' ')[idx]
df["led1BufferRc"] = df.apply(lambda x: parse(x['resultData'], 3), axis=1)
df["led1SampleRc"] = df.apply(lambda x: parse(x['resultData'], 5), axis=1)
df["led2BufferRc"] = df.apply(lambda x: parse(x['resultData'], 4), axis=1)
df["led2SampleRc"] = df.apply(lambda x: parse(x['resultData'], 6), axis=1)
df["led1BufferRc"] = pd.to_numeric(df["led1BufferRc"])
df["led1SampleRc"] = pd.to_numeric(df["led1SampleRc"])
df["led2BufferRc"] = pd.to_numeric(df["led2BufferRc"])
df["led2SampleRc"] = pd.to_numeric(df["led2SampleRc"])
df["absorbance"] = - np.log(df["led1BufferRc"] / df["led1SampleRc"]) / - np.log(df["led2BufferRc"] / df["led2SampleRc"])
# =IF(E17=W17,"Match"," ")
print(df)
writer = pd.ExcelWriter(curdir + path_delim + "data/recompute7.xlsx", engine = 'openpyxl')
df.to_excel(writer, sheet_name = 'op', index=False)
writer.close()