Skip to content

Commit 158a826

Browse files
committed
Added scatter plot in case of missing data
Previously, in case of alternating missing and good values, the good values would not be shown since they do not connect directly. Now, scattered points will be shown in addition to the line. Also fixed name of the pressure unit from "db" to "dbar".
1 parent 130e38a commit 158a826

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

auxil/plot_timeseries.m

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function plot_timeseries(Data, Mdata, variables, depth, basename, varargin)
5353
% default depends on length of time shown:
5454
% 'd' for up to 60 days, 'm' for up to 18 months,
5555
% 'y' otherwise
56-
% 'title',title : title for the plot (default: "Depth: .. db"); an
56+
% 'title',title : title for the plot (default: "Depth: .. dbar"); an
5757
% empty string ('') suppresses the title
5858
% 'var2',variable : if variable is not empty, profiles of this second
5959
% variable will be plotted; if it is the same type as the
@@ -228,8 +228,8 @@ function plot_timeseries(Data, Mdata, variables, depth, basename, varargin)
228228
[mini, idx{f,d}] = min(abs(Datai.(floats{f}).PRES(:,1) - depth(d)));
229229
press{f,d} = Datai.(floats{f}).PRES(idx{f,d},1);
230230
if mini > Settings.depth_tol
231-
warning(['Closest depth level to requested %.1f db for ', ...
232-
'float %s is %.1f db'], depth(d), floats{f}, press{f,d});
231+
warning(['Closest depth level to requested %.1f dbar for ', ...
232+
'float %s is %.1f dbar'], depth(d), floats{f}, press{f,d});
233233
end
234234
end
235235
end
@@ -261,16 +261,34 @@ function plot_timeseries(Data, Mdata, variables, depth, basename, varargin)
261261
set(gca,'ColorOrderIndex',1);
262262
hold(gca, 'on')
263263
end
264-
plot(Datai.(floats{f}).TIME(1,:), ...
264+
plt1 = plot(Datai.(floats{f}).TIME(1,:), ...
265265
Datai.(floats{f}).(variables{v})(idx{f,d},:), 'LineWidth', 2);
266+
% good values between missing values will not be connected by
267+
% a line, so plot them individually as points as well
268+
if find(isnan(Datai.(floats{f}).(variables{v})(idx{f,d},:)), 1)
269+
color1 = get(plt1, 'color');
270+
sc1 = scatter(Datai.(floats{f}).TIME(1,:), ...
271+
Datai.(floats{f}).(variables{v})(idx{f,d},:), 7, ...
272+
color1, 'filled');
273+
set(get(get(sc1, 'Annotation'), 'LegendInformation'), ...
274+
'IconDisplayStyle', 'off');
275+
end
266276
[long_name, units] = get_var_name_units(variables{v});
267277
ylabel([long_name, ' ', units])
268278
if ~isempty(var2_orig)
269279
if ~same_var_type
270280
yyaxis right;
271281
end
272-
plot(Datai.(floats{f}).TIME(1,:), ...
282+
plt2 = plot(Datai.(floats{f}).TIME(1,:), ...
273283
Datai.(floats{f}).(var2{v})(idx{f,d},:), 'LineWidth', 2);
284+
if find(isnan(Datai.(floats{f}).(var2{v})(idx{f,d},:)), 1)
285+
color2 = get(plt2, 'color');
286+
sc2 = scatter(Datai.(floats{f}).TIME(1,:), ...
287+
Datai.(floats{f}).(var2{v})(idx{f,d},:), 7, ...
288+
color2, 'filled');
289+
set(get(get(sc2, 'Annotation'), 'LegendInformation'), ...
290+
'IconDisplayStyle', 'off');
291+
end
274292
if ~same_var_type
275293
[long_name, units] = get_var_name_units(var2_orig);
276294
ylabel([long_name, ' ', units])
@@ -285,10 +303,10 @@ function plot_timeseries(Data, Mdata, variables, depth, basename, varargin)
285303
if isempty(title1) && ~ischar(title1) % i.e., []
286304
if strcmp(lgnd, 'no') || ~isempty(var2_orig)
287305
% add float number to title instead
288-
title(sprintf('Depth: %d db (%s)%s', press{f,d}, ...
306+
title(sprintf('Depth: %d dbar (%s)%s', press{f,d}, ...
289307
floats{f}, title_added{v}));
290308
else % legend shows float number
291-
title(sprintf('Depth: %d db%s', press{f,d}, ...
309+
title(sprintf('Depth: %d dbar%s', press{f,d}, ...
292310
title_added{v}));
293311
end
294312
else
@@ -305,7 +323,7 @@ function plot_timeseries(Data, Mdata, variables, depth, basename, varargin)
305323
end
306324
end
307325
if ~isempty(basename)
308-
fn_png = sprintf('%s_%d_%s%s_%ddb.png', basename, ...
326+
fn_png = sprintf('%s_%d_%s%s_%ddbar.png', basename, ...
309327
Mdata.(float_ids{f}).WMO_NUMBER, variables{v}, ...
310328
var2_insert{v}, press{f,d});
311329
print(f1, '-dpng', fn_png);
@@ -319,10 +337,10 @@ function plot_timeseries(Data, Mdata, variables, depth, basename, varargin)
319337
end_date, time_label)
320338
if isempty(title1) && ~ischar(title1) % i.e., []
321339
if strcmp(lgnd, 'yes')
322-
title(sprintf('Depth: %d db%s', press{f,d}, ...
340+
title(sprintf('Depth: %d dbar%s', press{f,d}, ...
323341
title_added{v}));
324342
else
325-
title(sprintf('Depth: %d db (%s)%s', press{f,d}, ...
343+
title(sprintf('Depth: %d dbar (%s)%s', press{f,d}, ...
326344
floats{f}, title_added{v}));
327345
end
328346
else
@@ -333,7 +351,7 @@ function plot_timeseries(Data, Mdata, variables, depth, basename, varargin)
333351
'AutoUpdate','off');
334352
end
335353
if ~isempty(basename)
336-
fn_png = sprintf('%s_%s%s_%ddb.png', basename, variables{v}, ...
354+
fn_png = sprintf('%s_%s%s_%ddbar.png', basename, variables{v}, ...
337355
var2_insert{v}, press{f,d});
338356
print(f1, '-dpng', fn_png);
339357
end

show_timeseries.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
% or all in one plot (0); default: 1
2828
% 'png',basename: if basename is not empty, png files will be created
2929
% for all plots; the file names will be
30-
% <basename>_<WMOID>_<variable>_<depth>db.png
30+
% <basename>_<WMOID>_<variable>_<depth>dbar.png if
31+
% per_float is 1 or <basename>_<variable>_<depth>dbar.png
32+
% if per_float is 0
3133
% 'qc',flags : show only values with the given QC flags (as an array)
3234
% 0: no QC was performed;
3335
% 1: good data;
@@ -49,7 +51,7 @@
4951
% default depends on length of time shown:
5052
% 'd' for up to 60 days, 'm' for up to 18 months,
5153
% 'y' otherwise
52-
% 'title',title : title for the plot (default: "Depth: .. db"); an
54+
% 'title',title : title for the plot (default: "Depth: .. dbar"); an
5355
% empty string ('') suppresses the title
5456
% 'var2',variable: if variable is not empty, time series of this second
5557
% variable will be plotted; if it is the same type as the

0 commit comments

Comments
 (0)