Newer
Older
% Draw the 3 plots of the validation figure
% -----------------------------------------
plot_Validation( hMainFig, hPlotAxes, 1, PARA );
plot_Validation( hMainFig, hPlotAxes, 2, 'SSJT' );
plot_Validation( hMainFig, hPlotAxes, 3, 'SPDC' );
% Draw the map with the ship track
% --------------------------------
% The callback to detect the mouse motion can be set to on
% --------------------------------------------------------
set( hMainFig, 'UserData', 'ButtonMotionOn');
% Hide handles marked as hidden with HandleVisibility property set to
% callback or off
% -------------------------------------------------------------------
set(0, 'ShowHiddenHandles', 'off');
end
%% *************************** CALLBACKS **********************************
%% OpenMenuCallback

jacques.grelet_ird.fr
committed
%----------------------------------------------------------------------
% Callback function run when the Open menu item is selected
%----------------------------------------------------------------------

jacques.grelet_ird.fr
committed
function OpenMenuCallback(hObject, eventdata)
Yves Gouriou
committed
% Activate or desactivate uipanels
% --------------------------------
set( hpCalCoef, 'Visible', 'off' );
set( hpDateLimit, 'Visible', 'off' );
set( hpInterpPos, 'Visible', 'off' );
% set( hbgParameter, 'Visible', 'off');
set( hBottleToggletool, 'state', 'off' );
set( hCalToggletool, 'state', 'off' );
set( hInterpToggletool, 'state', 'off' );
set( hPanToggletool, 'state', 'off' );
set( hQCToggletool, 'state', 'off' );
set( hTimelimitToggletool, 'state', 'off' );
set( hZoomToggletool, 'state', 'off' );
set( hHeaderPushtool, 'enable', 'off' );
Yves Gouriou
committed

jacques.grelet_ird.fr
committed
% Open standard dialog box for retrieving files
% ---------------------------------------------

jacques.grelet_ird.fr
committed
[fileName, pathname, filterIndex] = uigetfile( ...
Yves Gouriou
committed
{'*.txt';'*.xml';'*.nc';'*.lbv';'*.btl'; '*.arg'}, 'Pick a file');

jacques.grelet_ird.fr
committed

jacques.grelet_ird.fr
committed
% flushes the event queue and updates the closed uigetfile window
% ---------------------------------------------------------------
drawnow;

jacques.grelet_ird.fr
committed
% if the user clicks the Cancel button or closes the dialog window,
% FileName and PathName are set to 0.
% -----------------------------------------------------------------

jacques.grelet_ird.fr
committed
if ~isequal(fileName, 0)
% Pointer set to watch during reading and plotting
% ------------------------------------------------
set( hMainFig, 'Pointer', 'watch' );
% construct valid and full file path
% -----------------------------------

jacques.grelet_ird.fr
committed
fullFileName = strcat(pathname, fileName);

jacques.grelet_ird.fr
committed
% Read the data
% -------------
errTsg = -2;
errSpl = -2;

jacques.grelet_ird.fr
committed
switch filterIndex
case 1 % read TSG text file *.txt
errTsg = readTsgDataTxt( hMainFig, fullFileName );
case 2 % read TSG XML file *.xml
errTsg = readTsgDataXML( hMainFig, fullFileName );
case 3 % read TSG netcdf file *.nc
errTsg = readTsgDataNetCDF( hMainFig, fullFileName );
case 4 % read TSG labview file *.lbv
tsg_initialisation(hMainFig);
errTsg = readTsgDataLabview( hMainFig, fullFileName );
case 5 % Read bucket file *.btl
errSpl = readBucketData( hMainFig, fullFileName );
else
msgbox( 'Load a TSG file before a Water sample file', 'Read Bucket');
end
case 6 % Read Argo file *.arg (G. Reverdin format)
errSpl = readCoriolisData( hMainFig, fullFileName );
else
msgbox( 'Load a TSG file before a Water sample file', 'Read Bucket');
end

jacques.grelet_ird.fr
committed
otherwise
return;
end % switch filterIndex
% Get the tsg structure
% ---------------------
tsg = getappdata( hMainFig, 'tsg_data');
% Default parameter
% -----------------
PARA = tsg.preference.parameter;

jacques.grelet_ird.fr
committed
% A TSG file has been read
% ------------------------
if errTsg > 0
% set WindowButtonMotionFcn on
% ----------------------------
set( hMainFig, 'WindowButtonMotionFcn', @MouseMotion);

jacques.grelet_ird.fr
committed
% A TSG file has been open and read
% ---------------------------------
set( hOpenMenu, 'UserData', 'on' );

jacques.grelet_ird.fr
committed

