diff --git a/.mplstyle b/.mplstyle index b9a1831..4a90745 100644 --- a/.mplstyle +++ b/.mplstyle @@ -4,6 +4,11 @@ text.usetex: True text.latex.preamble: "\usepackage{arev}\usepackage{accents}\usepackage{siunitx}\usepackage{mhchem}\newcommand{\der}[1]{\ensuremath{\textnormal{d}\,{#1}}}" lines.linewidth: 1.00 # line width in points lines.linestyle: - # solid line +lines.marker: None # the default marker +lines.markerfacecolor: black # the default marker face color +lines.markeredgecolor: None # the default marker edge color +lines.markeredgewidth: 0 # the line width around the marker symbol +lines.markersize: 2 # marker size, in points # AXES AND BOX axes.facecolor: white # axes background color diff --git a/main.py b/main.py index d267817..1584d6e 100644 --- a/main.py +++ b/main.py @@ -1,11 +1,68 @@ -# Imports +# Importing custom code from defs.OFR import OFRSample, OFRAnalyser +from defs.Helper import DATFile + +# Importing required libraries +import numpy as np from pathlib import Path +import pandas as pd + +def ozone_averager(ozon_analyser: DATFile, smps_analyser: OFRAnalyser, voc_on_times, cut_edges = True, subtract_5min_baseline = True) -> np.ndarray: + + average_ozon_values = [] + mass_production_rates = [] + + local_smps_data = smps_analyser.data[(smps_analyser.data['Starting Time (-)'] >= voc_on_times[0]) & (smps_analyser.data['Starting Time (-)'] >= voc_on_times[0])].reset_index() + + baseline = None + + for index, data in local_smps_data.iterrows(): + + start = data['Starting Time (-)'] + + if index == 0: + + if subtract_5min_baseline == True: + baseline_start = start - pd.Timedelta(minutes=5) + baseline_ozone_data = ozon_analyser.data[(ozon_analyser.data['timestamp'] >= baseline_start) & (ozon_analyser.data['timestamp'] <= start)] + baseline = np.average(baseline_ozone_data['ozone']) + + if cut_edges == True: + continue + + stop = start + pd.Timedelta(seconds = data['Sampling Time (s)']) + + mass_production_rates.append(data['Mass Production Rate (kg/s)']) + + local_ozone_data = ozon_analyser.data[(ozon_analyser.data['timestamp'] >= start) & (ozon_analyser.data['timestamp'] <= stop)] + average_ozon_values.append(np.average(local_ozone_data['ozone'])) + + if cut_edges == True: + del average_ozon_values[-1] + del mass_production_rates[-1] + + if subtract_5min_baseline == True: + output_average_ozone_values = [baseline - value for value in average_ozon_values] + elif subtract_5min_baseline == False: + output_average_ozone_values = [value for value in average_ozon_values] + + return output_average_ozone_values, mass_production_rates # 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\20260902\20260902_aPinene_SOA.txt"), - flow_source_file = Path(r"Z:\People\David_Tschan\OFR_SMPS\flow_files\20260902_SET02_EXP13_flow_file.txt"), - smpl_number_list = range(1, 60)) +# Specify the source file paths to for SMPS data for the different filters used +smps_analyser = 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)) + +# Specify the source file paths to the API O3 monitor data for the different filters used +ozon_analyser =DATFile(file = Path(r"Z:\Data\API_O3\2026\09_September\2026-09-03_14.23.44_PC14750_API_O3.dat"), data_name = 'ozone') + +voc_on_times = [pd.Timestamp('2026-09-03 15:20:00'), pd.Timestamp('2026-09-03 16:20:00')] + smps_analyser.GetData() +ozon_analyser.read() + +ozone_average, mass_production_rates = ozone_averager(ozon_analyser=ozon_analyser, smps_analyser=smps_analyser, voc_on_times = voc_on_times, cut_edges=False, subtract_5min_baseline=True) + +print('hello')