Newer
Older
tsg.([SAMPLE '_EXT_QC'])(ind) = tsg.qc.active.Code;
Yves Gouriou
committed
% Save the modifications
% ----------------------
setappdata( hMainFig, 'tsg_data', tsg);
% plot selected data with selected code
% --------------------------------------
plot_Correction( hMainFig, hPlotAxes, PARA);
end
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
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));
% 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;
% put last SSPS_QC in queue (Undo/Redo)
% -------------------------------------
tsg.queue = push( tsg.queue, tsg.([PARA '_QC']));
% store QC in queue object, for undo
% ----------------------------------
tsg.queue = push(tsg.queue, tsg.([PARA '_QC']));
% Save the modifications
% ----------------------
setappdata( hMainFig, 'tsg_data', tsg);
% Draw plot 1 of the validation figure
% ------------------------------------
plot_Validation( hMainFig, hPlotAxes, 1, PARA );
% 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' );
end
% enable ButtonMotion on main fig after select QC area
% ----------------------------------------------------
set( hMainFig, 'WindowButtonMotionFcn', @MouseMotion);
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' );
set( hTimelimitToggletool, 'state', 'off' );
if strcmp( get(hBottleToggletool, 'state'), 'off' )
set( hCalToggletool, 'state', 'off', 'enable', 'on' );
set( hInterpToggletool, 'state', 'off', 'enable', 'on' );
end
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
% 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
%% 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)
% Retrieve Default Quality Code and Color
% ---------------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
% Get the parameter (SSPS, SSJT or SSTP)
% --------------------------------------
PARA = tsg.preference.parameter{1};
SAMPLE = tsg.preference.sample;
% 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;
% Modify and plot the last selected tsg data
% ------------------------------------------
if isfield(tsg, 'rbboxind') && ~isempty( tsg.rbboxind )
if strcmp( get(hBottleToggletool, 'state'), 'on')
tsg.([SAMPLE '_EXT_QC'])(tsg.rbboxind) = tsg.qc.active.Code;
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
% Save tsg.SSPS_QC and tsg.qc.active.Code
% in the application data
% ----------------------------------------
setappdata( hMainFig, 'tsg_data', tsg );
% Draw the 3 plots of the Correction figure
% -----------------------------------------
plot_Correction( hMainFig, hPlotAxes, PARA );
else
tsg.([PARA '_QC'])(tsg.rbboxind) = tsg.qc.active.Code;
% 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 );
end
end
% 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 );
end
%% 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');
% Retrieve the key from the active RadioButton
% --------------------------------------------
rbTag = get(eventdata.NewValue,'Tag');
key = strrep(rbTag, 'TAG_QC_RADIO_', '');
% 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
%% preQcPanCallback .................................Quality Control Module
% ---------------------------------------------------------------
% Callback function ... to be completed
% ---------------------------------------------------------------
function preQcPanCallback(obj, evd)
set(hQCToggletool, 'state', 'off' );
end
%% postQcPanCallback ............................... Quality Control Module
% ---------------------------------------------------------------
% Callback function ... to be completed
% ---------------------------------------------------------------
function postQcPanCallback(obj, evd)
% 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
% Re-draw the map once the pan is off - only valide in QC mode
% -------------------------------------------------------------
if strcmp( get(hMapPanel, 'visible'), 'on') == 1
erase_Line( hPlotAxes, 4 );
plot_map( hMainFig, hPlotAxes);
end
% restacks the figure to the top of the screen
% --------------------------------------------
figure( hMainFig);
set(hQCToggletool, 'state', 'on' );
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
end
%% MouseMotion
%---------------------------------------------------------------------
% Callback function run when mouse pointer is moving on temperature plot
% draw corresponding measurement position on map
%---------------------------------------------------------------------
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
% -----------------------------------------------------------
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');
% 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)
hPan = pan(hMainFig);
set(hPan,'ActionPreCallback', @preQcPanCallback);
set(hPan,'ActionPostCallback', @postQcPanCallback);
set(hPan,'Enable','on');
else
pan(hMainFig, '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(mod(tsg.LONX(indCursor(1))+180,360)-180,1));
if ~isempty(tsg.SSPS)
set( hInfoSSPSText, 'String', tsg.SSPS(indCursor(1)));
end
if ~isempty(tsg.SSJT)
set( hInfoSSJTText, 'String', tsg.SSJT(indCursor(1)));
end
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));
% Look for a MARKER (Red point) on the ship track
% -----------------------------------------------
h = findobj( hPlotAxes(4), '-regexp','Tag', 'TAG_PLOT4_LINE_MARKER');
if isempty( h ) % if no Marker
% Plot a Marker (Red point) on the ship track
% -------------------------------------------
hMarker = m_line( tsg.LONX(indCursor(1)), tsg.LATX(indCursor(1)),...
'Marker','o','MarkerSize',5, ...
'Color','r', 'MarkerFaceColor','r');
% Put a tag on the Marker - This tag allows to get the handle
% of the Marker
% -----------------------------------------------------------
set( hMarker, 'TAG', 'TAG_PLOT4_LINE_MARKER' );
else % a marker exists
if ~isnan( tsg.LONX(indCursor(1)) )
% Delete the Marker and redraw it
% -------------------------------
delete( h);
hMarker = m_line( ...
tsg.LONX(indCursor(1)), tsg.LATX(indCursor(1)),...
'Marker','o','MarkerSize',5, ...
'Color','r', 'MarkerFaceColor','r');
% Put a tag on the Marker - This tag allows to get the handle
% of the Marker
% -----------------------------------------------------------
set( hMarker, 'TAG', 'TAG_PLOT4_LINE_MARKER' );
end
end
end
end
end
end
%% Map_OnMenuCallback
%---------------------------------------------------------------------
% Callback function run when the Map tool bar item is selected
%---------------------------------------------------------------------
function Map_OnMenuCallback(hObject, eventdata)
% Desactivate Zoom and Pan toggle buttons
% ---------------------------------------
set(hZoomInToggletool, 'state', 'off' );
set(hZoomOutToggletool, 'state', 'off' );
set(hPanToggletool, 'state', 'off' );
% Make the earth map visible
% --------------------------
set(hMapPanel, 'Visible', 'on' );
erase_Line( hPlotAxes, 4 );
plot_map( hMainFig, hPlotAxes)
end
%% Map_OffMenuCallback
%---------------------------------------------------------------------
% 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
%% Bottle_OnMenuCallback ................................ Correction Module
%---------------------------------------------------------------------
% Callback function run when the bootle push tool is selected
%---------------------------------------------------------------------
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');
% Get the parameter we are working on (SSPS, SSJT, SSTP)
% ------------------------------------------------------
PARA = tsg.preference.parameter{1};
SAMPLE = tsg.preference.sample;
% Switch somme buttons
% --------------------
set( hQCToggletool, 'state', 'off' );
set( hZoomInToggletool, 'state', 'off', 'enable', 'on' );
set( hZoomOutToggletool, 'state', 'off', 'enable', 'on' );
set( hPanToggletool, 'state', 'off' );
% set( hMapToggletool, 'state', 'off' );
set( hClimToggletool, 'state', 'off', 'enable', 'off');
set( hCalToggletool, 'enable', 'off' );
set( hInterpToggletool, 'enable', 'off' );
set( hTimelimitToggletool, 'enable', 'on' );
% Activate or desactivate uipanels
% ---------------------------------
set( hpDateLimit, 'Visible', 'on' );
set( hbgCorMethod, 'Visible', 'on' );
set( hCorPanel, 'Visible', 'on' );
set( hbgParameter, 'Visible', 'off');
set( hbgQc, 'Visible', 'off');
if ~isempty( tsg.([SAMPLE '_EXT']) )
Yves Gouriou
committed
% Compute the sample-TSG differences
% ----------------------------------
diffTsgSample( hMainFig, PARA );
else
msgbox('No sample data file has been read', 'modal');
Yves Gouriou
committed
end
Yves Gouriou
committed
% Plot in the 3 axes
% ------------------
plot_Correction( hMainFig, hPlotAxes, PARA );
Yves Gouriou
committed
% 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));
end
%% Bottle_OffMenuCallback ............................... Correction module
%---------------------------------------------------------------------
% Callback function run when the bootle push tool is selected
%---------------------------------------------------------------------
function Bottle_OffMenuCallback(hObject, eventdata)
% If necessary toggle off some buttons
% ------------------------------------
set( hQCToggletool, 'state', 'off' );
set( hZoomInToggletool, 'state', 'off' );
set( hZoomOutToggletool, 'state', 'off' );
set( hPanToggletool, 'state', 'off' );
% set( hMapToggletool, 'state', 'off' );
set( hClimToggletool, 'enable', 'on');
set( hCalToggletool, 'enable', 'on' );
set( hInterpToggletool, 'enable', 'on' );
set( hTimelimitToggletool, 'enable', 'off' );
% Activate or Desactivate uipanel
% --------------------------------
set( hpDateLimit, 'Visible', 'off' );
set( hCorPanel, 'Visible', 'off' );
set( hbgCorMethod, 'Visible', 'off' );
set( hbgParameter, 'Visible', 'on');
% Desactivate Click Mouse on figure
% ---------------------------------
set( hMainFig, 'WindowButtonDownFcn', []);
% Get tsg structure
% -----------------
tsg = getappdata( hMainFig, 'tsg_data' );
% Get the parameter (SSPS, SSJT, SSTP)
% ------------------------------------
% PARA = tsg.preference.parameter;
Yves Gouriou
committed
% Draw the 3 plots of the validation figure
% -----------------------------------------
plot_Validation( hMainFig, hPlotAxes, 1, tsg.preference.parameter{1} );
plot_Validation( hMainFig, hPlotAxes, 2, tsg.preference.parameter{2} );
plot_Validation( hMainFig, hPlotAxes, 3, tsg.preference.parameter{3} );
Yves Gouriou
committed
% Set the pointer
% ---------------
set( hMainFig, 'Pointer', 'arrow');
end
%% CorCancelCallback .................................... Correction Module
function CorCancelCallback(hObject, eventdata)
% Callback function run when ...
% Desactivate somme Toggle button
% -------------------------------
set( hZoomInToggletool, 'state', 'off' );
set( hZoomOutToggletool, 'state', 'off' );
set( hPanToggletool, 'state', 'off' );
set( hQCToggletool, 'state', 'off' );
set( hTimelimitToggletool, 'state', 'off' );
% Get tsg application data
% ------------------------
tsg = getappdata(hMainFig, 'tsg_data');
% Get parameter we are working on (SSPS, SSJT, SSTP)
% --------------------------------------------------
PARA = tsg.preference.parameter{1};
% To cancel the correction set the ADJUSTED variable
% to []
% --------------------------------------------------
tsg.([PARA '_ADJUSTED']) = [];
tsg.([PARA '_ADJUSTED_QC']) = [];
tsg.([PARA '_ADJUSTED_ERROR']) = [];
% Save tsg data
% -------------
setappdata(hMainFig, 'tsg_data', tsg);
% Set the ADJUSTED variable either to the raw variable or to
% the calibrated variable
% ----------------------------------------------------------
% Plot in the 3 axes
% ------------------
plot_Correction( hMainFig, hPlotAxes, PARA );
end
%% CorLinearCallback .................................... Correction Module
function CorLinearCallback(hObject, eventdata)
% Callback function run when
% Desactivate somme Toggle button
% -------------------------------
set( hZoomInToggletool, 'state', 'off' );
set( hZoomOutToggletool, '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');
% Get the parameter (SSPS, SSJT, or SSTP)
% ---------------------------------------
tsg = getappdata(hMainFig, 'tsg_data');
PARA = tsg.preference.parameter{1};
SAMPLE = tsg.preference.sample;
if ~isempty( tsg.([SAMPLE '_EXT']) )
Yves Gouriou
committed
% Compute the sample-TSG differences
% ----------------------------------
diffTsgSample( hMainFig, PARA );
Yves Gouriou
committed
% Correction
% ----------
error = corTsgLinear(hMainFig, PARA, dateMin, dateMax);
Yves Gouriou
committed
switch error
Yves Gouriou
committed
case 1
Yves Gouriou
committed
% Plot in the 3 axes
% ------------------
plot_Correction( hMainFig, hPlotAxes, PARA );
case -1
msgbox( 'Date limits are not correct',...
'Correction module', 'warn', 'modal');
end
end
end
%% CorMedianCallback .................................... Correction Module
function CorMedianCallback(hObject, eventdata)
% Callback function run when
% Desactivate somme Toggle button
% -------------------------------
set( hZoomInToggletool, 'state', 'off' );
set( hZoomOutToggletool, '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');
% Get the parameter (SSPS, SSJT, or SSTP)
% ---------------------------------------
tsg = getappdata(hMainFig, 'tsg_data');
PARA = tsg.preference.parameter{1};
SAMPLE = tsg.preference.sample;
if ~isempty( tsg.([SAMPLE '_EXT']) )
Yves Gouriou
committed
% Compute the sample-TSG differences
% ----------------------------------
diffTsgSample( hMainFig, PARA );
Yves Gouriou
committed
% Correction
% ----------
error = corTsgMedian(hMainFig, PARA, dateMin, dateMax);
Yves Gouriou
committed
switch error
Yves Gouriou
committed
case 1
Yves Gouriou
committed
% Plot in the 3 axes
% ------------------
plot_Correction( hMainFig, hPlotAxes, PARA );
otherwise
% Nothing is done - Error msg within the corTsgMedian function
Yves Gouriou
committed
end
%% PopupMenu Select Parameter
% ---------------------------
function SelectParameter(hObject, eventdata, nplot)
% Callback function run when the ....
% Get application data
% --------------------
tsg = getappdata( hMainFig, 'tsg_data');
% Get the active string of the selected box
% -----------------------------------------
val = get( hObject, 'Value' );
string_list = get( hObject, 'String' );
selected_string = string_list{val};
% Get the default parameter
% -------------------------
tsg.preference.parameter{nplot} = selected_string;
if nplot == 1
tsg.preference.sample = selected_string;
if strcmp( tsg.preference.sample, 'SSJT' )
tsg.preference.sample = 'SSTP';
end
end
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
% Save application data
% --------------------
setappdata( hMainFig, 'tsg_data', tsg);
% Disable the climatology
% -----------------------
plotClim = 0;
if strcmp( get(hClimToggletool, 'state'), 'on' )
set( hClimToggletool, 'state', 'off' );
plotClim = 1;
end
% Disable the climatology
% -----------------------
set( hClimToggletool, 'state', 'off' );
plot_Validation( hMainFig, hPlotAxes, 1, tsg.preference.parameter{1} );
plot_Validation( hMainFig, hPlotAxes, 2, tsg.preference.parameter{2} );
plot_Validation( hMainFig, hPlotAxes, 3, tsg.preference.parameter{3} );
% Plot the climatology if it was already plotted
% ----------------------------------------------
if plotClim
set( hClimToggletool, 'state', 'on' );
plot_Climatology(hMainFig, hPlotAxes);
%% SelectTime_OnMenuCallback
%---------------------------
function SelectTime_OnMenuCallback(hObject, eventdata)
% Callback function run when the ....
% Desactivate Zoom and Pan functions.
% ----------------------------------
set( hZoomInToggletool, 'state', 'off' );
set( hZoomOutToggletool, 'state', 'off' );
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
set( hQCToggletool, 'state', 'off' );
set( hPanToggletool, 'state', 'off' );
% Create a pointer to select the time limits
% ------------------------------------------
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
% ---------------
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);
end
end
%% SelectTime_OffMenuCallback
%----------------------------
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');
end
%% Clim_OffMenuCallback
%------------------------------------------------------------------------
% Callback function run when the Levitus climatology toolbar is unselected
%------------------------------------------------------------------------
function Clim_OffMenuCallback(hObject, eventdata)
% Get lines handles from tag
% --------------------------
hLines = findobj('-regexp', 'Tag', 'TAG_LINE_CLIMATO_');
% Delete climatology lines on axes
% ---------------------------------
delete(hLines);
end
%% Clim_OnMenuCallback
%------------------------------------------------------------------------
% Callback function run when the Levitus climatology toolbar is unselected
%------------------------------------------------------------------------
function Clim_OnMenuCallback(hObject, eventdata)
% Test if the TSG and bucket files have been read
% -----------------------------------------------
if strcmp( get(hOpenMenu, 'UserData'), 'on' )
% plot climatology
% ----------------
plot_Climatology(hMainFig, hPlotAxes);
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
end
end
%% ClimatoSelectMenuCallback
% -------------------------------------------------------------------
% Callback function run when climato submenu is selected
% -------------------------------------------------------------------
function ClimatoSelectMenuCallback(hObject, eventdata, climato, time)
% find all climato submenu and set 'checked' property to 'off'
% ------------------------------------------------------------
hdl = findobj( '-regexp', 'tag', 'TAG_UIMENU_CLIMATO');
set(hdl, 'checked', 'off');
% set current climato submenu checked
% -----------------------------------
set(hObject, 'checked', 'on');
% memorize action on climatology menu for next use
% ------------------------------------------------
s.type = climato;
s.time = time;
set(hClimatoMenu, 'userdata', s);
% check if climatology toggle button is set
% -----------------------------------------
if strcmp(get(hClimToggletool, 'state'), 'on')
% clear last plotted climatology
% ------------------------------
Clim_OffMenuCallback;
% plot and read (eventually) new climatology
% ------------------------------------------
plot_Climatology(hMainFig, hPlotAxes);
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
end
end
%% PreferencesMenuCallback
% -------------------------------------------------------------------
% Callback function run when Option/Preference is selected
% -------------------------------------------------------------------
function PreferencesMenuCallback(hObject, eventdata)
% Test if the preference menu is allready checked
% -----------------------------------------------
if strcmp( get(hObject, 'checked'), 'on' )
% set preference autoload off (unchecked)
% ---------------------------------------
tsg.preference.autoload = 'off';
else
% set preference autoload on (checked)
% ------------------------------------
tsg.preference.autoload = 'on';
end
% set current option/preference submenu state
% -------------------------------------------
set(hObject, 'checked', tsg.preference.autoload);
end
%% HeaderMenuCallback
% -------------------------------------------------------------------
% Callback function run when the headerForm tool bar item is selected
% -------------------------------------------------------------------
function HeaderMenuCallback(hObject, eventdata)
% call header form function
% -------------------------
headerForm(hMainFig);
end
%% PrintFigMenuCallback
% -------------------------------------------------------------------
% Callback function run when the Report tool bar item is selected
% -------------------------------------------------------------------
function PrintFigMenuCallback(hObject, eventdata)
% disable ButtonMotion on main fig during select
% prevent drawing to map
% ----------------------------------------------
set( hMainFig, 'WindowButtonMotionFcn', []);
%msgbox( 'Function not yet implemented', 'warn', 'modal');
% Get the tsg structure
% ---------------------
tsg = getappdata( hMainFig, 'tsg_data');
% Default parameter
% -----------------
PARA = tsg.preference.parameter{1};
hPrintFig = figure( 'Name', 'Print','NumberTitle', 'off','Resize', 'on');
hPlot(1) = subplot(3,1,1);
hPlot(2) = subplot(3,1,2);
hPlot(3) = subplot(3,1,3);
title( hPlot(1), tsg.file.name);
if strcmp(get(hBottleToggletool,'state'), 'on')
plot_Correction( hMainFig, hPlot, PARA );
elseif strcmp(get(hCalToggletool,'state'), 'on')
plot_Calibration( hMainFig, hPlot, 1, 'SSPS' );
plot_Calibration( hMainFig, hPlot, 2, 'SSJT' );
plot_Calibration( hMainFig, hPlot, 3, 'SSTP' );
% elseif strcmp(get(hMapToggletool,'state'), 'on')
% plot_map( hMainFig, hPlot)
elseif strcmp(get(hInterpToggletool,'state'), 'on')
plot_Interpolation( hMainFig, hPlot, 1 );
plot_Interpolation( hMainFig, hPlot, 2 );
plot_Interpolation( hMainFig, hPlot, 3 );
else
plot_Validation( hMainFig, hPlotAxes, 1, tsg.preference.parameter{1} );
plot_Validation( hMainFig, hPlotAxes, 2, tsg.preference.parameter{2} );
plot_Validation( hMainFig, hPlotAxes, 3, tsg.preference.parameter{3} );
% I = getframe(hPlotAxes(1));
% imwrite(I.cdata, 'myplot.png');
end
for i = 1 : length( hPlot )
set(hPlot(i), 'box', 'on','XTickMode','auto');
datetick(hPlot(i),'x','keeplimits' );
end
% enable ButtonMotion on main fig after select QC area
% ----------------------------------------------------
set( hMainFig, 'WindowButtonMotionFcn', @MouseMotion);
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
end
%% ReportMenuCallback
% -------------------------------------------------------------------
% Callback function run when the Report tool bar item is selected
% -------------------------------------------------------------------
function ReportMenuCallback(hObject, eventdata)
% call report function
% --------------------
saveReport(hMainFig);
end
%% SaveMenuCallback
% -------------------------------------------------------------------
% Callback function run when the Save menu item is selected
% -------------------------------------------------------------------
function SaveMenuCallback(hObject, eventdata)
% Retrieve named application data
% -------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
% fill or append header form
% -------------------------
error = headerForm(hMainFig);
% if user press continue button, ask for netcdf file
% ------------------------------------------------
if error ~= -1
[fileName, pathName, filterindex] = uiputfile('*.nc', ...
'Save file name', strcat(tsg.file.name, '.nc'));
% if user press cancel button, all var are set to zero
% ----------------------------------------------------
if filterindex == 0
return;
end