diff --git a/tsgqc_GUI.m b/tsgqc_GUI.m index f07ec9a8300b2c7b675a68f03145a0beeff37c5a..b4d8efe1d012de53ae4ffcda270b24f2283d983d 100644 --- a/tsgqc_GUI.m +++ b/tsgqc_GUI.m @@ -143,7 +143,7 @@ hPanPushtool = uipushtool(... % Open Pan toolbar button 'Tag','PUSHTOOL_PAN',... 'Enable', 'off',... 'ClickedCallback', @PanMenuCallback); -hQCPushtool = uipushtool(... % Open QC toolbar button +hQCPushtool = uitoggletool(... % Open QC toolbar button 'Parent',hToolbar,... 'TooltipString','Validation codes',... 'Separator', 'on', ... @@ -153,8 +153,9 @@ hQCPushtool = uipushtool(... % Open QC toolbar button 'Tag','PUSHTOOL_QC',... 'UserData', 'off',... 'Enable', 'off',... - 'ClickedCallback', @QCMenuCallback); -hMapPushtool = uipushtool(... % Open Map toolbar button + 'OffCallback', @QC_OffMenuCallback,... + 'ONCallback', @QC_OnMenuCallback); +hMapPushtool = uitoggletool(... % Open Map toolbar button 'Parent',hToolbar,... 'TooltipString','Map and ship track',... 'Separator', 'on', ... @@ -164,8 +165,9 @@ hMapPushtool = uipushtool(... % Open Map toolbar button 'Tag','PUSHTOOL_MAP',... 'UserData', 'off', ... 'Enable', 'off',... - 'ClickedCallback', @MapMenuCallback); -hClimPushtool = uipushtool(... % Open Climatology toolbar button + 'OffCallback', @Map_OffMenuCallback,... + 'ONCallback', @Map_OnMenuCallback); +hClimPushtool = uitoggletool(... % Open Climatology toolbar button 'Parent',hToolbar,... 'TooltipString','Climatology',... 'Separator', 'on', ... @@ -175,7 +177,8 @@ hClimPushtool = uipushtool(... % Open Climatology toolbar button 'Tag','PUSHTOOL_CLIM',... 'UserData', 'off',... 'Enable', 'off',... - 'ClickedCallback', @ClimMenuCallback); + 'OffCallback', @Clim_OffMenuCallback,... + 'ONCallback', @Clim_OnMenuCallback); hBottlePushtool = uipushtool(... % Open toolbar button 'Parent',hToolbar,... 'TooltipString','Plot the Samples',... @@ -359,18 +362,27 @@ hPlotAxes(1) = axes(... % the axes for plotting Salinity 'Visible', 'off', ... 'HandleVisibility','callback', ... 'Position',[.05, .6, .9, .32]); -hPlotAxes(2) = axes(... % the axes for plotting temperature + +% The second and third axes will be plot in a uipanel +hPlotsPanel = uipanel( ... 'Parent', hMainFig, ... 'Units', 'normalized', ... + 'BorderType', 'none',... + 'Visible', 'on', ... + 'Position',[0, 0, 1, .57]); + +hPlotAxes(2) = axes(... % the axes for plotting temperature + 'Parent', hPlotsPanel, ... + 'Units', 'normalized', ... 'Visible', 'off', ... 'HandleVisibility','callback', ... - 'Position',[.05, .3, .9, .25]); + 'Position',[.05, .48, .9, .47]); hPlotAxes(3) = axes(... % the axes for plotting ship velocity - 'Parent', hMainFig, ... + 'Parent', hPlotsPanel, ... 'Units', 'normalized', ... 'Visible', 'off', ... 'HandleVisibility','callback', ... - 'Position',[.05, .05, .9, .2]); + 'Position',[.05, .06, .9, .32]); % The map will be plot in a uipanel hMapPanel = uipanel( ... @@ -385,7 +397,6 @@ hPlotAxes(4) = axes(... % the axes for plotting ship track map 'Visible', 'off', ... 'Color', 'none', ... 'UserData', 'off', ... - 'UserData', [], ... 'HandleVisibility','callback', ... 'Position',[.05, .05, .9, .9]); @@ -431,14 +442,15 @@ hQcCmenuBad = uimenu(... % -------------- tsg_initialisation(hMainFig, hQcCmenu) - +% ------------------------- % Callbacks for tsgcqc_GUI -% ************************ +% ------------------------ -%---------------------------------------------------------------------- + %---------------------------------------------------------------------- + % Callback function run when the Open menu item is selected + %---------------------------------------------------------------------- function OpenMenuCallback(hObject, eventdata) - % Callback function run when the Open menu item is selected - + % Pointer set to watch during reading and plotting % ------------------------------------------------ set( hMainFig, 'Pointer', 'watch' ); @@ -485,6 +497,9 @@ tsg_initialisation(hMainFig, hQcCmenu) % A TSG file has been open and read % --------------------------------- set( hOpenMenu, 'UserData', 'on' ); + + % enable menu pushtool + % -------------------- hdl_pushtool = findobj('-regexp','Tag', 'PUSHTOOL_'); set(hdl_pushtool, 'Enable', 'on'); @@ -528,9 +543,9 @@ tsg_initialisation(hMainFig, hQcCmenu) % NOT at that step. It will interfere with the QC process % Maybe use a new pushbutton to draw or delete the bucket % ------------------------------------------------------- - %if error2 ~= -1 - % plot_SalTsgSample( hMainFig, hPlotAxes ); - %end + if error2 ~= -1 + plot_SalTsgSample( hMainFig, hPlotAxes ); + end % Pointer reset to arrow % ---------------------- @@ -538,7 +553,8 @@ tsg_initialisation(hMainFig, hQcCmenu) end -%---------------------------------------------------------------------- + %---------------------------------------------------------------------- + %---------------------------------------------------------------------- function ZoomMenuCallback(hObject, eventdata) % Callback function run when the Open menu item is selected @@ -561,7 +577,8 @@ tsg_initialisation(hMainFig, hQcCmenu) % set(hZoomplusPushtool,'CData', zoomColor); end -%---------------------------------------------------------------------- + %---------------------------------------------------------------------- + %---------------------------------------------------------------------- function PanMenuCallback(hObject, eventdata) % Callback function run when the Open menu item is selected @@ -583,117 +600,203 @@ tsg_initialisation(hMainFig, hQcCmenu) end end -%---------------------------------------------------------------------- - function QCMenuCallback(gcbo, eventdata,handles) - % Callback function run when the QC pushbutton is selected + %---------------------------------------------------------------------- + %---------------------------------------------------------------------- + function QC_OffMenuCallback(gcbo, eventdata) + + % Desactive right clic menu on first axes (salinity) + % --------------------------------------------------- + set(hPlotAxes(1),'UIContextMenu', []); + + % Desactive clic mouse menu (zoom) on first axes (salinity) + % ---------------------------------------------------------- + set(hPlotAxes(1),'ButtonDownFcn', []); + + % cursor back to normal + % --------------------- + set(hMainFig,'Pointer','arrow'); + end + %---------------------------------------------------------------------- + %---------------------------------------------------------------------- + function QC_OnMenuCallback(gcbo, eventdata) + % Desactivate the Zoom and Pan functions. % --------------------------------------- zoom off; pan off panAdaptiveDateTicks('off');zoomAdaptiveDateTicks('off'); + + % Activate right clic context menu on first axes (salinity) + % --------------------------------------------------------- + set(hPlotAxes(1),'UIContextMenu', hQcCmenu); + + % Activate clic mouse menu on first axes (salinity) + % ------------------------------------------------- + set(hPlotAxes(1),'ButtonDownFcn', @QC_ZoomCallback); + + % change cursor to crosshai aspect + % -------------------------------- + set( hMainFig, 'Pointer', 'crosshair'); + + % ------------------------------------------------------------- + % nested function on mouse clic + % ------------------------------------------------------------- + function QC_ZoomCallback(gcbo, eventdata) - % Toggle the tag of the Qc pushbutton to 'on' or 'off' - % ---------------------------------------------------- - switch get(hQCPushtool, 'UserData'); - case 'off' - set(hQCPushtool, 'UserData', 'on' ); - set(hPlotAxes(1),'UIContextMenu', hQcCmenu); - set( hMainFig, 'Pointer', 'crosshair'); - case 'on' - set(hQCPushtool, 'UserData', 'off' ); - set(hPlotAxes(1),'UIContextMenu', []); - set(hMainFig,'Pointer','arrow'); - end - - qualityCode = -1; - ind = []; - while strcmp( get(hQCPushtool, 'UserData'),'on') - - k = waitforbuttonpress; - - % If the QC pushbutton is pressed we quit the callback - % ---------------------------------------------------- - if strcmp( get(hQCPushtool, 'UserData'),'off') - - % Desactivate the context menu use to choose the Quality Codes - % ------------------------------------------------------------ - set(hQcCmenu, 'Visible', 'off'); - break - end - - % Test if the right mouse button is clicked - % ----------------------------------------- - if strcmp(get(hMainFig, 'SelectionType'), 'alt') && ~isempty(ind) - % Wait for a QC Context Menu choice : The user choose the - % quality code - % ------------------------------------------------------- - uiwait - qualityCode = 1; - - else - - % Mouse motion callback desactivated when a selection is made. - % Otherwise there is a conflict with the map if it is activated - % ------------------------------------------------------------- - set( hMainFig, 'UserData', 'ButtonMotionOff'); - - % Selection of the data within the figure - % --------------------------------------- - point1 = get(gca,'CurrentPoint'); % button down detected - finalRect = rbbox; % return figure units - point2 = get(gca,'CurrentPoint'); % button up detected - - point1 = point1(1,1:2); % extract x and y - point2 = point2(1,1:2); - - p1 = min(point1,point2); - p2 = max(point1,point2); % calculate locations - - % Retrieve named application data - % ------------------------------- - tsg = getappdata( hMainFig, 'tsg_data'); - - ind = find(tsg.DAYD > p1(1,1) & tsg.DAYD < p2(1,1) & ... - tsg.SSPS > p1(1,2) & tsg.SSPS < p2(1,2)); - - % As soon as a modification took place the data should be saved - % ------------------------------------------------------------- - set( hSaveMenu, 'UserData', 'on' ); - - % Selection made : Mouse motion callback re-activated - % -------------------------------------------------- - set( hMainFig, 'UserData', 'ButtonMotionOn'); - - end - - % Plot the data with the color of the chosen quality Code. - % Is it the right place for this source code ???? - % -------------------------------------------------------- - if qualityCode ~= -1 - - % Retrieve named application data - Code could have been changed - % -------------------------------------------------------------- - tsg = getappdata( hMainFig, 'tsg_data'); - - tsg.SSPS_QC(ind) = tsg.qc.Code.ACTIVE; + % Retrieve named application data + % ------------------------------- + tsg = getappdata( hMainFig, 'tsg_data'); + + % Selection of the data within the figure + % --------------------------------------- + point1 = get(gca,'CurrentPoint'); % button down detected + finalRect = rbbox; % return figure units + point2 = get(gca,'CurrentPoint'); % button up detected - % Save the modifications - % ---------------------- - setappdata( hMainFig, 'tsg_data', tsg); + point1 = point1(1,1:2); % extract x and y + point2 = point2(1,1:2); + + p1 = min(point1,point2); + p2 = max(point1,point2); % calculate locations - axes(hPlotAxes(1)); - hold on - color = ['.' tsg.qc.Color.ACTIVE]; - plot(tsg.DAYD(ind), tsg.SSPS(ind), color ); - hold off + % get index on selected zone + % --------------------------- + ind = find(tsg.DAYD > p1(1,1) & tsg.DAYD < p2(1,1) & ... + tsg.SSPS > p1(1,2) & tsg.SSPS < p2(1,2)); + + tsg.SSPS_QC(ind) = tsg.qc.Code.ACTIVE; + + % set current axes and plot + % ------------------------- + axes(hPlotAxes(1)); + hold on + color = ['.' tsg.qc.Color.ACTIVE]; + plot(tsg.DAYD(ind), tsg.SSPS(ind), color ); + hold off + + % As soon as a modification took place the data should be saved + % ------------------------------------------------------------- + set( hSaveMenu, 'UserData', 'on' ); + + % Save the modifications + % ---------------------- + setappdata( hMainFig, 'tsg_data', tsg); - end end end -%--------------------------------------------------------------------- - function Qc(hObject, eventdata) - % Callback function run when the QC context menu is selected +% %---------------------------------------------------------------------- +% function QCMenuCallback_old(gcbo, eventdata,handles) +% % Callback function run when the QC pushbutton is selected +% +% % Desactivate the Zoom and Pan functions. +% % --------------------------------------- +% zoom off; pan off +% panAdaptiveDateTicks('off');zoomAdaptiveDateTicks('off'); +% +% % Toggle the tag of the Qc pushbutton to 'on' or 'off' +% % ---------------------------------------------------- +% switch get(hQCPushtool, 'UserData'); +% case 'off' +% set(hQCPushtool, 'UserData', 'on' ); +% set(hPlotAxes(1),'UIContextMenu', hQcCmenu); +% set( hMainFig, 'Pointer', 'crosshair'); +% case 'on' +% set(hQCPushtool, 'UserData', 'off' ); +% set(hPlotAxes(1),'UIContextMenu', []); +% set(hMainFig,'Pointer','arrow'); +% end +% +% qualityCode = -1; +% ind = []; +% while strcmp( get(hQCPushtool, 'UserData'),'on') +% +% k = waitforbuttonpress; +% +% % If the QC pushbutton is pressed we quit the callback +% % ---------------------------------------------------- +% if strcmp( get(hQCPushtool, 'UserData'),'off') +% +% % Desactivate the context menu use to choose the Quality Codes +% % ------------------------------------------------------------ +% set(hQcCmenu, 'Visible', 'off'); +% break +% end +% +% % Test if the right mouse button is clicked +% % ----------------------------------------- +% if strcmp(get(hMainFig, 'SelectionType'), 'alt') && ~isempty(ind) +% % Wait for a QC Context Menu choice : The user choose the +% % quality code +% % ------------------------------------------------------- +% uiwait +% qualityCode = 1; +% +% else +% +% % Mouse motion callback desactivated when a selection is made. +% % Otherwise there is a conflict with the map if it is activated +% % ------------------------------------------------------------- +% set( hMainFig, 'UserData', 'ButtonMotionOff'); +% +% % Selection of the data within the figure +% % --------------------------------------- +% point1 = get(gca,'CurrentPoint'); % button down detected +% finalRect = rbbox; % return figure units +% point2 = get(gca,'CurrentPoint'); % button up detected +% +% point1 = point1(1,1:2); % extract x and y +% point2 = point2(1,1:2); +% +% p1 = min(point1,point2); +% p2 = max(point1,point2); % calculate locations +% +% % Retrieve named application data +% % ------------------------------- +% tsg = getappdata( hMainFig, 'tsg_data'); +% +% ind = find(tsg.DAYD > p1(1,1) & tsg.DAYD < p2(1,1) & ... +% tsg.SSPS > p1(1,2) & tsg.SSPS < p2(1,2)); +% +% % As soon as a modification took place the data should be saved +% % ------------------------------------------------------------- +% set( hSaveMenu, 'UserData', 'on' ); +% +% % Selection made : Mouse motion callback re-activated +% % -------------------------------------------------- +% set( hMainFig, 'UserData', 'ButtonMotionOn'); +% +% end +% +% % Plot the data with the color of the chosen quality Code. +% % Is it the right place for this source code ???? +% % -------------------------------------------------------- +% if qualityCode ~= -1 +% +% % Retrieve named application data - Code could have been changed +% % -------------------------------------------------------------- +% tsg = getappdata( hMainFig, 'tsg_data'); +% +% tsg.SSPS_QC(ind) = tsg.qc.Code.ACTIVE; +% +% % Save the modifications +% % ---------------------- +% setappdata( hMainFig, 'tsg_data', tsg); +% +% axes(hPlotAxes(1)); +% hold on +% color = ['.' tsg.qc.Color.ACTIVE]; +% plot(tsg.DAYD(ind), tsg.SSPS(ind), color ); +% hold off +% +% end +% end +% end + + %---------------------------------------------------------------------- + % Callback function run when the QC context menu is selected + %--------------------------------------------------------------------- + function Qc(hObject, eventdata) % Retrieve Default Quality Code and Color % --------------------------------------- @@ -722,9 +825,10 @@ tsg_initialisation(hMainFig, hQcCmenu) % uiwait in the QCMenuCallback function % ------------------------------------- uiresume - end + end -%--------------------------------------------------------------------- + %--------------------------------------------------------------------- + %--------------------------------------------------------------------- function MouseMotion(hObject, eventdata) % Test if the callback can be activated @@ -788,19 +892,28 @@ tsg_initialisation(hMainFig, hQcCmenu) end end -%--------------------------------------------------------------------- - function MapMenuCallback(hObject, eventdata) - % Callback function run when the Map tool bar item is selected - % Make the earth map visible or not + %--------------------------------------------------------------------- + % Callback function run when the Map tool bar item is unselected + %--------------------------------------------------------------------- + function Map_OffMenuCallback(hObject, eventdata) + + % Make the earth map invisible + % ---------------------------- + set(hMapPanel, 'Visible', 'off' ); + end - if strcmp( get(hMapPanel, 'Visible'), 'off' ) - set(hMapPanel, 'Visible', 'on' ); - else - set(hMapPanel, 'Visible', 'off' ); - end + %--------------------------------------------------------------------- + % Callback function run when the Map tool bar item is selected + %--------------------------------------------------------------------- + function Map_OnMenuCallback(hObject, eventdata) + + % Make the earth map visible + % -------------------------- + set(hMapPanel, 'Visible', 'on' ); end -%--------------------------------------------------------------------- + %--------------------------------------------------------------------- + %--------------------------------------------------------------------- function BottleMenuCallback(hObject, eventdata) % Callback function run when the Bottle tool bar item is selected @@ -861,157 +974,157 @@ tsg_initialisation(hMainFig, hQcCmenu) % end end -%--------------------------------------------------------------------- - function ClimMenuCallback(hObject, eventdata) - % Callback function run when the ClimMenu menu item is selected - % - % Plot or delete salinity climatology over Salinity plot - % - % Function to be written - - % Test if the climatology Push button has been pressed - % ---------------------------------------------------- - if strcmp( get(hClimPushtool, 'UserData'), 'off') - - % Climatology push button - UserData set to 'on' - % ----------------------------------------- - set( hClimPushtool, 'UserData', 'on' ); - - - % Test if the TSG and bucket files have been read - % ----------------------------------------------- - if strcmp( get(hOpenMenu, 'UserData'), 'on' ) - - % Get data - % ----------------------- - tsg = getappdata( hMainFig, 'tsg_data' ); - hLine1 = get( hPlotAxes(1), 'UserData'); - hLine2 = get( hPlotAxes(2), 'UserData'); - - % Read Climatology - % ---------------- - if isempty( tsg.levitus.data) - levitus = read_file_woa01( 'woa01an.nc' ); - if ~isstruct(levitus) - errordlg({'NetCDF climatology file not present in you path',... - 'Check your matlab path or download it from',... - 'ftp://ftp.ifremer.fr/ifremer/ird/us191/oceano/lib/matlab/woa01an.nc'},... - 'NetCDF climatology file access error'); - return; - else - tsg.levitus.data = levitus; - tsg.levitus.type = 'woa01an'; - end - setappdata( hMainFig, 'tsg_data', tsg ); - end + %------------------------------------------------------------------------ + % Callback function run when the Levitus climatology toolbar is unselected + %------------------------------------------------------------------------ + function Clim_OffMenuCallback(hObject, eventdata) - % round positive latitude and Longitude toward zero - % ------------------------------------------------- - ind = find(tsg.LATX > 0); - lat(ind) = fix(tsg.LATX(ind)) + 0.5; - - ind = find(tsg.LONX > 0); - lon(ind) = fix(tsg.LONX(ind)) + 0.5; - - % rounds negative latitude and Longitudeto the nearest lowest integers - % --------------------------------------------------------------------- - ind = find(tsg.LATX <= 0); - lat(ind) = floor(tsg.LATX(ind)) + 0.5; - - ind = find(tsg.LONX <= 0); - lon(ind) = floor(tsg.LONX(ind)) + 0.5; - - % Calculates differences between adjacent elements of X. - % 0 if adajacent latitude or longitude are equal - % - 1 or -1 otherwise - % ------------------------------------------------------------ - lat_diff = [diff( lat )'; 0]; - lon_diff = [diff( lon )'; 0]; - - % Select latitude and longitude - % ----------------------------- - ind = find(abs(lat_diff) == 1 | abs(lon_diff == 1)); - lat2 = lat( ind ); - lon2 = lon( ind ); - time = tsg.DAYD( ind ); - temp = tsg.SSJT( ind ); - psal = tsg.SSPS( ind ); - - % Get Climatology - % LATX(80) = -0.5 et LATX(81) = 0.5 - % LONX(180) = -0.5 et LONX(181) = 0.5 - % ---------------- - axes( hPlotAxes(1) ); - mean_temp = zeros(size(ind)); - mean_psal = zeros(size(ind)); - std_temp = zeros(size(ind)); - std_psal = zeros(size(ind)); - for i=1:length(ind) - ilat = find(tsg.levitus.data.WOA01_LATX == lat2(i)); - ilon = find(tsg.levitus.data.WOA01_LONX == lon2(i)); - mean_temp(i) = tsg.levitus.data.WOA01_MEAN_TEMP(ilat,ilon,1); - mean_psal(i) = tsg.levitus.data.WOA01_MEAN_PSAL(ilat,ilon,1); - std_temp(i) = tsg.levitus.data.WOA01_STD_TEMP(ilat,ilon,1); - std_psal(i) = tsg.levitus.data.WOA01_STD_PSAL(ilat,ilon,1); - end + % Get line handles + % ---------------------------------------------- + hLine1 = get( hPlotAxes(1), 'UserData'); + hLine2 = get( hPlotAxes(2), 'UserData'); + + % Delete climatology linesthe on axes + % ----------------------------------- + try + delete(hLine1.stdClimMinus); + delete(hLine1.stdClimPlus); + delete(hLine1.meanClim); + delete(hLine2.stdClimMinus); + delete(hLine2.stdClimPlus); + delete(hLine2.meanClim); + catch + end + end - % Plot mean salinity climatology - hLine1.meanClim = line( ... - time, mean_psal,'Linestyle', '-', 'Color','k'); - % Plot 2 standard deviation - hLine1.stdClimPlus = line( ... - time, mean_psal + 3 * std_psal ,'Linestyle', '-', 'Color','r'); - hLine1.stdClimMinus = line( ... - time, mean_psal - 3 * std_psal ,'Linestyle', '-', 'Color','r'); - % Plot mean temperature climatology - axes( hPlotAxes(2)); - hLine2.meanClim = line( ... - time, mean_temp,'Linestyle', '-', 'Color','k'); - hLine2.stdClimPlus = line( ... - time, mean_temp + 3 * std_temp ,'Linestyle', '-', 'Color','r'); - hLine2.stdClimMinus = line( ... - time, mean_temp - 3 * std_temp ,'Linestyle', '-', 'Color','r'); - - % Store the handle of the bucketline - % ---------------------------------- - set( hPlotAxes(1), 'UserData', hLine1 ); - set( hPlotAxes(2), 'UserData', hLine2 ); - end + %------------------------------------------------------------------------ + % Callback function run when the Levitus climatology toolbar is unselected + %------------------------------------------------------------------------ + function Clim_OnMenuCallback(hObject, eventdata) - else + % Test if the TSG and bucket files have been read + % ----------------------------------------------- + if strcmp( get(hOpenMenu, 'UserData'), 'on' ) - set( hClimPushtool, 'UserData', 'off' ); + % Get data + % ----------------------- + tsg = getappdata( hMainFig, 'tsg_data' ); - % The bucket pushbutton has been pressed again : - % Delete the bucket on figure - % ---------------------------------------------- + % Get line handles + % ---------------- hLine1 = get( hPlotAxes(1), 'UserData'); hLine2 = get( hPlotAxes(2), 'UserData'); - % bug...... - try - delete(hLine1.stdClimMinus); - delete(hLine1.stdClimPlus); - delete(hLine1.meanClim); - delete(hLine2.stdClimMinus); - delete(hLine2.stdClimPlus); - delete(hLine2.meanClim); - catch + + % Read Climatology + % ---------------- + if isempty( tsg.levitus.data) + levitus = read_file_woa01( 'woa01an.nc' ); + if ~isstruct(levitus) + errordlg({'NetCDF climatology file not present in you path',... + 'Check your matlab path or download it from',... + 'ftp://ftp.ifremer.fr/ifremer/ird/us191/oceano/lib/matlab/woa01an.nc'},... + 'NetCDF climatology file access error'); + return; + else + tsg.levitus.data = levitus; + tsg.levitus.type = 'woa01an'; + end + setappdata( hMainFig, 'tsg_data', tsg ); + end + + % round positive latitude and Longitude toward zero + % ------------------------------------------------- + ind = find(tsg.LATX > 0); + lat(ind) = fix(tsg.LATX(ind)) + 0.5; + + ind = find(tsg.LONX > 0); + lon(ind) = fix(tsg.LONX(ind)) + 0.5; + + % rounds negative latitude and Longitudeto the nearest lowest integers + % --------------------------------------------------------------------- + ind = find(tsg.LATX <= 0); + lat(ind) = floor(tsg.LATX(ind)) + 0.5; + + ind = find(tsg.LONX <= 0); + lon(ind) = floor(tsg.LONX(ind)) + 0.5; + + % Calculates differences between adjacent elements of X. + % 0 if adajacent latitude or longitude are equal + % - 1 or -1 otherwise + % ------------------------------------------------------------ + lat_diff = [diff( lat )'; 0]; + lon_diff = [diff( lon )'; 0]; + + % Select latitude and longitude + % ----------------------------- + ind = find(abs(lat_diff) == 1 | abs(lon_diff == 1)); + lat2 = lat( ind ); + lon2 = lon( ind ); + time = tsg.DAYD( ind ); + temp = tsg.SSJT( ind ); + psal = tsg.SSPS( ind ); + + % Get Climatology + % LATX(80) = -0.5 et LATX(81) = 0.5 + % LONX(180) = -0.5 et LONX(181) = 0.5 + % ---------------- + axes( hPlotAxes(1) ); + mean_temp = zeros(size(ind)); + mean_psal = zeros(size(ind)); + std_temp = zeros(size(ind)); + std_psal = zeros(size(ind)); + for i=1:length(ind) + ilat = find(tsg.levitus.data.WOA01_LATX == lat2(i)); + ilon = find(tsg.levitus.data.WOA01_LONX == lon2(i)); + mean_temp(i) = tsg.levitus.data.WOA01_MEAN_TEMP(ilat,ilon,1); + mean_psal(i) = tsg.levitus.data.WOA01_MEAN_PSAL(ilat,ilon,1); + std_temp(i) = tsg.levitus.data.WOA01_STD_TEMP(ilat,ilon,1); + std_psal(i) = tsg.levitus.data.WOA01_STD_PSAL(ilat,ilon,1); end + + % Plot mean salinity climatology + % ------------------------------ + hLine1.meanClim = line( ... + time, mean_psal,'Linestyle', '-', 'Color','k'); + + % Plot with 3 standard deviation + % ------------------------------ + hLine1.stdClimPlus = line( ... + time, mean_psal + 3 * std_psal ,'Linestyle', '-', 'Color','r'); + hLine1.stdClimMinus = line( ... + time, mean_psal - 3 * std_psal ,'Linestyle', '-', 'Color','r'); + + % Plot mean temperature climatology + % --------------------------------- + axes( hPlotAxes(2)); + hLine2.meanClim = line( ... + time, mean_temp,'Linestyle', '-', 'Color','k'); + hLine2.stdClimPlus = line( ... + time, mean_temp + 3 * std_temp ,'Linestyle', '-', 'Color','r'); + hLine2.stdClimMinus = line( ... + time, mean_temp - 3 * std_temp ,'Linestyle', '-', 'Color','r'); + + % Store the handle of the bucketline + % ---------------------------------- + set( hPlotAxes(1), 'UserData', hLine1 ); + set( hPlotAxes(2), 'UserData', hLine2 ); end end -% ------------------------------------------------------------------- + % ------------------------------------------------------------------- + % Callback function run when the headerForm tool bar item is selected + % ------------------------------------------------------------------- function HeaderMenuCallback(hObject, eventdata) - % Callback function run when the headerForm tool bar item is selected - + % call header form function % ------------------------- headerForm(hMainFig); end -% ------------------------------------------------------------------- + % ------------------------------------------------------------------- + % Callback function run when the Save menu item is selected + % ------------------------------------------------------------------- function SaveMenuCallback(hObject, eventdata) - % Callback function run when the Save menu item is selected % Retrieve named application data % ------------------------------- @@ -1073,9 +1186,10 @@ tsg_initialisation(hMainFig, hQcCmenu) end -% ----------------------------------------------------------------- - function QuitMenuCallback(hObject, eventdata) - % Callback function run when the Quit menu item is selected + % ----------------------------------------------------------------- + % Callback function run when the Quit menu item is selected + % ----------------------------------------------------------------- + function QuitMenuCallback(hObject, eventdata) % If the data have been modified and not save, the program % ask to save the data @@ -1104,7 +1218,8 @@ tsg_initialisation(hMainFig, hQcCmenu) end -% ---------------------------------------------------------------- + % ----------------------------------------------------------------- + % ----------------------------------------------------------------- function QuitProgram(hObject, eventdata) % needed during QC operation if waitbuttonpress is active