diff --git a/TSGQC_amelioration.xls b/TSGQC_amelioration.xls index d22eaac479daede8bd30552cb33c3ba44eca6518..52efdd34fd0a3391dcc6a098da9ad192b95a1b91 100644 Binary files a/TSGQC_amelioration.xls and b/TSGQC_amelioration.xls differ diff --git a/tsg_io/concatStructTSG.m b/tsg_io/concatStructTSG.m new file mode 100644 index 0000000000000000000000000000000000000000..0a92c157780f8f2d06a013c97219a57388ecdf15 --- /dev/null +++ b/tsg_io/concatStructTSG.m @@ -0,0 +1,332 @@ +function concatStructTSG( hMainFig, tsg_old ) +% +% Concatenate some elements of a TSG structure. Mainly : +% - TSG data members (DAYD, DATE, LATX, LONX, SSPS, SSJT, SSTP) +% - Discrete data (_EXT) members (DAYD, DATE, LATX, LONX, SSPS, SSTP) +% +% Right now, the function do not concatenate : +% - Calibration coefficent +% - '_HIST' +% - preference +% +% If the concatenanted TSG structures have identical dates, the double +% are supressed. +% +% This function is called by read_data.m + +% The function calls : +% concatNumTsg - At the end of this file +% concatInt8Tsg - At the end of this file +% supTsgDouble - At the end of this file +% supTsgExtDouble - At the end of this file +% +% Input +% hMainFig .... Handle to the main application +% tsg_old ..... TSG struct array, the first loaded in tsgqc. The data will +% be concatenated in this variable +% +% The tsg structure array to concatenate has been initialised in +% read_data and saved in the application data variable 'tsg_data'. +% +% $Id$ + +% Retrieve the new tsg struct that we want to concatenate +% ------------------------------------------------------- +tsg_new = getappdata( hMainFig, 'tsg_data' ); + +% Get NO_CONTROL code value +% ------------------------- +NO_CONTROL = tsg_old.qc.hash.NO_CONTROL.code; + +% Sort the date in ascending order. +% iOrder is used to sort the members of the strcture +% DAYD is not concatenated right now because the function concatNumTsg uses +% the variable DAYD to konw the size of the arrays. +% ---------------------------------------------------------------------- +DAYD = [tsg_old.DAYD; tsg_new.DAYD]; +[DAYD, iOrder] = sort(DAYD); + +% Concatenate the arrays +% ---------------------- +tsg_old.DATE = [tsg_old.DATE; tsg_new.DATE]; +tsg_old.DATE = tsg_old.DATE(iOrder,:); + +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'LATX'); +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'LONX'); +tsg_old = concatInt8Tsg( iOrder, NO_CONTROL, tsg_old, tsg_new, 'POSITION_QC'); +% +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'SPDC'); +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'PRES'); +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'FLOW'); +% +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'CNDC'); +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'CNDC_STD'); +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'CNDC_CAL'); +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'CNDC_FREQ'); +% +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'SSJT'); +tsg_old = concatInt8Tsg( iOrder, NO_CONTROL, tsg_old, tsg_new, 'SSJT_QC'); +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'SSJT_STD'); +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'SSJT_CAL'); +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'SSJT_FREQ'); +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'SSJT_ADJUSTED'); +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'SSJT_ADJUSTED_ERROR'); +tsg_old = concatInt8Tsg( iOrder, NO_CONTROL, tsg_old, tsg_new, 'SSJT_ADJUSTED_QC'); +% % concatStrTsg( iOrder, tsg_old, tsg_new, 'SSJT_ADJUSTED_HIST'); +% +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'SSPS'); +tsg_old = concatInt8Tsg( iOrder, NO_CONTROL, tsg_old, tsg_new, 'SSPS_QC'); +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'SSPS_STD'); +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'SSPS_CAL'); +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'SSPS_ADJUSTED'); +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'SSPS_ADJUSTED_ERROR'); +tsg_old = concatInt8Tsg( iOrder, NO_CONTROL, tsg_old, tsg_new, 'SSPS_ADJUSTED_QC'); +% % concatStrTsg( iOrder, tsg_old, tsg_new, 'SSPS_ADJUSTED_HIST'); +% +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'SSTP'); +tsg_old = concatInt8Tsg( iOrder, NO_CONTROL, tsg_old, tsg_new, 'SSTP_QC'); +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'SSTP_CAL'); +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'SSTP_FREQ'); +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'SSTP_ADJUSTED'); +tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, 'SSTP_ADJUSTED_ERROR'); +tsg_old = concatInt8Tsg( iOrder, NO_CONTROL, tsg_old, tsg_new, 'SSTP_ADJUSTED_QC'); +% % concatStrTsg( iOrder, tsg_old, tsg_new, 'SSTP_ADJUSTED_HIST'); + +tsg_old.DAYD = DAYD; + +% Suppress double. Compare the dates +% ---------------------------------- +tsg_old = supTsgDouble(tsg_old); + +% Discrete samples +% ---------------- +tsg_old.DAYD_EXT = [tsg_old.DAYD_EXT; tsg_new.DAYD_EXT]; +tsg_old.DATE_EXT = [tsg_old.DATE_EXT; tsg_new.DATE_EXT]; +tsg_old.LATX_EXT = [tsg_old.LATX_EXT; tsg_new.LATX_EXT]; +tsg_old.LONX_EXT = [tsg_old.LONX_EXT; tsg_new.LONX_EXT]; +tsg_old.SSPS_EXT = [tsg_old.SSPS_EXT; tsg_new.SSPS_EXT]; +tsg_old.SSPS_EXT_BOTTLE = strvcat(tsg_old.SSPS_EXT_BOTTLE, tsg_new.SSPS_EXT_BOTTLE); +tsg_old.SSPS_EXT_QC = [tsg_old.SSPS_EXT_QC; tsg_new.SSPS_EXT_QC]; +tsg_old.SSPS_EXT_TYPE = strvcat(tsg_old.SSPS_EXT_TYPE, tsg_new.SSPS_EXT_TYPE); +tsg_old.SSPS_EXT_ANALDATE = strvcat(tsg_old.SSPS_EXT_ANALDATE,tsg_new.SSPS_EXT_ANALDATE); +tsg_old.SSTP_EXT = [tsg_old.SSTP_EXT; tsg_new.SSTP_EXT]; +tsg_old.SSTP_EXT_QC = [tsg_old.SSTP_EXT_QC; tsg_new.SSTP_EXT_QC]; +tsg_old.SSTP_EXT_TYPE = strvcat(tsg_old.SSTP_EXT_TYPE, tsg_new.SSTP_EXT_TYPE); + +if ~isempty(tsg_old.DAYD_EXT) + [tsg_old.DAYD_EXT, iOrder] = sort(tsg_old.DAYD_EXT); + tsg_old.DATE_EXT = tsg_old.DATE_EXT(iOrder,:); + tsg_old.LATX_EXT = tsg_old.LATX_EXT(iOrder); + tsg_old.LONX_EXT = tsg_old.LONX_EXT(iOrder); + tsg_old.SSPS_EXT = tsg_old.SSPS_EXT(iOrder); + tsg_old.SSPS_EXT_QC = tsg_old.SSPS_EXT_QC(iOrder); + tsg_old.SSPS_EXT_BOTTLE = tsg_old.SSPS_EXT_BOTTLE(iOrder,:); + tsg_old.SSPS_EXT_TYPE = tsg_old.SSPS_EXT_TYPE(iOrder,:); + tsg_old.SSPS_EXT_ANALDATE = tsg_old.SSPS_EXT_ANALDATE(iOrder,:); + tsg_old.SSTP_EXT = tsg_old.SSTP_EXT(iOrder); + tsg_old.SSTP_EXT_QC = tsg_old.SSTP_EXT_QC(iOrder); + tsg_old.SSTP_EXT_TYPE = tsg_old.SSTP_EXT_TYPE(iOrder,:); +end + +% Suppress Double. Compare the dates +% ---------------------------------- +tsg_old = supTsgExtDouble(tsg_old); + +setappdata( hMainFig, 'tsg_data', tsg_old ); + +end + +%% ************************************************************************ +function tsg_old = concatNumTsg( iOrder, tsg_old, tsg_new, Para) +% +% function concatNumTsg : Concatenate 2 numeric TSG arrays +% +% Input +% iOrder - Indicies to organise the array in time ascending order +% tsg_old - First TSG structure +% tsg_new - TSG structure that we want to concatenate +% Para - Member of the structures to concatenate +% +% Output +% tsg_old - TSG structure +% + +% If tsg_new.Para and tsg_old.Para are empty nothing is done +% ---------------------------------------------------------- +if isempty(tsg_new.(Para)) && isempty(tsg_old.(Para)) + return; + +% If only tsg_new.PARA is empty, fill it with NaN. The dimension of the +% final array must must be equal to the sum of the dimension of tsg.DAYD +% and tsg_old.DAYD +% ---------------------------------------------------------------------- +elseif isempty(tsg_new.(Para)) + tsg_new.(Para) = NaN * ones( size( tsg_new.DAYD ) ); + +% See preceding comment +% --------------------- +elseif isempty(tsg_old.(Para)) + tsg_old.(Para) = NaN * ones( size( tsg_old.DAYD ) ); +end + +% Concatenation +% ------------- +tsg_old.(Para) = [tsg_old.(Para); tsg_new.(Para)]; + +% Re-order the struct array +% ------------------------- +tsg_old.(Para) = tsg_old.(Para)(iOrder); + +end + +%% ************************************************************************* +function tsg_old = concatInt8Tsg( iOrder, NO_CONTROL, tsg_old, tsg_new, Para) +% +% function concatInt8Tsg : Concatenate 2 numeric int8 arrays +% +% Input +% iOrder - Indicies to organise the array in time ascending order +% NO_CONTROL - Value for no control quality code +% tsg_old - First TSG structure +% tsg_new - Second TSG structure +% Para - Member of the structures to concatenate +% +% Output +% tsg_old - TSG structure +% + +% If tsg_new.Para and tsg_old.Para are empty nothing is done +% ---------------------------------------------------------- +if isempty(tsg_new.(Para)) && isempty(tsg_old.(Para)) + return; + +% If only tsg.PARA is empty, fill it with NO_CONTROL. The dimension of the +% concatenate array must must be equal to the sum of the dimension of +% tsg.DAYD and tsg_old.DAYD +% -------------------------------------------------------------------- +elseif isempty(tsg_new.(Para)) + tsg_new.(Para) = int8(NO_CONTROL) * int8(ones( size( tsg_new.DAYD ))); + +% See preceding comment +% --------------------- +elseif isempty(tsg_old.(Para)) + tsg_old.(Para) = int8(NO_CONTROL) * int8(ones( size( tsg_old.DAYD ))); +end + +% Concatenation +% ------------- +tsg_old.(Para) = [tsg_old.(Para); tsg_new.(Para)]; + +% Re-order the struct array +% ------------------------- +tsg_old.(Para) = tsg_old.(Para)(iOrder); + +end + +%% ************************************************************************ +function tsg = supTsgDouble( tsg) +% +% function supTsgDouble : Suppress TSG measurements made at the same date +% The comparison cannot be made using tsg.DAYD : +% This cannot be done using the Matlab Serial Date format as there can be +% some loss of precision. Especially when a floating number was written in +% a file. +% +% I use tsg.DATE. Could be simplify by comparing string rather than +% converting DATE with datenum +% +% ------------------------------------------------------------------------ + +% Convert string array DATE in numerical array +% -------------------------------------------- +date = str2num(tsg.DATE); + +% Compare adjacent element in an array +% ------------------------------------ +date_diff = find( diff( date ) == 0 ); +if ~isempty( date_diff ) + tsg.DAYD(date_diff) = []; + tsg.DATE(date_diff,:) = []; + + tsg.LATX(date_diff) = []; + tsg.LONX(date_diff) = []; + tsg.POSITION_QC(date_diff) = []; + + if ~isempty(tsg.SPDC); tsg.SPDC(date_diff) = []; end + if ~isempty(tsg.PRES); tsg.PRES(date_diff) = []; end + if ~isempty(tsg.FLOW); tsg.FLOW(date_diff) = []; end + if ~isempty(tsg.CNDC); tsg.CNDC(date_diff) = []; end + if ~isempty(tsg.CNDC_STD); tsg.CNDC_STD(date_diff) = []; end + if ~isempty(tsg.CNDC_CAL); tsg.CNDC_CAL(date_diff) = []; end + if ~isempty(tsg.CNDC_FREQ); tsg.CNDC_FREQ(date_diff) = []; end + + if ~isempty(tsg.SSJT); tsg.SSJT(date_diff) = []; end + if ~isempty(tsg.SSJT_QC); tsg.SSJT_QC(date_diff) = []; end + if ~isempty(tsg.SSJT_STD); tsg.SSJT_STD(date_diff) = []; end + if ~isempty(tsg.SSJT_CAL); tsg.SSJT_CAL(date_diff) = []; end + if ~isempty(tsg.SSJT_FREQ); tsg.SSJT_FREQ(date_diff) = []; end + if ~isempty(tsg.SSJT_ADJUSTED); tsg.SSJT_ADJUSTED(date_diff) = []; end + if ~isempty(tsg.SSJT_ADJUSTED_ERROR); tsg.SSJT_ADJUSTED_ERROR(date_diff) = []; end + if ~isempty(tsg.SSJT_ADJUSTED_QC); tsg.SSJT_ADJUSTED_QC(date_diff) = []; end + % if ~isempty(tsg.SSJT_ADJUSTED_HIST(date_diff,:) = []; end + + if ~isempty(tsg.SSPS); tsg.SSPS(date_diff) = []; end + if ~isempty(tsg.SSPS_QC); tsg.SSPS_QC(date_diff) = []; end + if ~isempty(tsg.SSPS_STD); tsg.SSPS_STD(date_diff) = []; end + if ~isempty(tsg.SSPS_CAL); tsg.SSPS_CAL(date_diff) = []; end + if ~isempty(tsg.SSPS_ADJUSTED); tsg.SSPS_ADJUSTED(date_diff) = []; end + if ~isempty(tsg.SSPS_ADJUSTED_ERROR); tsg.SSPS_ADJUSTED_ERROR(date_diff) = []; end + if ~isempty(tsg.SSPS_ADJUSTED_QC); tsg.SSPS_ADJUSTED_QC(date_diff) = []; end + % if ~isempty(tsg.SSPS_ADJUSTED_HIST(date_diff,:) = []; end + + if ~isempty(tsg.SSTP); tsg.SSTP(date_diff) = []; end + if ~isempty(tsg.SSTP_QC); tsg.SSTP_QC(date_diff) = []; end + if ~isempty(tsg.SSTP_CAL); tsg.SSTP_CAL(date_diff) = []; end + if ~isempty(tsg.SSTP_FREQ); tsg.SSTP_FREQ(date_diff) = []; end + if ~isempty(tsg.SSTP_ADJUSTED); tsg.SSTP_ADJUSTED(date_diff) = []; end + if ~isempty(tsg.SSTP_ADJUSTED_ERROR); tsg.SSTP_ADJUSTED_ERROR(date_diff) = []; end + if ~isempty(tsg.SSTP_ADJUSTED_QC); tsg.SSTP_ADJUSTED_QC(date_diff) = []; end + % if ~isempty(tsg.SSTP_ADJUSTED_HIST);tsg.SSTP_ADJUSTED_HIST(date_diff,:) = []; end +end +end + +%% ************************************************************************ +function tsg = supTsgExtDouble(tsg) +% +% supTsgExtDouble : suppress EXT measurements made at the same date +% The comparison cannot be made using tsg.DAYD_EXT. +% This cannot be done using the Matlab Serial Date format as there can be +% some loss of precision. +% +% I use tsg.DATE_EXT +% ------------------------------------------------------------------------ +if ~isempty( tsg.DATE_EXT ) + + % Convert string array DATE in numerical array + % -------------------------------------------- + date = str2num(tsg.DATE_EXT); + + % Compare adjacent element in an array + % --------------------------------------------- + date_diff = find( diff( date ) == 0 ); + + if ~isempty( date_diff ) + tsg.DAYD_EXT(date_diff) = []; + tsg.DATE_EXT(date_diff,:) = []; + tsg.LATX_EXT(date_diff) = []; + tsg.LONX_EXT(date_diff) = []; + tsg.SSPS_EXT(date_diff) = []; + tsg.SSPS_EXT_QC(date_diff) = []; + tsg.SSPS_EXT_BOTTLE(date_diff,:) = []; + tsg.SSPS_EXT_TYPE(date_diff,:) = []; + tsg.SSPS_EXT_ANALDATE(date_diff,:)= []; + tsg.SSTP_EXT(date_diff) = []; + tsg.SSTP_EXT_QC(date_diff) = []; + tsg.SSTP_EXT_TYPE(date_diff,:) = []; + end + +end +end + + + diff --git a/tsg_io/readTsgIniLabview.m b/tsg_io/readTsgIniLabview.m index f7e0d24731382a11d78a0ab2c18c74d603a61d7f..595980476f98da22b72db9f3e34bca3fa10a4ac6 100644 --- a/tsg_io/readTsgIniLabview.m +++ b/tsg_io/readTsgIniLabview.m @@ -65,7 +65,7 @@ while ~feof(fid) % construct regex with pair cle=value % and extract value % use quantifier none greedy (.*?) - % remove double quote from experssion : ["]* + % remove double quote from expression : ["]* % --------------------------------------------------- regex = strcat('^\s*', clef, '\s*=\s*["]*(.+?)["]*$'); match = regexp( str, regex, 'tokens'); @@ -129,12 +129,20 @@ while ~feof(fid) % -------- k = match{1}{1}; + % get value + % --------- + v = match{1}{2}; + % convert date in julian day when key is 'DATE', else to double % ------------------------------------------------------------- if strcmpi(k, 'DATE') - v = datenumToJulian(datenum(match{1}{2}, 'dd/mm/yyyy')); + v = datenumToJulian(datenum(v, 'dd/mm/yyyy')); else - v = str2double(match{1}{2}); + + % in case where comma is decimal separator, replace it + % with by dot + % ---------------------------------------------------- + v = str2double(regexprep(v, ',', '.')); end % add key to _CONV array, with length of STRING8 @@ -147,17 +155,19 @@ while ~feof(fid) % for debbuging only % ------------------ - %fprintf('%s: %s -> %f\n', clef, k, v); + fprintf('%s: %s -> %f\n', clef, k, v); case 1 % add value to variable array - % --------------------------- - tsg.(clef) = str2double(match{1}{1}); + % in case where comma is decimal separator, replace it + % with by dot + % ---------------------------------------------------- + tsg.(clef) = str2double(regexprep(match{1}{1}, ',', '.')); % for debbuging only % ------------------ - %fprintf('%s: %f\n', clef, tsg.(clef)); + fprintf('%s: %f\n', clef, tsg.(clef)); end % quit for loop diff --git a/tsg_io/read_data.m b/tsg_io/read_data.m new file mode 100644 index 0000000000000000000000000000000000000000..5d5998024cc32e2c03b4eb92cc5f758ce2b6d5c8 --- /dev/null +++ b/tsg_io/read_data.m @@ -0,0 +1,151 @@ +function [errTsg, errSpl] = read_data( hMainFig, filterIndex, fullFileName) +% +% Read TSG file or Discrete data (Water sample, ARGO, etc.) +% +% Called by TSGQC.M +% +% Input +% hMainFig Handle to the Main figure - Defined in TSGQC.m +% filterIndex Integer - Type of file +% fullFileName file name to read - Directory+filename +% +% Output +% errTsg Error code for TSG files +% errSpl Error code for discrete data file +% +% Filter index values +% 1 - Argo file *.arg (G. Reverdin format) +% 2 - TSG Astrolabe text file *.ast +% 3 - WS ascii file *.btl (tsgqc ascci format) +% 4 - TSG labview file *.lbv +% 5 - TSG netcdf file *.nc +% 6 - TSG Oracle text file *.ora +% 7 - TSG SDF file *.sdf +% 8 - SPL ascii file *.spl (tsgqc ascci format) +% 9 - TSG Nuka transmit file *.transmit* +% 10 - TSG text file *.tsgqc (tsgqc ascci format) +% 11 - TSG XML file *.xml +% +% errTsg, errSpl +% 1 - File read OK +% < 0 - An error occured +% +% $id:$ + +% Error code - Initialisation +% --------------------------- +errTsg = -2; +errSpl = -2; + +% Retrieve named application data +% ------------------------------- +tsg = getappdata( hMainFig, 'tsg_data'); + +switch filterIndex + + % Read discrete data (Water sample, Argo, etc.) + % --------------------------------------------- + case {1, 3, 8} + + % A TSG file must have been uploaded before reading Water sample file + % -------------------------------------------------------------------- + if isempty( tsg.SSPS ) + + msgbox('Load a TSG file before a Water sample file', 'Read Bucket'); + return; + + elseif filterIndex == 1 + % Read Argo file *.arg (G. Reverdin format) + errSpl = readArgoLocean( hMainFig, fullFileName ); + + elseif filterIndex == 3 || filterIndex == 8 + % Read sample file *.spl + errSpl = readAsciiSample( hMainFig, fullFileName, 'SPL'); + + end + + % Read TSG data file + % ------------------ + case {2, 4, 5, 6, 7, 9, 10, 11} + + % Save the TSG structure - Temporary variable + % ------------------------------------------- + tsg_old = tsg; + + % Initialisation of TSG data struct : tsg variable + % ------------------------------------------------ + tsg_initialisation(hMainFig); + + % Read the file. TSG values are stored in a tsg variable + % ------------- + switch filterIndex + case 2 % read TSG Astrolabe text file *.ast + errTsg = readTsgDataAstrolabe(hMainFig, fullFileName); + case 4 % read TSG labview file *.lbv + errTsg = readTsgDataLabview(hMainFig, fullFileName ); + case 5 % read TSG netcdf file *.nc + errTsg = readTsgDataNetCDF(hMainFig, fullFileName ); + case 6 % read TSG Oracle text file *.ora + errTsg = readTsgDataOracle(hMainFig, fullFileName); + case 7 % read TSG SDF file *.sdf + errTsg = readTsgDataSDF(hMainFig, fullFileName ); + case 9 % read TSG Nuka transmit file *.transmit* + errTsg = readTsgDataNuka(hMainFig, fullFileName); + case 10 % read TSG text file *.tsgqc + errTsg = readAsciiTsg(hMainFig, fullFileName); + case 11 % read TSG XML file *.xml + errTsg = readTsgDataXML(hMainFig, fullFileName ); + end + + % Problem to read the file - Back to tsgqc.m + % ------------------------------------------ + if errTsg < 0 + return + end + + % Test if a TSG file is already uploaded in TSGQC + % Give the possibility to concatenate new and old files + % ----------------------------------------------------- + button = 'Replace'; + if ~isempty( tsg.SSPS ) + qstring = {'TSG data have already been uploaded in TSGQC '; ' '; ... + 'Do you want to Replace or to Concatenate them?'}; + title = 'Read TSG Data'; + button = questdlg(qstring, title,'Replace','Concatenate','Cancel', 'Cancel'); + end + + switch button + case 'Replace' + return + + case 'Concatenate' + if strcmp( button, 'Concatenate') + concatStructTSG( hMainFig, tsg_old ); + end + + case 'Cancel' + % reassign the structure array tsg_old to the application data + % tsg_data + % -------------------------------------------------------------- + setappdata( hMainFig, 'tsg_data', tsg_old); + return; + + otherwise + return; + end + + otherwise + + % Reset pointer to arrow + % ---------------------- + set( hMainFig, 'Pointer', 'arrow' ); + + % diplay warning msgbox + % --------------------- + msgbox( {['Invalid TSG file: ' fileName],... + 'Please select another file'},... + 'Warning open file', 'warn', 'modal' ); + + return; +end % switch filterIndex +end % function diff --git a/tsg_util/updateTsgStruct.m b/tsg_util/updateTsgStruct.m index d88d884b33e6ce5cbface426f71184120c1105a1..61185549f962fb2b971c8fc17f4230dc4485fb03 100644 --- a/tsg_util/updateTsgStruct.m +++ b/tsg_util/updateTsgStruct.m @@ -138,13 +138,14 @@ for i = 1:numel(var) for j = 1:tsg.dim.LINCOEF tsg.(var{i})(j) = lin_val(j); end + + % write LINCOEF_CONV's + % convert cell array of string to char array + % ------------------------------------------ + tsg.([var{i} '_CONV']) = char(lin_type); + end - % rewrite LINCOEF's - % convert cell array of string to char array - % ------------------------------------------ - tsg.([var{i} '_CONV']) = char(lin_type); - end diff --git a/tsgqc.m b/tsgqc.m index 473aeae5c8b2dfc11b9c7adc7472e94e84d09336..5892484cbb607a948b430daa1e9ee4e36d7c8148 100644 --- a/tsgqc.m +++ b/tsgqc.m @@ -37,8 +37,8 @@ global NETCDF_FORMAT_VERSION % version number, may be used to initialize some files when it change % 0.90x -> 1.0RCx % ------------------------------------------------------------------- -VERSION = 1.1; % -> 1.1 -CHAR_VERSION = '1.1'; +VERSION = 1.2; % -> 1.2 +CHAR_VERSION = '1.2'; % netcdf file version, see DATA FORMAT TSG document: % CORTSG_format_gosud_1.5.doc @@ -1201,7 +1201,7 @@ hrbInterpCancel = uicontrol( ... % Open standard dialog box for retrieving files % --------------------------------------------- [fileName, pathname, filterIndex] = uigetfile( ... - {'*.nc';'*.ast';'*.btl';'*.lbv';'*.arg';'*.ora';'*.sdf';'*.spl';... + {'*.arg';'*.ast';'*.btl';'*.lbv';'*.nc';'*.ora';'*.sdf';'*.spl';... '*.transmit*'; '*.tsgqc';'*.xml'}, 'Pick a file'); % flushes the event queue and updates the closed uigetfile window @@ -1223,79 +1223,8 @@ hrbInterpCancel = uicontrol( ... % Read the data % ------------- - errTsg = -2; - errSpl = -2; - switch filterIndex - - case 5 % Read Argo file *.arg (G. Reverdin format) - if ~isempty( tsg.SSPS ) - errSpl = readArgoLocean( hMainFig, fullFileName ); - else - msgbox('Load a TSG file before a Water sample file', 'Read Bucket'); - end - - case 2 % read TSG Astrolabe text file *.ast - tsg_initialisation(hMainFig); - errTsg = readTsgDataAstrolabe( hMainFig, fullFileName); - - case 3 % read bucket file *.btl - if ~isempty( tsg.SSPS ) - errSpl = readAsciiSample( hMainFig, fullFileName, 'WS'); - else - msgbox('Load a TSG file before a Water sample file', 'Read Bucket'); - end - - case 4 % read TSG labview file *.lbv - tsg_initialisation(hMainFig); - errTsg = readTsgDataLabview( hMainFig, fullFileName ); - - case 1 % read TSG netcdf file *.nc - tsg_initialisation(hMainFig); - errTsg = readTsgDataNetCDF( hMainFig, fullFileName ); - - case 6 % read TSG Oracle text file *.ora - tsg_initialisation(hMainFig); - errTsg = readTsgDataOracle( hMainFig, fullFileName); - - case 7 % read TSG SDF file *.sdf - tsg_initialisation(hMainFig); - errTsg = readTsgDataSDF( hMainFig, fullFileName ); - - case 8 % Read Sample file *.spl - if ~isempty( tsg.SSPS ) - errSpl = readAsciiSample( hMainFig, fullFileName, 'SPL'); - else - msgbox('Load a TSG file before a Water sample file', 'Read Bucket'); - end - - case 9 % read TSG Nuka transmit file *.transmit* - tsg_initialisation(hMainFig); - errTsg = readTsgDataNuka( hMainFig, fullFileName); - - case 10 % read TSG text file *.tsgqc - tsg_initialisation(hMainFig); - errTsg = readAsciiTsg( hMainFig, fullFileName); - - case 11 % read TSG XML file *.xml - tsg_initialisation(hMainFig); - errTsg = readTsgDataXML( hMainFig, fullFileName ); - - otherwise - - % Reset pointer to arrow - % ---------------------- - set( hMainFig, 'Pointer', 'arrow' ); - - % diplay warning msgbox - % --------------------- - msgbox( {['Invalid TSG file: ' fileName],... - 'Please select another file'},... - 'Warning open file', 'warn', 'modal' ); - - return; - - end % switch filterIndex - + [errTsg, errSpl] = read_data( hMainFig, filterIndex, fullFileName); + % Get the tsg structure % --------------------- tsg = getappdata( hMainFig, 'tsg_data');