%% Compile LOPAP data % from different data set %% Choose data % % * Choose the mat files with the Lopap timetables to be plotted % * For each data set, define the 0-time. This could be the time when you % turned on the UV, or when the flow was directed via the flow tube. This % depends on what you want to compare and plot % % The data is then imported and then transferred to relative time % clear variables in workspace, clear text in command window clearvars clc % set the path to the data and define some custom colours for plotting [fileLocation, myColorMap] = localInitializeMatlab; % : data files to be loaded tmpFileList = {'Lopap20211201_1033.mat';... 'Lopap20211115_1431.mat'}; % : define 0-time for each data set to be loaded. This needs one % date for each data set. tmpRefTime = [datetime('01-Dec-2021 15:24:23');... datetime('15-Nov-2021 16:49:23')]; % : define time window to be plotted, in seconds tmpPlotTime = -30*60:2:120*60; % 30 minutes prior, 2 s interval, 2 hours after event %% Load data and process % for ii = 1: length(tmpFileList) % load data from mat file load(tmpFileList{ii},'LopapTimeT') % get time tmpX = duration(LopapTimeT.Time-tmpRefTime(ii)); % interpolate HONO data (to have same time axis) tmpY = interp1(seconds(tmpX),LopapTimeT.HONO,... tmpPlotTime); if ~exist('LopapData','var') % make new timetable if timetable does not exist % arrange in table LopapData = timetable(minutes(tmpPlotTime./60)',tmpY'); LopapData = renamevars(LopapData,'Var1',tmpFileList{ii}); else % or add new variable to existing timetable LopapData = addvars(LopapData,tmpY','NewVariableNames',tmpFileList{ii}); end end % tidy up clearvars ii tmp* LopapTimeT %% Plot data figure stackedplot(LopapData) title('HONO in ppt') %% Local functions function [fileLocation, myColorMap] = localInitializeMatlab %INITIALIZEMATLAB Sets Lopap specific settings % Adds processing functions to path and defines file locations for mac, windows, % and Matlab online (which runs on unix) % change working directory path = matlab.desktop.editor.getActiveFilename; [filepath,~,~] = fileparts(path); cd(filepath); % Data Server Address if ismac fileLocation.server = '/Volumes/'; fileLocation.dataPath = 'data_2411/Lopap/'; % add Lopap functions and general add-ons to path addpath('/Users/bartels-rausch/Documents/SwitchDrive/PSI_Matlab/Add-Ons'); addpath('/Users/bartels-rausch/Documents/SwitchDrive/PSI_Matlab/Lopap/1.LOPAP_Restliche Daten'); elseif ispc fileLocation.server = '\\fs00\'; %UNC name for file server that hosts Napp shared drive fileLocation.dataPath = 'data_2411\Lopap\'; % add Lopap functions and general add-ons to path addpath('C:\Users\iezzi_l\switchdrive\Add-Ons'); addpath('C:\Users\bletry_c\switchdrive\Add-Ons'); addpath('C:\Users\iezzi_l\switchdrive\Lopap\1.LOPAP_Restliche Daten'); addpath('C:\Users\bletry_c\switchdrive\Lopap\1.LOPAP_Restliche Daten'); % addpath('\\fs02\5601_surface_chemistry\People\Marc\Switchdrive\PSI_Matlab\Add-Ons'); % addpath('\\fs02\5601_surface_chemistry\People\Marc\Switchdrive\PSI_Matlab\Lopap\1.LOPAP_Restliche Daten'); elseif isunix fileLocation.server = '/'; fileLocation.dataPath = 'Lopap/'; end % Color maps myColorMap.red = colormap(autumn(7)); myColorMap.blue = colormap(winter(7)); close all end