Newer
Older
% ----------------
set(hSaveMenu, 'Enable', 'on');

jacques.grelet_ird.fr
committed

jacques.grelet_ird.fr
committed
% update the filename display
% ---------------------------

jacques.grelet_ird.fr
committed
set( hInfoFileText, 'String', fileName);

jacques.grelet_ird.fr
committed
% update some fields in tsg structure
% -----------------------------------
updateTsgStruct(hMainFig);
Yves Gouriou
committed
% Running average of TSG time series
% ----------------------------------
tsg_moveaverage(hMainFig);

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

jacques.grelet_ird.fr
committed
end
% Get application data
% --------------------
tsg = getappdata( hMainFig, 'tsg_data');
% Merge bucket and external samples
% ---------------------------------
if ~isempty( tsg.SSPS_WS ) || ~isempty( tsg.SSPS_EXT )
tsg_mergesample( hMainFig );
tsg = getappdata( hMainFig, 'tsg_data');
% Draw the 3 plots of the validation figure
% -----------------------------------------
plot_Validation( hMainFig, hPlotAxes, 1 );
plot_Validation( hMainFig, hPlotAxes, 2 );
plot_Validation( hMainFig, hPlotAxes, 3 );

jacques.grelet_ird.fr
committed
% Pointer reset to arrow
% ----------------------
set( hMainFig, 'Pointer', 'arrow' );
end
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
%% Cal_OnMenuCallback ..................................... Calibration
%----------------------------------------------------------------------
% Callback function run when
%----------------------------------------------------------------------
function Cal_OnMenuCallback( hObject, eventdata)
set( hpCalCoef, 'Visible', 'on' );
set( hbgQc, 'Visible', 'off');
% Pushbutton
set( hQCToggletool, 'enable', 'off' );
set( hClimToggletool, 'enable', 'off' );
set( hBottleToggletool, 'enable', 'off' );
set( hHeaderPushtool, 'enable', 'off' );
% Activate Time selection uipanels
% --------------------------------
set( hpDateLimit, 'Visible', 'on' );
set( hTimelimitToggletool, 'enable', 'on' );
% Draw the 3 plots of the validation figure
% -----------------------------------------
plot_Calibration( hMainFig, hPlotAxes, 1 );
plot_Calibration( hMainFig, hPlotAxes, 2 );
plot_Calibration( hMainFig, hPlotAxes, 3 );
% Get tsg application data
% ------------------------
tsg = getappdata( hMainFig, 'tsg_data' );
% Write the Cal Coef in the Editable uicontrol
% --------------------------------------------
if isempty( tsg.CNDC_LINCOEF )
set( hetCalCNDCSlope, 'String', '1');
set( hetCalCNDCOffset, 'String', '0');
else
set( hetCalCNDCSlope, 'String', num2str(tsg.CNDC_LINCOEF(1)));
set( hetCalCNDCOffset, 'String', num2str(tsg.CNDC_LINCOEF(2)));
end
if isempty( tsg.SSJT_LINCOEF )
set( hetCalSSJTSlope, 'String', '1');
set( hetCalSSJTOffset, 'String', '0');
else
set( hetCalSSJTSlope, 'String', num2str(tsg.SSJT_LINCOEF(1)));
set( hetCalSSJTOffset, 'String', num2str(tsg.SSJT_LINCOEF(2)));
end
end
%% Cal_OffMenuCallback ..................................... Calibration
%----------------------------------------------------------------------
% Callback function run when
%----------------------------------------------------------------------
function Cal_OffMenuCallback( hObject, eventdata)
set( hpCalCoef, 'Visible', 'off' );
set( hbgQc, 'Visible', 'on');
% Enable Pushbuttons
% ------------------
set( hQCToggletool, 'enable', 'on' );
set( hClimToggletool, 'enable', 'on' );
set( hBottleToggletool, 'enable', 'on' );
set( hHeaderPushtool, 'enable', 'on' );
% Desactivate Time selection uipanels
% --------------------------------
set( hpDateLimit, 'Visible', 'off' );
set( hTimelimitToggletool, 'enable', 'off' );
% 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'));
% Save tsg application data
% --------------------------
setappdata( hMainFig, 'tsg_data', tsg );
% Draw the 3 plots of the validation figure
% -----------------------------------------
plot_Validation( hMainFig, hPlotAxes, 1 );
plot_Validation( hMainFig, hPlotAxes, 2 );
plot_Validation( hMainFig, hPlotAxes, 3 );
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)

