Newer
Older

jacques.grelet_ird.fr
committed
% ---------------------------------------------------------
set(hPlotAxes(1),'UIContextMenu', hQcCmenu);

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');
Yves Gouriou
committed

jacques.grelet_ird.fr
committed
% Active keyPress/release callback in QC mode for PAN and Zoom
% ------------------------------------------------------------
%set( hMainFig, 'KeyReleaseFcn', @QC_keyReleaseCallback);

jacques.grelet_ird.fr
committed
%set( hMainFig, 'KeyReleaseFcn',@QC_keyReleaseCallback);

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)

jacques.grelet_ird.fr
committed
% 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');
% 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

jacques.grelet_ird.fr
committed

jacques.grelet_ird.fr
committed
point1 = point1(1,1:2); % extract x and y
point2 = point2(1,1:2);
p1 = min(point1,point2);
p2 = max(point1,point2); % calculate locations

jacques.grelet_ird.fr
committed

jacques.grelet_ird.fr
committed
% 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));

jacques.grelet_ird.fr
committed

jacques.grelet_ird.fr
committed
tsg.SSPS_QC(ind) = tsg.qc.active.Code;

jacques.grelet_ird.fr
committed
% put last SSPS_QC in queue (Undo/Redo)
% -------------------------------------
tsg.queue = push( tsg.queue, tsg.SSPS_QC);

jacques.grelet_ird.fr
committed
% set current axes and plot
% -------------------------
axes(hPlotAxes(1));
hold on

jacques.grelet_ird.fr
committed
color = ['.' tsg.qc.active.Color];

jacques.grelet_ird.fr
committed
% plot selected data with selected code
% --------------------------------------

jacques.grelet_ird.fr
committed
plot(tsg.DAYD(ind), tsg.SSPS(ind), color );
hold off
% As soon as a modification took place the data should be saved
% -------------------------------------------------------------
set( hSaveMenu, 'UserData', 'on' );
% refresh QC statistic panel
% --------------------------
display_QC( hMainFig, hPlotAxes );
% store QC in queue object, for undo
% ----------------------------------
tsg.queue = push(tsg.queue, tsg.SSPS_QC);

jacques.grelet_ird.fr
committed
% Save the modifications
% ----------------------
setappdata( hMainFig, 'tsg_data', tsg);
% enable undo menu
% ----------------
set(findobj('tag','UIMENU_UNDO'),'enable','on');

jacques.grelet_ird.fr
committed

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

jacques.grelet_ird.fr
committed
end
%% Qc context menu selected ........................ Quality Control Module
%-----------------------------------------------------------

jacques.grelet_ird.fr
committed
% Callback function run when the QC context menu is selected
%-----------------------------------------------------------

jacques.grelet_ird.fr
committed
function Qc(hObject, eventdata, key)
% Retrieve Default Quality Code and Color
% ---------------------------------------
tsg = getappdata( hMainFig, 'tsg_data');

jacques.grelet_ird.fr
committed
% 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 );

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');
% 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
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
%% 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);
% Code to Activate the PAN function when QC mode is active
% A PAN zone is defined in the bottom (5%) 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' );
limx = get(hPlotAxes(1), 'XLim');
limy = get(hPlotAxes(1), 'YLim');
% Suppose that Y axes is increasing from the bottom to the top
% ------------------------------------------------------------
limy2 = limy(1) + (limy(2)-limy(1)) * 0.05;
if x > limx(1) && x < limx(2) && y <= limy2
hPan = pan(hMainFig);
Yves Gouriou
committed
set(hPan,'ActionPreCallback', @preQcPanCallback);
set(hPan,'ActionPostCallback', @postQcPanCallback);
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
set(hPan,'Enable','on');
else
pan off
end
end
% Dynamically display data in uicontrol
% -------------------------------------
if x > tsg.DAYD(1) && x < tsg.DAYD(end)
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');
set(hMapPanel, 'UserData', hMarker);

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)
% Make the earth map invisible
% ----------------------------

