70 lines
2.7 KiB
Python
70 lines
2.7 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_TOC = Calibration(cal_file = Path(r"C:\Users\tschan_d\Documents\analysis\TOC_Analysis\20260923\TOC_Calibration.cal"))
|
|
cal_NPOC = Calibration(cal_file = Path(r"C:\Users\tschan_d\Documents\analysis\TOC_Analysis\20260923\NPOC_Calibration.cal"))
|
|
cal_IC = Calibration(cal_file = Path(r"C:\Users\tschan_d\Documents\analysis\TOC_Analysis\20260923\IC_Calibration.cal"))
|
|
|
|
for cal, name in zip([cal_TOC, cal_NPOC, cal_IC], ['TOC', 'NPOC', 'IC']):
|
|
cal.calibrate(excluded_points=None, write_to_new_file=False)
|
|
|
|
# Creating figure
|
|
fig = plt.figure(figsize=(8.8 / 2.54, 5 / 2.54))
|
|
ax = plt.axes([0.15, 0.2, 0.7, 0.6], frameon=True)
|
|
|
|
# Calibration curve with outliers
|
|
ax.scatter(cal.calibrant_data['area_average'],
|
|
cal.calibrant_data['concentration'],
|
|
color = 'red',
|
|
marker = 'o',
|
|
s = 10,
|
|
facecolor = 'None',
|
|
edgecolor = 'red',
|
|
linewidth = 0.75)
|
|
ax.plot([0, 50], cal.compute([0, 50]), linestyle = '-', color = 'black', linewidth = 1, label = str(f"$c={cal.curve.slope:1.3f}A-{abs(cal.curve.intercept):1.3f}$"))
|
|
|
|
# Axes labels
|
|
ax.set_xlabel(r'Area $A$ $(-)$')
|
|
ax.set_ylabel(r'Concentration $c$ $(\unit{\milli\gram\per\liter})$')
|
|
|
|
# Axes limits
|
|
ax.set_xlim([0, 50])
|
|
ax.set_ylim([0, 4.5])
|
|
|
|
# Legend
|
|
lines_1, labels_1 = ax.get_legend_handles_labels()
|
|
ax.legend(loc = 'upper left')
|
|
|
|
# Export
|
|
plt.savefig('figure_' + name + format, dpi=400)
|
|
plt.close() |