From 53412c4d7e6d1d5f0562f693c0cbb23107521b92 Mon Sep 17 00:00:00 2001
From: alory <gael.alory@legos.obs-mip.fr>
Date: Fri, 25 Jan 2019 19:22:08 +0100
Subject: [PATCH] fix issue #1, Samples do not display with harbor code

---
 tsg_util/diffTsgSample.m | 17 +++++++++++------
 tsg_util/tsg_average.m   | 12 +++++++++---
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/tsg_util/diffTsgSample.m b/tsg_util/diffTsgSample.m
index 19b3c57..77898cf 100644
--- a/tsg_util/diffTsgSample.m
+++ b/tsg_util/diffTsgSample.m
@@ -26,10 +26,12 @@ errDif = 0;
 % ------------------------------------------------------
 tsg = getappdata( hMainFig, 'tsg_data');
 
-% Get PROBABLY_GOOD code
-% ----------------------
+% Get QC codes
+% ------------
 probablyGoodCode = tsg.qc.hash.PROBABLY_GOOD.code;
-defaultValueCode = tsg.qc.hash.MISSING_VALUE.code;
+GoodCode = tsg.qc.hash.GOOD.code;
+harbourCode = tsg.qc.hash.HARBOUR.code;
+noControlCode = tsg.qc.hash.NO_CONTROL.code;
 
 % For temperature : 
 % IF PARA = 'SSJT' use 'SSTP' to get the samples
@@ -39,9 +41,12 @@ if strcmp( SAMPLE, 'SSJT')
   SAMPLE = 'SSTP';
 end
 
-% Consider only tsg data with NO_CONTROL, GOOD and PROBABLY_GOOD code
-% -------------------------------------------------------------------
-indTsg = find( tsg.([PARA{1} '_QC']) <= probablyGoodCode );
+% Consider only tsg data with NO_CONTROL, HARBOUR, GOOD or PROBABLY_GOOD code
+% ---------------------------------------------------------------------------
+indTsg = find( tsg.([PARA{1} '_QC']) == probablyGoodCode | ...
+    tsg.([PARA{1} '_QC']) == GoodCode | ...
+    tsg.([PARA{1} '_QC']) == harbourCode | ...
+    tsg.([PARA{1} '_QC']) == noControlCode);
 
 if ~isempty( indTsg )
 
diff --git a/tsg_util/tsg_average.m b/tsg_util/tsg_average.m
index 6df2f10..62ff1f6 100644
--- a/tsg_util/tsg_average.m
+++ b/tsg_util/tsg_average.m
@@ -22,9 +22,12 @@ function [smooth] = tsg_average(hMainFig, PARA, iTsg)
 % ------------------------------------------
 tsg = getappdata( hMainFig, 'tsg_data');
 
-% Get PROBABLY_GOOD code
-% ----------------------
+% Get QC codes
+% ------------
 probablyGoodCode = tsg.qc.hash.PROBABLY_GOOD.code;
+GoodCode = tsg.qc.hash.GOOD.code;
+harbourCode = tsg.qc.hash.HARBOUR.code;
+noControlCode = tsg.qc.hash.NO_CONTROL.code;
 
 % Select the param data over 'tsg.cst.TSG_DT_SMOOTH' time interval
 % taking into account the TSG quality code
@@ -33,7 +36,10 @@ probablyGoodCode = tsg.qc.hash.PROBABLY_GOOD.code;
 % -----------------------------------------------------------------------
 ind1 = find( tsg.DAYD >= tsg.DAYD(iTsg) - tsg.cst.TSG_DT_SMOOTH/2 & ...
     tsg.DAYD <= tsg.DAYD(iTsg) + tsg.cst.TSG_DT_SMOOTH/2 & ...
-    tsg.([PARA{1} '_QC']) <= probablyGoodCode);
+    (tsg.([PARA{1} '_QC']) == probablyGoodCode | ...
+    tsg.([PARA{1} '_QC']) == GoodCode | ...
+    tsg.([PARA{1} '_QC']) == harbourCode | ...
+    tsg.([PARA{1} '_QC']) == noControlCode));
 
 ind2 = ind1;
 if ~isempty(ind2)
-- 
GitLab