jacques.grelet_ird.fr
committed
% enable toolbar menu pushtool
% ----------------------------

jacques.grelet_ird.fr
committed
hdl_pushtool = findobj('-regexp','Tag', 'PUSHTOOL_');
set(hdl_pushtool, 'Enable', 'on');
set( hbgParameter, 'Visible', 'on');
% enable Save menu
% ----------------
set(hSaveMenu, 'Enable', 'on');

jacques.grelet_ird.fr
committed
% update some fields in tsg structure and restore tsg
% ---------------------------------------------------
Yves Gouriou
committed
% update the filename display
% ---------------------------
set( hInfoFileText, 'String', strcat(tsg.file.name, tsg.file.ext));
Yves Gouriou
committed
% The smooth TSG time series (tsg_moveaverage) is
% no more computed : too long
% We now computed a smooth value only at the position of the sample
% in diffTsgSample
% -----------------------------------------------------------------
%tsg_moveaverage(hMainFig, PARA);

jacques.grelet_ird.fr
committed
% The callback to detect the mouse motion can be set to on
% --------------------------------------------------------
set( hMainFig, 'UserData', 'ButtonMotionOn');
% Update QC statistics
% --------------------

jacques.grelet_ird.fr
committed
display_QC( hMainFig, hPlotAxes);
elseif errTsg > -2
% Problem to read the file or
% Choice of parameters for Labview file canceled by the user
% TSG structure has been reinitialize
% Disable toolbar menu pushtool except the open file button
% ----------------------------------------------------------
hdl_pushtool = findobj('-regexp','Tag', 'PUSHTOOL_');
set(hdl_pushtool, 'Enable', 'off');
set( hOpenPushtool, 'Enable', 'on' );
end %if errTsg > 0
% Merge sample from different origins : WS and EXT
% ------------------------------------------------
tsg_mergesample( hMainFig, PARA );

jacques.grelet_ird.fr
committed
end % if ~isequal(fileName, 0)
% Draw the 3 plots of the validation figure
% -----------------------------------------
plot_Validation( hMainFig, hPlotAxes, 1, PARA );
plot_Validation( hMainFig, hPlotAxes, 2, 'SSJT' );
plot_Validation( hMainFig, hPlotAxes, 3, 'SPDC' );