jacques.grelet_ird.fr
committed
% Desactivate Zoom and Pan functions.
% ----------------------------------
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

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.SSPS_SPL_DIF > p1(1,2) & tsg.SSPS_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.SSPS_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 );
Yves Gouriou
committed
% plot selected data with selected code
% --------------------------------------
plot_Correction( hMainFig, hPlotAxes);
Yves Gouriou
committed
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
else
% 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));
% Keep the information on the indices of the selected zone
% --------------------------------------------------------
tsg.rbboxind = ind .* ones(size(ind));
% Modifiy the QC
% --------------
tsg.SSPS_QC(ind) = tsg.qc.active.Code;
% put last SSPS_QC in queue (Undo/Redo)
% -------------------------------------
tsg.queue = push( tsg.queue, tsg.SSPS_QC);
% store QC in queue object, for undo
% ----------------------------------
tsg.queue = push(tsg.queue, tsg.SSPS_QC);
% Save the modifications
% ----------------------
setappdata( hMainFig, 'tsg_data', tsg);
% Draw plot 1 of the validation figure
% ------------------------------------
plot_Validation( hMainFig, hPlotAxes, 1 );
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
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
%% 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 no more visible
% -----------------------
%set( hbgQc, 'Visible', 'off' );
% 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');
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.SSPS_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 );
Yves Gouriou
committed
else
tsg.SSPS_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 );
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
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
%% preQcPanCallback .................................Quality Control Module
function preQcPanCallback(obj, evd)
set(hQCToggletool, 'state', 'off' );
end
%% postQcPanCallback ............................... Quality Control Module
function postQcPanCallback(obj, evd)
set(hQCToggletool, 'state', 'on' );
% 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
end
%% MouseMotion

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

jacques.grelet_ird.fr
committed
% Callback function run when mouse pointer is moving on temperature plot
% draw corresponding measurement position on map

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

jacques.grelet_ird.fr
committed
function MouseMotion(hObject, eventdata)
% Test if the callback can be activated
% -------------------------------------
if strcmp( get( hMainFig, 'UserData'), 'ButtonMotionOn')
% Retrieve named application data
% -------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
% Get current position of cusor and return its coordinates in
% axes with handle h_axes
% -----------------------------------------------------------
Yves Gouriou
committed
a = get(hPlotAxes(1), 'CurrentPoint');
x = a(2,1);
y = a(2,2);
% Get the Limits of axes 1
% ------------------------
limx = get(hPlotAxes(1), 'XLim');
limy = get(hPlotAxes(1), 'YLim');
Yves Gouriou
committed
% Code to Activate the PAN function when QC mode is active
% A PAN zone is defined in the bottom (10%) of PlotAxes(1)
% 2 callback are needed :
% 1 - one to desactivate QC when Pan is set to on.
% 2 - one to reactivate QC once the pan has been used.
% ---------------------------------------------------------
qcState = get(hQCToggletool, 'state' );
if strcmp(qcState, 'on' );
% Suppose that Y axes is increasing from the bottom to the top
% ------------------------------------------------------------
limy2 = limy(1) + (limy(2)-limy(1)) * 0.10;
if x > limx(1) && x < limx(2) && y <= limy2 && y >= limy(1)
Yves Gouriou
committed
set(hPan,'ActionPreCallback', @preQcPanCallback);
set(hPan,'ActionPostCallback', @postQcPanCallback);
set(hPan,'Enable','on');
else
pan off
end
end
% Dynamically display data in uicontrol
% -------------------------------------
if x > tsg.DAYD(1) && x < tsg.DAYD(end)
%if x > limx(1) && x < limx(2)
indCursor = find( tsg.DAYD > x);
set( hInfoDateText, 'String',...
datestr(tsg.DAYD(indCursor(1)),'dd/mm/yyyy HH:MM'));
set( hInfoLatText, 'String', dd2dm(tsg.LATX(indCursor(1)),0));
set( hInfoLongText, 'String', dd2dm(tsg.LONX(indCursor(1)),1));
set( hInfoSSPSText, 'String', tsg.SSPS(indCursor(1)));
set( hInfoSSJTText, 'String', tsg.SSJT(indCursor(1)));
if ~isempty(tsg.SSTP)
set( hInfoSSTPText, 'String', tsg.SSTP(indCursor(1)));
end
% Plot the position on the map if this one is active
% --------------------------------------------------
if strcmp( get(hMapPanel, 'Visible'), 'on')
% Select the map axes
% -------------------
axes( hPlotAxes(4));
if isempty( get(hMapPanel, 'UserData'))
hMarker = m_line( tsg.LONX(indCursor(1)), tsg.LATX(indCursor(1)),...
'Marker','o','MarkerSize',5, ...
'Color','r', 'MarkerFaceColor','r');
set(hMapPanel, 'UserData', hMarker)
else
delete(get(hMapPanel, 'UserData'));
hMarker = m_line( ...
tsg.LONX(indCursor(1)), tsg.LATX(indCursor(1)),...
'Marker','o','MarkerSize',5, ...
'Color','r', 'MarkerFaceColor','r');

