Skip to content

Commit c98719e

Browse files
committed
scripts for chl quality control and vicarious calibration of CTD fluorometers
1 parent b61e675 commit c98719e

File tree

3 files changed

+122
-1
lines changed

3 files changed

+122
-1
lines changed

Chl/SPIROPAchl_importfile.m

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
function SPIROPAchl = importfile(workbookFile, sheetName, dataLines)
2+
%IMPORTFILE Import data from a spreadsheet
3+
% SPIROPACHL = IMPORTFILE(FILE) reads data from the first worksheet in
4+
% the Microsoft Excel spreadsheet file named FILE. Returns the data as
5+
% a table.
6+
%
7+
% SPIROPACHL = IMPORTFILE(FILE, SHEET) reads from the specified
8+
% worksheet.
9+
%
10+
% SPIROPACHL = IMPORTFILE(FILE, SHEET, DATALINES) reads from the
11+
% specified worksheet for the specified row interval(s). Specify
12+
% DATALINES as a positive scalar integer or a N-by-2 array of positive
13+
% scalar integers for dis-contiguous row intervals.
14+
%
15+
% Example:
16+
% SPIROPAchl = importfile("\\sosiknas1\Lab_data\SPIROPA\CHL\SPIROPAchl.xlsx", "chl", [2, 3887]);
17+
%
18+
% See also READTABLE.
19+
%
20+
% Auto-generated by MATLAB on 01-Nov-2019 08:23:42
21+
22+
%% Input handling
23+
24+
% If no sheet is specified, read first sheet
25+
if nargin == 1 || isempty(sheetName)
26+
sheetName = 1;
27+
end
28+
29+
% If row start and end points are not specified, define defaults
30+
if nargin <= 2
31+
dataLines = [2, 3887];
32+
end
33+
34+
%% Setup the Import Options
35+
opts = spreadsheetImportOptions("NumVariables", 28);
36+
37+
% Specify sheet and range
38+
opts.Sheet = sheetName;
39+
opts.DataRange = "A" + dataLines(1, 1) + ":AB" + dataLines(1, 2);
40+
41+
% Specify column names and types
42+
opts.VariableNames = ["Cruise", "Cast", "Niskin", "TargetDepth", "Replicate", "VolFilt", "FilterSize", "VolExtracted", "Sample", "Acetone", "DilutionDuringReading", "Chl_Cal_Filename", "tau_Calibration", "Fd_Calibration", "Rb", "Ra", "blank", "Rbblank", "Rablank", "Chlugl", "Phaeougl", "Cal_Date", "Fluorometer", "Labnotebookandpagenumber", "Comments", "quality_flag", "Sample1", "Acetone1"];
43+
opts.SelectedVariableNames = ["Cruise", "Cast", "Niskin", "TargetDepth", "Replicate", "VolFilt", "FilterSize", "VolExtracted", "Sample", "Acetone", "DilutionDuringReading", "Chl_Cal_Filename", "tau_Calibration", "Fd_Calibration", "Rb", "Ra", "blank", "Rbblank", "Rablank", "Chlugl", "Phaeougl", "Cal_Date", "Fluorometer", "Labnotebookandpagenumber", "Comments", "quality_flag", "Sample1", "Acetone1"];
44+
opts.VariableTypes = ["categorical", "double", "double", "double", "categorical", "double", "double", "double", "double", "double", "double", "categorical", "double", "double", "double", "double", "double", "double", "double", "double", "double", "datetime", "string", "categorical", "categorical", "double", "double", "double"];
45+
opts = setvaropts(opts, 22, "InputFormat", "");
46+
opts = setvaropts(opts, 23, "WhitespaceRule", "preserve");
47+
opts = setvaropts(opts, [1, 5, 12, 23, 24, 25], "EmptyFieldRule", "auto");
48+
49+
% Import the data
50+
SPIROPAchl = readtable(workbookFile, opts, "UseExcel", false);
51+
52+
for idx = 2:size(dataLines, 1)
53+
opts.DataRange = "A" + dataLines(idx, 1) + ":AB" + dataLines(idx, 2);
54+
tb = readtable(workbookFile, opts, "UseExcel", false);
55+
SPIROPAchl = [SPIROPAchl; tb]; %#ok<AGROW>
56+
end
57+
58+
end