jacques.grelet_ird.fr
committed
% Pointer reset to arrow
% ----------------------
set( hMainFig, 'Pointer', 'arrow' );
end
%% Inter_OnMenuCallback ................................... Interpolation
%----------------------------------------------------------------------
% Callback function run when
%
function Inter_OnMenuCallback( hObject, eventdata)
% Activate or desactivate uipanels
% --------------------------------
set( hpDateLimit, 'Visible', 'on' );
set( hpInterpPos, 'Visible', 'on' );
set( hpCalCoef, 'Visible', 'off');
set( hbgQc, 'Visible', 'off');
set( hbgParameter, 'Visible', 'off');
set( hBottleToggletool, 'state', 'off', 'enable', 'off');
set( hCalToggletool, 'state', 'off', 'enable', 'off');
set( hClimToggletool, 'state', 'off', 'enable', 'off');
set( hPanToggletool, 'state', 'off', 'enable', 'on' );
set( hQCToggletool, 'enable', 'off');
set( hTimelimitToggletool, 'state', 'off', 'enable', 'on' );
set( hZoomToggletool, 'state', 'off', 'enable', 'on' );
% Get application data TSG
% ------------------------
tsg = getappdata( hMainFig, 'tsg_data');
% Get the information on time limits of the time series
% Write them in the uipanel
% -----------------------------------------------------
noNaN = tsg.DAYD(~isnan( tsg.DAYD ));
set( hetDateMin, 'String', datestr(noNaN(1), 31));
set( hetDateMax, 'String', datestr(noNaN(end), 31));
% Draw the 3 plots of the interpolation figure
% --------------------------------------------
plot_Interpolation( hMainFig, hPlotAxes, 1 );
plot_Interpolation( hMainFig, hPlotAxes, 2 );
plot_Interpolation( hMainFig, hPlotAxes, 3 );
end
%% Inter_OffMenuCallback .................................. Interpolation
%----------------------------------------------------------------------
% Callback function run when
%
function Inter_OffMenuCallback( hObject, eventdata)
% Activate or desactivate uipanels
% --------------------------------
set( hpCalCoef, 'Visible', 'off' );
set( hpDateLimit, 'Visible', 'off' );
set( hbgParameter, 'Visible', 'on' );
% Enable Pushbuttons
% ------------------
set( hBottleToggletool, 'state', 'off', 'enable', 'on' );
set( hCalToggletool, 'state', 'off', 'enable', 'on' );
set( hClimToggletool, 'state', 'off', 'enable', 'on' );
set( hPanToggletool, 'state', 'off', 'enable', 'on' );
set( hQCToggletool, 'state', 'off', 'enable', 'on' );
set( hTimelimitToggletool, 'state', 'off', 'enable', 'off' );
set( hZoomToggletool, 'state', 'off', 'enable', 'on' );
% Get tsg structure
% -----------------
tsg = getappdata( hMainFig, 'tsg_data' );
% Draw the 3 plots of the validation figure
% -----------------------------------------
plot_Validation( hMainFig, hPlotAxes, 1, tsg.preference.parameter );
plot_Validation( hMainFig, hPlotAxes, 2, 'SSJT' );
plot_Validation( hMainFig, hPlotAxes, 3, 'SPDC' );
% Set the pointer
% ---------------
set( hMainFig, 'Pointer', 'arrow');
end
%% InterpLinearCallback ...............................Interpolation Linear
%------------------------------------------------------------------------
% Callback function run when
%----------------------------------------------------------------------
function InterpPosLinearCallback( hObject, eventdata)
% Get the time limits for the correction A TESTER
% --------------------------------------
dateMin = datenum(get( hetDateMin, 'String'), 'yyyy-mm-dd HH:MM:SS');
dateMax = datenum(get( hetDateMax, 'String'), 'yyyy-mm-dd HH:MM:SS');
error = interpPosLinear( hMainFig, dateMin, dateMax );
switch error
case 1
% Plot in the 3 axes
% ------------------
plot_Interpolation( hMainFig, hPlotAxes, 2 );
plot_Interpolation( hMainFig, hPlotAxes, 3 );
case -1
msgbox( 'Date limits are not correct',...
'Correction module', 'warn', 'modal');
end
end
%% InterpOtherCallback ...............................Interpolation OTher
%----------------------------------------------------------------------
% Callback function run when
%----------------------------------------------------------------------
function InterpPosOtherCallback( hObject, eventdata)
msgbox( 'Method not yet implemented', ...
'Function InterpOtherCallback', ...
'warn',...
'modal' );
end
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
%% InterpPosCancelCallback ..........................Cancel Interpolation
%----------------------------------------------------------------------
function InterpPosCancelCallback(hObject, eventdata)
% Callback function run when
% Get tsg application data
% ------------------------
tsg = getappdata( hMainFig, 'tsg_data' );
% Get NO_CONTROL and INTERPOLATED_VALUE codes
% -------------------------------------------
NO_CONTROL = get(tsg.qc.hash, 'NO_CONTROL', 'code');
INTERPOLATED_VALUE = get(tsg.qc.hash, 'INTERPOLATED_VALUE', 'code');
if ~isempty( tsg.POSITION_QC )
iINTERP = find( tsg.POSITION_QC == INTERPOLATED_VALUE);
tsg.LATX( iINTERP ) = NaN * ones( size( iINTERP), 1 );
tsg.LONX( iINTERP ) = NaN * ones( size( iINTERP), 1 );
tsg.POSITION_QC = [];
end
% Save tsg application data
% --------------------------
setappdata( hMainFig, 'tsg_data', tsg );
% Refresh plots
% -------------
plot_Interpolation( hMainFig, hPlotAxes, 1 );
plot_Interpolation( hMainFig, hPlotAxes, 2 );
plot_Interpolation( hMainFig, hPlotAxes, 3 );
end
%% Cal_OnMenuCallback ..................................... Calibration
%----------------------------------------------------------------------
% Callback function run when
%----------------------------------------------------------------------
function Cal_OnMenuCallback( hObject, eventdata)
% Activate or desactivate uipanels
% --------------------------------
set( hpCalCoef, 'Visible', 'on' );
set( hbgParameter, 'Visible', 'off');
set( hbgQc, 'Visible', 'off');
set( hQCToggletool, 'enable', 'off' );
set( hClimToggletool, 'enable', 'off' );
set( hBottleToggletool, 'enable', 'off' );
set( hHeaderPushtool, 'enable', 'off' );
set( hPanToggletool, 'state', 'off', 'enable', 'on' );
set( hTimelimitToggletool, 'state', 'off', 'enable', 'off' );
set( hZoomToggletool, 'state', 'off', 'enable', 'on' );
% Get tsg application data
% ------------------------
tsg = getappdata( hMainFig, 'tsg_data' );
% pour test
tsg.SSTP = [];
setappdata( hMainFig, 'tsg_data', tsg );
% Draw the 3 plots of the validation figure
% -----------------------------------------
plot_Calibration( hMainFig, hPlotAxes, 1, 'SSPS' );
plot_Calibration( hMainFig, hPlotAxes, 2, 'SSJT' );
plot_Calibration( hMainFig, hPlotAxes, 3, 'SSTP' );
% Write the Cal Coef in the Editable uicontrol
% --------------------------------------------
set( hetCalCNDCSlope, 'String', num2str(tsg.CNDC_LINCOEF(1)));
set( hetCalCNDCOffset, 'String', num2str(tsg.CNDC_LINCOEF(2)));
set( hetCalSSJTSlope, 'String', num2str(tsg.SSJT_LINCOEF(1)));
set( hetCalSSJTOffset, 'String', num2str(tsg.SSJT_LINCOEF(2)));
set( hetCalSSTPSlope, 'String', num2str(tsg.SSTP_LINCOEF(1)));
set( hetCalSSTPOffset, 'String', num2str(tsg.SSTP_LINCOEF(2)));
end
%% Cal_OffMenuCallback ..................................... Calibration
%----------------------------------------------------------------------
% Callback function run when
%----------------------------------------------------------------------
function Cal_OffMenuCallback( hObject, eventdata)
% Activate or desactivate uipanels
% --------------------------------
set( hpCalCoef, 'Visible', 'off' );
set( hbgParameter, 'Visible', 'on');
% Enable Pushbuttons
% ------------------
set( hClimToggletool, 'enable', 'on' );
set( hBottleToggletool, 'enable', 'on' );
set( hHeaderPushtool, 'enable', 'on' );
set( hQCToggletool, 'state', 'off', 'enable', 'on' );
set( hPanToggletool, 'state', 'off', 'enable', 'on' );
set( hTimelimitToggletool, 'state', 'off', 'enable', 'on' );
set( hZoomToggletool, 'state', 'off', 'enable', 'on' );
% Get tsg application data
% ------------------------
tsg = getappdata( hMainFig, 'tsg_data' );
% Save the calibration coefficient
% --------------------------------
tsg.CNDC_LINCOEF(1) = str2num(get( hetCalCNDCSlope, 'String'));
tsg.CNDC_LINCOEF(2) = str2num(get( hetCalCNDCOffset, 'String'));
tsg.SSJT_LINCOEF(1) = str2num(get( hetCalSSJTSlope, 'String'));
tsg.SSJT_LINCOEF(2) = str2num(get( hetCalSSJTOffset, 'String'));
tsg.SSTP_LINCOEF(1) = str2num(get( hetCalSSTPSlope, 'String'));
tsg.SSTP_LINCOEF(2) = str2num(get( hetCalSSTPOffset, 'String'));
% Save tsg application data
% --------------------------
setappdata( hMainFig, 'tsg_data', tsg );
% Draw the 3 plots of the validation figure
% -----------------------------------------
plot_Validation( hMainFig, hPlotAxes, 1, tsg.preference.parameter );
plot_Validation( hMainFig, hPlotAxes, 2, 'SSJT' );
plot_Validation( hMainFig, hPlotAxes, 3, 'SPDC' );
%% CalibrateCallback .......................................... Calibration
function CalibrateCallback(hObject, eventdata)
% Callback function run when
% Get tsg application data
% ------------------------
tsg = getappdata( hMainFig, 'tsg_data' );
% Get the calibration coefficients.
% They will be used in the function calibration
% ---------------------------------------------
tsg.CNDC_LINCOEF(1) = str2num(get( hetCalCNDCSlope, 'String'));
tsg.CNDC_LINCOEF(2) = str2num(get( hetCalCNDCOffset, 'String'));
tsg.SSJT_LINCOEF(1) = str2num(get( hetCalSSJTSlope, 'String'));
tsg.SSJT_LINCOEF(2) = str2num(get( hetCalSSJTOffset, 'String'));
tsg.SSTP_LINCOEF(1) = str2num(get( hetCalSSTPSlope, 'String'));
tsg.SSTP_LINCOEF(2) = str2num(get( hetCalSSTPOffset, 'String'));
% Save tsg application data
% --------------------------
setappdata( hMainFig, 'tsg_data', tsg );
% Calibrate the sensors
% ---------------------
calibration( hMainFig );
% Update the Adjusted variables (SSPS - SSJT) with calibrated records
% -------------------------------------------------------------------
updateAdjustedVariable( hMainFig );
% Refresh plot #1
% ---------------
plot_Calibration( hMainFig, hPlotAxes, 1, 'SSPS' );
plot_Calibration( hMainFig, hPlotAxes, 2, 'SSJT' );
plot_Calibration( hMainFig, hPlotAxes, 3, 'SSTP' );
% As soon as a modification took place the data should be saved
% -------------------------------------------------------------
set( hSaveMenu, 'UserData', 'on' );
end
%% CancelCalibrationCallback .................................. Calibration
function CancelCalibrationCallback(hObject, eventdata)
% Callback function run when
% Get tsg application data
% ------------------------
tsg = getappdata( hMainFig, 'tsg_data' );
tsg.SSPS_CAL = [];
tsg.SSJT_CAL = [];
% Save tsg application data
% --------------------------
setappdata( hMainFig, 'tsg_data', tsg );
% Update the Adjusted variables (SSPS - SSJT) with calibrated records
% -------------------------------------------------------------------
updateAdjustedVariable( hMainFig );
% Refresh plot #1
% ---------------
plot_Calibration( hMainFig, hPlotAxes, 1, 'SSPS' );
plot_Calibration( hMainFig, hPlotAxes, 2, 'SSJT' );
plot_Calibration( hMainFig, hPlotAxes, 3, 'SSTP' );
% As soon as a modification took place the data should be saved
% -------------------------------------------------------------
set( hSaveMenu, 'UserData', 'on' );
end
%% Zoom_OffMenuCallback
%----------------------------------------------------------------------

