Starting TOC.py, for analysis and calibration of TOC measurements.
This commit is contained in:
1 parent
b6ac4ddeaf
commit
9ff1dd603a
1 file changed
+98
+98
@@ -0,0 +1,98 @@
|
||||
# Author: David Tschan
|
||||
# Institute: Paul-Scherrer Institute, Laboratory for Atmospheric Chemistry, Multiphase Chemistry Group,
|
||||
# Forschungsstrasse 111, 5232 Villigen PSI, Switzerland
|
||||
# Role: Master Student
|
||||
# License: n/a
|
||||
# Date: 2026
|
||||
|
||||
### ----------------------------------------------------------------------------------------------------------------------------------- ###
|
||||
### SUBMODULE DOCSTRING
|
||||
|
||||
"""The docstring for this submodule
|
||||
"""
|
||||
|
||||
### ----------------------------------------------------------------------------------------------------------------------------------- ###
|
||||
### IMPORTS AND CONFIGURATIONS
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import math
|
||||
import warnings
|
||||
|
||||
### ----------------------------------------------------------------------------------------------------------------------------------- ###
|
||||
### TOC.py
|
||||
|
||||
class TC_Calibration():
|
||||
|
||||
def init(self, cal_file):
|
||||
|
||||
self.slope = None
|
||||
self.intercept = None
|
||||
self.R2_value = None
|
||||
|
||||
self.cal_file = cal_file
|
||||
self.date = None
|
||||
|
||||
self.__read_calibration_file()
|
||||
|
||||
def calibrate(self):
|
||||
pass
|
||||
|
||||
def __read_calibration_file(self):
|
||||
|
||||
concentrations = []
|
||||
dilutions = []
|
||||
A1s = []
|
||||
A2s = []
|
||||
A3s = []
|
||||
|
||||
unit = None
|
||||
|
||||
calibration_results_flag = False
|
||||
|
||||
with open(self.cal_file, 'r', errors = 'ignore') as file:
|
||||
|
||||
results_index = None
|
||||
|
||||
for index, line in enumerate(file.readlines()):
|
||||
|
||||
if index == 8:
|
||||
unit = line.split()[0]
|
||||
|
||||
if index >= 9 and calibration_results_flag == False:
|
||||
|
||||
if line.startswith('CALIBRATION RESULTS'):
|
||||
|
||||
calibration_results_flag = True
|
||||
continue
|
||||
|
||||
else:
|
||||
|
||||
items = line.split()
|
||||
|
||||
concentrations.append(float(items[0]))
|
||||
dilutions.append(float(items[1]))
|
||||
A1s.append(float(items[2]))
|
||||
A2s.append(float(items[3]))
|
||||
A3s.append(float(items[4]))
|
||||
|
||||
if calibration_results_flag == True:
|
||||
|
||||
if line.startswith('-'):
|
||||
|
||||
if results_index is None:
|
||||
results_index = index + 1
|
||||
else:
|
||||
continue
|
||||
|
||||
continue
|
||||
|
||||
items = line.split()
|
||||
|
||||
if index == results_index:
|
||||
self.slope = float(items[1])
|
||||
elif index == results_index + 1:
|
||||
self.intercept = float(items[2])
|
||||
elif index == results_index + 2:
|
||||
self.R2_value = float(items[3])
|
||||
|
||||
Reference in new issue
Block a user