jacques.grelet_ird.fr
committed
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' );

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' );
% Activate some toolbar buttons
% -----------------------------
hdl_Toggletool = findobj('-regexp','Tag', 'CORRECT_');
set(hdl_Toggletool, 'Enable', 'on');
% Test if tsg and sample data have been loaded
% --------------------------------------------
if ~isempty( tsg.SSPS_WS ) || ~isempty( tsg.SSPS_EXT )
% Merge bucket and external samples
% ---------------------------------
tsg_mergesample( hMainFig );
% Compute the sample-TSG differences
% ----------------------------------
Yves Gouriou
committed
diffTsgSample( hMainFig );
% plot Salinity Difference
% ------------------------
plot_Sample( hMainFig, hPlotAxes );
% Get the information on time limits of the time series
% Write them in the uipanel
% -----------------------------------------------------
set( hetDateMin, 'String', datestr(tsg.DAYD(1), 31));
set( hetDateMax, 'String', datestr(tsg.DAYD(end), 31));
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' );
% Desactivate some toolbar buttons
% --------------------------------
hdl_Toggletool = findobj('-regexp','Tag', 'CORRECT_');
Yves Gouriou
committed
set(hdl_Toggletool, 'Enable', 'off');
set( hStartlimitToggletool, 'State', 'off' );
set( hEndlimitToggletool, 'State', 'off' );
Yves Gouriou
committed
% Desactivate Click Mouse on figure
% ---------------------------------
set( hMainFig,'WindowButtonDownFcn', []);
Yves Gouriou
committed
% Plot the SSS, SST and Velocity
% ------------------------------
plot_SalTempVel( hMainFig, hPlotAxes );
plot_WS( hMainFig, hPlotAxes );
plot_EXT( hMainFig, hPlotAxes );
end
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
% Toggle the state of the Qc Togglebutton to 'on' or 'off'
% ----------------------------------------------------
if hObject == hEndlimitToggletool
set( hStartlimitToggletool, 'State', 'off' );
else
set( hEndlimitToggletool, 'State', 'off' );
end
% Activate clic mouse menu on first axes (salinity) for next rbbox
% DO NOT USE :
% ButtonDownFcn - the callback executes whenever you press a button
% while the pointer is within the axes, but not over another graphics
% object parented to the axes.
% -------------------------------------------------------------------
%set(hPlotAxes(1),'ButtonDownFcn', @Time_SelectCallback);
set( hMainFig,'WindowButtonDownFcn', @Time_SelectCallback);
% change cursor to crosshair aspect
% ---------------------------------
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', []);
% Get the current mouse position
% ------------------------------
a = get(hPlotAxes(1), 'CurrentPoint');
Yves Gouriou
committed
x = a(2,1);
% Write the date in the Editable uicontrol
% ----------------------------------------
if hObject == hEndlimitToggletool
set( hetDateMax, 'String', datestr(x, 31));
else
set( hetDateMin, 'String', datestr(x, 31));
end
% Enable ButtonMotion on main fig
% -------------------------------
%set( hMainFig, 'WindowButtonMotionFcn', @MouseMotion);
end
end
%% SelectTime_OffMenuCallback ........................... Correction module
%----------------------------------------------------------------------
function SelectTime_OffMenuCallback(hObject, eventdata)
% Callback function run when the ....
% Desactivate Zoom and Pan functions.
% ----------------------------------
%set( hZoomToggletool, 'state', 'off' );
%set( hQCToggletool, 'state', 'off' );
%set( hPanToggletool, 'state', 'off' );
% Desactivate time limit buttons
% ------------------------------
if hObject == hEndlimitToggletool
set( hEndlimitToggletool, 'State', 'off');
else
set( hStartlimitToggletool, 'State', 'off');
end
set(hMainFig,'Pointer','arrow');
end
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
%% CorCancelCallback .................................... Correction Module
function CorCancelCallback(hObject, eventdata)
% Callback function run when
msgbox('Method not yet implemented', 'modal' );
end
%% CorLinearCallback .................................... Correction Module
function CorLinearCallback(hObject, eventdata)
% Callback function run when
msgbox('Method not yet implemented', 'modal' );
end
%% CorMedianCallback .................................... Correction Module
function CorMedianCallback(hObject, eventdata)
% Callback function run when
% 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');
% Correction
% ----------
corTsgMethod1(hMainFig, dateMin, dateMax);
plot_TsgAdjusted(hMainFig, hPlotAxes)
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

jacques.grelet_ird.fr
committed
% Get line handles
% ----------------------------------------------
hLine1 = get( hPlotAxes(1), 'UserData');
hLine2 = get( hPlotAxes(2), 'UserData');

jacques.grelet_ird.fr
committed
% Delete climatology lines on axes