jacques.grelet_ird.fr
committed
% Callback function run when the zoom toggle toolbar is released

jacques.grelet_ird.fr
committed
%----------------------------------------------------------------------

jacques.grelet_ird.fr
committed
function Zoom_OffMenuCallback(hObject, eventdata)
% turns interactive zooming off
% -----------------------------
zoom off;
% Set the right limit and interval to the 3 axes
% ----------------------------------------------
for iaxe = 1:3
set(hPlotAxes(iaxe),'XTickMode','auto')
datetick(hPlotAxes(iaxe),'x','keeplimits')
end

jacques.grelet_ird.fr
committed

jacques.grelet_ird.fr
committed
% Turns off the automatic adaptation of date ticks
% ------------------------------------------------
zoomAdaptiveDateTicks('off');

jacques.grelet_ird.fr
committed
end

jacques.grelet_ird.fr
committed
%% Zoom_OnMenuCallback

jacques.grelet_ird.fr
committed
%----------------------------------------------------------------------
% Callback function run when the zoom toggle toolbar is released
%----------------------------------------------------------------------
function Zoom_OnMenuCallback(hObject, eventdata)
% cursor back to normal
% ---------------------
set(hMainFig,'Pointer','arrow');

jacques.grelet_ird.fr
committed
% returns a zoom mode object for the figure hMainFig handle
% --------------------------------------------------------