jacques.grelet_ird.fr
committed
end
end
end
end

jacques.grelet_ird.fr
committed
end
%% Map_OffMenuCallback

jacques.grelet_ird.fr
committed
%---------------------------------------------------------------------
% Callback function run when the Map tool bar item is unselected
%---------------------------------------------------------------------
function Map_OffMenuCallback(hObject, eventdata)
Yves Gouriou
committed
%if ~isempty( get(hMapPanel, 'UserData'))
% delete(get(hMapPanel, 'UserData'));
%end
%hLines = findobj( hPlotAxes(4), 'Tag', 'TAG_AXES_MAP');
%hLines = get( hPlotAxes(4), 'Children' );
%if ~isempty( hLines )
% delete(hLines);
%end
Yves Gouriou
committed
% Make the earth map invisible
% ----------------------------
set(hMapPanel, 'Visible', 'off' );

jacques.grelet_ird.fr
committed
end

jacques.grelet_ird.fr
committed
%% Map_OnMenuCallback

jacques.grelet_ird.fr
committed
%---------------------------------------------------------------------
% Callback function run when the Map tool bar item is selected
%---------------------------------------------------------------------
function Map_OnMenuCallback(hObject, eventdata)

jacques.grelet_ird.fr
committed
% Desactivate Zoom and Pan toggle buttons
% may be change in the futur ...
% ---------------------------------------
set(hZoomToggletool, 'state', 'off' );
set(hPanToggletool, 'state', 'off' );

jacques.grelet_ird.fr
committed
% Make the earth map visible
% --------------------------

jacques.grelet_ird.fr
committed
set(hMapPanel, 'Visible', 'on' );
Yves Gouriou
committed
plot_map( hMainFig, hPlotAxes)

jacques.grelet_ird.fr
committed
end
%% Bottle_OnMenuCallback ................................ Correction Module

jacques.grelet_ird.fr
committed
%---------------------------------------------------------------------
% Callback function run when the bootle push tool is selected

jacques.grelet_ird.fr
committed
%---------------------------------------------------------------------
function Bottle_OnMenuCallback(hObject, eventdata)
% Callback function run when the Bottle tool bar item is selected
% Get the tsg structure
% ---------------------
tsg = getappdata(hMainFig, 'tsg_data');
Yves Gouriou
committed
% Desactivate the Climatology button
% ----------------------------------
set( hClimToggletool, 'Enable', 'off');
% Switch somme buttons
% --------------------
set( hZoomToggletool, 'state', 'off' );
set( hQCToggletool, 'state', 'off' );
set( hPanToggletool, 'state', 'off' );
set( hMapToggletool, 'state', 'off' );
set( hCalToggletool, 'enable', 'off' );
set( hTimelimitToggletool, 'enable', 'on' );
% Activate uipanels
% -----------------
set( hpDateLimit, 'Visible', 'on' );
set( hbgCorMethod, 'Visible', 'on' );
% Test if tsg and sample data have been loaded
% --------------------------------------------
% Compute the sample-TSG differences
% ----------------------------------
diffTsgSample( hMainFig );
% Plot in the 3 axes
% ------------------
plot_Correction( hMainFig, hPlotAxes );
% 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));
% Desactivate the corretion module
% --------------------------------
set( hBottleToggletool, 'state', 'off' );
msgbox('Sample data not loaded in the program', 'modal');

