diff --git a/tsg_util/tsg_preferences.m b/tsg_util/tsg_preferences.m index 916de0e55db96bd68fdb23a302c2858b0dcb4410..3257d8489ab40dc1e0b5fdd023d56f892408123c 100644 --- a/tsg_util/tsg_preferences.m +++ b/tsg_util/tsg_preferences.m @@ -137,6 +137,8 @@ return preference.char_version = CHAR_VERSION; preference.date_version = DATE_VERSION; preference.autoload = 'off'; + preference.fileExtension = ({'*.lbv';'*.nc';'*.arg';'*.ast';'*.btl';'*.ora';... + '*.sdf';'*.spl'; '*.transmit*'; '*.tsgqc';'*.xml';'*.cnv'}); % Climatology preference.levitus_version = {'WOA01','WOA05','ISAS13'}; preference.levitus_value = 2; % WOA05 diff --git a/tsgqc.m b/tsgqc.m index b02270a9f090683c35c237d8a0e8f9838a3363cf..8e935e249edb215498e291fa1df87af17eeb30cb 100644 --- a/tsgqc.m +++ b/tsgqc.m @@ -38,9 +38,9 @@ global GOSUD_FORMAT_VERSION % version number, may be used to initialize some files when it change % 0.90x -> 1.0RCx % ------------------------------------------------------------------- -VERSION = 1.48; % -> 1.44 -CHAR_VERSION = '1.48'; -DATE_VERSION = '25/05/2018'; +VERSION = 1.481; % -> 1.44 +CHAR_VERSION = '1.48.1'; +DATE_VERSION = '29/05/2018'; % netcdf file version, see DATA FORMAT TSG document: % CORTSG_format_gosud.doc @@ -1251,16 +1251,13 @@ hrbInterpCancel = uicontrol( ... set( hTimelimitToggletool, 'state', 'off' ); % set( hZoomToggletool, 'state', 'off' ); + % Get the tsg structure + % --------------------- + tsg = getappdata( hMainFig, 'tsg_data'); + % Open standard dialog box for retrieving files % --------------------------------------------- - fileExtension = ({'*.lbv';'*.nc';'*.arg';'*.ast';'*.btl';'*.ora';... - '*.sdf';'*.spl'; '*.transmit*'; '*.tsgqc';'*.xml';'*.cnv'}); - [fileName, pathname, filterIndex] = uigetfile( fileExtension, 'Pick a file'); - - % uigetfile add an extra index (*.*) and a bug if user select file from - % *.* and fileExtension(filterIndex) create an Index exceeds matrix - % now, we use strcat('*',ext) instead - [~,~,ext] = fileparts(fileName); + [fileName, pathname, filterIndex] = uigetfile( tsg.preference.fileExtension, 'Pick a file'); % flushes the event queue and updates the closed uigetfile window % --------------------------------------------------------------- @@ -1271,6 +1268,11 @@ hrbInterpCancel = uicontrol( ... % ----------------------------------------------------------------- if ~isequal(fileName, 0) + % uigetfile add an extra index (*.*) and a bug if user select file from + % *.* and fileExtension(filterIndex) create an Index exceeds matrix + % now, we use strcat('*',ext) instead + [~,~,ext] = fileparts(fileName); + % Pointer set to watch during reading and plotting % ------------------------------------------------ set( hMainFig, 'Pointer', 'watch' ); @@ -1278,14 +1280,19 @@ hrbInterpCancel = uicontrol( ... % construct valid and full file path % ----------------------------------- fullFileName = strcat(pathname, fileName); - + + % the last extension selected move on top in cell array preference.fileExtensions + % ---------------------------------------------------------------------- + tsg.preference.fileExtension = ... + circshift(tsg.preference.fileExtension, 1 - filterIndex); + setappdata( hMainFig, 'tsg_data', tsg); + % Read the data % ------------- [errTsg, errSpl] = read_data( hMainFig, strcat('*',ext), fullFileName); - % Get the tsg structure - % --------------------- - tsg = getappdata( hMainFig, 'tsg_data'); + + % Keep the pathname of the tsgqc m_file % ------------------------------------- @@ -2137,106 +2144,106 @@ hrbInterpCancel = uicontrol( ... % is used when the context menu (callback 'Qc') is called % ----------------------------------------------------------------- if ~strcmp( get(gcf, 'SelectionType'), 'alt') + + % The QC is applied either on TSG data either on Sample data. + % it depends if the Botte Toggle button has been cliked on + % ----------------------------------------------------------- + if strcmp( get(hBottleToggletool, 'state'), 'on') - % The QC is applied either on TSG data either on Sample data. - % it depends if the Botte Toggle button has been cliked on - % ----------------------------------------------------------- - if strcmp( get(hBottleToggletool, 'state'), 'on') - - % get index on selected zone - % -------------------------- - if ~isempty(tsg.DAYD_EXT) - - ind = find(tsg.DAYD_EXT > p1(1) & tsg.DAYD_EXT < p2(1) & ... - tsg.EXT_DIF > p1(2) & tsg.EXT_DIF < p2(2)); - - % Keep the information on the indices of the selected zone - % -------------------------------------------------------- - tsg.rbboxind = ind .* ones(size(ind)); - - % Modifiy the QC - % -------------- - tsg.([SAMPLE '_EXT_QC'])(ind) = tsg.qc.active.Code; - - % Save the modifications - % ---------------------- - setappdata( hMainFig, 'tsg_data', tsg); - - % plot selected data with selected code - % -------------------------------------- - plot_Correction( hMainFig, hPlotAxes, PARA); - - end - + % get index on selected zone + % -------------------------- + if ~isempty(tsg.DAYD_EXT) + + ind = find(tsg.DAYD_EXT > p1(1) & tsg.DAYD_EXT < p2(1) & ... + tsg.EXT_DIF > p1(2) & tsg.EXT_DIF < p2(2)); + + % Keep the information on the indices of the selected zone + % -------------------------------------------------------- + tsg.rbboxind = ind .* ones(size(ind)); + + % Modifiy the QC + % -------------- + tsg.([SAMPLE '_EXT_QC'])(ind) = tsg.qc.active.Code; + + % Save the modifications + % ---------------------- + setappdata( hMainFig, 'tsg_data', tsg); + + % plot selected data with selected code + % -------------------------------------- + plot_Correction( hMainFig, hPlotAxes, PARA); + + end + + else + + % store last QC in history for undo + % --------------------------------- + + if (tsg.qc_history_pointer == 0) + tsg.qc_history_state = int8(zeros(size(tsg.([PARA{1} '_QC']),1),tsg.qc_history_size)); + end + + if (tsg.qc_history_pointer == tsg.qc_history_size) + tsg.qc_history_state = circshift(tsg.qc_history_state,[0 -1]); else - - % store last QC in history for undo - % --------------------------------- - - if (tsg.qc_history_pointer == 0) - tsg.qc_history_state = int8(zeros(size(tsg.([PARA{1} '_QC']),1),tsg.qc_history_size)); - end - - if (tsg.qc_history_pointer == tsg.qc_history_size) - tsg.qc_history_state = circshift(tsg.qc_history_state,[0 -1]); - else - tsg.qc_history_pointer = tsg.qc_history_pointer + 1; - end - - tsg.qc_history_state(:,tsg.qc_history_pointer) = tsg.([PARA{1} '_QC']); - tsg.qc_redo_possible = 0; - - - % get index on selected zone - % --------------------------- - ind = find(tsg.DAYD > p1(1,1) & tsg.DAYD < p2(1,1) & ... - tsg.(PARA{1}) > p1(1,2) & tsg.(PARA{1}) < p2(1,2)); - - % Keep the information on the indices of the selected zone - % -------------------------------------------------------- - tsg.rbboxind = ind .* ones(size(ind)); - - % Modify the QC - % -------------- - tsg.([PARA{1} '_QC'])(ind) = tsg.qc.active.Code; - - % Save the modifications - % ---------------------- - setappdata( hMainFig, 'tsg_data', tsg); - - % Draw plot 1 of the validation figure - % ------------------------------------ - plot_Validation( hMainFig, hPlotAxes, 1, PARA{1} ); - - % refresh QC statistic panel - % -------------------------- - display_QC( hMainFig ); - - % Update the map if already displayed - % ----------------------------------- - if strcmp( get(hMapFig,'visible'), 'on') == 1 - erase_Line( hPlotAxes, 4 ); - plot_map( hMainFig, hPlotAxes); - end - - % enable Undo menu if QC flags applied - % ------------------------------------ - if (tsg.qc_history_pointer > 0) - set(findobj('tag','UIMENU_UNDO'),'enable','on'); - end + tsg.qc_history_pointer = tsg.qc_history_pointer + 1; + end + + tsg.qc_history_state(:,tsg.qc_history_pointer) = tsg.([PARA{1} '_QC']); + tsg.qc_redo_possible = 0; + + + % get index on selected zone + % --------------------------- + ind = find(tsg.DAYD > p1(1,1) & tsg.DAYD < p2(1,1) & ... + tsg.(PARA{1}) > p1(1,2) & tsg.(PARA{1}) < p2(1,2)); - % enable Redo menu if QC flags applied - % ------------------------------------ - if (tsg.qc_history_pointer > 0) - set(findobj('tag','UIMENU_REDO'),'enable','on'); - end + % Keep the information on the indices of the selected zone + % -------------------------------------------------------- + tsg.rbboxind = ind .* ones(size(ind)); + % Modify the QC + % -------------- + tsg.([PARA{1} '_QC'])(ind) = tsg.qc.active.Code; + + % Save the modifications + % ---------------------- + setappdata( hMainFig, 'tsg_data', tsg); + + % Draw plot 1 of the validation figure + % ------------------------------------ + plot_Validation( hMainFig, hPlotAxes, 1, PARA{1} ); + + % refresh QC statistic panel + % -------------------------- + display_QC( hMainFig ); + + % Update the map if already displayed + % ----------------------------------- + if strcmp( get(hMapFig,'visible'), 'on') == 1 + erase_Line( hPlotAxes, 4 ); + plot_map( hMainFig, hPlotAxes); end - % As soon as a modification took place the data should be saved - % ------------------------------------------------------------- - set( hSaveMenu, 'UserData', 'on' ); + % enable Undo menu if QC flags applied + % ------------------------------------ + if (tsg.qc_history_pointer > 0) + set(findobj('tag','UIMENU_UNDO'),'enable','on'); + end + + % enable Redo menu if QC flags applied + % ------------------------------------ + if (tsg.qc_history_pointer > 0) + set(findobj('tag','UIMENU_REDO'),'enable','on'); + end + end + + % As soon as a modification took place the data should be saved + % ------------------------------------------------------------- + set( hSaveMenu, 'UserData', 'on' ); + end % enable ButtonMotion on main fig after select QC area @@ -2326,7 +2333,7 @@ hrbInterpCancel = uicontrol( ... % ------------------------------------------ if isfield(tsg, 'rbboxind') && ~isempty( tsg.rbboxind ) - if strcmp( get(hBottleToggletool, 'state'), 'on') + if strcmp( get(hBottleToggletool, 'state'), 'on') tsg.([SAMPLE '_EXT_QC'])(tsg.rbboxind) = tsg.qc.active.Code; @@ -2339,29 +2346,29 @@ hrbInterpCancel = uicontrol( ... % ----------------------------------------- plot_Correction( hMainFig, hPlotAxes, PARA ); - else - - % store last QC in history for undo - % --------------------------------- - - if (tsg.qc_history_pointer == 0) - tsg.qc_history_state = int8(zeros(size(tsg.([PARA{1} '_QC']),1),tsg.qc_history_size)); - end - - if (tsg.qc_history_pointer == tsg.qc_history_size) - tsg.qc_history_state = circshift(tsg.qc_history_state,[0 -1]); - else - tsg.qc_history_pointer = tsg.qc_history_pointer + 1; - end - - tsg.qc_history_state(:,tsg.qc_history_pointer) = tsg.([PARA{1} '_QC']); - tsg.qc_redo_possible = 0; - - - % Modify the QC - % -------------- - tsg.([PARA{1} '_QC'])(tsg.rbboxind) = tsg.qc.active.Code; - + else + + % store last QC in history for undo + % --------------------------------- + + if (tsg.qc_history_pointer == 0) + tsg.qc_history_state = int8(zeros(size(tsg.([PARA{1} '_QC']),1),tsg.qc_history_size)); + end + + if (tsg.qc_history_pointer == tsg.qc_history_size) + tsg.qc_history_state = circshift(tsg.qc_history_state,[0 -1]); + else + tsg.qc_history_pointer = tsg.qc_history_pointer + 1; + end + + tsg.qc_history_state(:,tsg.qc_history_pointer) = tsg.([PARA{1} '_QC']); + tsg.qc_redo_possible = 0; + + + % Modify the QC + % -------------- + tsg.([PARA{1} '_QC'])(tsg.rbboxind) = tsg.qc.active.Code; + % Save tsg.SSPS_QC in the application data before use % inside plot_Validation % --------------------------------------------------- @@ -2754,7 +2761,7 @@ hrbInterpCancel = uicontrol( ... % ----------------- tsg = getappdata( hMainFig, 'tsg_data' ); - % Draw the 3 plots of the validation figure and unzoom as the new + % Draw the 3 plots of the validation figure and unzoom as the new % plot keep in memory the preceding zoom % ----------------------------------------- plot_Validation( hMainFig, hPlotAxes, 1, tsg.plot.parameter{1} ); @@ -3673,112 +3680,112 @@ hrbInterpCancel = uicontrol( ... % ----------------------------------------------------------------------- % Callback function run when the Edit/Undo menu item is selected (Ctrl+Z) % ----------------------------------------------------------------------- - function UndoMenuCallback(hObject, eventdata) - - if (tsg.qc_history_pointer > 0) - - % Get the parameter (SSPS, SSJT or SSTP) - % -------------------------------------- - PARA = getParaCorModule( hMainFig ); - - if (tsg.qc_history_pointer == tsg.qc_history_size) - tsg.qc_history_state = circshift(tsg.qc_history_state,[0 -1]); - tsg.qc_history_pointer = tsg.qc_history_pointer - 1; - end - - % Back to previous QC flags - % ------------------------- - tsg.qc_history_state(:,tsg.qc_history_pointer+1) = tsg.([PARA{1} '_QC']); - tsg.([PARA{1} '_QC']) = tsg.qc_history_state(:,tsg.qc_history_pointer); - tsg.qc_history_pointer = tsg.qc_history_pointer - 1; - - % Allow redo - % ---------- - tsg.qc_redo_possible = tsg.qc_redo_possible + 1; - - % Save the modifications - % ---------------------- - setappdata( hMainFig, 'tsg_data', tsg); - - % Draw plot 1 of the validation figure - % ------------------------------------ - plot_Validation( hMainFig, hPlotAxes, 1, PARA{1} ); - - % refresh QC statistic panel - % -------------------------- - display_QC( hMainFig ); - - % Update the map if already displayed - % ----------------------------------- - if strcmp( get(hMapFig,'visible'), 'on') == 1 - erase_Line( hPlotAxes, 4 ); - plot_map( hMainFig, hPlotAxes); - end - - % As soon as a modification took place the data should be saved - % ------------------------------------------------------------- - set( hSaveMenu, 'UserData', 'on' ); - - else - - msgbox('Undo not possible', 'modal'); - - end - + function UndoMenuCallback(hObject, eventdata) + + if (tsg.qc_history_pointer > 0) + + % Get the parameter (SSPS, SSJT or SSTP) + % -------------------------------------- + PARA = getParaCorModule( hMainFig ); + + if (tsg.qc_history_pointer == tsg.qc_history_size) + tsg.qc_history_state = circshift(tsg.qc_history_state,[0 -1]); + tsg.qc_history_pointer = tsg.qc_history_pointer - 1; + end + + % Back to previous QC flags + % ------------------------- + tsg.qc_history_state(:,tsg.qc_history_pointer+1) = tsg.([PARA{1} '_QC']); + tsg.([PARA{1} '_QC']) = tsg.qc_history_state(:,tsg.qc_history_pointer); + tsg.qc_history_pointer = tsg.qc_history_pointer - 1; + + % Allow redo + % ---------- + tsg.qc_redo_possible = tsg.qc_redo_possible + 1; + + % Save the modifications + % ---------------------- + setappdata( hMainFig, 'tsg_data', tsg); + + % Draw plot 1 of the validation figure + % ------------------------------------ + plot_Validation( hMainFig, hPlotAxes, 1, PARA{1} ); + + % refresh QC statistic panel + % -------------------------- + display_QC( hMainFig ); + + % Update the map if already displayed + % ----------------------------------- + if strcmp( get(hMapFig,'visible'), 'on') == 1 + erase_Line( hPlotAxes, 4 ); + plot_map( hMainFig, hPlotAxes); + end + + % As soon as a modification took place the data should be saved + % ------------------------------------------------------------- + set( hSaveMenu, 'UserData', 'on' ); + + else + + msgbox('Undo not possible', 'modal'); + end - - + + end + + %% RedoMenuCallback % ----------------------------------------------------------------------- % Callback function run when the Edit/Redo menu item is selected (Ctrl+R) % ----------------------------------------------------------------------- function RedoMenuCallback(hObject, eventdata) - if (tsg.qc_redo_possible >0) - - % Get the parameter (SSPS, SSJT or SSTP) - % -------------------------------------- - PARA = getParaCorModule( hMainFig ); - - % Forward to undone QC flags - % -------------------------- - tsg.qc_history_pointer = tsg.qc_history_pointer + 1; - tsg.([PARA{1} '_QC']) = tsg.qc_history_state(:,tsg.qc_history_pointer+1); - - % Reduce number of possible redo - % ------------------------------ - tsg.qc_redo_possible = tsg.qc_redo_possible-1; - - % Save the modifications - % ---------------------- - setappdata( hMainFig, 'tsg_data', tsg); - - % Draw plot 1 of the validation figure - % ------------------------------------ - plot_Validation( hMainFig, hPlotAxes, 1, PARA{1} ); - - % refresh QC statistic panel - % -------------------------- - display_QC( hMainFig ); - - % Update the map if already displayed - % ----------------------------------- - if strcmp( get(hMapFig,'visible'), 'on') == 1 - erase_Line( hPlotAxes, 4 ); - plot_map( hMainFig, hPlotAxes); - end - - % As soon as a modification took place the data should be saved - % ------------------------------------------------------------- - set( hSaveMenu, 'UserData', 'on' ); - - else - - msgbox('Redo not possible', 'modal'); - - end - - + if (tsg.qc_redo_possible >0) + + % Get the parameter (SSPS, SSJT or SSTP) + % -------------------------------------- + PARA = getParaCorModule( hMainFig ); + + % Forward to undone QC flags + % -------------------------- + tsg.qc_history_pointer = tsg.qc_history_pointer + 1; + tsg.([PARA{1} '_QC']) = tsg.qc_history_state(:,tsg.qc_history_pointer+1); + + % Reduce number of possible redo + % ------------------------------ + tsg.qc_redo_possible = tsg.qc_redo_possible-1; + + % Save the modifications + % ---------------------- + setappdata( hMainFig, 'tsg_data', tsg); + + % Draw plot 1 of the validation figure + % ------------------------------------ + plot_Validation( hMainFig, hPlotAxes, 1, PARA{1} ); + + % refresh QC statistic panel + % -------------------------- + display_QC( hMainFig ); + + % Update the map if already displayed + % ----------------------------------- + if strcmp( get(hMapFig,'visible'), 'on') == 1 + erase_Line( hPlotAxes, 4 ); + plot_map( hMainFig, hPlotAxes); + end + + % As soon as a modification took place the data should be saved + % ------------------------------------------------------------- + set( hSaveMenu, 'UserData', 'on' ); + + else + + msgbox('Redo not possible', 'modal'); + + end + + end %% KeyPressFcnCallback