jacques.grelet_ird.fr
committed
hZoom = zoom(hMainFig);

jacques.grelet_ird.fr
committed
% Disallows a zoom operation on the MAP axes objects
% --------------------------------------------------
setAllowAxesZoom(hZoom, hPlotAxes(4), false);

jacques.grelet_ird.fr
committed
% turns on interactive zooming (same effect than zoom on) but prevent
% side effect on another figure
% -------------------------------------------------------------------
set(hZoom,'enable', 'on');

jacques.grelet_ird.fr
committed
%zoom on;

jacques.grelet_ird.fr
committed
% Turns on the automatic adaptation of date ticks
% -----------------------------------------------
zoomAdaptiveDateTicks('on');
% Desactivate some toggle buttons
% -------------------------------
set( hQCToggletool, 'state', 'off' );
set( hPanToggletool, 'state', 'off' );
set( hTimelimitToggletool, 'state', 'off' );

jacques.grelet_ird.fr
committed
end
%% Pan_OffMenuCallback

jacques.grelet_ird.fr
committed
%----------------------------------------------------------------------

jacques.grelet_ird.fr
committed
% Callback function run when the pan toggle toolbar is released

jacques.grelet_ird.fr
committed
%----------------------------------------------------------------------

jacques.grelet_ird.fr
committed
function Pan_OffMenuCallback(hObject, eventdata)
% turns interactive pan off
% -------------------------
pan off;
% Set the right limit and interval to the 3 axes
% ----------------------------------------------
for iaxe = 1:3
set(hPlotAxes(iaxe),'XTickMode','auto')
datetick(hPlotAxes(iaxe),'x','keeplimits')
end

jacques.grelet_ird.fr
committed
% Turns off the automatic adaptation of date ticks
% ------------------------------------------------
panAdaptiveDateTicks('off');

jacques.grelet_ird.fr
committed
end

jacques.grelet_ird.fr
committed
%% Pan_OnMenuCallback

