106 lines
3.7 KiB
Python
106 lines
3.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
|
|
|
|
### ----------------------------------------------------------------------------------------------------------------------------------- ###
|
|
### SUBMODULE DOCSTRING
|
|
|
|
"""The docstring for this submodule
|
|
"""
|
|
|
|
### ----------------------------------------------------------------------------------------------------------------------------------- ###
|
|
### IMPORTS AND CONFIGURATIONS
|
|
|
|
import numpy as np
|
|
import pandas as pd
|
|
from defs.Helper import DATFile
|
|
from defs.SMPS import OFRAnalyser
|
|
|
|
### ----------------------------------------------------------------------------------------------------------------------------------- ###
|
|
### OzoneAnalyser.py
|
|
|
|
class OzoneAnalyser():
|
|
|
|
"""The docstring for this class
|
|
|
|
Description: Bla bla bla
|
|
|
|
Attributes
|
|
----------
|
|
word: str
|
|
A word
|
|
|
|
Methods
|
|
-------
|
|
__init__: HelloWorld
|
|
The class constructor
|
|
"""
|
|
|
|
def __init__(self, file: DATFile, on_time_interval):
|
|
|
|
self.file = file
|
|
self.on_time_interval = on_time_interval
|
|
self.averaged_data = None
|
|
|
|
def GetData(self):
|
|
|
|
self.file.read()
|
|
|
|
def AverageWithSMPS(self, smps_analyser: OFRAnalyser, cut_edges: int, subtract_baseline = ['yes', 5], normalise_flow = True):
|
|
|
|
avg_ozone = []
|
|
mprr_data = []
|
|
vflo_data = []
|
|
|
|
local_smps_data = smps_analyser.data[(smps_analyser.data['Starting Time (-)'] >= smps_analyser.on_time_interval[0]) &
|
|
(smps_analyser.data['Starting Time (-)'] <= smps_analyser.on_time_interval[1])].reset_index()
|
|
|
|
baseline = None
|
|
|
|
for index, data in local_smps_data.iterrows():
|
|
|
|
start = data['Starting Time (-)']
|
|
|
|
if index == 0:
|
|
|
|
if subtract_baseline[0] == 'yes':
|
|
baseline_start = start - pd.Timedelta(minutes = int(subtract_baseline[1]))
|
|
baseline_ozone_data = self.file.data[(self.file.data['timestamp'] >= baseline_start) &
|
|
(self.file.data['timestamp'] <= start)]
|
|
baseline = np.average(baseline_ozone_data['ozone'])
|
|
|
|
if index in list(range(cut_edges)):
|
|
continue
|
|
|
|
stop = start + pd.Timedelta(seconds = data['Sampling Time (s)'])
|
|
|
|
mprr_data.append(data['Mass Production Rate (kg/s)'])
|
|
vflo_data.append(data['Filter Flow (m^3/s)'] * 1E-3 / 60)
|
|
|
|
local_ozone_data = self.file.data[(self.file.data['timestamp'] >= start) &
|
|
(self.file.data['timestamp'] <= stop)]
|
|
|
|
avg_ozone.append(np.average(local_ozone_data['ozone']))
|
|
|
|
for sub_index in list(range(cut_edges)):
|
|
del avg_ozone[-(sub_index + 1)]
|
|
del mprr_data[-(sub_index + 1)]
|
|
del vflo_data[-(sub_index + 1)]
|
|
|
|
out_mprr_data = np.array(mprr_data)
|
|
|
|
if subtract_baseline[0] == 'yes':
|
|
out_avg_ozone = np.array([baseline - value for value in avg_ozone])
|
|
elif subtract_baseline[0] != 'yes':
|
|
out_avg_ozone = np.array([value for value in avg_ozone])
|
|
|
|
if normalise_flow == True:
|
|
out_mprr_data = np.divide(out_mprr_data, np.array(vflo_data))
|
|
key = 'Density (kg m^-3)'
|
|
else:
|
|
key = 'Mass Production Rate (kg s^-1)'
|
|
|
|
self.averaged_data = pd.DataFrame({'Ozone (ppb)': out_avg_ozone, key: out_mprr_data}) |