Files
hpos-data/scripts/recompute.py

34 lines
1.2 KiB
Python
Raw Normal View History

2023-09-23 11:39:23 +05:30
import pandas as pd
import os
import numpy as np
import re
import math
curdir = os.getcwd()
path_delim = '/'
2023-09-25 10:24:16 +05:30
df = pd.read_excel(curdir + path_delim + "data/data_25_09_2023_10_06.xlsx", sheet_name="data")
2023-09-23 11:39:23 +05:30
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)
2023-09-25 10:24:16 +05:30
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"," ")
2023-09-23 11:39:23 +05:30
print(df)
2023-09-25 10:24:16 +05:30
writer = pd.ExcelWriter(curdir + path_delim + "data/recompute3.xlsx", engine = 'openpyxl')
2023-09-23 11:39:23 +05:30
df.to_excel(writer, sheet_name = 'op', index=False)
writer.close()