Chl/compare_extract_BTL.m

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
% Import SPIROPAchl spreadsheet
2+
% Import CTD-only bottle summary file for each SPIROPA cruise
3+
% Produce BTLmatch with same number of rows as SPIROPAchl
4+
% Plot extracted Chl vs BTL_chl_fluorescence for each cruise
5+
%
6+
% Heidi M. Sosik, Woods Hole Oceanographic Institution; November 2019
7+
8+
%AR29
9+
load('\\sosiknas1\Lab_data\SPIROPA\20180414_AR29\fromOlga\p_11_ar29_BTL_data_v2.mat');
10+
AR29_BTL = p_11_ar29_BTL_data_v2; clear p_11_ar29_BTL_data_v2
11+
ARcolnum = [1 2 19 25]; %cast, niskin, pressure, FL-chl?
12+
13+
%RB1904
14+
load('\\sosiknas1\Lab_data\SPIROPA\20180503_RB1904\fromOlga\rb1904_BTL_data.mat');
15+
RB1904_BTL = rb1904_BTL_data; clear rb1904_BTL_data
16+
RBcolnum = [1 2 20 26 36]; %cast, niskin, depth, FL-chl, FL-V
17+
18+
%TN368
19+
load('\\sosiknas1\Lab_data\SPIROPA\20190705_TN368\fromOlga\tn368_BTL_data.mat')
20+
TN368_BTL = tn368_BTL_data; clear tn368_BTL_data
21+
TNcolnum = [1 2 20 26 36]; %cast, niskin, depth, FL-chl, FL-V
22+
23+
SPIROPAchl = SPIROPAchl_importfile("\\sosiknas1\Lab_data\SPIROPA\CHL\SPIROPAchl.xlsx", "chl", [2, 3887]);
24+
25+
ARrow = find(SPIROPAchl.Cruise == 'AR29');
26+
RBrow = find(SPIROPAchl.Cruise == 'RB1904');
27+
TNrow = find(SPIROPAchl.Cruise == 'TN368');
28+
29+
BTLmatch = NaN(size(SPIROPAchl,1),5);
30+
indmatch = NaN(size(ARrow));
31+
for ii = 1:length(ARrow)
32+
indmatch(ii) = find(AR29_BTL(:,ARcolnum(1)) == SPIROPAchl.Cast(ARrow(ii)) & AR29_BTL(:,ARcolnum(2)) == SPIROPAchl.Niskin(ARrow(ii)));
33+
end
34+
BTLmatch(ARrow,1:4) = AR29_BTL(indmatch,ARcolnum);
35+
36+
indmatch = NaN(size(RBrow));
37+
for ii = 1:length(RBrow)
38+
indmatch(ii) = find(RB1904_BTL(:,ARcolnum(1)) == SPIROPAchl.Cast(RBrow(ii)) & RB1904_BTL(:,RBcolnum(2)) == SPIROPAchl.Niskin(RBrow(ii)));
39+
end
40+
BTLmatch(RBrow,:) = RB1904_BTL(indmatch,RBcolnum);
41+
42+
indmatch = NaN(size(TNrow));
43+
for ii = 1:length(TNrow)
44+
indmatch(ii) = find(TN368_BTL(:,TNcolnum(1)) == SPIROPAchl.Cast(TNrow(ii)) & TN368_BTL(:,TNcolnum(2)) == SPIROPAchl.Niskin(TNrow(ii)));
45+
end
46+
BTLmatch(TNrow,:) = TN368_BTL(indmatch,TNcolnum);
47+
48+
ARrow = find(SPIROPAchl.Cruise == 'AR29' & SPIROPAchl.FilterSize == 0);
49+
RBrow = find(SPIROPAchl.Cruise == 'RB1904' & SPIROPAchl.FilterSize == 0);
50+
TNrow = find(SPIROPAchl.Cruise == 'TN368' & SPIROPAchl.FilterSize == 0);
51+
52+
figure
53+
plot(BTLmatch(ARrow,4), SPIROPAchl.Chlugl(ARrow), '.')
54+
title('AR29')
55+
56+
figure
57+
plot(BTLmatch(RBrow,4), SPIROPAchl.Chlugl(RBrow), '.')
58+
title('RB1904')
59+
60+
figure
61+
plot(BTLmatch(TNrow,4), SPIROPAchl.Chlugl(TNrow), '.')
62+
title('TN368')

Tools/btlmat2table.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
%to handle highly non-standard column labels, create and save a table data
77
%type for easier handling in MATLAB
88

9-
file2load = 'C:\work\SPIROPA\ar29_bottle_data_Apr_2019.mat';
9+
%file2load = 'C:\work\SPIROPA\ar29_bottle_data_Apr_2019.mat';
10+
file2load = 'C:\work\SPIROPA\RB1904\rb1904_bottle_data_Jul_2019.mat';
1011
if ~exist(file2load,'file')
1112
[FileName,PathName] = uigetfile('*.mat','Select BTL mat file');
1213
file2load = fullfilename(PathName, FileName);

0 commit comments

Comments
 (0)