jacques.grelet_ird.fr
committed
%----------------------------------------------------------------------
% Callback function run when the pan toggle toolbar is selected
%----------------------------------------------------------------------
function Pan_OnMenuCallback(hObject, eventdata)
% cursor back to normal
% ---------------------
set(hMainFig,'Pointer','arrow');

jacques.grelet_ird.fr
committed
% Returns a pan mode object for the figure handle

jacques.grelet_ird.fr
committed
% -----------------------------------------------

jacques.grelet_ird.fr
committed
hPan = pan(hMainFig);

jacques.grelet_ird.fr
committed
% Disallows a pan operation on the MAP axes objects
% --------------------------------------------------
setAllowAxesPan(hPan, hPlotAxes(4), false);

jacques.grelet_ird.fr
committed
% turns on interactive pan (same effect than pan on) but prevent
% side effect on another figure
% --------------------------------------------------------------

jacques.grelet_ird.fr
committed
set(hPan,'enable', 'on');
% Turns on the automatic adaptation of date ticks
% -----------------------------------------------
panAdaptiveDateTicks('on');
% Desactivate some toggle buttons
% -------------------------------
set( hQCToggletool, 'state', 'off' );
set( hZoomToggletool, 'state', 'off' );
set( hTimelimitToggletool, 'state', 'off' );

jacques.grelet_ird.fr
committed
end

jacques.grelet_ird.fr
committed
%% QC_OnMenuCallback ............................... Quality Control Module

jacques.grelet_ird.fr
committed
%----------------------------------------------------------------------

jacques.grelet_ird.fr
committed
% Callback function run when the QC toggle tool is pressed

jacques.grelet_ird.fr
committed
%----------------------------------------------------------------------
function QC_OnMenuCallback(gcbo, eventdata)
PARA = tsg.preference.parameter;
% Make the QC code uipanel visible
% --------------------------------
set( hbgQc, 'Visible' ,'on');
set( hbgParameter, 'Visible', 'off');
% Desactivate toggletools.
% ------------------------
set( hZoomToggletool, 'state', 'off' );
set( hPanToggletool, 'state', 'off' );
set( hTimelimitToggletool, 'state', 'off' );
set( hCalToggletool, 'state', 'off' );

jacques.grelet_ird.fr
committed
% Activate right clic context menu on first axes (salinity)
% ---------------------------------------------------------

jacques.grelet_ird.fr
committed
% Activate clic mouse menu on first axes (salinity) for next rbbox
% ----------------------------------------------------------------
set(hPlotAxes(1),'ButtonDownFcn', @QC_SelectCallback);

jacques.grelet_ird.fr
committed
% change cursor to crosshair aspect
% ---------------------------------

jacques.grelet_ird.fr
committed
set( hMainFig, 'Pointer', 'crosshair');

jacques.grelet_ird.fr
committed

jacques.grelet_ird.fr
committed
% -------------------------------------------------------------

jacques.grelet_ird.fr
committed
% nested function on mouse clic when QC toggle tool is selected

jacques.grelet_ird.fr
committed
% -------------------------------------------------------------
function QC_SelectCallback(gcbo, eventdata)
% disable ButtonMotion on main fig during select

jacques.grelet_ird.fr
committed
% prevent drawing to map
% ----------------------------------------------
set( hMainFig, 'WindowButtonMotionFcn', []);

jacques.grelet_ird.fr
committed
% Retrieve named application data
% -------------------------------
tsg = getappdata( hMainFig, 'tsg_data');

jacques.grelet_ird.fr
committed
% Selection of the data within the figure
% ---------------------------------------
point1 = get(gca,'CurrentPoint'); % button down detected
Yves Gouriou
committed
finalRect = rbbox; % return figure units
point2 = get(gca,'CurrentPoint'); % button up detected

jacques.grelet_ird.fr
committed
Yves Gouriou
committed
point1 = point1(1,1:2); % extract x and y

jacques.grelet_ird.fr
committed
point2 = point2(1,1:2);

