diff --git a/tsg_io/readTsgDataAstrolabe.m b/tsg_io/readTsgDataAstrolabe.m index 925cdc6880311bb0becd5ecca89a1c261aa4d332..1bf6c5c8e0007560df736856a072d5d224478fae 100644 --- a/tsg_io/readTsgDataAstrolabe.m +++ b/tsg_io/readTsgDataAstrolabe.m @@ -23,9 +23,10 @@ nbFieldNames = length( tsgNames ); % Get NO_CONTROL, GOOD, PROBABLY_BAD codes % ---------------------------------------- -NO_CONTROL = tsg.qc.hash.NO_CONTROL.code; -GOOD = tsg.qc.hash.GOOD.code; -PROBABLY_BAD = tsg.qc.hash.PROBABLY_BAD.code; +%NO_CONTROL = int8(tsg.qc.hash.NO_CONTROL.code); +GOOD = int8(tsg.qc.hash.GOOD.code); +PROBABLY_BAD = int8(tsg.qc.hash.PROBABLY_BAD.code); +BAD = int8(tsg.qc.hash.BAD.code); % Display read file info on console % --------------------------------- @@ -128,9 +129,9 @@ mm = repmat(NaN, [nn 1]); yy = repmat(NaN, [nn 1]); for it = 1:nn ddmmyy_str = sprintf('%06d', ddmmyy(it)); - dd(it) = str2num(ddmmyy_str(:,1:2)); - mm(it) = str2num(ddmmyy_str(:,3:4)); - yy(it) = 2000 + str2num(ddmmyy_str(:,5:6)); + dd(it) = str2num(ddmmyy_str(:,1:2)); %#ok<ST2NM> + mm(it) = str2num(ddmmyy_str(:,3:4)); %#ok<ST2NM> + yy(it) = 2000 + str2num(ddmmyy_str(:,5:6)); %#ok<ST2NM> end % Warning: for post-2000 files only! @@ -160,18 +161,18 @@ end % Fill TSG attributes % ------------------- -tsg.PLATFORM_NAME='astrolabe'; -tsg.SHIP_CALL_SIGN='FHZI'; -tsg.PROJECT_NAME='SURVOSTRAL'; -tsg.PI_NAME='Rosemary Morrow'; -tsg.DATA_ACQUISITION='IPEV'; -tsg.PROCESSING_CENTRE='SURVOSTRAL'; -tsg.PROCESSING_STATES='2C+'; -tsg.SAMPLING_PERIOD='60'; +tsg.PLATFORM_NAME = 'astrolabe'; +tsg.SHIP_CALL_SIGN = 'FHZI'; +tsg.PROJECT_NAME = 'SURVOSTRAL'; +tsg.PI_NAME = 'Rosemary Morrow'; +tsg.DATA_ACQUISITION = 'IPEV'; +tsg.PROCESSING_CENTRE = 'SURVOSTRAL'; +tsg.PROCESSING_STATES = '2C+'; +tsg.SAMPLING_PERIOD = '60'; % Missing value to be replaced by NaNs % ------------------------------------ -miss=-90; +miss = -90; % Fill TSG variables % by default, SSPS before correction flagged PROBABLY_BAD @@ -179,19 +180,18 @@ miss=-90; % ------------------------------------------------------- if ~isempty(tsg.SSTP) - tsg.SSTP(tsg.SSTP<miss)=nan; - tsg.SSTP_QC(isnan(tsg.SSTP))=nan; - tsg.SSTP_QC=repmat(GOOD,[length(tsg.DAYD) 1]); + tsg.SSTP(tsg.SSTP < miss) = NaN; + tsg.SSTP_QC = castByteQC( GOOD, tsg.DAYD ); + tsg.SSTP_QC(isnan(tsg.SSTP)) = BAD; end -tsg.SSPS_QC=repmat(PROBABLY_BAD,[length(tsg.DAYD) 1]); -tsg.SSPS_ADJUSTED_QC=repmat(GOOD,[length(tsg.DAYD) 1]); -tsg.SSPS(tsg.SSPS<miss)=nan; -tsg.SSJT(tsg.SSJT<miss)=nan; -tsg.SSPS_ADJUSTED(tsg.SSPS_ADJUSTED<miss)=nan; -tsg.SSPS_QC(isnan(tsg.SSPS))=nan; -tsg.SSPS_ADJUSTED_QC(isnan(tsg.SSPS))=nan; - +tsg.SSPS_QC = castByteQC(PROBABLY_BAD, tsg.DAYD); +tsg.SSPS_ADJUSTED_QC = castByteQC(GOOD, tsg.DAYD); +tsg.SSPS(tsg.SSPS < miss) = NaN; +tsg.SSJT(tsg.SSJT < miss) = NaN; +tsg.SSPS_ADJUSTED(tsg.SSPS_ADJUSTED < miss) = NaN; +tsg.SSPS_QC(isnan(tsg.SSPS)) = BAD; +tsg.SSPS_ADJUSTED_QC(isnan(tsg.SSPS)) = BAD; % populate tsg.file structure % --------------------------- diff --git a/tsg_util/tsg_initialisation.m b/tsg_util/tsg_initialisation.m index cda808c798cd511dd3610f6f3056e52bdf4f091f..b7ced223f2182c026908054f85944683558d6239 100644 --- a/tsg_util/tsg_initialisation.m +++ b/tsg_util/tsg_initialisation.m @@ -126,18 +126,18 @@ tsg.report.badvelocity = 0; % Records deleted because of bad velocity % Quality flags reference table, see GOSUD, DATA FORMAT TSG V1.6, table 4 % ----------------------------------------------------------------------- -% Code Meaning +% Code Key Meaning % -% 0 No QC was performed -% 1 Good data -% 2 Probably good data -% 3 Bad data that are potentially correctable -% 4 Bad data -% 5 Value changed -% 6 Data acquired in harbour -% 7 Not used -% 8 Interpolated value -% 9 Missing value +% 0 NO_CONTROL No QC was performed +% 1 GOOD Good data +% 2 PROBABLY_GOOD Probably good data +% 3 PROBABLY_BAD Bad data that are potentially correctable +% 4 BAD Bad data +% 5 VALUE_CHANGED Value changed +% 6 HARBOUR Data acquired in harbour +% 7 NOT_USED Not used +% 8 INTERPOLATED_VALUE Interpolated value +% 9 MISSING_VALUE Missing value % Quality definition, we use an instance of dynaload object % --------------------------------------------------------- diff --git a/tsg_util/updateTsgStruct.m b/tsg_util/updateTsgStruct.m index 384a39f0726738400eb7c8e5d01e5018aa7f54d6..d88d884b33e6ce5cbface426f71184120c1105a1 100644 --- a/tsg_util/updateTsgStruct.m +++ b/tsg_util/updateTsgStruct.m @@ -20,8 +20,7 @@ shipVelocity( hMainFig ); % ------------------------------------- tsg = getappdata( hMainFig, 'tsg_data'); -nPARA = 3; -PARA = ['SSPS'; 'SSJT'; 'SSTP']; +PARA = {'SSPS', 'SSJT', 'SSTP'}; % Get NO_CONTROL and INTERPOLATED_VALUE codes % a modifier !!!!!!!!!!!!! @@ -31,61 +30,62 @@ NO_CONTROL = s.code; % shift to [-180 180] longitude by default % ---------------------------------------- -tsg.LONX = mod(tsg.LONX+180,360)-180; +tsg.LONX = mod(tsg.LONX + 180, 360) - 180; % Suppress longitude discontinuity at -180 or 180 crossing % -------------------------------------------------------- deflon = find(isfinite(tsg.LONX)); dlon = diff(tsg.LONX(deflon)); -tsg.indcross = find(abs(dlon)>180); +tsg.indcross = find(abs(dlon) > 180); if ~isempty(tsg.indcross) - tsg.loncross = sign(dlon(tsg.indcross))*360; + tsg.loncross = sign(dlon(tsg.indcross)) * 360; tsg.indcross = deflon(tsg.indcross); for i=1:length(tsg.indcross) - tsg.LONX(tsg.indcross(i)+1:end) = tsg.LONX(tsg.indcross(i)+1:end) - tsg.loncross(i); + tsg.LONX(tsg.indcross(i)+1:end) = ... + tsg.LONX(tsg.indcross(i)+1:end) - tsg.loncross(i); end end tsg.lonplus = 0; -tsg.lonmod = 0; +tsg.lonmod = 0; % get min and max values for position and set to globals attributes % ----------------------------------------------------------------- tsg.SOUTH_LATX = min(tsg.LATX); tsg.NORTH_LATX = max(tsg.LATX); -if (max(tsg.LONX)-min(tsg.LONX))>360 +if (max(tsg.LONX)-min(tsg.LONX)) > 360 tsg.WEST_LONX = -180; tsg.EAST_LONX = 180; else - tsg.WEST_LONX = mod(min(tsg.LONX)+180,360)-180; - tsg.EAST_LONX = mod(max(tsg.LONX)+180,360)-180; + tsg.WEST_LONX = mod(min(tsg.LONX)+180, 360) - 180; + tsg.EAST_LONX = mod(max(tsg.LONX)+180, 360) - 180; end % get date start and end value and set to globals attributes % ----------------------------------------------------------------- -date = datestr(min(tsg.DAYD),30); +date = datestr(min(tsg.DAYD), 30); tsg.DATE_START = [date(1:8) date(10:15)]; -date = datestr(max(tsg.DAYD),30); +date = datestr(max(tsg.DAYD), 30); tsg.DATE_END = [date(1:8) date(10:15)]; % Variables must exists % --------------------- -for i = 1: nPARA +for para = PARA - para1 = PARA(i,:); + para = char(para); - if ~isempty( tsg.(para1) ) && isempty( tsg.([para1 '_QC']) ) + if ~isempty( tsg.(para) ) && isempty( tsg.([para '_QC']) ) % If QC variables are emptied, fill them with NO_CONTROL code value % ----------------------------------------------------------------- - tsg.([para1 '_QC']) = castByteQC( NO_CONTROL, tsg.DAYD ); + tsg.([para '_QC']) = castByteQC( NO_CONTROL, tsg.DAYD ); end - if ~isempty( tsg.(para1) ) && isempty( tsg.([para1 '_ADJUSTED_QC']) ) + if ~isempty( tsg.(para) ) && isempty( tsg.([para '_ADJUSTED_QC']) ) % If QC variables are emptied, fill them with NO_CONTROL code value % ----------------------------------------------------------------- - tsg.([para1 '_ADJUSTED_QC']) = castByteQC( NO_CONTROL, tsg.DAYD ); + tsg.([para '_ADJUSTED_QC']) = castByteQC( NO_CONTROL, tsg.DAYD ); end end