diff --git a/OFR_Analysis/20260902_SET02_EXP13/analysis.py b/OFR_Analysis/20260902_SET02_EXP13/analysis.py index aefc51c..322a176 100644 --- a/OFR_Analysis/20260902_SET02_EXP13/analysis.py +++ b/OFR_Analysis/20260902_SET02_EXP13/analysis.py @@ -15,7 +15,7 @@ os.chdir(pathlib.Path(__file__).parents[0]) # Imports from own modules from defs.SMPS import OFRAnalyser, OFRSample -from defs.Helper import DATFile, quick_plot_setup, final_plot_setup +from defs.Helper import DATFile, final_plot_setup from defs.OzoneMonitor import OzoneAnalyser # Imports from other modueles diff --git a/OFR_Analysis/20260904_SET02_EXP15/analysis.py b/OFR_Analysis/20260904_SET02_EXP15/analysis.py index ed73908..cf746e4 100644 --- a/OFR_Analysis/20260904_SET02_EXP15/analysis.py +++ b/OFR_Analysis/20260904_SET02_EXP15/analysis.py @@ -32,59 +32,63 @@ if __name__ == '__main__': # Setting the output format format = final_plot_setup() - # Linking to the data + # Specify the source file paths to for SMPS data + smps_analyser = OFRAnalyser(data_source_file = Path(r"Z:\Data\SMPS\processed\2026\09_September\20260904\20260904_aPinene_SOA.txt"), + flow_source_file = Path(r"Z:\People\David_Tschan\OFR_SMPS\flow_files\20260904_SET02_EXP15_flow_file.txt"), + smpl_number_list = range(1, 60), + on_time_interval=[pd.Timestamp('2026-09-04 13:22:00'), pd.Timestamp('2026-09-04 14:22:00')]) -# Specify the source file paths to for SMPS data -smps_analyser = OFRAnalyser(data_source_file = Path(r"Z:\Data\SMPS\processed\2026\09_September\20260904\20260904_aPinene_SOA.txt"), - flow_source_file = Path(r"Z:\People\David_Tschan\OFR_SMPS\flow_files\20260904_SET02_EXP15_flow_file.txt"), - smpl_number_list = range(1, 60), - on_time_interval=[pd.Timestamp('2026-09-04 13:22:00'), pd.Timestamp('2026-09-04 14:22:00')]) + # Specify the source file paths to the API O3 monitor data + ozon_analyser = OzoneAnalyser(file = DATFile(file = Path(r"Z:\Data\API_O3\2026\09_September\2026-09-04_12.28.13_PC14750_API_O3.dat"), data_name = 'ozone'), + on_time_interval = [pd.Timestamp('2026-09-04 12:37:00'), pd.Timestamp('2026-09-04 14:52:00')]) -# Specify the source file paths to the API O3 monitor data -ozon_analyser = OzoneAnalyser(file = DATFile(file = Path(r"Z:\Data\API_O3\2026\09_September\2026-09-04_12.28.13_PC14750_API_O3.dat"), data_name = 'ozone'), - on_time_interval = [pd.Timestamp('2026-09-04 12:37:00'), pd.Timestamp('2026-09-04 14:52:00')]) + # Reading in SMPS data and writing it to disk as a csv + smps_analyser.GetData() + smps_analyser.data.to_csv(path_or_buf = 'smps_data.csv', index = False) -# Reading in SMPS data and writing it to disk as a csv -smps_analyser.GetData() -smps_analyser.data.to_csv(path_or_buf = 'smps_data.csv', index = False) + # Reading in the O3 data and writing it to disk as a csv + ozon_analyser.GetData() + ozon_analyser.file.data.to_csv(path_or_buf = 'ozone_data.csv', index = False) -# Reading in the O3 data and writing it to disk as a csv -ozon_analyser.GetData() -ozon_analyser.file.data.to_csv(path_or_buf = 'ozone_data.csv', index = False) + # Creating figure + fig = plt.figure(figsize=(9/ 2.54, 6 / 2.54)) + ax_1 = plt.axes([0.15, 0.15, 0.7, 0.7], frameon=True) + ax_2 = plt.twinx(ax=ax_1) + ax_1.set_zorder(0) + ax_2.set_zorder(ax_1.get_zorder()) -# Creating figure + # Plotting ozone data + ax_1.plot(ozon_analyser.file.data['timestamp'], ozon_analyser.file.data['ozone'], color = 'black', linewidth = 0.5, linestyle = '-',label=r'$\chi_{\ce{O3}}$') -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) -ax_2 = plt.twinx(ax=ax_1) -ax_1.set_zorder(0) -ax_2.set_zorder(ax_1.get_zorder()) + # Plotting SMPS data + ax_2.step(smps_analyser.data['Starting Time (-)'], smps_analyser.data['Mass Production Rate (kg/s)'], color='blue', linestyle='-', label=r'$\accentset{*}{m}$') -ax_1.plot(ozon_analyser.file.data['timestamp'], ozon_analyser.file.data['ozone'], color = 'black', linewidth = 0.5, linestyle = '-',label=r'$\chi_{\ce{O3}}$') -ax_1.set_ylabel(r'\ce{O3} mole fraction $\chi_{\ce{O3}}$ $(\text{ppb})$') + # Adding lines indicating when the different components were switched on and off, respectively + ax_1.vlines(ozon_analyser.on_time_interval, ymin=0, ymax=120000, colors='k', linestyles='--', linewidth=0.5) + ax_2.vlines(smps_analyser.on_time_interval, ymin=0, ymax=5E-09, colors='k', linestyles='-.', linewidth=0.5) -ax_2.step(smps_analyser.data['Starting Time (-)'], smps_analyser.data['Mass Production Rate (kg/s)'], color='blue', linestyle='-', label=r'$\accentset{*}{m}$') -ax_2.set_ylabel(r'Mass flux $\accentset{*}{m}$ $(\unit{\kilo\gram\per\second})$') + # Axes labels + ax_1.set_xlabel(r'Time $(-)$') + ax_1.set_ylabel(r'\ce{O3} mole fraction $\chi_{\ce{O3}}$ $(\text{ppb})$') + ax_2.set_ylabel(r'Mass flux $\accentset{*}{m}$ $(\unit{\kilo\gram\per\second})$') -ax_1.vlines(ozon_analyser.on_time_interval, ymin=0, ymax=120000, colors='k', linestyles='--', linewidth=0.5) -ax_2.vlines(smps_analyser.on_time_interval, ymin=0, ymax=5E-09, colors='k', linestyles='-.', linewidth=0.5) + # Axes formats + ax_1.xaxis.set_major_formatter(DateFormatter(r'%H:%M')) + ax_1.xaxis.set_major_locator(HourLocator()) -ax_1.set_xlabel(r'Time $(-)$') -ax_1.xaxis.set_major_formatter(DateFormatter(r'%H:%M')) -ax_1.xaxis.set_major_locator(HourLocator()) -ax_1.set_xlim([pd.Timestamp('2026-09-04 12:15:00'), pd.Timestamp('2026-09-04 15:15:00')]) + # Axes limits + ax_1.set_xlim([pd.Timestamp('2026-09-04 12:15:00'), pd.Timestamp('2026-09-04 15:15:00')]) + ax_1.set_ylim([0, 120000]) + ax_2.set_ylim([0, 5E-09]) -lines_1, labels_1 = ax_1.get_legend_handles_labels() -lines_2, labels_2 = ax_2.get_legend_handles_labels() + # Legend + lines_1, labels_1 = ax_1.get_legend_handles_labels() + lines_2, labels_2 = ax_2.get_legend_handles_labels() + legend = plt.legend(lines_1 + lines_2, labels_1 + labels_2, loc='upper right') + legend.get_frame().set_alpha(None) + legend.get_frame().set_facecolor('white') + legend.set_zorder(100) -ax_1.set_ylim([0, 120000]) -ax_2.set_ylim([0, 5E-09]) - -legend = plt.legend(lines_1 + lines_2, labels_1 + labels_2, loc='upper right') -legend.get_frame().set_alpha(None) -legend.get_frame().set_facecolor('white') -legend.set_zorder(100) - -#plt.show() -plt.savefig('figure' + format, dpi=400) -plt.close() \ No newline at end of file + # Export + plt.savefig('figure' + format, dpi=400) + plt.close() \ No newline at end of file diff --git a/OFR_Analysis/20260904_SET02_EXP15/figure.pdf b/OFR_Analysis/20260904_SET02_EXP15/figure.pdf index de387fb..02a0309 100644 Binary files a/OFR_Analysis/20260904_SET02_EXP15/figure.pdf and b/OFR_Analysis/20260904_SET02_EXP15/figure.pdf differ diff --git a/OFR_Analysis/20260906_SET02_EXP14-15-16-17/analysis.py b/OFR_Analysis/20260906_SET02_EXP14-15-16-17/analysis.py index c1d7c37..65c9a50 100644 --- a/OFR_Analysis/20260906_SET02_EXP14-15-16-17/analysis.py +++ b/OFR_Analysis/20260906_SET02_EXP14-15-16-17/analysis.py @@ -8,118 +8,133 @@ ### ----------------------------------------------------------------------------------------------------------------------------------- ### ### IMPORTS AND CONFIGURATIONS -# Importing custom code +# Bookkeeping to store figure in correct place +import pathlib +import os +os.chdir(pathlib.Path(__file__).parents[0]) + +# Importing from own modules from defs.SMPS import OFRAnalyser -from defs.Helper import DATFile +from defs.Helper import DATFile, final_plot_setup from defs.OzoneMonitor import OzoneAnalyser -# Importing required libraries -import numpy as np +# Importing from other modules from pathlib import Path import pandas as pd - -# Importing libraries required for plotting and exporting import matplotlib.pyplot as plt -from defs.Helper import quick_plot_setup -format = quick_plot_setup() -# Linking to the data +# Avoid executing this script if it's being imported +if __name__ == '__main__': -# Specify the source file paths to for SMPS data for the different filters used -smps_analyser_01 = OFRAnalyser(data_source_file = Path(r"Z:\Data\SMPS\processed\2026\09_September\20260903\20260903_aPinene_SOA.txt"), - flow_source_file = Path(r"Z:\People\David_Tschan\OFR_SMPS\flow_files\20260903_SET02_EXP14_flow_file.txt"), - smpl_number_list = range(1, 60), - on_time_interval=[pd.Timestamp('2026-09-03 15:20:00'), pd.Timestamp('2026-09-03 16:20:00')]) -smps_analyser_02 = OFRAnalyser(data_source_file = Path(r"Z:\Data\SMPS\processed\2026\09_September\20260904\20260904_aPinene_SOA.txt"), - flow_source_file = Path(r"Z:\People\David_Tschan\OFR_SMPS\flow_files\20260904_SET02_EXP15_flow_file.txt"), - smpl_number_list = range(1, 60), - on_time_interval = [pd.Timestamp('2026-09-04 13:22:00'), pd.Timestamp('2026-09-04 14:22:00')]) -smps_analyser_03 = OFRAnalyser(data_source_file = Path(r"Z:\Data\SMPS\processed\2026\09_September\20260910\20260910_aPinene_SOA.txt"), - flow_source_file = Path(r"Z:\People\David_Tschan\OFR_SMPS\flow_files\20260910_SET02_EXP16_flow_file.txt"), - smpl_number_list = range(1, 60), - on_time_interval=[pd.Timestamp('2026-09-10 15:42:00'), pd.Timestamp('2026-09-10 16:42:00')]) -# Specify the source file paths to for SMPS data -smps_analyser_04 = OFRAnalyser(data_source_file = Path(r"Z:\Data\SMPS\processed\2026\09_September\20260914\20260914_aPinene_SOA.txt"), - flow_source_file = Path(r"Z:\People\David_Tschan\OFR_SMPS\flow_files\20260914_SET02_EXP17_flow_file.txt"), - smpl_number_list = range(1, 60), - on_time_interval=[pd.Timestamp('2026-09-14 09:45:00'), pd.Timestamp('2026-09-14 10:45:00')]) + # Setting the output format + format = final_plot_setup() -# Specify the source file paths to the API O3 monitor data for the different filters used -ozon_analyser_01 = OzoneAnalyser(file = DATFile(file = Path(r"Z:\Data\API_O3\2026\09_September\2026-09-03_14.23.44_PC14750_API_O3.dat"), data_name = 'ozone'), - on_time_interval=None) -ozon_analyser_02 = OzoneAnalyser(file = DATFile(file = Path(r"Z:\Data\API_O3\2026\09_September\2026-09-04_12.28.13_PC14750_API_O3.dat"), data_name = 'ozone'), - on_time_interval=None) -ozon_analyser_03 = OzoneAnalyser(file = DATFile(file = Path(r"Z:\Data\API_O3\2026\09_September\2026-09-10_14.43.47_PC14750_API_O3.dat"), data_name = 'ozone'), - on_time_interval = [pd.Timestamp('2026-09-10 15:00:00'), pd.Timestamp('2026-09-04 17:12:00')]) -ozon_analyser_04 = OzoneAnalyser(file = DATFile(file = Path(r"Z:\Data\API_O3\2026\09_September\2026-09-14_08.48.31_PC14750_API_O3.dat"), data_name = 'ozone'), - on_time_interval = [pd.Timestamp('2026-09-14 09:00:00'), pd.Timestamp('2026-09-14 11:15:00')]) + # Specify the source file paths to for SMPS data for the different filters used + smps_analyser_01 = OFRAnalyser(data_source_file = Path(r"Z:\Data\SMPS\processed\2026\09_September\20260903\20260903_aPinene_SOA.txt"), + flow_source_file = Path(r"Z:\People\David_Tschan\OFR_SMPS\flow_files\20260903_SET02_EXP14_flow_file.txt"), + smpl_number_list = range(1, 60), + on_time_interval=[pd.Timestamp('2026-09-03 15:20:00'), pd.Timestamp('2026-09-03 16:20:00')]) + + smps_analyser_02 = OFRAnalyser(data_source_file = Path(r"Z:\Data\SMPS\processed\2026\09_September\20260904\20260904_aPinene_SOA.txt"), + flow_source_file = Path(r"Z:\People\David_Tschan\OFR_SMPS\flow_files\20260904_SET02_EXP15_flow_file.txt"), + smpl_number_list = range(1, 60), + on_time_interval = [pd.Timestamp('2026-09-04 13:22:00'), pd.Timestamp('2026-09-04 14:22:00')]) + + smps_analyser_03 = OFRAnalyser(data_source_file = Path(r"Z:\Data\SMPS\processed\2026\09_September\20260910\20260910_aPinene_SOA.txt"), + flow_source_file = Path(r"Z:\People\David_Tschan\OFR_SMPS\flow_files\20260910_SET02_EXP16_flow_file.txt"), + smpl_number_list = range(1, 60), + on_time_interval=[pd.Timestamp('2026-09-10 15:42:00'), pd.Timestamp('2026-09-10 16:42:00')]) + + smps_analyser_04 = OFRAnalyser(data_source_file = Path(r"Z:\Data\SMPS\processed\2026\09_September\20260914\20260914_aPinene_SOA.txt"), + flow_source_file = Path(r"Z:\People\David_Tschan\OFR_SMPS\flow_files\20260914_SET02_EXP17_flow_file.txt"), + smpl_number_list = range(1, 60), + on_time_interval=[pd.Timestamp('2026-09-14 09:45:00'), pd.Timestamp('2026-09-14 10:45:00')]) -# Reading in SMPS data + # Specify the source file paths to the API O3 monitor data for the different filters used + ozon_analyser_01 = OzoneAnalyser(file = DATFile(file = Path(r"Z:\Data\API_O3\2026\09_September\2026-09-03_14.23.44_PC14750_API_O3.dat"), + data_name = 'ozone'), + on_time_interval=None) + + ozon_analyser_02 = OzoneAnalyser(file = DATFile(file = Path(r"Z:\Data\API_O3\2026\09_September\2026-09-04_12.28.13_PC14750_API_O3.dat"), + data_name = 'ozone'), + on_time_interval=None) + + ozon_analyser_03 = OzoneAnalyser(file = DATFile(file = Path(r"Z:\Data\API_O3\2026\09_September\2026-09-10_14.43.47_PC14750_API_O3.dat"), + data_name = 'ozone'), + on_time_interval = [pd.Timestamp('2026-09-10 15:00:00'), pd.Timestamp('2026-09-04 17:12:00')]) + + ozon_analyser_04 = OzoneAnalyser(file = DATFile(file = Path(r"Z:\Data\API_O3\2026\09_September\2026-09-14_08.48.31_PC14750_API_O3.dat"), + data_name = 'ozone'), + on_time_interval = [pd.Timestamp('2026-09-14 09:00:00'), pd.Timestamp('2026-09-14 11:15:00')]) -for smps_analyser, ozon_analyser in zip([smps_analyser_01, smps_analyser_02, smps_analyser_03, smps_analyser_04], [ozon_analyser_01, ozon_analyser_02, ozon_analyser_03, ozon_analyser_04]): + # Reading in the data and averaging it so that a correlation diagram with ozone becomes feasible + for smps_analyser, ozon_analyser in zip([smps_analyser_01, smps_analyser_02, smps_analyser_03, smps_analyser_04], + [ozon_analyser_01, ozon_analyser_02, ozon_analyser_03, ozon_analyser_04]): - smps_analyser.GetData() - ozon_analyser.GetData() + smps_analyser.GetData() + ozon_analyser.GetData() - ozon_analyser.AverageWithSMPS(smps_analyser = smps_analyser, cut_edges = 2, subtract_baseline = ['yes', 1], normalise_flow=False) + ozon_analyser.AverageWithSMPS(smps_analyser = smps_analyser, cut_edges = 2, subtract_baseline = ['yes', 1], normalise_flow=False) -# Creating figure -# space for figure: 18 cm (text width), therefore we can use 9 cm for a figure. + # Creating figure + fig = plt.figure(figsize=(9/ 2.54, 6 / 2.54)) + ax = plt.axes([0.15, 0.15, 0.7, 0.7], frameon=True) -fig = plt.figure(figsize=(8.8 / 2.54, 5 / 2.54)) -ax = plt.axes([0.15, 0.2, 0.7, 0.6], frameon=True) + # Plotting data for first filter + ax.plot(ozon_analyser_01.averaged_data.values[:, 0] / 1000, + ozon_analyser_01.averaged_data.values[:, 1], + color = 'red', + linewidth = 0.5, + linestyle = ':', + marker = 'o', + markersize = 2.5, + markerfacecolor = 'red', + label = r'Set 2 Exp. 14') -ax.plot(ozon_analyser_01.averaged_data.values[:, 0] / 1000, - ozon_analyser_01.averaged_data.values[:, 1], - color = 'red', - linewidth = 0.5, - linestyle = ':', - marker = 'o', - markersize = 2.5, - markerfacecolor = 'red', - label = r'Set 2 Exp. 14') + # Plotting data for second filter + ax.plot(ozon_analyser_02.averaged_data.values[:, 0] / 1000, + ozon_analyser_02.averaged_data.values[:, 1], + color = 'blue', + linewidth = 0.5, + linestyle = ':', + marker = 'd', + markersize = 4, + markerfacecolor = 'blue', + label = 'Set 2 Exp. 15') -ax.plot(ozon_analyser_02.averaged_data.values[:, 0] / 1000, - ozon_analyser_02.averaged_data.values[:, 1], - color = 'blue', - linewidth = 0.5, - linestyle = ':', - marker = 'd', - markersize = 4, - markerfacecolor = 'blue', - label = 'Set 2 Exp. 15') + # Plotting data for third filter + ax.plot(ozon_analyser_03.averaged_data.values[:, 0] / 1000, + ozon_analyser_03.averaged_data.values[:, 1], + color = 'green', + linewidth = 0.5, + linestyle = ':', + marker = 's', + markersize = 2.5, + markerfacecolor = 'green', + label = 'Set 2 Exp. 16') -ax.plot(ozon_analyser_03.averaged_data.values[:, 0] / 1000, - ozon_analyser_03.averaged_data.values[:, 1], - color = 'green', - linewidth = 0.5, - linestyle = ':', - marker = 's', - markersize = 2.5, - markerfacecolor = 'green', - label = 'Set 2 Exp. 16') -ax.plot(ozon_analyser_04.averaged_data.values[:, 0] / 1000, - ozon_analyser_04.averaged_data.values[:, 1], - color = 'darkorange', - linewidth = 0.5, - linestyle = ':', - marker = '^', - markersize = 4, - markerfacecolor = 'darkorange', - label = 'Set 2 Exp. 17') + # Plotting data for forth filter + ax.plot(ozon_analyser_04.averaged_data.values[:, 0] / 1000, + ozon_analyser_04.averaged_data.values[:, 1], + color = 'darkorange', + linewidth = 0.5, + linestyle = ':', + marker = '^', + markersize = 4, + markerfacecolor = 'darkorange', + label = 'Set 2 Exp. 17') -#ax.set_yscale('log') + # Axes labels + ax.set_xlabel(r'Deviation from $\ce{O3}$ baseline $\Delta\chi_{\ce{O3}}$ $(\unit{\ppm})$') + ax.set_ylabel(r'Mass flux $\accentset{*}{m}$ $(\unit{\kilo\gram\per\second})$') -ax.set_xlabel(r'Deviation from $\ce{O3}$ baseline $\Delta\chi_{\ce{O3}}$ $(\unit{\ppm})$') -ax.set_ylabel(r'Mass flux $\accentset{*}{m}$ $(\unit{\kilo\gram\per\second})$') + # Axes limits + ax.set_ylim([1E-9, 5E-09]) + ax.set_xlim([2, 14]) -#ax.set_ylim([0, 70000]) -ax.set_ylim([1E-9, 5E-09]) -#ax.set_xscale('log') -ax.set_xlim([2, 14]) + # Legend + ax.legend(loc='upper right') -ax.legend(loc='upper right') - -#plt.show() -plt.savefig('figure' + format, dpi=400) -plt.close() \ No newline at end of file + # Export + plt.savefig('figure' + format, dpi=400) + plt.close() \ No newline at end of file diff --git a/OFR_Analysis/20260906_SET02_EXP14-15-16-17/figure.pdf b/OFR_Analysis/20260906_SET02_EXP14-15-16-17/figure.pdf index d9ad83d..cd3e5b8 100644 Binary files a/OFR_Analysis/20260906_SET02_EXP14-15-16-17/figure.pdf and b/OFR_Analysis/20260906_SET02_EXP14-15-16-17/figure.pdf differ diff --git a/OFR_Analysis/20260910_SET02_EXP16/analysis.py b/OFR_Analysis/20260910_SET02_EXP16/analysis.py index 3ce8bf8..f5f7820 100644 --- a/OFR_Analysis/20260910_SET02_EXP16/analysis.py +++ b/OFR_Analysis/20260910_SET02_EXP16/analysis.py @@ -8,75 +8,85 @@ ### ----------------------------------------------------------------------------------------------------------------------------------- ### ### IMPORTS AND CONFIGURATIONS -# Importing custom code +# Bookkeeping to store figure in correct place +import pathlib +import os +os.chdir(pathlib.Path(__file__).parents[0]) + +# Imports from own modules from defs.SMPS import OFRAnalyser, OFRSample -from defs.Helper import DATFile +from defs.Helper import DATFile, final_plot_setup from defs.OzoneMonitor import OzoneAnalyser -# Importing required libraries -import numpy as np +# Imports from other modueles from pathlib import Path import pandas as pd - -# Importing libraries required for plotting and exporting import matplotlib.pyplot as plt from matplotlib.dates import DateFormatter, HourLocator -from defs.Helper import quick_plot_setup, final_plot_setup -format = quick_plot_setup() -# Linking to the data +if __name__ == '__main__': -# Specify the source file paths to for SMPS data -smps_analyser = OFRAnalyser(data_source_file = Path(r"Z:\Data\SMPS\processed\2026\09_September\20260910\20260910_aPinene_SOA.txt"), - flow_source_file = Path(r"Z:\People\David_Tschan\OFR_SMPS\flow_files\20260910_SET02_EXP16_flow_file.txt"), - smpl_number_list = range(1, 60), - on_time_interval=[pd.Timestamp('2026-09-10 15:42:00'), pd.Timestamp('2026-09-10 16:42:00')]) + # Setting up the output format + format = final_plot_setup() -# Specify the source file paths to the API O3 monitor data -ozon_analyser = OzoneAnalyser(file = DATFile(file = Path(r"Z:\Data\API_O3\2026\09_September\2026-09-10_14.43.47_PC14750_API_O3.dat"), data_name = 'ozone'), - on_time_interval = [pd.Timestamp('2026-09-10 15:00:00'), pd.Timestamp('2026-09-04 17:12:00')]) + # Specify the source file paths to for SMPS data + smps_analyser = OFRAnalyser(data_source_file = Path(r"Z:\Data\SMPS\processed\2026\09_September\20260910\20260910_aPinene_SOA.txt"), + flow_source_file = Path(r"Z:\People\David_Tschan\OFR_SMPS\flow_files\20260910_SET02_EXP16_flow_file.txt"), + smpl_number_list = range(1, 60), + on_time_interval=[pd.Timestamp('2026-09-10 15:42:00'), pd.Timestamp('2026-09-10 16:42:00')]) -# Reading in SMPS data and writing it to disk as a csv -smps_analyser.GetData() -smps_analyser.data.to_csv(path_or_buf = 'smps_data.csv', index = False) + # Specify the source file paths to the API O3 monitor data + ozon_analyser = OzoneAnalyser(file = DATFile(file = Path(r"Z:\Data\API_O3\2026\09_September\2026-09-10_14.43.47_PC14750_API_O3.dat"), + data_name = 'ozone'), + on_time_interval = [pd.Timestamp('2026-09-10 15:00:00'), pd.Timestamp('2026-09-04 17:12:00')]) -# Reading in the O3 data and writing it to disk as a csv -ozon_analyser.GetData() -ozon_analyser.file.data.to_csv(path_or_buf = 'ozone_data.csv', index = False) + # Reading in SMPS data and writing it to disk as a csv + smps_analyser.GetData() + smps_analyser.data.to_csv(path_or_buf = 'smps_data.csv', index = False) -# Creating figure + # Reading in the O3 data and writing it to disk as a csv + ozon_analyser.GetData() + ozon_analyser.file.data.to_csv(path_or_buf = 'ozone_data.csv', index = False) -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) -ax_2 = plt.twinx(ax=ax_1) -ax_1.set_zorder(0) -ax_2.set_zorder(ax_1.get_zorder()) + # Creating figure + fig = plt.figure(figsize=(9/ 2.54, 6 / 2.54)) + ax_1 = plt.axes([0.15, 0.15, 0.7, 0.7], frameon=True) + ax_2 = plt.twinx(ax=ax_1) + ax_1.set_zorder(0) + ax_2.set_zorder(ax_1.get_zorder()) -ax_1.plot(ozon_analyser.file.data['timestamp'], ozon_analyser.file.data['ozone'], color = 'black', linewidth = 0.5, linestyle = '-',label=r'$\chi_{\ce{O3}}$') -ax_1.set_ylabel(r'\ce{O3} mole fraction $\chi_{\ce{O3}}$ $(\text{ppb})$') + # Plotting ozone data + ax_1.plot(ozon_analyser.file.data['timestamp'], ozon_analyser.file.data['ozone'], color = 'black', linewidth = 0.5, linestyle = '-',label=r'$\chi_{\ce{O3}}$') -ax_2.step(smps_analyser.data['Starting Time (-)'], smps_analyser.data['Mass Production Rate (kg/s)'], color='green', linestyle='-', label=r'$\accentset{*}{m}$') -ax_2.set_ylabel(r'Mass flux $\accentset{*}{m}$ $(\unit{\kilo\gram\per\second})$') + # Plotting SMPS data + ax_2.step(smps_analyser.data['Starting Time (-)'], smps_analyser.data['Mass Production Rate (kg/s)'], color='green', linestyle='-', label=r'$\accentset{*}{m}$') -ax_1.vlines(ozon_analyser.on_time_interval, ymin=0, ymax=120000, colors='k', linestyles='--', linewidth=0.5) -ax_2.vlines(smps_analyser.on_time_interval, ymin=0, ymax=5E-09, colors='k', linestyles='-.', linewidth=0.5) + # Adding lines indicating when the different components were switched on and off, respectively + ax_1.vlines(ozon_analyser.on_time_interval, ymin=0, ymax=120000, colors='k', linestyles='--', linewidth=0.5) + ax_2.vlines(smps_analyser.on_time_interval, ymin=0, ymax=5E-09, colors='k', linestyles='-.', linewidth=0.5) -ax_1.set_xlabel(r'Time $(-)$') -ax_1.xaxis.set_major_formatter(DateFormatter(r'%H:%M')) -ax_1.xaxis.set_major_locator(HourLocator()) -ax_1.set_xlim([pd.Timestamp('2026-09-10 14:45:00'), pd.Timestamp('2026-09-10 17:45:00')]) + # Axes labels + ax_1.set_xlabel(r'Time $(-)$') + ax_1.set_ylabel(r'\ce{O3} mole fraction $\chi_{\ce{O3}}$ $(\text{ppb})$') + ax_2.set_ylabel(r'Mass flux $\accentset{*}{m}$ $(\unit{\kilo\gram\per\second})$') -lines_1, labels_1 = ax_1.get_legend_handles_labels() -lines_2, labels_2 = ax_2.get_legend_handles_labels() + # Axes formats + ax_1.xaxis.set_major_formatter(DateFormatter(r'%H:%M')) + ax_1.xaxis.set_major_locator(HourLocator()) -ax_1.set_ylim([0, 120000]) -ax_2.set_ylim([0, 5E-09]) + # Axes limits + ax_1.set_xlim([pd.Timestamp('2026-09-10 14:45:00'), pd.Timestamp('2026-09-10 17:45:00')]) + ax_1.set_ylim([0, 120000]) + ax_2.set_ylim([0, 5E-09]) -legend = plt.legend(lines_1 + lines_2, labels_1 + labels_2, loc='upper right') -legend.get_frame().set_alpha(None) -legend.get_frame().set_facecolor('white') -legend.set_zorder(100) + # Legend + lines_1, labels_1 = ax_1.get_legend_handles_labels() + lines_2, labels_2 = ax_2.get_legend_handles_labels() + legend = plt.legend(lines_1 + lines_2, labels_1 + labels_2, loc='upper right') + legend.get_frame().set_alpha(None) + legend.get_frame().set_facecolor('white') + legend.set_zorder(100) -#plt.show() -plt.savefig('figure' + format, dpi=400) -plt.close() \ No newline at end of file + # Export + plt.savefig('figure' + format, dpi=400) + plt.close() \ No newline at end of file diff --git a/OFR_Analysis/20260910_SET02_EXP16/figure.pdf b/OFR_Analysis/20260910_SET02_EXP16/figure.pdf index 093f9ad..6428b4e 100644 Binary files a/OFR_Analysis/20260910_SET02_EXP16/figure.pdf and b/OFR_Analysis/20260910_SET02_EXP16/figure.pdf differ diff --git a/OFR_Analysis/20260914_SET02_EXP17/analysis.py b/OFR_Analysis/20260914_SET02_EXP17/analysis.py index 1151409..c6ea931 100644 --- a/OFR_Analysis/20260914_SET02_EXP17/analysis.py +++ b/OFR_Analysis/20260914_SET02_EXP17/analysis.py @@ -8,74 +8,88 @@ ### ----------------------------------------------------------------------------------------------------------------------------------- ### ### IMPORTS AND CONFIGURATIONS -# Importing custom code +# Bookkeeping to store figure in correct place +import pathlib +import os +os.chdir(pathlib.Path(__file__).parents[0]) + +# Imports from own modules from defs.SMPS import OFRAnalyser, OFRSample -from defs.Helper import DATFile +from defs.Helper import DATFile, final_plot_setup from defs.OzoneMonitor import OzoneAnalyser -# Importing required libraries -import numpy as np +# Imports from other modueles from pathlib import Path import pandas as pd - -# Importing libraries required for plotting and exporting import matplotlib.pyplot as plt from matplotlib.dates import DateFormatter, HourLocator -from defs.Helper import quick_plot_setup, final_plot_setup -format = quick_plot_setup() -# Linking to the data +### ----------------------------------------------------------------------------------------------------------------------------------- ### +### analysis.py -# Specify the source file paths to for SMPS data -smps_analyser = OFRAnalyser(data_source_file = Path(r"Z:\Data\SMPS\processed\2026\09_September\20260914\20260914_aPinene_SOA.txt"), - flow_source_file = Path(r"Z:\People\David_Tschan\OFR_SMPS\flow_files\20260914_SET02_EXP17_flow_file.txt"), - smpl_number_list = range(1, 60), - on_time_interval=[pd.Timestamp('2026-09-14 09:45:00'), pd.Timestamp('2026-09-14 10:45:00')]) +if __name__ == '__main__': -# Specify the source file paths to the API O3 monitor data -ozon_analyser = OzoneAnalyser(file = DATFile(file = Path(r"Z:\Data\API_O3\2026\09_September\2026-09-14_08.48.31_PC14750_API_O3.dat"), data_name = 'ozone'), - on_time_interval = [pd.Timestamp('2026-09-14 09:00:00'), pd.Timestamp('2026-09-14 11:15:00')]) -# Reading in SMPS data and writing it to disk as a csv -smps_analyser.GetData() -smps_analyser.data.to_csv(path_or_buf = 'smps_data.csv', index = False) + # Setting the output format + format = final_plot_setup() -# Reading in the O3 data and writing it to disk as a csv -ozon_analyser.GetData() -ozon_analyser.file.data.to_csv(path_or_buf = 'ozone_data.csv', index = False) + # Specify the source file paths to for SMPS data + smps_analyser = OFRAnalyser(data_source_file = Path(r"Z:\Data\SMPS\processed\2026\09_September\20260914\20260914_aPinene_SOA.txt"), + flow_source_file = Path(r"Z:\People\David_Tschan\OFR_SMPS\flow_files\20260914_SET02_EXP17_flow_file.txt"), + smpl_number_list = range(1, 60), + on_time_interval=[pd.Timestamp('2026-09-14 09:45:00'), pd.Timestamp('2026-09-14 10:45:00')]) -# Creating figure + # Specify the source file paths to the API O3 monitor data + ozon_analyser = OzoneAnalyser(file = DATFile(file = Path(r"Z:\Data\API_O3\2026\09_September\2026-09-14_08.48.31_PC14750_API_O3.dat"), + data_name = 'ozone'), + on_time_interval = [pd.Timestamp('2026-09-14 09:00:00'), pd.Timestamp('2026-09-14 11:15:00')]) + + # Reading in SMPS data and writing it to disk as a csv + smps_analyser.GetData() + smps_analyser.data.to_csv(path_or_buf = 'smps_data.csv', index = False) -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) -ax_2 = plt.twinx(ax=ax_1) -ax_1.set_zorder(0) -ax_2.set_zorder(ax_1.get_zorder()) + # Reading in the O3 data and writing it to disk as a csv + ozon_analyser.GetData() + ozon_analyser.file.data.to_csv(path_or_buf = 'ozone_data.csv', index = False) -ax_1.plot(ozon_analyser.file.data['timestamp'], ozon_analyser.file.data['ozone'], color = 'black', linestyle = '-', linewidth = 0.5,label=r'$\chi_{\ce{O3}}$') -ax_1.set_ylabel(r'\ce{O3} mole fraction $\chi_{\ce{O3}}$ $(\text{ppb})$') + # Creating figure + fig = plt.figure(figsize=(9/ 2.54, 6 / 2.54)) + ax_1 = plt.axes([0.15, 0.15, 0.7, 0.7], frameon=True) + ax_2 = plt.twinx(ax=ax_1) + ax_1.set_zorder(0) + ax_2.set_zorder(ax_1.get_zorder()) -ax_2.step(smps_analyser.data['Starting Time (-)'], smps_analyser.data['Mass Production Rate (kg/s)'], color='darkorange', linestyle='-', label=r'$\accentset{*}{m}$') -ax_2.set_ylabel(r'Mass flux $\accentset{*}{m}$ $(\unit{\kilo\gram\per\second})$') + # Plotting ozone data + ax_1.plot(ozon_analyser.file.data['timestamp'], ozon_analyser.file.data['ozone'], color = 'black', linestyle = '-', linewidth = 0.5,label=r'$\chi_{\ce{O3}}$') -ax_1.vlines(ozon_analyser.on_time_interval, ymin=0, ymax=120000, colors='k', linestyles='--', linewidth=0.5) -ax_2.vlines(smps_analyser.on_time_interval, ymin=0, ymax=5E-09, colors='k', linestyles='-.', linewidth=0.5) + # Plotting SMPS data + ax_2.step(smps_analyser.data['Starting Time (-)'], smps_analyser.data['Mass Production Rate (kg/s)'], color='darkorange', linestyle='-', label=r'$\accentset{*}{m}$') -ax_1.set_xlabel(r'Time $(-)$') -ax_1.xaxis.set_major_formatter(DateFormatter(r'%H:%M')) -ax_1.xaxis.set_major_locator(HourLocator()) -ax_1.set_xlim([pd.Timestamp('2026-09-14 08:45:00'), pd.Timestamp('2026-09-14 11:45:00')]) + # Adding lines indicating when the different components were switched on and off, respectively + ax_1.vlines(ozon_analyser.on_time_interval, ymin=0, ymax=120000, colors='k', linestyles='--', linewidth=0.5) + ax_2.vlines(smps_analyser.on_time_interval, ymin=0, ymax=5E-09, colors='k', linestyles='-.', linewidth=0.5) -lines_1, labels_1 = ax_1.get_legend_handles_labels() -lines_2, labels_2 = ax_2.get_legend_handles_labels() + # Axes labels + ax_1.set_xlabel(r'Time $(-)$') + ax_1.set_ylabel(r'\ce{O3} mole fraction $\chi_{\ce{O3}}$ $(\text{ppb})$') + ax_2.set_ylabel(r'Mass flux $\accentset{*}{m}$ $(\unit{\kilo\gram\per\second})$') -ax_1.set_ylim([0, 120000]) -ax_2.set_ylim([0, 5E-09]) + # Axes formats + ax_1.xaxis.set_major_formatter(DateFormatter(r'%H:%M')) + ax_1.xaxis.set_major_locator(HourLocator()) -legend = plt.legend(lines_1 + lines_2, labels_1 + labels_2, loc='upper right') -legend.get_frame().set_alpha(None) -legend.get_frame().set_facecolor('white') -legend.set_zorder(100) + # Axes limits + ax_1.set_xlim([pd.Timestamp('2026-09-14 08:45:00'), pd.Timestamp('2026-09-14 11:45:00')]) + ax_1.set_ylim([0, 120000]) + ax_2.set_ylim([0, 5E-09]) -#plt.show() -plt.savefig('figure' + format, dpi=400) -plt.close() \ No newline at end of file + # Legend + lines_1, labels_1 = ax_1.get_legend_handles_labels() + lines_2, labels_2 = ax_2.get_legend_handles_labels() + legend = plt.legend(lines_1 + lines_2, labels_1 + labels_2, loc='upper right') + legend.get_frame().set_alpha(None) + legend.get_frame().set_facecolor('white') + legend.set_zorder(100) + + # Export + plt.savefig('figure' + format, dpi=400) + plt.close() \ No newline at end of file diff --git a/OFR_Analysis/20260914_SET02_EXP17/figure.pdf b/OFR_Analysis/20260914_SET02_EXP17/figure.pdf index 3352a37..aec9ebd 100644 Binary files a/OFR_Analysis/20260914_SET02_EXP17/figure.pdf and b/OFR_Analysis/20260914_SET02_EXP17/figure.pdf differ