jacques.grelet_ird.fr
committed
p1 = min(point1,point2);
Yves Gouriou
committed
p2 = max(point1,point2); % calculate locations
% The following code is only executed if the left mouse button is clicked.
% If the right mouse button is clicked, this code must not be
% executed as the variable 'ind' will be emptied. And this variable
% 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')
% get index on selected zone
% --------------------------
ind = find(tsg.DAYD_SPL > p1(1,1) &...
tsg.DAYD_SPL < p2(1,1) & ...
tsg.([PARA '_SPL_DIF']) > p1(1,2) &...
tsg.([PARA '_SPL_DIF']) < p2(1,2));
Yves Gouriou
committed
% Keep the information on the indices of the selected zone
% --------------------------------------------------------
tsg.rbboxind = ind .* ones(size(ind));
% Modifiy the QC
% --------------
tsg.([PARA '_SPL_QC'])(ind) = tsg.qc.active.Code;
Yves Gouriou
committed
% Save the modifications
% ----------------------
setappdata( hMainFig, 'tsg_data', tsg);
Yves Gouriou
committed
% Update sample QC in the _WS and _EXT records
% --------------------------------------------
updateSampleQC( hMainFig, PARA );
Yves Gouriou
committed
% plot selected data with selected code
% --------------------------------------
plot_Correction( hMainFig, hPlotAxes, PARA);
Yves Gouriou
committed
else
% get index on selected zone
% ---------------------------
ind = find(tsg.DAYD > p1(1,1) & tsg.DAYD < p2(1,1) & ...
tsg.(PARA) > p1(1,2) & tsg.(PARA) < p2(1,2));
Yves Gouriou
committed
% Keep the information on the indices of the selected zone
% --------------------------------------------------------
tsg.rbboxind = ind .* ones(size(ind));
% Modifiy the QC
% --------------
tsg.([PARA '_QC'])(ind) = tsg.qc.active.Code;
Yves Gouriou
committed
% put last SSPS_QC in queue (Undo/Redo)
% -------------------------------------
tsg.queue = push( tsg.queue, tsg.([PARA '_QC']));
Yves Gouriou
committed
% store QC in queue object, for undo
% ----------------------------------
tsg.queue = push(tsg.queue, tsg.([PARA '_QC']));
Yves Gouriou
committed
% Save the modifications
% ----------------------
setappdata( hMainFig, 'tsg_data', tsg);
% Draw plot 1 of the validation figure
% ------------------------------------
plot_Validation( hMainFig, hPlotAxes, 1, PARA );
Yves Gouriou
committed
% refresh QC statistic panel
% --------------------------
display_QC( hMainFig, hPlotAxes );
% enable undo menu
% ----------------
set(findobj('tag','UIMENU_UNDO'),'enable','on');
end
% As soon as a modification took place the data should be saved
% -------------------------------------------------------------
set( hSaveMenu, 'UserData', 'on' );

jacques.grelet_ird.fr
committed
Yves Gouriou
committed
end

jacques.grelet_ird.fr
committed
Yves Gouriou
committed
% enable ButtonMotion on main fig after select QC area
% ----------------------------------------------------
set( hMainFig, 'WindowButtonMotionFcn', @MouseMotion);

jacques.grelet_ird.fr
committed
Yves Gouriou
committed
end
end
%% QC_OffMenuCallback .............................. Quality Control Module
%----------------------------------------------------------------------
% Callback function run when the QC toggle tool is released
%----------------------------------------------------------------------
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', []);
% Uipanel visible or not
% -----------------------
set( hbgQc, 'Visible', 'off' );
% uibuttongroup uipanel used to choose a parameter is set to
% on only if the Correction screen (bottle toggletool) is off
% -----------------------------------------------------------
if strcmp( get( hBottleToggletool, 'state'), 'off')
set( hbgParameter, 'Visible', 'on');
end
% cursor back to normal
% ---------------------
set(hMainFig,'Pointer','arrow');
end
Yves Gouriou
committed
%% Qc context menu selected ........................ Quality Control Module
%-----------------------------------------------------------
% Callback function run when the QC context menu is selected
%
% Context menu used to attribute a QC to the TSG time series
%
%-----------------------------------------------------------
function Qc(hObject, eventdata, key)
Yves Gouriou
committed
% Retrieve Default Quality Code and Color
% ---------------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
% Get the parameter (SSPS, SSJT or SSTP)
% --------------------------------------
PARA = tsg.preference.parameter;
Yves Gouriou
committed
% get key and some values in hashtable
% ------------------------------------
code = get(tsg.qc.hash, key, 'code');
color = get(tsg.qc.hash, key, 'color');
Yves Gouriou
committed
% set active code and color from selected context menu
% ----------------------------------------------------
tsg.qc.active.Code = code;
tsg.qc.active.Color = color;
% Modify and plot the last selected tsg data
% ------------------------------------------
if ~isempty( tsg.rbboxind )
if strcmp( get(hBottleToggletool, 'state'), 'on')
tsg.([PARA '_SPL_QC'])(tsg.rbboxind) = tsg.qc.active.Code;
% Save tsg.SSPS_QC and tsg.qc.active.Code
% in the application data
Yves Gouriou
committed
% ----------------------------------------
% Draw the 3 plots of the Correction figure
% -----------------------------------------
plot_Correction( hMainFig, hPlotAxes, PARA );
Yves Gouriou
committed
else
tsg.([PARA '_QC'])(tsg.rbboxind) = tsg.qc.active.Code;
Yves Gouriou
committed
% Save tsg.SSPS_QC in the application data
% ----------------------------------------
setappdata( hMainFig, 'tsg_data', tsg );
% Draw plot 1 of the validation figure
% ------------------------------------
plot_Validation( hMainFig, hPlotAxes, 1, PARA );
Yves Gouriou
committed
end
Yves Gouriou
committed
% Update the radio button corresponding to the selected
% QC context menu (rbg : RadioButtonGroup)
% -----------------------------------------------------
radioTag = ['TAG_QC_RADIO_' key]; % Build the TAG of the CODE
hbgChildren = get(hbgQc,'Children'); % Get the handles of the rbg
hbgTagCell = get(hbgChildren, 'tag'); % get the TAG of the rbg
ind = strcmp(radioTag, hbgTagCell); % Compare the TAG
hRadioButton = hbgChildren( ind == 1 ); % Get the handle of the button
set(hbgQc, 'SelectedObject', hRadioButton); % Make this button active
setappdata( hMainFig, 'tsg_data', tsg );

