Files

76 lines
2.8 KiB
Python

# 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
### ----------------------------------------------------------------------------------------------------------------------------------- ###
### IMPORTS AND CONFIGURATIONS
# Bookkeeping to store figure in correct place
import pathlib
import os
os.chdir(pathlib.Path(__file__).parents[0])
# Imports from own modules
from defs.TOC import Calibration
from defs.Helper import final_plot_setup, quick_plot_setup
# Imports from other modueles
from pathlib import Path
import matplotlib.pyplot as plt
from matplotlib.dates import DateFormatter, HourLocator
### ----------------------------------------------------------------------------------------------------------------------------------- ###
### analysis.py
if __name__ == '__main__':
# Setting the output format
format = final_plot_setup()
# Obtaining the calibrations
cal_01 = Calibration(cal_file = Path(r"C:\Users\tschan_d\Documents\analysis\TOC_Analysis\20260909\IC_Calibration.cal"))
cal_02 = Calibration(cal_file = Path(r"C:\Users\tschan_d\Documents\analysis\TOC_Analysis\20260909\IC_Calibration.cal"))
cal_02.calibrate(excluded_points=[7], write_to_new_file=True)
# Creating figure
fig = plt.figure(figsize=(8.8 / 2.54, 5 / 2.54))
ax_1 = plt.axes([0.15, 0.2, 0.7, 0.6], frameon=True)
# Calibration curve with outliers
ax_1.scatter(cal_01.calibrant_data['area_average'],
cal_01.calibrant_data['concentration'],
color = 'red',
marker = 'o',
s = 10,
facecolor = 'None',
edgecolor = 'red',
linewidth = 0.75)
ax_1.plot([0, 17], cal_01.compute([0, 17]), linestyle = '-.', color = 'red', linewidth = 0.75, label = str(f"$c={cal_01.curve.slope:1.3f}A-{abs(cal_01.curve.intercept):1.3f}$"))
# Calibration curve without outliers
ax_1.scatter(cal_02.calibrant_data['area_average'][cal_02.mask],
cal_02.calibrant_data['concentration'][cal_02.mask],
color = 'black',
marker = '.',
s = 5,
facecolor = 'black')
ax_1.plot([0, 17], cal_02.compute([0, 17]), linestyle = '-', color = 'black', linewidth = 0.75, label = str(f"$c={cal_02.curve.slope:1.3f}A-{abs(cal_02.curve.intercept):1.3f}$"))
# Axes labels
ax_1.set_xlabel(r'Area $A$ $(-)$')
ax_1.set_ylabel(r'Concentration $c$ $(\unit{\milli\gram\per\liter})$')
# Axes limits
ax_1.set_xlim([0, 15])
ax_1.set_ylim([0, 2.5])
# Legend
lines_1, labels_1 = ax_1.get_legend_handles_labels()
ax_1.legend(loc = 'upper left')
# Export
plt.savefig('figure' + format, dpi=400)
plt.close()