1186 lines
79 KiB
HTML
1186 lines
79 KiB
HTML
|
|
<!DOCTYPE html
|
|
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html><head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<!--
|
|
This HTML was auto-generated from MATLAB code.
|
|
To make changes, update the MATLAB code and republish this document.
|
|
--><title>Lopap Template</title><meta name="generator" content="MATLAB 9.7"><link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"><meta name="DC.date" content="2020-11-12"><meta name="DC.source" content="LabBook_20200916_1326.m"><style type="text/css">
|
|
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}:focus{outine:0}ins{text-decoration:none}del{text-decoration:line-through}table{border-collapse:collapse;border-spacing:0}
|
|
|
|
html { min-height:100%; margin-bottom:1px; }
|
|
html body { height:100%; margin:0px; font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#000; line-height:140%; background:#fff none; overflow-y:scroll; }
|
|
html body td { vertical-align:top; text-align:left; }
|
|
|
|
h1 { padding:0px; margin:0px 0px 25px; font-family:Arial, Helvetica, sans-serif; font-size:1.5em; color:#d55000; line-height:100%; font-weight:normal; }
|
|
h2 { padding:0px; margin:0px 0px 8px; font-family:Arial, Helvetica, sans-serif; font-size:1.2em; color:#000; font-weight:bold; line-height:140%; border-bottom:1px solid #d6d4d4; display:block; }
|
|
h3 { padding:0px; margin:0px 0px 5px; font-family:Arial, Helvetica, sans-serif; font-size:1.1em; color:#000; font-weight:bold; line-height:140%; }
|
|
|
|
a { color:#005fce; text-decoration:none; }
|
|
a:hover { color:#005fce; text-decoration:underline; }
|
|
a:visited { color:#004aa0; text-decoration:none; }
|
|
|
|
p { padding:0px; margin:0px 0px 20px; }
|
|
img { padding:0px; margin:0px 0px 20px; border:none; }
|
|
p img, pre img, tt img, li img, h1 img, h2 img { margin-bottom:0px; }
|
|
|
|
ul { padding:0px; margin:0px 0px 20px 23px; list-style:square; }
|
|
ul li { padding:0px; margin:0px 0px 7px 0px; }
|
|
ul li ul { padding:5px 0px 0px; margin:0px 0px 7px 23px; }
|
|
ul li ol li { list-style:decimal; }
|
|
ol { padding:0px; margin:0px 0px 20px 0px; list-style:decimal; }
|
|
ol li { padding:0px; margin:0px 0px 7px 23px; list-style-type:decimal; }
|
|
ol li ol { padding:5px 0px 0px; margin:0px 0px 7px 0px; }
|
|
ol li ol li { list-style-type:lower-alpha; }
|
|
ol li ul { padding-top:7px; }
|
|
ol li ul li { list-style:square; }
|
|
|
|
.content { font-size:1.2em; line-height:140%; padding: 20px; }
|
|
|
|
pre, code { font-size:12px; }
|
|
tt { font-size: 1.2em; }
|
|
pre { margin:0px 0px 20px; }
|
|
pre.codeinput { padding:10px; border:1px solid #d3d3d3; background:#f7f7f7; }
|
|
pre.codeoutput { padding:10px 11px; margin:0px 0px 20px; color:#4c4c4c; }
|
|
pre.error { color:red; }
|
|
|
|
@media print { pre.codeinput, pre.codeoutput { word-wrap:break-word; width:100%; } }
|
|
|
|
span.keyword { color:#0000FF }
|
|
span.comment { color:#228B22 }
|
|
span.string { color:#A020F0 }
|
|
span.untermstring { color:#B20000 }
|
|
span.syscmd { color:#B28C00 }
|
|
|
|
.footer { width:auto; padding:10px 0px; margin:25px 0px 0px; border-top:1px dotted #878787; font-size:0.8em; line-height:140%; font-style:italic; color:#878787; text-align:left; float:none; }
|
|
.footer p { margin:0px; }
|
|
.footer a { color:#878787; }
|
|
.footer a:hover { color:#878787; text-decoration:underline; }
|
|
.footer a:visited { color:#878787; }
|
|
|
|
table th { padding:7px 5px; text-align:left; vertical-align:middle; border: 1px solid #d6d4d4; font-weight:bold; }
|
|
table td { padding:7px 5px; text-align:left; vertical-align:top; border:1px solid #d6d4d4; }
|
|
|
|
|
|
|
|
|
|
|
|
</style></head><body><div class="content"><h1>Lopap Template</h1><!--introduction--><p>Uses data from 16.9.2020 13h26</p><!--/introduction--><h2>Contents</h2><div><ul><li><a href="#1">Info: How to use this</a></li><li><a href="#2">Info: Output & Variables</a></li><li><a href="#3">Matlab: Initialise</a></li><li><a href="#4">Process: Import data</a></li><li><a href="#5">Matlab: Run mode</a></li><li><a href="#6">LabBook : ChronoNotes</a></li><li><a href="#7">LabBook : Measurement Settings</a></li><li><a href="#8">LabBook : Define data ranges</a></li><li><a href="#9">Process: Modify data ranges</a></li><li><a href="#10">Process: Find closest match of selected dates in data set</a></li><li><a href="#11">LabBook: Data ranges used in this work</a></li><li><a href="#12">Process: Calculate difference zero-air to nitrite calibration</a></li><li><a href="#16">Plot all data</a></li><li><a href="#20">Labbook: Notes to Figures</a></li><li><a href="#21">Plot selected data</a></li><li><a href="#25">Plot several spectra</a></li><li><a href="#29">Plot selected spectra</a></li><li><a href="#33">Process: Absorption spectrum</a></li><li><a href="#37">Process :: Absorption with time</a></li><li><a href="#41">Process :: Background</a></li><li><a href="#42">Plot bkgrd corrected data</a></li><li><a href="#43">Process :: Calibrate</a></li><li><a href="#44">Plot calibrated data</a></li><li><a href="#48">Save the data</a></li><li><a href="#49">Local functions</a></li></ul></div><h2 id="1">Info: How to use this</h2><div><ol><li>Make a copy of this file for each Lopap measurement. Name it "Lopap"_date_time.m and store it in the folder with the Lopap data. % Remove all the general text and comments in your file and add notes and observations about the experiment.</li></ol></div><div><ol><li>You can run this script, publish it, or evaluate it section wise. For new data run it section wise to carefully update the settings and to observe the results.</li><li>Once the data is loaded, you can also run individual sections only.</li><li>Use the LabBook :: Chrono Notes section as lab book.</li><li>First, you need to give the date and time of the Lopap measurement to load and process the data.</li><li>All sections that can be modified are marked with the word "<Adapt>:".</li><li>You also need to give time regions such as for the background fit, as well as to calculate means. There are several options how to do this</li></ol></div><div><ul><li>While running the experiments and observing the signal in the Lopap software, you can enter the date and times directly in the LabBook : Select data ranges section.</li><li>You can manually select the regions in a plot. A window will pop up to select the region to modify. To modify several regions, re-run this section of the script. This overwrites the current settings.</li><li>The times of the regions are stored in the "TimeRanges.mat" file. If it exists, this is read; the LabBook : Select data ranges section is then ignored.</li></ul></div><h2 id="2">Info: Output & Variables</h2><div><ul><li><b>lopapReferenceWavelength</b>: This <i>string variable</i> holds text with stating the reference wavelength for channel 1 and 2 used to process the data by the Lopap software.</li><li><b>LopapDataCh1 & LopapDataCh2</b>: These <i>time tables</i> hold the data that have been processed by the Lopap Software during the data acquisition. It contains the absorption for a number of selected wavelength. The absorption is the log of the intensity at the reference wavelength relative to the intensity at each wavelength of interest. The timetables hold the time in each row and the wavelength in the columns. The content is thus identical to that shown in the "measurement window" of the Lopap software.</li><li><b>LopapSpecCh1,LopapSpecCh2</b>: The <i>time tables</i> hold the full spectrum for each time. Time is in the rows, wavelength in the columns. The wavelength are read from the *.prj file, the spectra data from the *.spec file. The information is identical to that shown in the "spectrum window" of the Lopap software.</li></ul></div><div><ul><li><b>TimeRanges.mat</b>: Time ranges after they have been manually modified. If this file exists, the time range definitions in this script are ignored.</li><li><b>LopapMatlabDataDATE_TIME.mat</b>: Raw data and experimental settings. Background subtraction and calibration are not saved in this file. When this file exists, data will not be read from the windows server.</li><li><b>LopapDATE_TIME.mat</b>: Processed data - absorption with time (column 1 and 2: 'Ch #1' and 'Ch #2') after background (columns 3 and 4: 'Ch #1 Bkgrd' and 'Ch #2 Bkgrd') subtraction and calibration (columns 5 and 6: 'Ch #1 Calib' and 'Ch #2 Calib') for one wavelength - that can be used for further comparison with other experiments and discussion.</li></ul></div><h2 id="3">Matlab: Initialise</h2><p>This starts Matlab and defines some common settings such as the path to the Lopap data. Any modifications can be done at the end of this file in where the local function <i>localInitializeMatlab</i> is stored.</p><pre class="codeinput"><span class="comment">% clear variables in workspace, clear text in command window</span>
|
|
clearvars
|
|
clc
|
|
<span class="comment">% set the path to the data and define some custom colours for plotting</span>
|
|
[fileLocation, myColorMap] = localInitializeMatlab;
|
|
<span class="comment">% <Adapt>: Date when Lopap recording was started. Defines names of Lopap</span>
|
|
<span class="comment">% files and folders. Seconds are irrelevant, but format is important.</span>
|
|
LopapParameters.MeasurementDate = datenum(<span class="string">'16-Sep-2020 13:26:00'</span>);
|
|
|
|
|
|
<span class="comment">% Print info to command window</span>
|
|
disp(<span class="string">'The data is read from:'</span>);
|
|
disp(fullfile(fileLocation.server,fileLocation.dataPath,datestr(LopapParameters.MeasurementDate,<span class="string">'yyyymmdd_HHMM'</span>)));
|
|
disp(<span class="string">' '</span>)
|
|
disp(<span class="string">'Date of experiment:'</span>)
|
|
disp(datestr(LopapParameters.MeasurementDate));
|
|
disp(<span class="string">' '</span>)
|
|
disp(<span class="string">'Date of analyis:'</span>)
|
|
disp(datestr(today));
|
|
</pre><h2 id="4">Process: Import data</h2><p>Reads and imports data from Lopap *.dat, *.spec, and *.prj files into:</p><div><ul><li><b>lopapReferenceWavelength</b>: This <i>string variable</i> holds text with stating the reference wavelength for channel 1 and 2 used to process the data by the Lopap software.</li><li><b>LopapDataCh1 & LopapDataCh2</b>: These <i>time tables</i> hold the data that have been processed by the Lopap Software during the data acquisition. It contains the absorption for a number of selected wavelength. The absorption is the log of the intensity at the reference wavelength relative to the intensity at each wavelength of interest. The timetables hold the time in each row and the wavelength in the columns. The content is thus identical to that shown in the "measurement window" of the Lopap software.</li><li><b>LopapSpecCh1,LopapSpecCh2</b>: The <i>time tables</i> hold the full spectrum for each time. Time is in the rows, wavelength in the columns. The wavelength are read from the *.prj file, the spectra data from the *.spec file. The information is identical to that shown in the "spectrum window" of the Lopap software.</li></ul></div><pre class="codeinput"><span class="keyword">if</span> isfile([<span class="string">'LopapMatlabData'</span> datestr(LopapParameters.MeasurementDate,<span class="string">'yyyyMMdd_hhmm'</span>) <span class="string">'.mat'</span>])
|
|
load([<span class="string">'LopapMatlabData'</span> datestr(LopapParameters.MeasurementDate,<span class="string">'yyyyMMdd_hhmm'</span>) <span class="string">'.mat'</span>])
|
|
<span class="keyword">else</span>
|
|
[LopapParameters.instrumentReferenceWavelength, LopapDataCh1,LopapDataCh2,LopapSpecCh1,LopapSpecCh2] <span class="keyword">...</span>
|
|
= importLopap(LopapParameters.MeasurementDate,fileLocation);
|
|
<span class="keyword">end</span>
|
|
</pre><h2 id="5">Matlab: Run mode</h2><p><a href="Adapt">Adapt</a>:</p><div><ul><li>runs without user interaction and without ability to modify data ranges, when set to 0; use this to publish.</li><li>if set to 1: stops for user interaction, modify data ranges is enabled.Use this to run.</li></ul></div><pre class="codeinput">LopapParameters.Interactive = 0;
|
|
</pre><h2 id="6">LabBook : ChronoNotes</h2><p><a href="Adapt">Adapt</a>: Your notes go here</p><div><ul><li>Nitritstandardlösung: 1g/l</li><li>Nitritlösung: 0.01mg/l</li><li>Volumenfluss 1: 26.08min für 5ml -> 0.192ml/min</li><li>Volumenfluss 2: 26.33min für 5ml -> 0.190ml/min</li><li>Pumpgeschwindigkeit: 10U/min</li><li>Gasfluss: 2000ml/min</li><li><b>16.9.20 13h30</b>: Start instrument with water</li><li>time: 2s/2s</li><li>time: 80ms/4ms</li><li><b>16.9.20 13h00</b>: water -> R1 & R2, ABS closed</li></ul></div><h2 id="7">LabBook : Measurement Settings</h2><p><a href="Adapt">Adapt</a>: list the Lopap settings here:</p><pre class="codeinput">LopapParameters.concStandard = 0.01; <span class="comment">% mg/l concentration of nitrite in standard used for calibration</span>
|
|
LopapParameters.flowReagents = 5./[26.08 26.33]; <span class="comment">% ml/min, enter time for 5 ml</span>
|
|
LopapParameters.flowGas = 2000; <span class="comment">% ml/min, take average of 10.</span>
|
|
LopapParameters.temperature = 298; <span class="comment">% temp of gas flow in K</span>
|
|
LopapParameters.pressure = 1013; <span class="comment">% pressure of gas flow in mbar</span>
|
|
|
|
<span class="comment">% <Adapt>: Choose a reference wavelength. Default is 650 nm.</span>
|
|
LopapParameters.wavelengthR = 650; <span class="comment">%nm, reference intensity</span>
|
|
<span class="comment">% <Adapt>: Choose a signal wavelength to calculate the absorption with time</span>
|
|
<span class="comment">% from the spectra</span>
|
|
LopapParameters.wavelengthS = 534; <span class="comment">%nm, signal intensity</span>
|
|
</pre><h2 id="8">LabBook : Define data ranges</h2><p>These settings are ignored if the TimesRanges.mat file exist. If you do not want to use the data stored in the TimesRanges.mat file, you need to delete it before running this section.</p><p>These settings can be modified by selecting data ranges in a plot later. So, you do not necessarily need to type the dates and times here.</p><pre class="codeinput"><span class="keyword">if</span> isfile([<span class="string">'TimeRanges'</span> datestr(LopapParameters.MeasurementDate,<span class="string">'yyyyMMdd_hhmm'</span>) <span class="string">'.mat'</span>])
|
|
load([<span class="string">'TimeRanges'</span> datestr(LopapParameters.MeasurementDate,<span class="string">'yyyyMMdd_hhmm'</span>) <span class="string">'.mat'</span>])
|
|
<span class="keyword">elseif</span> ~exist(<span class="string">'TimeRange'</span>,<span class="string">'var'</span>)
|
|
<span class="comment">% <Adapt>: State the start and end time of the calibration. Usually</span>
|
|
<span class="comment">% this is included zero air with R1&2, zero air with nitrite standard,</span>
|
|
<span class="comment">% zero air with R1&2</span>
|
|
TimeRange.calibrationRange = [datenum(<span class="string">'16-Sep-2020 13:55:00'</span>) datenum(<span class="string">'16-Sep-2020 15:15:00'</span>)];
|
|
<span class="comment">% <Adapt>: State the time for one spectrum with R1&R2 without nitrite</span>
|
|
TimeRange.specWithReagents = datenum(<span class="string">'2020-09-16 14:31:06'</span>);
|
|
<span class="comment">% <Adapt>: State the time for one spectrum with R1&R2 and nitrite</span>
|
|
TimeRange.specWithNitrite = datenum(<span class="string">'2020-09-16 15:10:14'</span>);
|
|
<span class="comment">% <Adapt>: Choose a start and end time for one as many intervals that can</span>
|
|
<span class="comment">% be used to fit the background. Background is the signal when R1&R2 was</span>
|
|
<span class="comment">% attached to the Lopap with zero air entering the sampling coil.</span>
|
|
TimeRange.backgroundFit = [datenum(<span class="string">'16-Sep-2020 14:29:28'</span>) datenum(<span class="string">'16-Sep-2020 14:40:04'</span>);<span class="keyword">...</span>
|
|
datenum(<span class="string">'16-Sep-2020 15:40:50'</span>) datenum(<span class="string">'16-Sep-2020 15:51:06'</span>)];
|
|
<span class="comment">% <Adapt>: State the start and end time of data that can be used to</span>
|
|
<span class="comment">% calculate the mean of the zero air signal without nitrate</span>
|
|
TimeRange.MeanZeroAir = [datenum(<span class="string">'16-Sep-2020 14:28:42'</span>) datenum(<span class="string">'16-Sep-2020 14:38:36'</span>)];
|
|
<span class="comment">% <Adapt>: State the start and end time of data that can be used to</span>
|
|
<span class="comment">% calculate the mean of the zero air signal without nitrate</span>
|
|
TimeRange.MeanNitriteStandard = [datenum(<span class="string">'16-Sep-2020 15:09:20'</span>) datenum(<span class="string">'16-Sep-2020 15:18:30'</span>)];
|
|
|
|
save([<span class="string">'TimeRanges'</span> datestr(LopapParameters.MeasurementDate,<span class="string">'yyyyMMdd_hhmm'</span>) <span class="string">'.mat'</span>],<span class="string">'TimeRange'</span>);
|
|
<span class="keyword">else</span>
|
|
disp(<span class="string">'Nothing done: TimeRange in Workspace used'</span>)
|
|
<span class="keyword">end</span>
|
|
</pre><h2 id="9">Process: Modify data ranges</h2><p>Select the range to modify in the pop-up window and the number of fit ranges for the background fit in the 2nd pop-up window. Then, a figure will show, select the data ranges in the figure:</p><div><ul><li>a line for calibration range, mean zero air and mean nitrite standard. Select the range by keeping the mouse pushed while moving from start to end time.</li><li>a line for each background region, default is 2. Select the range by keeping the mouse pushed while moving from start to end time.</li><li>a point for spectrum with reagents and spectrum with nitrite. Click once to select a specific time.</li></ul></div><div><ol><li>Run this section several times to modify several time regions</li><li>Press cancel in the pop-up window if you do not want to modify any region.</li></ol></div><pre class="codeinput"><span class="keyword">if</span> LopapParameters.Interactive == 1
|
|
close <span class="string">all</span>
|
|
clc
|
|
list = {<span class="string">'Calibration Range'</span>,<span class="string">'Background Fit'</span>,<span class="string">'Mean ZeroAir'</span>,<span class="string">'Mean NitritStandard'</span>,<span class="keyword">...</span>
|
|
<span class="string">'Spectrum with Reagents'</span>,<span class="string">'Spectrum with Nitrite'</span>};
|
|
indx = listdlg(<span class="string">'ListString'</span>,list,<span class="string">'PromptString'</span>,{<span class="string">'Choose parameter to modify,'</span>,<span class="string">'then select region in figure'</span>}<span class="keyword">...</span>
|
|
,<span class="string">'SelectionMode'</span>,<span class="string">'single'</span>);
|
|
<span class="keyword">if</span> indx == 2
|
|
prompt = {<span class="string">'Enter number of regions to fit the background:'</span>};
|
|
dlgtitle = <span class="string">'Background Fit'</span>;
|
|
dims = [1 40];
|
|
definput = {<span class="string">'2'</span>};
|
|
answer = inputdlg(prompt,dlgtitle,dims,definput);
|
|
<span class="keyword">end</span>
|
|
<span class="keyword">if</span> indx >= 1
|
|
clc
|
|
close <span class="string">all</span>
|
|
figure( <span class="string">'Name'</span>, <span class="string">'LopapChannel 550'</span>,<span class="string">'NumberTitle'</span>,<span class="string">'off'</span>,<span class="string">'Position'</span>,[10 100 550 800]);
|
|
plot(datenum(LopapDataCh1.Time),LopapDataCh1.(<span class="string">"550.7"</span>));
|
|
hold <span class="string">on</span>
|
|
datetick(<span class="string">'x'</span>,<span class="string">'dd.mm hh:MM'</span>,<span class="string">'keeplimits'</span>,<span class="string">'keepticks'</span>);
|
|
ax = gca;
|
|
yyaxis <span class="string">right</span>
|
|
plot(datenum(LopapDataCh2.Time),LopapDataCh2.(<span class="string">"550.5"</span>));
|
|
datetick(<span class="string">'x'</span>,<span class="string">'dd.mm hh:MM'</span>,<span class="string">'keeplimits'</span>,<span class="string">'keepticks'</span>);
|
|
grid <span class="string">ON</span>
|
|
<span class="comment">% Add title and axis labels</span>
|
|
xlabel(<span class="string">'Lab Time'</span>)
|
|
legend({<span class="string">'MeasData Ch#1'</span>,<span class="string">'MeasData Ch#2'</span>})
|
|
<span class="comment">% select regions in plot</span>
|
|
<span class="keyword">if</span> indx == 1
|
|
Roi.calibrationRange = drawline(ax,<span class="string">'Color'</span>,<span class="string">'r'</span>);
|
|
TimeRange.calibrationRange = [Roi.calibrationRange.Position(1,1) Roi.calibrationRange.Position(2,1)];
|
|
pause(3)
|
|
close <span class="string">all</span>
|
|
<span class="keyword">elseif</span> indx == 2
|
|
<span class="keyword">for</span> ii = 1:str2double(answer)
|
|
Roi.backgroundFit = drawline(ax,<span class="string">'Color'</span>,<span class="string">'r'</span>);
|
|
TimeRange.backgroundFit(ii,:) = [Roi.backgroundFit.Position(1,1) Roi.backgroundFit.Position(2,1)];
|
|
<span class="keyword">end</span>
|
|
pause(3)
|
|
close <span class="string">all</span>
|
|
<span class="keyword">elseif</span> indx == 3
|
|
Roi.meanZeroAir = drawline(ax,<span class="string">'Color'</span>,<span class="string">'r'</span>);
|
|
TimeRange.MeanZeroAir = [Roi.meanZeroAir.Position(1,1) Roi.meanZeroAir.Position(2,1)];
|
|
pause(3)
|
|
close <span class="string">all</span>
|
|
<span class="keyword">elseif</span> indx == 4
|
|
Roi.meanNitriteStandard = drawline(ax,<span class="string">'Color'</span>,<span class="string">'r'</span>);
|
|
TimeRange.MeanNitriteStandard = [Roi.meanNitriteStandard.Position(1,1) Roi.meanNitriteStandard.Position(2,1)];
|
|
pause(3)
|
|
close <span class="string">all</span>
|
|
<span class="keyword">elseif</span> indx == 5
|
|
Roi.specWithReagents = drawpoint(ax,<span class="string">'Color'</span>,<span class="string">'r'</span>);
|
|
TimeRange.specWithReagents = Roi.specWithReagents.Position(1,1);
|
|
pause(3)
|
|
close <span class="string">all</span>
|
|
<span class="keyword">elseif</span> indx == 6
|
|
Roi.specWithNitrite = drawpoint(ax,<span class="string">'Color'</span>,<span class="string">'r'</span>);
|
|
TimeRange.specWithNitrite = Roi.specWithNitrite.Position(1,1);
|
|
pause(3)
|
|
close <span class="string">all</span>
|
|
<span class="keyword">end</span>
|
|
|
|
|
|
clearvars <span class="string">-except</span> <span class="string">Lopap*</span> <span class="string">fileLocation</span> <span class="string">myColorMap</span> <span class="string">LopapParameters</span> <span class="string">TimeRange*</span>
|
|
save([<span class="string">'TimeRanges'</span> datestr(LopapParameters.MeasurementDate,<span class="string">'yyyyMMdd_hhmm'</span>) <span class="string">'.mat'</span>],<span class="string">'TimeRange'</span>);
|
|
<span class="keyword">end</span>
|
|
<span class="keyword">else</span>
|
|
disp(<span class="string">'Variable LopapParameters.Interactive not set to 1: Modify data ranges manually has been skiped'</span>);
|
|
<span class="keyword">end</span>
|
|
</pre><pre class="codeoutput">Variable LopapParameters.Interactive not set to 1: Modify data ranges manually has been skiped
|
|
</pre><h2 id="10">Process: Find closest match of selected dates in data set</h2><p>The data is sampled at specific times with a certain interval. The selected or chosen dates might not necessarily exactly match the data. Here, closest match to the given dates are selected.</p><pre class="codeinput">tmp.d1 = TimeRange.specWithReagents;
|
|
tmp.d2 = LopapSpecCh1.Time;
|
|
[~,ind1] = min(abs(bsxfun(@minus,datenum(tmp.d2),datenum(tmp.d1)')));
|
|
TimeRange.specWithReagents = tmp.d2(ind1,:);
|
|
|
|
tmp.d1 = TimeRange.specWithNitrite ;
|
|
tmp.d2 = LopapSpecCh1.Time;
|
|
[~,ind1] = min(abs(bsxfun(@minus,datenum(tmp.d2),datenum(tmp.d1)')));
|
|
TimeRange.specWithNitrite = tmp.d2(ind1,:);
|
|
|
|
<span class="comment">% save current state of</span>
|
|
clearvars <span class="string">-except</span> <span class="string">Lopap*</span> <span class="string">fileLocation</span> <span class="string">myColorMap</span> <span class="string">LopapParameters</span> <span class="string">TimeRange*</span>
|
|
save([<span class="string">'LopapMatlabData'</span> datestr(LopapParameters.MeasurementDate,<span class="string">'yyyyMMdd_hhmm'</span>) <span class="string">'.mat'</span>])
|
|
save([<span class="string">'TimeRanges'</span> datestr(LopapParameters.MeasurementDate,<span class="string">'yyyyMMdd_hhmm'</span>) <span class="string">'.mat'</span>],<span class="string">'TimeRange'</span>);
|
|
</pre><h2 id="11">LabBook: Data ranges used in this work</h2><p>This plots the</p><pre class="codeinput">fprintf(<span class="string">'Calibration range: %s to %s \n'</span>,datestr(TimeRange.calibrationRange(1)), datestr(TimeRange.calibrationRange(2)))
|
|
<span class="keyword">for</span> ii=1:size(TimeRange.backgroundFit,2)
|
|
fprintf(<span class="string">'Background range: %s to %s \n'</span>,datestr(TimeRange.backgroundFit(ii,1)), datestr(TimeRange.backgroundFit(ii,2)))
|
|
<span class="keyword">end</span>
|
|
fprintf(<span class="string">'Zero mean: %s to %s \n'</span>,datestr(TimeRange.MeanZeroAir(1)), datestr(TimeRange.MeanZeroAir(2)))
|
|
fprintf(<span class="string">'Nitrite mean: %s to %s \n'</span>,datestr(TimeRange.MeanNitriteStandard(1)), datestr(TimeRange.MeanNitriteStandard(2)))
|
|
fprintf(<span class="string">'Zero spectrum: %s \n'</span>,datestr(TimeRange.specWithReagents(1)))
|
|
fprintf(<span class="string">'Nitrite spectrum: %s \n'</span>,datestr(TimeRange.specWithNitrite(1)))
|
|
</pre><pre class="codeoutput">Calibration range: 16-Sep-2020 14:19:34 to 16-Sep-2020 15:50:44
|
|
Background range: 16-Sep-2020 14:23:37 to 16-Sep-2020 14:32:56
|
|
Background range: 16-Sep-2020 15:43:50 to 16-Sep-2020 15:51:08
|
|
Zero mean: 16-Sep-2020 14:24:50 to 16-Sep-2020 14:36:35
|
|
Nitrite mean: 16-Sep-2020 15:10:13 to 16-Sep-2020 15:18:43
|
|
Zero spectrum: 16-Sep-2020 14:32:32
|
|
Nitrite spectrum: 16-Sep-2020 15:15:30
|
|
</pre><h2 id="12">Process: Calculate difference zero-air to nitrite calibration</h2><pre class="codeinput">deltaSignalCh1 = LopapSpecCh1{datestr(TimeRange.specWithNitrite),:}<span class="keyword">...</span>
|
|
-LopapSpecCh1{datestr(TimeRange.specWithReagents),:};
|
|
deltaSignalCh2 = LopapSpecCh2{datestr(TimeRange.specWithNitrite),:}<span class="keyword">...</span>
|
|
-LopapSpecCh2{datestr(TimeRange.specWithReagents),:};
|
|
|
|
figure( <span class="string">'Name'</span>, <span class="string">'LopapDelta'</span>,<span class="string">'NumberTitle'</span>,<span class="string">'off'</span>,<span class="string">'Position'</span>,[600 100 550 550]);
|
|
plot(str2double(LopapSpecCh1.Properties.VariableNames),deltaSignalCh1);
|
|
hold <span class="string">on</span>
|
|
plot(str2double(LopapSpecCh2.Properties.VariableNames),deltaSignalCh2);
|
|
title(<span class="string">'delta sigInt(nitirite) - sigInt(reagents)'</span>)
|
|
legend({<span class="string">'Ch #1'</span>, <span class="string">'Ch #2'</span>});
|
|
grid <span class="string">ON</span>
|
|
xlim([400 750])
|
|
<span class="comment">% Add title and axis labels</span>
|
|
xlabel(<span class="string">'Lab Time'</span>)
|
|
clearvars <span class="string">-except</span> <span class="string">Lopap*</span> <span class="string">fileLocation</span> <span class="string">myColorMap</span> <span class="string">LopapParameters</span> <span class="string">TimeRange*</span>
|
|
|
|
<span class="keyword">if</span> LopapParameters.Interactive == 1
|
|
</pre><pre class="codeinput"> distFig
|
|
fprintf(<span class="string">'press any key if you want to proceed\n'</span>)
|
|
pause
|
|
</pre><pre class="codeinput"> close <span class="string">all</span>
|
|
</pre><pre class="codeinput"><span class="keyword">end</span>
|
|
</pre><img vspace="5" hspace="5" src="LabBook_20200916_1326_01.png" alt=""> <h2 id="16">Plot all data</h2><p>Here, we plot the data as shown in the "Measurement window" of the Lopap software. That is, the processed <img src="LabBook_20200916_1326_eq10882575395515131244.png" alt="$I^{*}_{i}$" style="width:9px;height:11px;"> data for all wavelength as defined in the settings of the Lopap software.</p><p>For every measurement wavelength I_i the program calculates the measurement (absorption) value I_i^* from the spectral intensity on the measurement wavelength I_i and a reference wavelength I_r with the following operation:</p><p><img src="LabBook_20200916_1326_eq12623800947225674310.png" alt="$$I^{*}_{i} = log_{10} (\frac{I_r}{I_i})$$" style="width:67px;height:25px;"></p><p>The plots show time on the x-axis and the ABS intensity on the y axis for each wavelength in separate graphs. One Figure for each Channel.</p><pre class="codeinput">figure( <span class="string">'Name'</span>, <span class="string">'LopapChannel1'</span>,<span class="string">'NumberTitle'</span>,<span class="string">'off'</span>,<span class="string">'Position'</span>,[10 100 550 700]);
|
|
ch1s=stackedplot(LopapDataCh1);
|
|
title(LopapParameters.instrumentReferenceWavelength(1))
|
|
<span class="keyword">for</span> ii = 1:width(LopapDataCh1)
|
|
<span class="comment">% <Adapt>: The numbers in the brackets give the lower and upper limit</span>
|
|
<span class="comment">% of the y-axis. Adapt these to fit your data and remove the % sign.</span>
|
|
<span class="comment">% ch1s.AxesProperties(ii).YLimits = [-0.4 -0.1];</span>
|
|
<span class="keyword">end</span>
|
|
grid <span class="string">ON</span>
|
|
<span class="comment">% Add title and axis labels</span>
|
|
xlabel(<span class="string">'Lab Time'</span>)
|
|
|
|
figure( <span class="string">'Name'</span>, <span class="string">'LopapChannel2'</span>,<span class="string">'NumberTitle'</span>,<span class="string">'off'</span>,<span class="string">'Position'</span>,[600 100 550 700]);
|
|
ch2s=stackedplot(LopapDataCh2);
|
|
title(LopapParameters.instrumentReferenceWavelength(2))
|
|
<span class="keyword">for</span> ii = 1:width(LopapDataCh2)
|
|
<span class="comment">% <Adapt>: The numbers in the brackets give the lower and upper limit</span>
|
|
<span class="comment">% of the y-axis. Adapt these to fit your data and remove the % sign.</span>
|
|
<span class="comment">% ch2s.AxesProperties(ii).YLimits = [-0.2 0.3];</span>
|
|
<span class="keyword">end</span>
|
|
grid <span class="string">ON</span>
|
|
<span class="comment">% Add title and axis labels</span>
|
|
xlabel(<span class="string">'Lab Time'</span>)
|
|
clearvars <span class="string">-except</span> <span class="string">Lopap*</span> <span class="string">fileLocation</span> <span class="string">myColorMap</span> <span class="string">LopapParameters</span> <span class="string">TimeRange*</span>
|
|
<span class="keyword">if</span> LopapParameters.Interactive == 1
|
|
</pre><pre class="codeinput"> distFig
|
|
fprintf(<span class="string">'press any key if you want to proceed\n'</span>)
|
|
pause
|
|
</pre><pre class="codeinput"> close <span class="string">all</span>
|
|
</pre><pre class="codeinput"><span class="keyword">end</span>
|
|
</pre><img vspace="5" hspace="5" src="LabBook_20200916_1326_02.png" alt=""> <img vspace="5" hspace="5" src="LabBook_20200916_1326_03.png" alt=""> <h2 id="20">Labbook: Notes to Figures</h2><div><ul><li>Kanal 2 ist stärker am rauschen.</li><li>Ev. wegen Leck am T-Stück in der Absorptionskammer.</li></ul></div><h2 id="21">Plot selected data</h2><p>Here we plot the <img src="LabBook_20200916_1326_eq10882575395515131244.png" alt="$I^{*}_{i}$" style="width:9px;height:11px;"> data for one wavelength only.</p><pre class="codeinput">figure( <span class="string">'Name'</span>, <span class="string">'LopapChannel1 550'</span>,<span class="string">'NumberTitle'</span>,<span class="string">'off'</span>,<span class="string">'Position'</span>,[10 100 550 800]);
|
|
<span class="comment">% <Adapt>: The numbers in the curled brackets give wavelength for which you'd</span>
|
|
<span class="comment">% like to display the data. The numbers need to be exactly match the</span>
|
|
<span class="comment">% labels in the previous figure.</span>
|
|
ch1s=stackedplot(LopapDataCh1,{<span class="string">'550.7'</span>});
|
|
title(LopapParameters.instrumentReferenceWavelength(1))
|
|
<span class="comment">% <Adapt>: The numbers in the brackets give the lower and upper limit</span>
|
|
<span class="comment">% of the y-axis. Adapt these to fit your data and remove the % sign.</span>
|
|
<span class="comment">%ch1s.AxesProperties.YLimits = [-0.4 -0.1];</span>
|
|
grid <span class="string">ON</span>
|
|
<span class="comment">% Add title and axis labels</span>
|
|
xlabel(<span class="string">'Lab Time'</span>)
|
|
|
|
|
|
figure( <span class="string">'Name'</span>, <span class="string">'LopapChannel2 550'</span>,<span class="string">'NumberTitle'</span>,<span class="string">'off'</span>,<span class="string">'Position'</span>,[600 100 550 800]);
|
|
<span class="comment">% <Adapt>: The numbers in the curled brackets give wavelength for which you'd</span>
|
|
<span class="comment">% like to display the data. The numbers need to be exactly match the</span>
|
|
<span class="comment">% labels in the previous figure</span>
|
|
ch2s=stackedplot(LopapDataCh2,{<span class="string">'550.5'</span>});
|
|
title(LopapParameters.instrumentReferenceWavelength(2))
|
|
<span class="comment">% <Adapt>: The numbers in the brackets give the lower and upper limit</span>
|
|
<span class="comment">% of the y-axis. Adapt these to fit your data and remove the % sign.</span>
|
|
<span class="comment">% ch2s.AxesProperties.YLimits = [-0.2 0.3];</span>
|
|
grid <span class="string">ON</span>
|
|
<span class="comment">% Add title and axis labels</span>
|
|
xlabel(<span class="string">'Lab Time'</span>)
|
|
|
|
clearvars <span class="string">-except</span> <span class="string">Lopap*</span> <span class="string">fileLocation</span> <span class="string">myColorMap</span> <span class="string">lopap*</span> <span class="string">TimeRange*</span>
|
|
<span class="keyword">if</span> LopapParameters.Interactive == 1
|
|
</pre><pre class="codeinput"> distFig
|
|
fprintf(<span class="string">'press any key if you want to proceed\n'</span>)
|
|
pause
|
|
</pre><pre class="codeinput"> close <span class="string">all</span>
|
|
</pre><pre class="codeinput"><span class="keyword">end</span>
|
|
</pre><img vspace="5" hspace="5" src="LabBook_20200916_1326_04.png" alt=""> <img vspace="5" hspace="5" src="LabBook_20200916_1326_05.png" alt=""> <h2 id="25">Plot several spectra</h2><div><ul><li>A spectrum is obtained from the spectrometer.</li><li>This spectrum is averaged from multiple raw spectra with a given integration time. Optionally the raw spectra can be boxcar averaged with an adjustable boxcar window width. The recommended boxcar window width is 10 Pixel.</li><li>Then a background correction is performed: The mean of the values of the background pixels, which contains no measurement signal, is subtracted from the whole spectrum. The background pixels are freely configurable.</li></ul></div><pre class="codeinput">clc
|
|
close <span class="string">all</span>
|
|
S = timerange(datestr(TimeRange.calibrationRange(1)), datestr(TimeRange.calibrationRange(2)));
|
|
figure( <span class="string">'Name'</span>, <span class="string">'LopapSpectraWithTime'</span>,<span class="string">'NumberTitle'</span>,<span class="string">'off'</span>)
|
|
T = LopapSpecCh1(S,:);
|
|
plot3(repmat(str2double(T.Properties.VariableNames),[height(T),1]),repmat(T.Time,[1,width(T)]),T.Variables)
|
|
<span class="comment">% Set the viewing angle and the axis limits</span>
|
|
view(-25, 1)
|
|
xlim([400 700])
|
|
box <span class="string">ON</span>
|
|
grid <span class="string">ON</span>
|
|
<span class="comment">% Add title and axis labels</span>
|
|
xlabel(<span class="string">'wavelength [nm]'</span>)
|
|
ylabel(<span class="string">'Time'</span>)
|
|
zlabel(<span class="string">'Intensity'</span>)
|
|
|
|
clearvars <span class="string">-except</span> <span class="string">Lopap*</span> <span class="string">fileLocation</span> <span class="string">myColorMap</span> <span class="string">LopapParameters</span> <span class="string">TimeRange*</span>
|
|
<span class="keyword">if</span> LopapParameters.Interactive == 1
|
|
</pre><pre class="codeinput"> distFig
|
|
fprintf(<span class="string">'press any key if you want to proceed\n'</span>)
|
|
pause
|
|
</pre><pre class="codeinput"> close <span class="string">all</span>
|
|
</pre><pre class="codeinput"><span class="keyword">end</span>
|
|
</pre><img vspace="5" hspace="5" src="LabBook_20200916_1326_06.png" alt=""> <h2 id="29">Plot selected spectra</h2><p>Here, we plot a spectrum without ('R1&R2') and with nitrite ('R1+nitrite&R2'') for each channel.</p><pre class="codeinput">clc
|
|
close <span class="string">all</span>
|
|
figure(<span class="string">'Name'</span>, <span class="string">'LopapSelectedSpectra'</span>)
|
|
plot(str2double(LopapSpecCh1.Properties.VariableNames),LopapSpecCh1{datestr(TimeRange.specWithReagents),:},<span class="keyword">...</span>
|
|
<span class="string">'DisplayName'</span>,<span class="string">'#1 R1&R2'</span>) <span class="comment">% a time where only R1&R2 was connected to the Lopap</span>
|
|
hold <span class="string">on</span>
|
|
plot(str2double(LopapSpecCh2.Properties.VariableNames),LopapSpecCh2{datestr(TimeRange.specWithReagents),:},<span class="keyword">...</span>
|
|
<span class="string">'DisplayName'</span>,<span class="string">'#2 R1&R2'</span>,<span class="string">'LineStyle'</span>,<span class="string">'--'</span>) <span class="comment">% a time where only R1&R2 was connected to the Lopap</span>
|
|
plot(str2double(LopapSpecCh1.Properties.VariableNames),LopapSpecCh1{datestr(TimeRange.specWithNitrite),:},<span class="keyword">...</span>
|
|
<span class="string">'DisplayName'</span>,<span class="string">'#1 R1+nitrite&R2'</span>) <span class="comment">% a time where nitrite in R1 was connected to the Lopap</span>
|
|
plot(str2double(LopapSpecCh2.Properties.VariableNames),LopapSpecCh2{datestr(TimeRange.specWithNitrite),:},<span class="keyword">...</span>
|
|
<span class="string">'DisplayName'</span>,<span class="string">'#2 R1+nitrite&R2'</span>,<span class="string">'LineStyle'</span>,<span class="string">'--'</span>) <span class="comment">% a time where nitrite in R1 was connected to the Lopap</span>
|
|
legend
|
|
box <span class="string">ON</span>
|
|
grid <span class="string">ON</span>
|
|
<span class="comment">% Add title and axis labels</span>
|
|
xlabel(<span class="string">'wavelength [nm]'</span>)
|
|
ylabel(<span class="string">'Intensity'</span>)
|
|
|
|
clearvars <span class="string">-except</span> <span class="string">Lopap*</span> <span class="string">fileLocation</span> <span class="string">myColorMap</span> <span class="string">LopapParameters</span> <span class="string">TimeRange*</span>
|
|
<span class="keyword">if</span> LopapParameters.Interactive == 1
|
|
</pre><pre class="codeinput"> distFig
|
|
fprintf(<span class="string">'press any key if you want to proceed\n'</span>)
|
|
pause
|
|
</pre><pre class="codeinput"> close <span class="string">all</span>
|
|
</pre><pre class="codeinput"><span class="keyword">end</span>
|
|
</pre><img vspace="5" hspace="5" src="LabBook_20200916_1326_07.png" alt=""> <h2 id="33">Process: Absorption spectrum</h2><p>Here, we reprocess the data to derive an absorption spectrum. This should match the spectra shown for nitrite in the Lopap manual.</p><p>
|
|
<img src="../Bildschirmfoto2020-09-16um14.30.03.png" width="550">
|
|
</p><pre class="codeinput">clc
|
|
close <span class="string">all</span>
|
|
indexR(1) = find(str2double(LopapSpecCh1.Properties.VariableNames) >= LopapParameters.wavelengthR,1);
|
|
indexR(2) = find(str2double(LopapSpecCh2.Properties.VariableNames) >= LopapParameters.wavelengthR,1);
|
|
|
|
figure(<span class="string">'Name'</span>, <span class="string">'LopapAbsorbtionSpectra'</span>)
|
|
plot(str2double(LopapSpecCh1.Properties.VariableNames),log10(LopapSpecCh1{datestr(TimeRange.specWithNitrite),<span class="keyword">...</span>
|
|
indexR(1)}./LopapSpecCh1{datestr(TimeRange.specWithNitrite),:})-log10(LopapSpecCh1{datestr(TimeRange.specWithReagents),<span class="keyword">...</span>
|
|
indexR(1)}./LopapSpecCh1{datestr(TimeRange.specWithReagents),:}),<span class="string">'DisplayName'</span>,<span class="string">'#1 nitrite'</span>)
|
|
hold <span class="string">on</span>
|
|
plot(str2double(LopapSpecCh2.Properties.VariableNames),log10(LopapSpecCh2{datestr(TimeRange.specWithNitrite),<span class="keyword">...</span>
|
|
indexR(2)}./LopapSpecCh2{datestr(TimeRange.specWithNitrite),:})-log10(LopapSpecCh2{datestr(TimeRange.specWithReagents),<span class="keyword">...</span>
|
|
indexR(2)}./LopapSpecCh2{datestr(TimeRange.specWithReagents),:}),<span class="string">'DisplayName'</span>,<span class="string">'#2 nitrite'</span>,<span class="string">'LineStyle'</span>,<span class="string">'--'</span>)
|
|
legend
|
|
box <span class="string">ON</span>
|
|
grid <span class="string">ON</span>
|
|
<span class="comment">% Add title and axis labels</span>
|
|
xlabel(<span class="string">'wavelength [nm]'</span>)
|
|
ylabel(<span class="string">'ABS (log I_{r}/I_{i}'</span>)
|
|
clearvars <span class="string">-except</span> <span class="string">Lopap*</span> <span class="string">fileLocation</span> <span class="string">myColorMap</span> <span class="string">LopapParameters</span> <span class="string">TimeRange*</span>
|
|
<span class="keyword">if</span> LopapParameters.Interactive == 1
|
|
</pre><pre class="codeinput"> distFig
|
|
fprintf(<span class="string">'press any key if you want to proceed\n'</span>)
|
|
pause
|
|
</pre><pre class="codeinput"> close <span class="string">all</span>
|
|
</pre><pre class="codeinput"><span class="keyword">end</span>
|
|
</pre><img vspace="5" hspace="5" src="LabBook_20200916_1326_08.png" alt=""> <h2 id="37">Process :: Absorption with time</h2><p>Here, we reprocess the data to get the intensity with time for 1 chosen signal wavelength and 1 reference wavelength. The data is identical to that shown in the "measurement window" of the Lopap software.</p><p>The data is written to the <i>LopapTimeT</i> time table. Rows hold the time, columns hold the processed signal for channel 1 and channel 2.</p><p>It is important that the same signal wavelength and reference wavelength are taken for the calibration and for the experimental data.</p><pre class="codeinput">clc
|
|
close <span class="string">all</span>
|
|
indexS(1) = find(str2double(LopapSpecCh1.Properties.VariableNames) >= LopapParameters.wavelengthS,1);
|
|
indexS(2) = find(str2double(LopapSpecCh2.Properties.VariableNames) >= LopapParameters.wavelengthS,1);
|
|
indexR(1) = find(str2double(LopapSpecCh1.Properties.VariableNames) >= LopapParameters.wavelengthR,1);
|
|
indexR(2) = find(str2double(LopapSpecCh2.Properties.VariableNames) >= LopapParameters.wavelengthR,1);
|
|
LopapTimeT = timetable(LopapSpecCh1.Time,log10(LopapSpecCh1{:,indexR(1)}./LopapSpecCh1{:,indexS(1)}),log10(LopapSpecCh2{:,indexR(2)}./LopapSpecCh1{:,indexS(2)}));
|
|
LopapTimeT.Properties.VariableNames ={<span class="string">'Ch #1'</span>,<span class="string">'Ch #2'</span>};
|
|
figure(<span class="string">'Name'</span>, <span class="string">'Lopap TimeTable'</span>)
|
|
stackedplot(LopapTimeT,{{<span class="string">'Ch #1'</span>,<span class="string">'Ch #2'</span>}});
|
|
title([<span class="string">'Lopap'</span> datestr(LopapParameters.MeasurementDate)])
|
|
clearvars <span class="string">-except</span> <span class="string">Lopap*</span> <span class="string">fileLocation</span> <span class="string">myColorMap</span> <span class="string">LopapParameters</span> <span class="string">TimeRange*</span>
|
|
<span class="keyword">if</span> LopapParameters.Interactive == 1
|
|
</pre><pre class="codeinput"> distFig
|
|
fprintf(<span class="string">'press any key if you want to proceed\n'</span>)
|
|
pause
|
|
</pre><pre class="codeinput"> close <span class="string">all</span>
|
|
</pre><pre class="codeinput"><span class="keyword">end</span>
|
|
</pre><img vspace="5" hspace="5" src="LabBook_20200916_1326_09.png" alt=""> <h2 id="41">Process :: Background</h2><pre class="codeinput">clc
|
|
close <span class="string">all</span>
|
|
LopapTimeT = fitLopapBkgrd(LopapTimeT,<span class="string">'BkgrdPeriod'</span>,TimeRange.backgroundFit);
|
|
clearvars <span class="string">-except</span> <span class="string">Lopap*</span> <span class="string">fileLocation</span> <span class="string">myColorMap</span> <span class="string">LopapParameters</span> <span class="string">TimeRange*</span>
|
|
</pre><img vspace="5" hspace="5" src="LabBook_20200916_1326_10.png" alt=""> <img vspace="5" hspace="5" src="LabBook_20200916_1326_11.png" alt=""> <h2 id="42">Plot bkgrd corrected data</h2><pre class="codeinput">clc
|
|
close <span class="string">all</span>
|
|
<span class="comment">% Plot</span>
|
|
figure(<span class="string">'Name'</span>, <span class="string">'Lopap TimeTable Bkgrd'</span>)
|
|
s=stackedplot(LopapTimeT,{{<span class="string">'Ch #1 Bkgrd'</span>,<span class="string">'Ch #2 Bkgrd'</span>}});
|
|
title([<span class="string">'Lopap'</span> datestr(LopapParameters.MeasurementDate)])
|
|
s.AxesProperties.YLimits = [-0.01 0.3];
|
|
clearvars <span class="string">-except</span> <span class="string">Lopap*</span> <span class="string">fileLocation</span> <span class="string">myColorMap</span> <span class="string">LopapParameters</span> <span class="string">TimeRange*</span>
|
|
</pre><img vspace="5" hspace="5" src="LabBook_20200916_1326_12.png" alt=""> <h2 id="43">Process :: Calibrate</h2><pre class="codeinput">clc
|
|
close <span class="string">all</span>
|
|
|
|
S = timerange(datestr(TimeRange.MeanZeroAir(1)), datestr(TimeRange.MeanZeroAir(2)));
|
|
TZ = LopapTimeT(S,:);
|
|
S = timerange(datestr(TimeRange.MeanNitriteStandard(1)), datestr(TimeRange.MeanNitriteStandard(2)));
|
|
TN = LopapTimeT(S,:);
|
|
calib.mean = mean(TN{:,:},1) - mean(TZ{:,:},1);
|
|
calib.std = std(TN{:,:},1);
|
|
calib.mixingRatio = LopapParameters.concStandard./1000.*LopapParameters.flowReagents./1000./46.*6.022E23./<span class="keyword">...</span>
|
|
(246E17.*LopapParameters.flowGas).*1E12;
|
|
|
|
[LopapTimeT, calib.fitresult] = fitLopapCalibration(LopapTimeT,calib);
|
|
clearvars <span class="string">-except</span> <span class="string">Lopap*</span> <span class="string">fileLocation</span> <span class="string">myColorMap</span> <span class="string">LopapParameters</span> <span class="string">TimeRange*</span> <span class="string">fitresult</span> <span class="string">calib</span>
|
|
|
|
fprintf(<span class="string">'Detection limit channel #1 is %.0f ppt \n'</span>,calib.fitresult.calibChannel1(3.*calib.std(3)))
|
|
fprintf(<span class="string">'Detection limit channel #2 is %.0f ppt \n'</span>,calib.fitresult.calibChannel2(3.*calib.std(4)))
|
|
</pre><pre class="codeoutput">Detection limit channel #1 is 16 ppt
|
|
Detection limit channel #2 is 62 ppt
|
|
</pre><h2 id="44">Plot calibrated data</h2><pre class="codeinput">clc
|
|
close <span class="string">all</span>
|
|
<span class="comment">% Plot</span>
|
|
figure(<span class="string">'Name'</span>, <span class="string">'Lopap TimeTable Calibrated'</span>)
|
|
s=stackedplot(LopapTimeT,{{<span class="string">'Ch #1 Calib'</span>,<span class="string">'Ch #2 Calib'</span>}});
|
|
title([<span class="string">'Lopap'</span> datestr(LopapParameters.MeasurementDate)])
|
|
s.AxesProperties.YLimits = [-100 2500];
|
|
clearvars <span class="string">-except</span> <span class="string">Lopap*</span> <span class="string">fileLocation</span> <span class="string">myColorMap</span> <span class="string">LopapParameters</span> <span class="string">TimeRange*</span> <span class="string">fitresult</span> <span class="string">calib</span>
|
|
<span class="keyword">if</span> LopapParameters.Interactive == 1
|
|
</pre><pre class="codeinput"> distFig
|
|
fprintf(<span class="string">'press any key if you want to proceed\n'</span>)
|
|
pause
|
|
</pre><pre class="codeinput"> close <span class="string">all</span>
|
|
</pre><pre class="codeinput"><span class="keyword">end</span>
|
|
</pre><img vspace="5" hspace="5" src="LabBook_20200916_1326_13.png" alt=""> <h2 id="48">Save the data</h2><pre class="codeinput">save([<span class="string">'LopapMatlabData'</span> datestr(LopapParameters.MeasurementDate,<span class="string">'yyyyMMdd_hhmm'</span>) <span class="string">'.mat'</span>])
|
|
save([<span class="string">'Lopap'</span> datestr(LopapParameters.MeasurementDate,<span class="string">'yyyyMMdd_hhmm'</span>) <span class="string">'.mat'</span>],<span class="string">'LopapParameters'</span>,<span class="string">'LopapTimeT'</span>,<span class="string">'TimeRange'</span>)
|
|
</pre><h2 id="49">Local functions</h2><pre class="codeinput"><span class="keyword">function</span> [fileLocation, myColorMap] = localInitializeMatlab
|
|
<span class="comment">%INITIALIZEMATLAB Sets Lopap specific settings</span>
|
|
<span class="comment">% Adds processing functions to path and defines file locations for mac, windows,</span>
|
|
<span class="comment">% and Matlab online (which runs on unix)</span>
|
|
|
|
<span class="comment">% change working directory</span>
|
|
path = matlab.desktop.editor.getActiveFilename;
|
|
[filepath,~,~] = fileparts(path);
|
|
cd(filepath);
|
|
|
|
|
|
<span class="comment">% Data Server Address</span>
|
|
<span class="keyword">if</span> ismac
|
|
fileLocation.server = <span class="string">'/Volumes/'</span>;
|
|
fileLocation.dataPath = <span class="string">'data_2411/Lopap/Marc/'</span>;
|
|
<span class="comment">% add Lopap functions and general add-ons to path</span>
|
|
addpath(<span class="string">'/Users/bartels-rausch/Documents/SwitchDrive/PSI_Matlab/Add-Ons'</span>);
|
|
addpath(<span class="string">'/Users/bartels-rausch/Documents/SwitchDrive/PSI_Matlab/Lopap'</span>);
|
|
<span class="keyword">elseif</span> ispc
|
|
fileLocation.server = <span class="string">'\\fs00\'</span>; <span class="comment">%UNC name for file server that hosts Napp shared drive</span>
|
|
fileLocation.dataPath = <span class="string">'data_2411\Lopap\Marc\'</span>;
|
|
<span class="comment">% add Lopap functions and general add-ons to path</span>
|
|
addpath(<span class="string">'\\fs02\5601_surface_chemistry\People\Marc\Switchdrive\PSI_Matlab\Add-Ons'</span>);
|
|
addpath(<span class="string">'\\fs02\5601_surface_chemistry\People\Marc\Switchdrive\PSI_Matlab\Lopap'</span>);
|
|
<span class="keyword">elseif</span> isunix
|
|
fileLocation.server = <span class="string">'/'</span>;
|
|
fileLocation.dataPath = <span class="string">'Lopap/'</span>;
|
|
<span class="keyword">end</span>
|
|
|
|
<span class="comment">% Color maps</span>
|
|
myColorMap.red = colormap(autumn(7));
|
|
myColorMap.blue = colormap(winter(7));
|
|
|
|
close <span class="string">all</span>
|
|
<span class="keyword">end</span>
|
|
</pre><pre class="codeoutput">The data is read from:
|
|
/Volumes/data_2411/Lopap/Marc/20200916_1326
|
|
|
|
Date of experiment:
|
|
16-Sep-2020 13:26:00
|
|
|
|
Date of analyis:
|
|
12-Nov-2020
|
|
</pre><p class="footer"><br><a href="https://www.mathworks.com/products/matlab/">Published with MATLAB® R2019b</a><br></p></div><!--
|
|
##### SOURCE BEGIN #####
|
|
%% Lopap Template
|
|
% Uses data from 16.9.2020 13h26
|
|
%
|
|
%% Info: How to use this
|
|
%
|
|
% # Make a copy of this file for each Lopap measurement. Name it
|
|
% "Lopap"_date_time.m and store it in the folder with the Lopap data. %
|
|
% Remove all the general text and comments in your file and add notes and
|
|
% observations about the experiment.
|
|
%
|
|
% # You can run this script, publish it, or evaluate it section wise. For
|
|
% new data run it section wise to carefully update the settings and to
|
|
% observe the results.
|
|
% # Once the data is loaded, you can also run individual sections only.
|
|
% # Use the LabBook :: Chrono Notes section as lab book.
|
|
% # First, you need to give the date and time of the Lopap measurement to
|
|
% load and process the data.
|
|
% # All sections that can be modified are marked with the word "<Adapt>:".
|
|
% # You also need to give time regions such as for the background fit, as
|
|
% well as to calculate means. There are several options how to do this
|
|
%
|
|
% * While running the experiments and observing the signal in the Lopap
|
|
% software, you can enter the date and times directly in the LabBook :
|
|
% Select data ranges section.
|
|
% * You can manually select the regions in a plot. A window will pop up to
|
|
% select the region to modify. To modify several regions, re-run this
|
|
% section of the script. This overwrites the current settings.
|
|
% * The times of the regions are stored in the "TimeRanges.mat" file. If it
|
|
% exists, this is read; the LabBook : Select data ranges section is then
|
|
% ignored.
|
|
%% Info: Output & Variables
|
|
%
|
|
% * *lopapReferenceWavelength*: This _string variable_ holds text with
|
|
% stating the reference wavelength for channel 1 and 2 used to process the
|
|
% data by the Lopap software.
|
|
% * *LopapDataCh1 & LopapDataCh2*: These _time tables_ hold the data that
|
|
% have been processed by the Lopap Software during the data acquisition. It
|
|
% contains the absorption for a number
|
|
% of selected wavelength. The absorption is the log of the intensity at the
|
|
% reference wavelength relative to the intensity at each wavelength of
|
|
% interest. The timetables hold the time in each row and the wavelength in
|
|
% the columns. The content is thus identical to that shown in the
|
|
% "measurement window" of the Lopap software.
|
|
% * *LopapSpecCh1,LopapSpecCh2*: The _time tables_ hold the full spectrum
|
|
% for each time. Time is in the rows, wavelength in the columns. The
|
|
% wavelength are read from the *.prj file, the spectra data from the *.spec
|
|
% file. The information is identical to that shown in the "spectrum window"
|
|
% of the Lopap software.
|
|
%
|
|
% * *TimeRanges.mat*: Time ranges after they have been manually modified. If
|
|
% this file exists, the time range definitions in this script are ignored.
|
|
% * *LopapMatlabDataDATE_TIME.mat*: Raw data and experimental settings.
|
|
% Background subtraction and calibration are not saved in this file. When
|
|
% this file exists, data will not be read from the windows server.
|
|
% * *LopapDATE_TIME.mat*: Processed data - absorption with time (column 1
|
|
% and 2: 'Ch #1' and 'Ch #2') after background (columns 3 and 4: 'Ch #1
|
|
% Bkgrd' and 'Ch #2 Bkgrd') subtraction and calibration (columns 5 and 6:
|
|
% 'Ch #1 Calib' and 'Ch #2 Calib') for one wavelength - that can be used
|
|
% for further comparison with other experiments and discussion.
|
|
%
|
|
|
|
%% Matlab: Initialise
|
|
%
|
|
% This starts Matlab and defines some common settings such as the path to
|
|
% the Lopap data. Any modifications can be done at the end of this file in
|
|
% where the local function _localInitializeMatlab_ is stored.
|
|
|
|
|
|
% 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;
|
|
% <Adapt>: Date when Lopap recording was started. Defines names of Lopap
|
|
% files and folders. Seconds are irrelevant, but format is important.
|
|
LopapParameters.MeasurementDate = datenum('16-Sep-2020 13:26:00');
|
|
|
|
|
|
% Print info to command window
|
|
disp('The data is read from:');
|
|
disp(fullfile(fileLocation.server,fileLocation.dataPath,datestr(LopapParameters.MeasurementDate,'yyyymmdd_HHMM')));
|
|
disp(' ')
|
|
disp('Date of experiment:')
|
|
disp(datestr(LopapParameters.MeasurementDate));
|
|
disp(' ')
|
|
disp('Date of analyis:')
|
|
disp(datestr(today));
|
|
|
|
%% Process: Import data
|
|
%
|
|
% Reads and imports data from Lopap *.dat, *.spec, and *.prj files into:
|
|
%
|
|
% * *lopapReferenceWavelength*: This _string variable_ holds text with
|
|
% stating the reference wavelength for channel 1 and 2 used to process the
|
|
% data by the Lopap software.
|
|
% * *LopapDataCh1 & LopapDataCh2*: These _time tables_ hold the data that
|
|
% have been processed by the Lopap Software during the data acquisition. It
|
|
% contains the absorption for a number
|
|
% of selected wavelength. The absorption is the log of the intensity at the
|
|
% reference wavelength relative to the intensity at each wavelength of
|
|
% interest. The timetables hold the time in each row and the wavelength in
|
|
% the columns. The content is thus identical to that shown in the
|
|
% "measurement window" of the Lopap software.
|
|
% * *LopapSpecCh1,LopapSpecCh2*: The _time tables_ hold the full spectrum
|
|
% for each time. Time is in the rows, wavelength in the columns. The
|
|
% wavelength are read from the *.prj file, the spectra data from the *.spec
|
|
% file. The information is identical to that shown in the "spectrum window"
|
|
% of the Lopap software.
|
|
|
|
|
|
if isfile(['LopapMatlabData' datestr(LopapParameters.MeasurementDate,'yyyyMMdd_hhmm') '.mat'])
|
|
load(['LopapMatlabData' datestr(LopapParameters.MeasurementDate,'yyyyMMdd_hhmm') '.mat'])
|
|
else
|
|
[LopapParameters.instrumentReferenceWavelength, LopapDataCh1,LopapDataCh2,LopapSpecCh1,LopapSpecCh2] ...
|
|
= importLopap(LopapParameters.MeasurementDate,fileLocation);
|
|
end
|
|
|
|
%% Matlab: Run mode
|
|
%
|
|
% <Adapt>:
|
|
%
|
|
% * runs without user interaction and without ability to modify data
|
|
% ranges, when set to 0; use this to publish.
|
|
% * if set to 1: stops for user interaction,
|
|
% modify data ranges is enabled.Use this to run.
|
|
LopapParameters.Interactive = 0;
|
|
%% LabBook : ChronoNotes
|
|
%
|
|
% <Adapt>: Your notes go here
|
|
%
|
|
% * Nitritstandardlösung: 1g/l
|
|
% * Nitritlösung: 0.01mg/l
|
|
% * Volumenfluss 1: 26.08min für 5ml -> 0.192ml/min
|
|
% * Volumenfluss 2: 26.33min für 5ml -> 0.190ml/min
|
|
% * Pumpgeschwindigkeit: 10U/min
|
|
% * Gasfluss: 2000ml/min
|
|
% * *16.9.20 13h30*: Start instrument with water
|
|
% * time: 2s/2s
|
|
% * time: 80ms/4ms
|
|
% * *16.9.20 13h00*: water -> R1 & R2, ABS closed
|
|
%% LabBook : Measurement Settings
|
|
%
|
|
% <Adapt>: list the Lopap settings here:
|
|
LopapParameters.concStandard = 0.01; % mg/l concentration of nitrite in standard used for calibration
|
|
LopapParameters.flowReagents = 5./[26.08 26.33]; % ml/min, enter time for 5 ml
|
|
LopapParameters.flowGas = 2000; % ml/min, take average of 10.
|
|
LopapParameters.temperature = 298; % temp of gas flow in K
|
|
LopapParameters.pressure = 1013; % pressure of gas flow in mbar
|
|
|
|
% <Adapt>: Choose a reference wavelength. Default is 650 nm.
|
|
LopapParameters.wavelengthR = 650; %nm, reference intensity
|
|
% <Adapt>: Choose a signal wavelength to calculate the absorption with time
|
|
% from the spectra
|
|
LopapParameters.wavelengthS = 534; %nm, signal intensity
|
|
|
|
%% LabBook : Define data ranges
|
|
%
|
|
% These settings are ignored if the TimesRanges.mat file exist. If you do
|
|
% not want to use the data stored in the TimesRanges.mat file, you need to
|
|
% delete it before running this section.
|
|
%
|
|
% These settings can be modified by selecting data ranges in a plot later.
|
|
% So, you do not necessarily need to type the dates and times here.
|
|
|
|
if isfile(['TimeRanges' datestr(LopapParameters.MeasurementDate,'yyyyMMdd_hhmm') '.mat'])
|
|
load(['TimeRanges' datestr(LopapParameters.MeasurementDate,'yyyyMMdd_hhmm') '.mat'])
|
|
elseif ~exist('TimeRange','var')
|
|
% <Adapt>: State the start and end time of the calibration. Usually
|
|
% this is included zero air with R1&2, zero air with nitrite standard,
|
|
% zero air with R1&2
|
|
TimeRange.calibrationRange = [datenum('16-Sep-2020 13:55:00') datenum('16-Sep-2020 15:15:00')];
|
|
% <Adapt>: State the time for one spectrum with R1&R2 without nitrite
|
|
TimeRange.specWithReagents = datenum('2020-09-16 14:31:06');
|
|
% <Adapt>: State the time for one spectrum with R1&R2 and nitrite
|
|
TimeRange.specWithNitrite = datenum('2020-09-16 15:10:14');
|
|
% <Adapt>: Choose a start and end time for one as many intervals that can
|
|
% be used to fit the background. Background is the signal when R1&R2 was
|
|
% attached to the Lopap with zero air entering the sampling coil.
|
|
TimeRange.backgroundFit = [datenum('16-Sep-2020 14:29:28') datenum('16-Sep-2020 14:40:04');...
|
|
datenum('16-Sep-2020 15:40:50') datenum('16-Sep-2020 15:51:06')];
|
|
% <Adapt>: State the start and end time of data that can be used to
|
|
% calculate the mean of the zero air signal without nitrate
|
|
TimeRange.MeanZeroAir = [datenum('16-Sep-2020 14:28:42') datenum('16-Sep-2020 14:38:36')];
|
|
% <Adapt>: State the start and end time of data that can be used to
|
|
% calculate the mean of the zero air signal without nitrate
|
|
TimeRange.MeanNitriteStandard = [datenum('16-Sep-2020 15:09:20') datenum('16-Sep-2020 15:18:30')];
|
|
|
|
save(['TimeRanges' datestr(LopapParameters.MeasurementDate,'yyyyMMdd_hhmm') '.mat'],'TimeRange');
|
|
else
|
|
disp('Nothing done: TimeRange in Workspace used')
|
|
end
|
|
|
|
%% Process: Modify data ranges
|
|
%
|
|
% Select the range to modify in the pop-up window and the number of fit
|
|
% ranges for the background fit in the 2nd pop-up window. Then, a figure
|
|
% will show, select the data ranges in the figure:
|
|
%
|
|
% * a line for calibration range, mean zero air and mean
|
|
% nitrite standard. Select the range by keeping the mouse pushed while
|
|
% moving from start to end time.
|
|
% * a line for each background region, default is 2. Select the range by
|
|
% keeping the mouse pushed while moving from start to end time.
|
|
% * a point for spectrum with reagents and spectrum with nitrite. Click
|
|
% once to select a specific time.
|
|
%
|
|
% # Run this section several times to modify several time regions
|
|
% # Press cancel in the pop-up window if you do not want to modify any
|
|
% region.
|
|
|
|
if LopapParameters.Interactive == 1
|
|
close all
|
|
clc
|
|
list = {'Calibration Range','Background Fit','Mean ZeroAir','Mean NitritStandard',...
|
|
'Spectrum with Reagents','Spectrum with Nitrite'};
|
|
indx = listdlg('ListString',list,'PromptString',{'Choose parameter to modify,','then select region in figure'}...
|
|
,'SelectionMode','single');
|
|
if indx == 2
|
|
prompt = {'Enter number of regions to fit the background:'};
|
|
dlgtitle = 'Background Fit';
|
|
dims = [1 40];
|
|
definput = {'2'};
|
|
answer = inputdlg(prompt,dlgtitle,dims,definput);
|
|
end
|
|
if indx >= 1
|
|
clc
|
|
close all
|
|
figure( 'Name', 'LopapChannel 550','NumberTitle','off','Position',[10 100 550 800]);
|
|
plot(datenum(LopapDataCh1.Time),LopapDataCh1.("550.7"));
|
|
hold on
|
|
datetick('x','dd.mm hh:MM','keeplimits','keepticks');
|
|
ax = gca;
|
|
yyaxis right
|
|
plot(datenum(LopapDataCh2.Time),LopapDataCh2.("550.5"));
|
|
datetick('x','dd.mm hh:MM','keeplimits','keepticks');
|
|
grid ON
|
|
% Add title and axis labels
|
|
xlabel('Lab Time')
|
|
legend({'MeasData Ch#1','MeasData Ch#2'})
|
|
% select regions in plot
|
|
if indx == 1
|
|
Roi.calibrationRange = drawline(ax,'Color','r');
|
|
TimeRange.calibrationRange = [Roi.calibrationRange.Position(1,1) Roi.calibrationRange.Position(2,1)];
|
|
pause(3)
|
|
close all
|
|
elseif indx == 2
|
|
for ii = 1:str2double(answer)
|
|
Roi.backgroundFit = drawline(ax,'Color','r');
|
|
TimeRange.backgroundFit(ii,:) = [Roi.backgroundFit.Position(1,1) Roi.backgroundFit.Position(2,1)];
|
|
end
|
|
pause(3)
|
|
close all
|
|
elseif indx == 3
|
|
Roi.meanZeroAir = drawline(ax,'Color','r');
|
|
TimeRange.MeanZeroAir = [Roi.meanZeroAir.Position(1,1) Roi.meanZeroAir.Position(2,1)];
|
|
pause(3)
|
|
close all
|
|
elseif indx == 4
|
|
Roi.meanNitriteStandard = drawline(ax,'Color','r');
|
|
TimeRange.MeanNitriteStandard = [Roi.meanNitriteStandard.Position(1,1) Roi.meanNitriteStandard.Position(2,1)];
|
|
pause(3)
|
|
close all
|
|
elseif indx == 5
|
|
Roi.specWithReagents = drawpoint(ax,'Color','r');
|
|
TimeRange.specWithReagents = Roi.specWithReagents.Position(1,1);
|
|
pause(3)
|
|
close all
|
|
elseif indx == 6
|
|
Roi.specWithNitrite = drawpoint(ax,'Color','r');
|
|
TimeRange.specWithNitrite = Roi.specWithNitrite.Position(1,1);
|
|
pause(3)
|
|
close all
|
|
end
|
|
|
|
|
|
clearvars -except Lopap* fileLocation myColorMap LopapParameters TimeRange*
|
|
save(['TimeRanges' datestr(LopapParameters.MeasurementDate,'yyyyMMdd_hhmm') '.mat'],'TimeRange');
|
|
end
|
|
else
|
|
disp('Variable LopapParameters.Interactive not set to 1: Modify data ranges manually has been skiped');
|
|
end
|
|
|
|
%% Process: Find closest match of selected dates in data set
|
|
%
|
|
% The data is sampled at specific times with a certain interval. The
|
|
% selected or chosen dates might not necessarily exactly match the data.
|
|
% Here, closest match to the given dates are selected.
|
|
|
|
tmp.d1 = TimeRange.specWithReagents;
|
|
tmp.d2 = LopapSpecCh1.Time;
|
|
[~,ind1] = min(abs(bsxfun(@minus,datenum(tmp.d2),datenum(tmp.d1)')));
|
|
TimeRange.specWithReagents = tmp.d2(ind1,:);
|
|
|
|
tmp.d1 = TimeRange.specWithNitrite ;
|
|
tmp.d2 = LopapSpecCh1.Time;
|
|
[~,ind1] = min(abs(bsxfun(@minus,datenum(tmp.d2),datenum(tmp.d1)')));
|
|
TimeRange.specWithNitrite = tmp.d2(ind1,:);
|
|
|
|
% save current state of
|
|
clearvars -except Lopap* fileLocation myColorMap LopapParameters TimeRange*
|
|
save(['LopapMatlabData' datestr(LopapParameters.MeasurementDate,'yyyyMMdd_hhmm') '.mat'])
|
|
save(['TimeRanges' datestr(LopapParameters.MeasurementDate,'yyyyMMdd_hhmm') '.mat'],'TimeRange');
|
|
|
|
%% LabBook: Data ranges used in this work
|
|
%
|
|
% This plots the
|
|
|
|
fprintf('Calibration range: %s to %s \n',datestr(TimeRange.calibrationRange(1)), datestr(TimeRange.calibrationRange(2)))
|
|
for ii=1:size(TimeRange.backgroundFit,2)
|
|
fprintf('Background range: %s to %s \n',datestr(TimeRange.backgroundFit(ii,1)), datestr(TimeRange.backgroundFit(ii,2)))
|
|
end
|
|
fprintf('Zero mean: %s to %s \n',datestr(TimeRange.MeanZeroAir(1)), datestr(TimeRange.MeanZeroAir(2)))
|
|
fprintf('Nitrite mean: %s to %s \n',datestr(TimeRange.MeanNitriteStandard(1)), datestr(TimeRange.MeanNitriteStandard(2)))
|
|
fprintf('Zero spectrum: %s \n',datestr(TimeRange.specWithReagents(1)))
|
|
fprintf('Nitrite spectrum: %s \n',datestr(TimeRange.specWithNitrite(1)))
|
|
|
|
%% Process: Calculate difference zero-air to nitrite calibration
|
|
%
|
|
deltaSignalCh1 = LopapSpecCh1{datestr(TimeRange.specWithNitrite),:}...
|
|
-LopapSpecCh1{datestr(TimeRange.specWithReagents),:};
|
|
deltaSignalCh2 = LopapSpecCh2{datestr(TimeRange.specWithNitrite),:}...
|
|
-LopapSpecCh2{datestr(TimeRange.specWithReagents),:};
|
|
|
|
figure( 'Name', 'LopapDelta','NumberTitle','off','Position',[600 100 550 550]);
|
|
plot(str2double(LopapSpecCh1.Properties.VariableNames),deltaSignalCh1);
|
|
hold on
|
|
plot(str2double(LopapSpecCh2.Properties.VariableNames),deltaSignalCh2);
|
|
title('delta sigInt(nitirite) - sigInt(reagents)')
|
|
legend({'Ch #1', 'Ch #2'});
|
|
grid ON
|
|
xlim([400 750])
|
|
% Add title and axis labels
|
|
xlabel('Lab Time')
|
|
clearvars -except Lopap* fileLocation myColorMap LopapParameters TimeRange*
|
|
|
|
if LopapParameters.Interactive == 1
|
|
distFig
|
|
fprintf('press any key if you want to proceed\n')
|
|
pause
|
|
%%
|
|
%
|
|
close all
|
|
end
|
|
%% Plot all data
|
|
%
|
|
% Here, we plot the data as shown in the "Measurement window" of the Lopap
|
|
% software. That is, the processed $I^{*}_{i}$ data for all wavelength as
|
|
% defined in the settings of the Lopap software.
|
|
%
|
|
%
|
|
% For every measurement wavelength I_i the program calculates the
|
|
% measurement (absorption) value I_i^* from the spectral intensity on the
|
|
% measurement wavelength I_i and a reference wavelength I_r with the
|
|
% following operation:
|
|
%
|
|
%
|
|
% $$I^{*}_{i} = log_{10} (\frac{I_r}{I_i})$$
|
|
%
|
|
%
|
|
%
|
|
% The plots show time on the x-axis and the ABS intensity on the y axis for
|
|
% each wavelength in separate graphs. One Figure for each Channel.
|
|
|
|
figure( 'Name', 'LopapChannel1','NumberTitle','off','Position',[10 100 550 700]);
|
|
ch1s=stackedplot(LopapDataCh1);
|
|
title(LopapParameters.instrumentReferenceWavelength(1))
|
|
for ii = 1:width(LopapDataCh1)
|
|
% <Adapt>: The numbers in the brackets give the lower and upper limit
|
|
% of the y-axis. Adapt these to fit your data and remove the % sign.
|
|
% ch1s.AxesProperties(ii).YLimits = [-0.4 -0.1];
|
|
end
|
|
grid ON
|
|
% Add title and axis labels
|
|
xlabel('Lab Time')
|
|
|
|
figure( 'Name', 'LopapChannel2','NumberTitle','off','Position',[600 100 550 700]);
|
|
ch2s=stackedplot(LopapDataCh2);
|
|
title(LopapParameters.instrumentReferenceWavelength(2))
|
|
for ii = 1:width(LopapDataCh2)
|
|
% <Adapt>: The numbers in the brackets give the lower and upper limit
|
|
% of the y-axis. Adapt these to fit your data and remove the % sign.
|
|
% ch2s.AxesProperties(ii).YLimits = [-0.2 0.3];
|
|
end
|
|
grid ON
|
|
% Add title and axis labels
|
|
xlabel('Lab Time')
|
|
clearvars -except Lopap* fileLocation myColorMap LopapParameters TimeRange*
|
|
if LopapParameters.Interactive == 1
|
|
distFig
|
|
fprintf('press any key if you want to proceed\n')
|
|
pause
|
|
%%
|
|
%
|
|
close all
|
|
end
|
|
%% Labbook: Notes to Figures
|
|
%
|
|
% * Kanal 2 ist stärker am rauschen.
|
|
% * Ev. wegen Leck am T-Stück in der Absorptionskammer.
|
|
|
|
%% Plot selected data
|
|
%
|
|
% Here we plot the $I^{*}_{i}$ data for one wavelength only.
|
|
|
|
|
|
figure( 'Name', 'LopapChannel1 550','NumberTitle','off','Position',[10 100 550 800]);
|
|
% <Adapt>: The numbers in the curled brackets give wavelength for which you'd
|
|
% like to display the data. The numbers need to be exactly match the
|
|
% labels in the previous figure.
|
|
ch1s=stackedplot(LopapDataCh1,{'550.7'});
|
|
title(LopapParameters.instrumentReferenceWavelength(1))
|
|
% <Adapt>: The numbers in the brackets give the lower and upper limit
|
|
% of the y-axis. Adapt these to fit your data and remove the % sign.
|
|
%ch1s.AxesProperties.YLimits = [-0.4 -0.1];
|
|
grid ON
|
|
% Add title and axis labels
|
|
xlabel('Lab Time')
|
|
|
|
|
|
figure( 'Name', 'LopapChannel2 550','NumberTitle','off','Position',[600 100 550 800]);
|
|
% <Adapt>: The numbers in the curled brackets give wavelength for which you'd
|
|
% like to display the data. The numbers need to be exactly match the
|
|
% labels in the previous figure
|
|
ch2s=stackedplot(LopapDataCh2,{'550.5'});
|
|
title(LopapParameters.instrumentReferenceWavelength(2))
|
|
% <Adapt>: The numbers in the brackets give the lower and upper limit
|
|
% of the y-axis. Adapt these to fit your data and remove the % sign.
|
|
% ch2s.AxesProperties.YLimits = [-0.2 0.3];
|
|
grid ON
|
|
% Add title and axis labels
|
|
xlabel('Lab Time')
|
|
|
|
clearvars -except Lopap* fileLocation myColorMap lopap* TimeRange*
|
|
if LopapParameters.Interactive == 1
|
|
distFig
|
|
fprintf('press any key if you want to proceed\n')
|
|
pause
|
|
%%
|
|
%
|
|
close all
|
|
end
|
|
%% Plot several spectra
|
|
%
|
|
% * A spectrum is obtained from the spectrometer.
|
|
% * This spectrum is averaged from multiple raw spectra with a given
|
|
% integration time. Optionally the raw spectra can be boxcar averaged with
|
|
% an adjustable boxcar window width. The recommended boxcar window width is
|
|
% 10 Pixel.
|
|
% * Then a background correction is performed: The mean of the values of
|
|
% the background pixels, which contains no measurement signal, is
|
|
% subtracted from the whole spectrum. The background pixels are freely
|
|
% configurable.
|
|
clc
|
|
close all
|
|
S = timerange(datestr(TimeRange.calibrationRange(1)), datestr(TimeRange.calibrationRange(2)));
|
|
figure( 'Name', 'LopapSpectraWithTime','NumberTitle','off')
|
|
T = LopapSpecCh1(S,:);
|
|
plot3(repmat(str2double(T.Properties.VariableNames),[height(T),1]),repmat(T.Time,[1,width(T)]),T.Variables)
|
|
% Set the viewing angle and the axis limits
|
|
view(-25, 1)
|
|
xlim([400 700])
|
|
box ON
|
|
grid ON
|
|
% Add title and axis labels
|
|
xlabel('wavelength [nm]')
|
|
ylabel('Time')
|
|
zlabel('Intensity')
|
|
|
|
clearvars -except Lopap* fileLocation myColorMap LopapParameters TimeRange*
|
|
if LopapParameters.Interactive == 1
|
|
distFig
|
|
fprintf('press any key if you want to proceed\n')
|
|
pause
|
|
%%
|
|
%
|
|
close all
|
|
end
|
|
%% Plot selected spectra
|
|
%
|
|
% Here, we plot a spectrum without ('R1&R2') and with nitrite
|
|
% ('R1+nitrite&R2'') for each channel.
|
|
clc
|
|
close all
|
|
figure('Name', 'LopapSelectedSpectra')
|
|
plot(str2double(LopapSpecCh1.Properties.VariableNames),LopapSpecCh1{datestr(TimeRange.specWithReagents),:},...
|
|
'DisplayName','#1 R1&R2') % a time where only R1&R2 was connected to the Lopap
|
|
hold on
|
|
plot(str2double(LopapSpecCh2.Properties.VariableNames),LopapSpecCh2{datestr(TimeRange.specWithReagents),:},...
|
|
'DisplayName','#2 R1&R2','LineStyle','REPLACE_WITH_DASH_DASH') % a time where only R1&R2 was connected to the Lopap
|
|
plot(str2double(LopapSpecCh1.Properties.VariableNames),LopapSpecCh1{datestr(TimeRange.specWithNitrite),:},...
|
|
'DisplayName','#1 R1+nitrite&R2') % a time where nitrite in R1 was connected to the Lopap
|
|
plot(str2double(LopapSpecCh2.Properties.VariableNames),LopapSpecCh2{datestr(TimeRange.specWithNitrite),:},...
|
|
'DisplayName','#2 R1+nitrite&R2','LineStyle','REPLACE_WITH_DASH_DASH') % a time where nitrite in R1 was connected to the Lopap
|
|
legend
|
|
box ON
|
|
grid ON
|
|
% Add title and axis labels
|
|
xlabel('wavelength [nm]')
|
|
ylabel('Intensity')
|
|
|
|
clearvars -except Lopap* fileLocation myColorMap LopapParameters TimeRange*
|
|
if LopapParameters.Interactive == 1
|
|
distFig
|
|
fprintf('press any key if you want to proceed\n')
|
|
pause
|
|
%%
|
|
%
|
|
close all
|
|
end
|
|
%% Process: Absorption spectrum
|
|
%
|
|
% Here, we reprocess the data to derive an absorption spectrum. This should
|
|
% match the spectra shown for nitrite in the Lopap manual.
|
|
%
|
|
%
|
|
%
|
|
% <html>
|
|
% <img src="../Bildschirmfoto2020-09-16um14.30.03.png" width="550">
|
|
% </html>
|
|
%
|
|
clc
|
|
close all
|
|
indexR(1) = find(str2double(LopapSpecCh1.Properties.VariableNames) >= LopapParameters.wavelengthR,1);
|
|
indexR(2) = find(str2double(LopapSpecCh2.Properties.VariableNames) >= LopapParameters.wavelengthR,1);
|
|
|
|
figure('Name', 'LopapAbsorbtionSpectra')
|
|
plot(str2double(LopapSpecCh1.Properties.VariableNames),log10(LopapSpecCh1{datestr(TimeRange.specWithNitrite),...
|
|
indexR(1)}./LopapSpecCh1{datestr(TimeRange.specWithNitrite),:})-log10(LopapSpecCh1{datestr(TimeRange.specWithReagents),...
|
|
indexR(1)}./LopapSpecCh1{datestr(TimeRange.specWithReagents),:}),'DisplayName','#1 nitrite')
|
|
hold on
|
|
plot(str2double(LopapSpecCh2.Properties.VariableNames),log10(LopapSpecCh2{datestr(TimeRange.specWithNitrite),...
|
|
indexR(2)}./LopapSpecCh2{datestr(TimeRange.specWithNitrite),:})-log10(LopapSpecCh2{datestr(TimeRange.specWithReagents),...
|
|
indexR(2)}./LopapSpecCh2{datestr(TimeRange.specWithReagents),:}),'DisplayName','#2 nitrite','LineStyle','REPLACE_WITH_DASH_DASH')
|
|
legend
|
|
box ON
|
|
grid ON
|
|
% Add title and axis labels
|
|
xlabel('wavelength [nm]')
|
|
ylabel('ABS (log I_{r}/I_{i}')
|
|
clearvars -except Lopap* fileLocation myColorMap LopapParameters TimeRange*
|
|
if LopapParameters.Interactive == 1
|
|
distFig
|
|
fprintf('press any key if you want to proceed\n')
|
|
pause
|
|
%%
|
|
%
|
|
close all
|
|
end
|
|
%% Process :: Absorption with time
|
|
%
|
|
% Here, we reprocess the data to get the intensity with time for 1 chosen
|
|
% signal wavelength and 1 reference wavelength. The data is identical to that
|
|
% shown in the "measurement window" of the Lopap software.
|
|
%
|
|
% The data is written to the _LopapTimeT_ time table. Rows hold the time,
|
|
% columns hold the processed signal for channel 1 and channel 2.
|
|
%
|
|
% It is important that the same signal wavelength and reference wavelength
|
|
% are taken for the calibration and for the experimental data.
|
|
|
|
clc
|
|
close all
|
|
indexS(1) = find(str2double(LopapSpecCh1.Properties.VariableNames) >= LopapParameters.wavelengthS,1);
|
|
indexS(2) = find(str2double(LopapSpecCh2.Properties.VariableNames) >= LopapParameters.wavelengthS,1);
|
|
indexR(1) = find(str2double(LopapSpecCh1.Properties.VariableNames) >= LopapParameters.wavelengthR,1);
|
|
indexR(2) = find(str2double(LopapSpecCh2.Properties.VariableNames) >= LopapParameters.wavelengthR,1);
|
|
LopapTimeT = timetable(LopapSpecCh1.Time,log10(LopapSpecCh1{:,indexR(1)}./LopapSpecCh1{:,indexS(1)}),log10(LopapSpecCh2{:,indexR(2)}./LopapSpecCh1{:,indexS(2)}));
|
|
LopapTimeT.Properties.VariableNames ={'Ch #1','Ch #2'};
|
|
figure('Name', 'Lopap TimeTable')
|
|
stackedplot(LopapTimeT,{{'Ch #1','Ch #2'}});
|
|
title(['Lopap' datestr(LopapParameters.MeasurementDate)])
|
|
clearvars -except Lopap* fileLocation myColorMap LopapParameters TimeRange*
|
|
if LopapParameters.Interactive == 1
|
|
distFig
|
|
fprintf('press any key if you want to proceed\n')
|
|
pause
|
|
%%
|
|
%
|
|
close all
|
|
end
|
|
%% Process :: Background
|
|
%
|
|
clc
|
|
close all
|
|
LopapTimeT = fitLopapBkgrd(LopapTimeT,'BkgrdPeriod',TimeRange.backgroundFit);
|
|
clearvars -except Lopap* fileLocation myColorMap LopapParameters TimeRange*
|
|
%% Plot bkgrd corrected data
|
|
%
|
|
clc
|
|
close all
|
|
% Plot
|
|
figure('Name', 'Lopap TimeTable Bkgrd')
|
|
s=stackedplot(LopapTimeT,{{'Ch #1 Bkgrd','Ch #2 Bkgrd'}});
|
|
title(['Lopap' datestr(LopapParameters.MeasurementDate)])
|
|
s.AxesProperties.YLimits = [-0.01 0.3];
|
|
clearvars -except Lopap* fileLocation myColorMap LopapParameters TimeRange*
|
|
|
|
%% Process :: Calibrate
|
|
%
|
|
clc
|
|
close all
|
|
|
|
S = timerange(datestr(TimeRange.MeanZeroAir(1)), datestr(TimeRange.MeanZeroAir(2)));
|
|
TZ = LopapTimeT(S,:);
|
|
S = timerange(datestr(TimeRange.MeanNitriteStandard(1)), datestr(TimeRange.MeanNitriteStandard(2)));
|
|
TN = LopapTimeT(S,:);
|
|
calib.mean = mean(TN{:,:},1) - mean(TZ{:,:},1);
|
|
calib.std = std(TN{:,:},1);
|
|
calib.mixingRatio = LopapParameters.concStandard./1000.*LopapParameters.flowReagents./1000./46.*6.022E23./...
|
|
(246E17.*LopapParameters.flowGas).*1E12;
|
|
|
|
[LopapTimeT, calib.fitresult] = fitLopapCalibration(LopapTimeT,calib);
|
|
clearvars -except Lopap* fileLocation myColorMap LopapParameters TimeRange* fitresult calib
|
|
|
|
fprintf('Detection limit channel #1 is %.0f ppt \n',calib.fitresult.calibChannel1(3.*calib.std(3)))
|
|
fprintf('Detection limit channel #2 is %.0f ppt \n',calib.fitresult.calibChannel2(3.*calib.std(4)))
|
|
|
|
%% Plot calibrated data
|
|
%
|
|
clc
|
|
close all
|
|
% Plot
|
|
figure('Name', 'Lopap TimeTable Calibrated')
|
|
s=stackedplot(LopapTimeT,{{'Ch #1 Calib','Ch #2 Calib'}});
|
|
title(['Lopap' datestr(LopapParameters.MeasurementDate)])
|
|
s.AxesProperties.YLimits = [-100 2500];
|
|
clearvars -except Lopap* fileLocation myColorMap LopapParameters TimeRange* fitresult calib
|
|
if LopapParameters.Interactive == 1
|
|
distFig
|
|
fprintf('press any key if you want to proceed\n')
|
|
pause
|
|
%%
|
|
%
|
|
close all
|
|
end
|
|
%% Save the data
|
|
%
|
|
save(['LopapMatlabData' datestr(LopapParameters.MeasurementDate,'yyyyMMdd_hhmm') '.mat'])
|
|
save(['Lopap' datestr(LopapParameters.MeasurementDate,'yyyyMMdd_hhmm') '.mat'],'LopapParameters','LopapTimeT','TimeRange')
|
|
%% 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/Marc/';
|
|
% 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');
|
|
elseif ispc
|
|
fileLocation.server = '\\fs00\'; %UNC name for file server that hosts Napp shared drive
|
|
fileLocation.dataPath = 'data_2411\Lopap\Marc\';
|
|
% add Lopap functions and general add-ons to path
|
|
addpath('\\fs02\5601_surface_chemistry\People\Marc\Switchdrive\PSI_Matlab\Add-Ons');
|
|
addpath('\\fs02\5601_surface_chemistry\People\Marc\Switchdrive\PSI_Matlab\Lopap');
|
|
elseif isunix
|
|
fileLocation.server = '/';
|
|
fileLocation.dataPath = 'Lopap/';
|
|
end
|
|
|
|
% Color maps
|
|
myColorMap.red = colormap(autumn(7));
|
|
myColorMap.blue = colormap(winter(7));
|
|
|
|
close all
|
|
end
|
|
|
|
|
|
##### SOURCE END #####
|
|
--></body></html> |