jacques.grelet_ird.fr
committed
end

jacques.grelet_ird.fr
committed
%% Radiobutton Quality Control ..................... Quality Control Module
% ---------------------------------------------------------------
% Callback to select CODE and COLOR QC from the RadioButton Group
% ---------------------------------------------------------------
function RadiobuttonQc(source, eventdata)
% Retrieve Default Quality Code and Color
% ---------------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
Yves Gouriou
committed
% Retrieve the key from the active RadioButton
% --------------------------------------------
rbTag = get(eventdata.NewValue,'Tag');
key = strrep(rbTag, 'TAG_QC_RADIO_', '');
Yves Gouriou
committed
% store his handle to uibuttongroup userdata
% ------------------------------------------
set(hbgQc,'Userdata', eventdata.NewValue);
% get key and some values in hashtable
% ------------------------------------
code = get(tsg.qc.hash, key, 'code');
color = get(tsg.qc.hash, key, 'color');
% set active code and color from selected context menu
% ----------------------------------------------------
tsg.qc.active.Code = code;
tsg.qc.active.Color = color;
setappdata( hMainFig, 'tsg_data', tsg );
end
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
%% Radiobutton Parameter choice ..................... Parameter choice
% ---------------------------------------------------------------
% Callback to select CODE and COLOR QC from the RadioButton Group
% ---------------------------------------------------------------
function RadiobuttonParameter(source, eventdata)
% If the map is visible, hide it
% ------------------------------
set( hMapPanel, 'visible' ,'off' );
set( hMapToggletool, 'state', 'off');
% Retrieve Default Quality Code and Color
% ---------------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
% Retrieve the key from the active RadioButton
% --------------------------------------------
rbTag_Old = get(eventdata.OldValue,'Tag');
rbTag = get(eventdata.NewValue,'Tag');
PARA = strrep(rbTag, 'TAG_PARA_RADIO_', '');
% Test if PARA exists
% -------------------
ind = find( isnan(tsg.(PARA)) == 0 );
if ~isempty( tsg.(PARA) ) & ~isempty (ind )
% store his handle to uibuttongroup userdata
% ------------------------------------------
set(hbgParameter,'Userdata', eventdata.NewValue);
tsg.preference.parameter = PARA;
setappdata( hMainFig, 'tsg_data', tsg );
% Get sample data
% ---------------
tsg_mergesample( hMainFig, PARA );
% The smooth TSG time series (tsg_moveaverage) is
% no more computed : too long
% We now computed a smooth value only at the position of the sample
% in diffTsgSample
% -----------------------------------------------------------------
%tsg_moveaverage(hMainFig, PARA);
% Draw the 3 plots of the validation figure
% -----------------------------------------
resetAxes( hMainFig, hPlotAxes )
plot_Validation( hMainFig, hPlotAxes, 1, PARA );
plot_Validation( hMainFig, hPlotAxes, 2, 'SSJT' );
plot_Validation( hMainFig, hPlotAxes, 3, 'SPDC' );
else
msgbox( ['No ' PARA ' data in the file'], 'Parameter choice', 'warn', 'modal');
% Set the old radio-button active
% -------------------------------
hbgChildren = get(hbgParameter,'Children'); % Get the handles of the rbg
hbgTagCell = get(hbgChildren, 'tag'); % get the TAG of the rbg
ind = strcmp(rbTag_Old, hbgTagCell); % Compare the TAG
hRadioButton = hbgChildren( ind == 1 ); % Get the handle of the button
set(hbgParameter, 'SelectedObject', hRadioButton); % Make this button active