jacques.grelet_ird.fr
committed
% -----------------------------------
try
delete(hLine1.stdClimMinus);
delete(hLine1.stdClimPlus);
delete(hLine1.meanClim);
delete(hLine2.stdClimMinus);
delete(hLine2.stdClimPlus);
delete(hLine2.meanClim);
% if handle is missing, prevent warning message on console
% --------------------------------------------------------

jacques.grelet_ird.fr
committed
catch
end

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
% -----------------------------------------------
if strcmp( get(hOpenMenu, 'UserData'), 'on' )

jacques.grelet_ird.fr
committed

jacques.grelet_ird.fr
committed
% plot climatology

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

jacques.grelet_ird.fr
committed
plot_climatology();

jacques.grelet_ird.fr
committed
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
end
end
%% ClimatoSelectMenuCallback
% -------------------------------------------------------------------
% Callback function run when climato submenu is selected
% -------------------------------------------------------------------
function ClimatoSelectMenuCallback(hObject, eventdata, climato, time)
% Retrieve named application data
% -------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
% 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');
% check for different selected climatology
% ----------------------------------------
if ~strcmp( climato, tsg.levitus.type)
% different type, need to read corresponding file
% -----------------------------------------------
%tsg.levitus.type = climato;
%tsg.levitus.time = time;
% save tsg structure
% ------------------
setappdata( hMainFig, 'tsg_data', tsg );
% Read surface climatology (annual, seasonal or monthly)
% ------------------------------------------------------
read_climatology(climato);
end

jacques.grelet_ird.fr
committed
% plot new loaded climatology
% ---------------------------
plot_climatology();

jacques.grelet_ird.fr
committed
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
% save climatology state in tsg structure
% ---------------------------------------
%tsg.levitus.type = climato;
tsg.levitus.time = time;
% save tsg structure
% ------------------
setappdata( hMainFig, 'tsg_data', tsg );
end
%% Read_climatology file
% -------------------------------------------------------------------
% nested fucntion call to read climatology
% -------------------------------------------------------------------
function read_climatology(type)
% Retrieve named application data
% -------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
% is tsg.levitus empty, climatology file is not loaded in memory
% --------------------------------------------------------------

jacques.grelet_ird.fr
committed
if isempty( tsg.levitus.data) || ~strcmp(tsg.levitus.type,type)

jacques.grelet_ird.fr
committed
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
% construct the filename and read file
% ------------------------------------
file = which(['woa01_' type '_surf.nc']);
% open netcdf climatology file
% ----------------------------
levitus = read_file_woa01(file);
% test for structure concordance
% ------------------------------
if ~isstruct(levitus)
% show dialog box with help to get climatology file
% -------------------------------------------------
errordlg({'NetCDF climatology file :', file, ...
'not present in you path',...
'Check your matlab path or download it from',...
'ftp://ftp.ifremer.fr/ifremer/ird/us191/oceano/lib/matlab/woa01_annual_surf.nc'},...
'NetCDF climatology file access error');
return;
% structure is ok, save climatology & type in tsg structure
% ---------------------------------------------------------
else
tsg.levitus.data = levitus;
tsg.levitus.type = type;
end
% save tsg structure
% ------------------
setappdata( hMainFig, 'tsg_data', tsg );

jacques.grelet_ird.fr
committed
end