jacques.grelet_ird.fr
committed
end
%% Bottle_OffMenuCallback ............................... Correction module
%---------------------------------------------------------------------
% Callback function run when the bootle push tool is selected
%---------------------------------------------------------------------
function Bottle_OffMenuCallback(hObject, eventdata)
Yves Gouriou
committed
% Activate the Climatology button
% -------------------------------
set( hClimToggletool, 'Enable', 'on');
% If necessary toggle off some buttons
% ------------------------------------
set( hZoomToggletool, 'state', 'off' );
set( hQCToggletool, 'state', 'off' );
set( hPanToggletool, 'state', 'off' );
set( hMapToggletool, 'state', 'off' );
set( hCalToggletool, 'enable', 'on' );
set( hTimelimitToggletool, 'enable', 'off' );
% Desactivate some toolbar buttons
% --------------------------------
set( hpDateLimit, 'Visible', 'off' );
set( hbgCorMethod, 'Visible', 'off' );
Yves Gouriou
committed
% Desactivate Click Mouse on figure
% ---------------------------------
set( hMainFig, 'WindowButtonDownFcn', []);
% Drawing only necessary if the Correction moduel has been activated
% ------------------------------------------------------------------
if ~isempty( tsg.SSPS_SPL )
% Draw the 3 plots of the validation figure
% -----------------------------------------
plot_Validation( hMainFig, hPlotAxes, 1 );
plot_Validation( hMainFig, hPlotAxes, 2 );
plot_Validation( hMainFig, hPlotAxes, 3 );
end
Yves Gouriou
committed
Yves Gouriou
committed
%% SelectTime_OnMenuCallback ............................ Correction module
%----------------------------------------------------------------------
function SelectTime_OnMenuCallback(hObject, eventdata)
% Callback function run when the ....
% Desactivate Zoom and Pan functions.
% ----------------------------------
set( hZoomToggletool, 'state', 'off' );
set( hQCToggletool, 'state', 'off' );
set( hPanToggletool, 'state', 'off' );
% Create a pointer to select the time limits
% ------------------------------------------
Yves Gouriou
committed
selTimePointer = ones(16)+1;
selTimePointer(1,:) = 1; selTimePointer(16,:) = 1;
selTimePointer(:,1) = 1; selTimePointer(:,16) = 1;
selTimePointer(1:4,8:9) = 1; selTimePointer(13:16,8:9) = 1;
selTimePointer(8:9,1:4) = 1; selTimePointer(8:9,13:16) = 1;
selTimePointer(5:12,5:12) = NaN; % Create a transparent region in the center
% Activate clic mouse menu on second axes (salinity) for next rbbox
% ----------------------------------------------------------------
set(hMainFig,'WindowButtonDownFcn', @Time_SelectCallback);
% change cursor
% ---------------
Yves Gouriou
committed
set( hMainFig, 'Pointer', 'custom',...
'PointerShapeCData', selTimePointer, 'PointerShapeHotSpot',[9 9]);
% ----------------------------------------------------------------------
% nested function on mouse clic when Select Time toggle tool is selected
% ----------------------------------------------------------------------
function Time_SelectCallback(gcbo, eventdata)
% disable ButtonMotion on main fig during select
% prevent drawing to map
% ----------------------------------------------
set( hMainFig, 'WindowButtonMotionFcn', []);
% 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
point1 = point1(1,1:2); % extract x and y
point2 = point2(1,1:2);
p1 = min(point1,point2);
p2 = max(point1,point2); % calculate locations
% get index on selected zone - Only on X axes (time)
% --------------------------------------------------
ind = find(tsg.DAYD >= p1(1,1) & tsg.DAYD <= p2(1,1));
% Write the date in the Editable uicontrol
% ----------------------------------------
set( hetDateMin, 'String', datestr(tsg.DAYD(ind(1)), 31));
set( hetDateMax, 'String', datestr(tsg.DAYD(ind(end)), 31));
% enable ButtonMotion on main fig after select QC area
% ----------------------------------------------------
set( hMainFig, 'WindowButtonMotionFcn', @MouseMotion);
%% SelectTime_OffMenuCallback ........................... Correction module
%--------------------------------------------------------------------------
function SelectTime_OffMenuCallback(hObject, eventdata)
% Callback function run when the ....
% Desactivate time limit buttons
% ------------------------------
set( hTimelimitToggletool, 'state', 'off');
set( hMainFig,'WindowButtonDownFcn', []);
set(hMainFig,'Pointer','arrow');
%% CorCancelCallback .................................... Correction Module
function CorCancelCallback(hObject, eventdata)
% Desactivate somme Toggle button
% -------------------------------
set( hZoomToggletool, 'state', 'off' );
set( hPanToggletool, 'state', 'off' );
set( hQCToggletool, 'state', 'off' );
set( hTimelimitToggletool, 'state', 'off' );
tsg = getappdata(hMainFig, 'tsg_data');
tsg.SSPS_ADJUSTED_ERROR = NaN*ones(size(tsg.SSPS));
setappdata(hMainFig, 'tsg_data', tsg);
% Plot in the 3 axes
% ------------------
plot_Correction( hMainFig, hPlotAxes );
%% CorLinearCallback .................................... Correction Module
function CorLinearCallback(hObject, eventdata)
% Callback function run when
% Desactivate somme Toggle button
% -------------------------------
set( hZoomToggletool, 'state', 'off' );
set( hPanToggletool, 'state', 'off' );
set( hQCToggletool, 'state', 'off' );
set( hTimelimitToggletool, 'state', 'off' );
% 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');
% Compute the sample-TSG differences
% ----------------------------------
diffTsgSample( hMainFig );
% Correction
% ----------
error = corTsgLinear(hMainFig, dateMin, dateMax);
% Plot in the 3 axes
% ------------------
plot_Correction( hMainFig, hPlotAxes );
case -1
msgbox( 'Date limits are not correct',...
'Correction module', 'warn', 'modal');
end
%% CorMedianCallback .................................... Correction Module
function CorMedianCallback(hObject, eventdata)
% Callback function run when
% Desactivate somme Toggle button
% -------------------------------
set( hZoomToggletool, 'state', 'off' );
set( hPanToggletool, 'state', 'off' );
set( hQCToggletool, 'state', 'off' );
set( hTimelimitToggletool, 'state', 'off' );
% 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');
% Compute the sample-TSG differences
% ----------------------------------
diffTsgSample( hMainFig );
% Correction
% ----------
error = corTsgMedian(hMainFig, dateMin, dateMax);
switch error
case 1
% Plot in the 3 axes
% ------------------
plot_Correction( hMainFig, hPlotAxes );
case -1
msgbox( 'Date limits are not correct',...
'Correction module', 'warn', 'modal');
end
end
%% Clim_OffMenuCallback
%------------------------------------------------------------------------

jacques.grelet_ird.fr
committed
% Callback function run when the Levitus climatology toolbar is unselected
%------------------------------------------------------------------------
function Clim_OffMenuCallback(hObject, eventdata)

jacques.grelet_ird.fr
committed
% Get lines handles from tag
% --------------------------
hLines = findobj('-regexp', 'Tag', 'TAG_LINE_CLIMATO_');

jacques.grelet_ird.fr
committed

jacques.grelet_ird.fr
committed
% Delete climatology lines on axes
% ---------------------------------
delete(hLines);

jacques.grelet_ird.fr
committed
end

jacques.grelet_ird.fr
committed
%% Clim_OnMenuCallback

jacques.grelet_ird.fr
committed
%------------------------------------------------------------------------
% Callback function run when the Levitus climatology toolbar is unselected
%------------------------------------------------------------------------
function Clim_OnMenuCallback(hObject, eventdata)

jacques.grelet_ird.fr
committed

jacques.grelet_ird.fr
committed
% Test if the TSG and bucket files have been read