jacques.grelet_ird.fr
committed
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
%% Plot_climatology data
% -------------------------------------------------------------------
% nested function call to plot climatology
% -------------------------------------------------------------------
function plot_climatology()
% Get data
% -----------------------
tsg = getappdata( hMainFig, 'tsg_data' );
% Get line handles
% ----------------
hLine1 = get( hPlotAxes(1), 'UserData');
hLine2 = get( hPlotAxes(2), 'UserData');
% Read surface climatology (annual, seasonal or monthly)
% ------------------------------------------------------
read_climatology(tsg.levitus.type);
% select time dimension for climatology
dim_time = tsg.levitus.time;
% round positive latitude and Longitude toward zero
% -------------------------------------------------
ind = find(tsg.LATX > 0);
lat(ind) = fix(tsg.LATX(ind)) + 0.5;
ind = find(tsg.LONX > 0);
lon(ind) = fix(tsg.LONX(ind)) + 0.5;
% rounds negative latitude and Longitudeto the nearest lowest integers
% ---------------------------------------------------------------------
ind = find(tsg.LATX <= 0);
lat(ind) = floor(tsg.LATX(ind)) + 0.5;
ind = find(tsg.LONX <= 0);
lon(ind) = floor(tsg.LONX(ind)) + 0.5;
% Calculates differences between adjacent elements of X.
% 0 if adajacent latitude or longitude are equal
% - 1 or -1 otherwise
% ------------------------------------------------------------
lat_diff = [diff( lat )'; 0];
lon_diff = [diff( lon )'; 0];
% Select latitude and longitude
% -----------------------------
ind = find(abs(lat_diff) == 1 | abs(lon_diff == 1));
lat2 = lat( ind );
lon2 = lon( ind );
dayd = tsg.DAYD( ind );
ssjt = tsg.SSJT( ind );
ssps = tsg.SSPS( ind );
% Get Climatology
% LATX(80) = -0.5 et LATX(81) = 0.5
% LONX(180) = -0.5 et LONX(181) = 0.5
% ----------------
axes( hPlotAxes(1) );
mean_sstp = zeros(size(ind));
mean_ssps = zeros(size(ind));
std_sstp = zeros(size(ind));
std_ssps = zeros(size(ind));
for ii=1:length(ind)
ilat = find(tsg.levitus.data.WOA01_LATX == lat2(ii));
ilon = find(tsg.levitus.data.WOA01_LONX == lon2(ii));
mean_sstp(ii) = tsg.levitus.data.WOA01_MEAN_SSTP(dim_time,1,ilat,ilon);
mean_ssps(ii) = tsg.levitus.data.WOA01_MEAN_SSPS(dim_time,1,ilat,ilon);
std_sstp(ii) = tsg.levitus.data.WOA01_STD_SSTP(dim_time,1,ilat,ilon);
std_ssps(ii) = tsg.levitus.data.WOA01_STD_SSPS(dim_time,1,ilat,ilon);
end
% Plot mean salinity climatology
% ------------------------------
hLine1.meanClim = line( ...
dayd, mean_ssps,'Linestyle', '-', 'Color','k');
% Plot with 3 standard deviation
% ------------------------------
hLine1.stdClimPlus = line( ...
dayd, mean_ssps + 3 * std_ssps ,'Linestyle', '-', 'Color','r');
hLine1.stdClimMinus = line( ...
dayd, mean_ssps - 3 * std_ssps ,'Linestyle', '-', 'Color','r');
% Plot mean temperature climatology
% ---------------------------------
axes( hPlotAxes(2));
hLine2.meanClim = line( ...
dayd, mean_sstp,'Linestyle', '-', 'Color','k');
hLine2.stdClimPlus = line( ...
dayd, mean_sstp + 3 * std_sstp ,'Linestyle', '-', 'Color','r');
hLine2.stdClimMinus = line( ...
dayd, mean_sstp - 3 * std_sstp ,'Linestyle', '-', 'Color','r');
% Store the handle of the bucketline
% ----------------------------------
set( hPlotAxes(1), 'UserData', hLine1 );
set( hPlotAxes(2), 'UserData', hLine2 );
% save tsg structure
% ------------------
setappdata( hMainFig, 'tsg_data', tsg );
end
%% HeaderMenuCallback

jacques.grelet_ird.fr
committed
% -------------------------------------------------------------------
% Callback function run when the headerForm tool bar item is selected
% -------------------------------------------------------------------

jacques.grelet_ird.fr
committed
function HeaderMenuCallback(hObject, eventdata)

jacques.grelet_ird.fr
committed

jacques.grelet_ird.fr
committed
% call header form function
% -------------------------
headerForm(hMainFig);

jacques.grelet_ird.fr
committed

jacques.grelet_ird.fr
committed
end
%% SaveMenuCallback

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

jacques.grelet_ird.fr
committed
function SaveMenuCallback(hObject, eventdata)

jacques.grelet_ird.fr
committed

jacques.grelet_ird.fr
committed
% Retrieve named application data
% -------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
% get fileName without extension in cell
% --------------------------------------
file = textscan( tsg.file.name,'%s','delimiter','.');

jacques.grelet_ird.fr
committed
% 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', ...

jacques.grelet_ird.fr
committed
'Save file name', [file{1}{1} '.nc']);

jacques.grelet_ird.fr
committed
% if user press cancel button, all var set to zero
% ------------------------------------------------
if fileName == 0
return;
end
% Pointer set to watch during reading and plotting
% ------------------------------------------------
set( hMainFig, 'Pointer', 'watch' );
% flushes the event queue and updates the closed uiputfile window
% ---------------------------------------------------------------
drawnow;
% write netcdf file
% -----------------

jacques.grelet_ird.fr
committed
error = writeTSGDataNetCDF( hMainFig, [pathName fileName] );

jacques.grelet_ird.fr
committed
% Pointer reset to arrow
% ----------------------
set( hMainFig, 'Pointer', 'arrow' );
% Check for a writing pb to NetCDF
% must to be rewriting
% --------------------------------
if error == -1

jacques.grelet_ird.fr
committed
warning('NetCDF writing error: %s %s', pathName, fileName);

jacques.grelet_ird.fr
committed
return;

jacques.grelet_ird.fr
committed

jacques.grelet_ird.fr
committed
% update the display
% ------------------
set( hInfoFileText, 'String', fileName);

jacques.grelet_ird.fr
committed

jacques.grelet_ird.fr
committed
% enable Quality Control mode
% ---------------------------
hdl_pushtool = findobj('Tag', 'QC');
set(hdl_pushtool, 'Enable', 'on');

jacques.grelet_ird.fr
committed

jacques.grelet_ird.fr
committed
end
%% QuitMenuCallback

jacques.grelet_ird.fr
committed
% -----------------------------------------------------------------
% Callback function run when the Quit menu item is selected
% -----------------------------------------------------------------
function QuitMenuCallback(hObject, eventdata)

jacques.grelet_ird.fr
committed
% If the data have been modified and not save, the program

jacques.grelet_ird.fr
committed
% ask to save the data

jacques.grelet_ird.fr
committed
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
% --------------------------------------------------------
if strcmp( get( hSaveMenu, 'UserData' ), 'on')
selection = ...
questdlg('The file has been modified. Do you want to save it ?',...
'Save before Quit?',...
'Yes', 'No', 'Yes');
if strcmp(selection, 'Yes')
return;
else
QuitProgram;
end
else
selection = ...
questdlg(['Quit ' get(hMainFig, 'Name') '?'],...
['Quit ' get(hMainFig, 'Name') '?'],...
'Yes', 'No', 'Yes');
if strcmp(selection, 'No')
return;
else
QuitProgram;
end

jacques.grelet_ird.fr
committed
end

jacques.grelet_ird.fr
committed
end
%% UndoMenuCallback
% -----------------------------------------------------------------------
% Callback function run when the Edit/Undo menu item is selected (Ctrl+Z)
% -----------------------------------------------------------------------
function UndoMenuCallback(hObject, eventdata)
% Undo module not yet implemented
% -------------------------------
% msgbox('Undo module not yet implemented', 'modal');
tsg.queue = undo(tsg.queue);
tsg.SSPS_QC = get(tsg.queue);
% Make the Salinity, temperature and velocity plot
% ------------------------------------------------
plot_SalTempVel( hMainFig, hPlotAxes );
end
%% RedoMenuCallback
% -----------------------------------------------------------------------
% Callback function run when the Edit/Redo menu item is selected (Ctrl+R)
% -----------------------------------------------------------------------
function RedoMenuCallback(hObject, eventdata)
% Redo module not yet implemented
% -------------------------------
msgbox('Redo module not yet implemented', 'modal');
end
%% QuitProgram

jacques.grelet_ird.fr
committed
% -----------------------------------------------------------------
% call from:
% QuitMenuCallback
% callback 'CloseRequestFcn', @QuitProgram

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

jacques.grelet_ird.fr
committed
function QuitProgram(hObject, eventdata)

jacques.grelet_ird.fr
committed
% close the main windows
% ----------------------

jacques.grelet_ird.fr
committed
delete(hMainFig);

jacques.grelet_ird.fr
committed

jacques.grelet_ird.fr
committed
% reset Matlab search path to default

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

jacques.grelet_ird.fr
committed
rmpath( [DEFAULT_PATH_FILE filesep 'tsg_util'] );
rmpath( [DEFAULT_PATH_FILE filesep 'tsg_data'] );
rmpath( [DEFAULT_PATH_FILE filesep 'tsg_io'] );

jacques.grelet_ird.fr
committed
% Refresh file system caches
% --------------------------

jacques.grelet_ird.fr
committed
rehash;

jacques.grelet_ird.fr
committed

jacques.grelet_ird.fr
committed
end

jacques.grelet_ird.fr
committed
% end of tsgqc_GUI
% ----------------
end