Skip to content
Snippets Groups Projects
Commit 6ca994a6 authored by jacques.grelet_ird.fr's avatar jacques.grelet_ird.fr
Browse files

utilise les conventions NetCDF V1.4

parent 381190a2
No related branches found
No related tags found
No related merge requests found
......@@ -62,13 +62,14 @@ function tsgqc_GUI
'Resize', 'on', ...
'Menubar','none', ...
'Toolbar', 'none', ...
'Tag', 'ButtonMotionOff', ...
'UserData', 'ButtonMotionOff', ...
'WindowButtonMotionFcn', @MouseMotion, ...
'CloseRequestFcn', @QuitProgram,...
'HandleVisibility','callback',...
'Visible','on',...
'Units', 'normalized',...
'Position',guiLimits);
'Position',guiLimits, ...
'Color', get( 0, 'DefaultUIControlBackgroundColor' ));
% Construct the Menu
% -----------------
......@@ -78,7 +79,7 @@ function tsgqc_GUI
'Label', 'File');
hOpenMenu = uimenu(...
'Parent', hFileMenu,...
'Tag', 'off', ...
'UserData', 'off', ...
'Label','Open',...
'Accelerator','O',...
'HandleVisibility','callback',...
......@@ -87,7 +88,7 @@ function tsgqc_GUI
'Parent', hFileMenu,...
'Label','Save',...
'Accelerator','S',...
'Tag', 'off', ...
'UserData', 'off', ...
'HandleVisibility','callback',...
'Callback',@SaveMenuCallback);
hQuitMenu = uimenu(...
......@@ -103,12 +104,24 @@ function tsgqc_GUI
hToolbar = uitoolbar(... % Toolbar for Open and Print buttons
'Parent',hMainFig, ...
'HandleVisibility','callback');
hOpenPushtool = uipushtool(... % Opendoc toolbar button
'Parent',hToolbar,...
'TooltipString','Open file',...
'CData', iconRead(fullfile(matlabroot, ...
'/toolbox/matlab/icons/opendoc.mat')),...
'HandleVisibility','callback', ...
'Tag','PUSHTOOL_OPEN',...
'UserData', 'off',...
'Enable', 'on',...
'ClickedCallback', @OpenMenuCallback);
hSavePushtool = uipushtool(... % Open Save toolbar button
'Parent',hToolbar,...
'TooltipString','Save file',...
'TooltipString','Save NetCDF file',...
'CData',iconRead( ...
[DEFAULT_PATH_FILE 'tsg_icon' filesep 'savedoc.mat']),...
'HandleVisibility','callback', ...
'Tag','PUSHTOOL_SAVE',...
'Enable', 'off',...
'ClickedCallback', @SaveMenuCallback);
hZoomPushtool = uipushtool(... % Open Zoom toolbar button
'Parent',hToolbar,...
......@@ -117,6 +130,8 @@ function tsgqc_GUI
'CData', iconRead(fullfile(matlabroot, ...
'/toolbox/matlab/icons/zoom.mat')),...
'HandleVisibility','callback', ...
'Tag','PUSHTOOL_ZOOM',...
'Enable', 'off',...
'ClickedCallback', @ZoomMenuCallback);
hPanPushtool = uipushtool(... % Open Pan toolbar button
'Parent',hToolbar,...
......@@ -124,43 +139,62 @@ function tsgqc_GUI
'CData',iconRead(fullfile(matlabroot, ...
'/toolbox/matlab/icons/pan.mat')),...
'HandleVisibility','callback', ...
'Tag','PUSHTOOL_PAN',...
'Enable', 'off',...
'ClickedCallback', @PanMenuCallback);
hQCPushtool = uipushtool(... % Open QC toolbar button
'Parent',hToolbar,...
'TooltipString','Validation codes',...
'Separator', 'on', ...
'Tag', 'off', ...
'CData',iconRead(...
[DEFAULT_PATH_FILE 'tsg_icon' filesep 'qcicon.mat']),...
'HandleVisibility','callback', ...
'Tag','QC',...
'UserData', 'off',...
'Enable', 'off',...
'ClickedCallback', @QCMenuCallback);
hMapPushtool = uipushtool(... % Open Map toolbar button
'Parent',hToolbar,...
'TooltipString','Map and ship track',...
'Separator', 'on', ...
'Tag', 'off', ...
'CData',iconRead(...
[DEFAULT_PATH_FILE 'tsg_icon' filesep 'mapicon.mat']),...
'HandleVisibility','callback', ...
'Tag','PUSHTOOL_MAP',...
'UserData', 'off', ...
'Enable', 'off',...
'ClickedCallback', @MapMenuCallback);
hClimPushtool = uipushtool(... % Open Climatology toolbar button
'Parent',hToolbar,...
'TooltipString','Climatology',...
'Separator', 'on', ...
'Tag', 'off', ...
'CData',iconRead(...
[DEFAULT_PATH_FILE 'tsg_icon' filesep 'climicon.mat']),...
'HandleVisibility','callback', ...
'Tag','PUSHTOOL_CLIM',...
'UserData', 'off',...
'Enable', 'off',...
'ClickedCallback', @ClimMenuCallback);
hBottlePushtool = uipushtool(... % Open toolbar button
'Parent',hToolbar,...
'TooltipString','Plot the Samples',...
'Separator', 'on', ...
'Tag', 'off', ...
'CData',iconRead(...
[DEFAULT_PATH_FILE 'tsg_icon' filesep 'bottleicon.mat']),...
'HandleVisibility','callback', ...
'Tag','BOTTLE',...
'Enable', 'off',...
'ClickedCallback', @BottleMenuCallback);
hHeaderPushtool = uipushtool(... % Open headerForm button
'Parent',hToolbar,...
'TooltipString','Fill the header form',...
'Separator', 'on', ...
'CData',iconRead(...
[DEFAULT_PATH_FILE 'tsg_icon' filesep 'hdricon.mat']),...
'HandleVisibility','callback', ...
'Tag','PUSHTOOL_HEADER',...
'Enable', 'off',...
'ClickedCallback', @HeaderMenuCallback);
% Static text that displays the position, salinity and temperature
% ----------------------------------------------------------------
......@@ -208,11 +242,12 @@ function tsgqc_GUI
'Units', 'normalized', ...
'Visible', 'off', ...
'Color', 'none', ...
'Tag', 'off', ...
'UserData', 'off', ...
'UserData', [], ...
'HandleVisibility','callback', ...
'Position',[.05, .05, .9, .9]);
% Construct the context menu for the Quality control codes
% -------------------------------------------------------
hQcCmenu = uicontextmenu(...
......@@ -275,6 +310,7 @@ function tsgqc_GUI
error1 = -1;
error2 = -1;
if ~isequal(filename, 0)
% Read the data
......@@ -287,6 +323,10 @@ function tsgqc_GUI
error1 = tsg_readTsgDataXML( hMainFig, filename );
case 3
error1 = tsg_readTsgDataNetCDF( hMainFig, filename );
%# a modifier
if error1 == 1
error2 = error1;
end
case 4
error2 = tsg_readBucketData(hMainFig, filename );
otherwise
......@@ -300,12 +340,15 @@ function tsgqc_GUI
% A TSG file has been open and read
% ---------------------------------
set( hOpenMenu, 'Tag', 'on' );
set( hOpenMenu, 'UserData', 'on' );
hdl_pushtool = findobj('-regexp','Tag', 'PUSHTOOL_');
set(hdl_pushtool, 'Enable', 'on');
% The callback to detect the mouse motion can be set to on
% --------------------------------------------------------
set( hMainFig, 'Tag', 'ButtonMotionOn');
set( hMainFig, 'UserData', 'ButtonMotionOn');
% Make the Salinity, temperature and velocity plot
% ------------------------------------------------
tsg_plot_SalTempVel( hMainFig, hPlotAxes );
......@@ -320,14 +363,22 @@ function tsgqc_GUI
% Merge the different water sample (NetCdf or ASCII files) in
% a unique structure : 'sample'
% -----------------------------------------------------------
[sample] = tsg_mergesample( hMainFig );
% Save the 'sample' struct. as an application data
%@ desactive le merge pour l'instant en attente d'une structure de
%donnes validee
%@[sample] = tsg_mergesample( hMainFig );
%@ Save the 'sample' struct. as an application data
% ------------------------------------------------
if ~isempty( sample )
setappdata( hMainFig, 'sample', sample );
%if ~isempty( sample )
% setappdata( hMainFig, 'sample', sample );
%end
% Plot Salinity bucket
% ------------------------------------------------
if error2 ~= -1
tsg_plot_SalTsgSample( hMainFig, hPlotAxes );
end
% Pointer reset to arrow
% ----------------------
set( hMainFig, 'Pointer', 'arrow' );
......@@ -348,7 +399,7 @@ function tsgqc_GUI
zoomAdaptiveDateTicks('off');
case 'off'
pan off
set(hQCPushtool, 'Tag', 'off' );
set(hQCPushtool, 'UserData', 'off' );
zoom on
zoomAdaptiveDateTicks('on');
......@@ -371,7 +422,7 @@ function tsgqc_GUI
panAdaptiveDateTicks('off');
case 'off'
zoom off
set(hQCPushtool, 'Tag', 'off' );
set(hQCPushtool, 'UserData', 'off' );
pan on
panAdaptiveDateTicks('on');
......@@ -394,26 +445,26 @@ function tsgqc_GUI
% Toggle the tag of the Qc pushbutton to 'on' or 'off'
% ----------------------------------------------------
switch get(hQCPushtool, 'Tag');
switch get(hQCPushtool, 'UserData');
case 'off'
set(hQCPushtool, 'Tag', 'on' );
set(hQCPushtool, 'UserData', 'on' );
set(hPlotAxes(1),'UIContextMenu', hQcCmenu);
set( hMainFig, 'Pointer', 'crosshair');
case 'on'
set(hQCPushtool, 'Tag', 'off' );
set(hQCPushtool, 'UserData', 'off' );
set(hPlotAxes(1),'UIContextMenu', []);
set(hMainFig,'Pointer','arrow');
end
qualityCode = -1;
ind = [];
while strcmp( get(hQCPushtool, 'Tag'),'on')
while strcmp( get(hQCPushtool, 'UserData'),'on')
k = waitforbuttonpress;
% If the QC pushbutton is pressed we quit the callback
% ----------------------------------------------------
if strcmp( get(hQCPushtool, 'Tag'),'off')
if strcmp( get(hQCPushtool, 'UserData'),'off')
% Desactivate the context menu use to choose the
% Quality Codes
......@@ -437,7 +488,7 @@ function tsgqc_GUI
% made. Otherwise there is a conflict with the map if it
% is activated
% -------------------------------------------------------
set( hMainFig, 'Tag', 'ButtonMotionOff');
set( hMainFig, 'UserData', 'ButtonMotionOff');
% Selection of the data within the figure
% ---------------------------------------
......@@ -451,17 +502,17 @@ function tsgqc_GUI
p1 = min(point1,point2);
p2 = max(point1,point2); % calculate locations
ind = find(tsg.TIME > p1(1,1) & tsg.TIME < p2(1,1) & ...
tsg.PSAL > p1(1,2) & tsg.PSAL < p2(1,2));
ind = find(tsg.DAYD > p1(1,1) & tsg.DAYD < p2(1,1) & ...
tsg.SSPS > p1(1,2) & tsg.SSPS < p2(1,2));
% As soon as a modification took place the data should be
% saved
% -------------------------------------------------------
set( hSaveMenu, 'Tag', 'on' );
set( hSaveMenu, 'UserData', 'on' );
% Selection made : Mouse motion callback re-activated
% --------------------------------------------------
set( hMainFig, 'Tag', 'ButtonMotionOn');
set( hMainFig, 'UserData', 'ButtonMotionOn');
end
......@@ -472,7 +523,7 @@ function tsgqc_GUI
quality = get( hQcCmenu, 'UserData');
tsg.PSAL_QC(ind) = quality.Code;
tsg.SSPS_QC(ind) = quality.Code;
% Save the modifications
% ----------------------
......@@ -481,7 +532,7 @@ function tsgqc_GUI
axes(hPlotAxes(1));
hold on
color = ['.' quality.Color];
plot(tsg.TIME(ind), tsg.PSAL(ind), color );
plot(tsg.DAYD(ind), tsg.SSPS(ind), color );
hold off
end
......@@ -578,7 +629,7 @@ function tsgqc_GUI
% Test if the callback can be activated
% -------------------------------------
if strcmp( get( hMainFig, 'Tag'), 'ButtonMotionOn')
if strcmp( get( hMainFig, 'UserData'), 'ButtonMotionOn')
% Retrieve named application data
% -------------------------------
......@@ -595,19 +646,19 @@ function tsgqc_GUI
% -----------------------------------------------------------
[x, y] = gpos(hPlotAxes(1));
if x > tsg.TIME(1) && x < tsg.TIME(end)
if x > tsg.DAYD(1) && x < tsg.DAYD(end)
indCursor = find( tsg.TIME > x);
indCursor = find( tsg.DAYD > x);
% use sprintf with format instead strcat & num2str but flag
% - don't work with 0, eg %+07.4f
set( hInfoText, 'String',...
sprintf(['%s - Latitude = %s - Longitude = %s '...
' - Salinity = %07.4f - Temperature = %07.4f'],...
datestr(tsg.TIME(indCursor(1)),'dd/mm/yyyy HH:MM'),...
dd2dm(tsg.LATITUDE(indCursor(1)),0), ...
dd2dm(tsg.LONGITUDE(indCursor(1)),1), ...
tsg.PSAL(indCursor(1)), ...
tsg.TEMP_TSG(indCursor(1))...
datestr(tsg.DAYD(indCursor(1)),'dd/mm/yyyy HH:MM'),...
dd2dm(tsg.LATX(indCursor(1)),0), ...
dd2dm(tsg.LONX(indCursor(1)),1), ...
tsg.SSPS(indCursor(1)), ...
tsg.SSJT(indCursor(1))...
));
% Plot the position on the map if this one is active
......@@ -620,17 +671,17 @@ function tsgqc_GUI
if isempty( get(hMapPanel, 'UserData'))
hMarker = m_line( ...
tsg.LONGITUDE(indCursor(1)), tsg.LATITUDE(indCursor(1)),...
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.LONGITUDE(indCursor(1)), tsg.LATITUDE(indCursor(1)),...
tsg.LONX(indCursor(1)), tsg.LATX(indCursor(1)),...
'Marker','o','MarkerSize',5, ...
'Color','r', 'MarkerFaceColor','r');
set(hMapPanel, 'UserData', hMarker);
set(hMapPanel, 'UserData', hMarker);
end
end
end
......@@ -661,11 +712,11 @@ function tsgqc_GUI
% Test if the sample Push button has been pressed
% -----------------------------------------------
if strcmp( get(hBottlePushtool, 'Tag'), 'off')
if strcmp( get(hBottlePushtool, 'UserData'), 'off')
% Sample Push button - Tag set to 'on'
% Sample Push button - UserData set to 'on'
% ------------------------------------
set( hBottlePushtool, 'Tag', 'on' );
set( hBottlePushtool, 'UserData', 'on' );
% Test if tsg and sample data have been loaded
% --------------------------------------------
......@@ -688,7 +739,7 @@ function tsgqc_GUI
% Plot the samples if the TSG file has been read
% ----------------------------------------------
% if strcmp( get(hOpenMenu, 'Tag'), 'on' ) && ~isempty( sample )
% if strcmp( get(hOpenMenu, 'UserData'), 'on' ) && ~isempty( sample )
% axes( hPlotAxes(1) );
% hLine.Sample = line( ...
% sample.TIME, sample.PSAL,...
......@@ -702,7 +753,7 @@ function tsgqc_GUI
% else
set( hBottlePushtool, 'Tag', 'off' );
set( hBottlePushtool, 'UserData', 'off' );
% The bucket pushbutton has been pressed again :
% Delete the bucket on figure
......@@ -724,16 +775,16 @@ function tsgqc_GUI
% Test if the climatology Push button has been pressed
% ----------------------------------------------------
if strcmp( get(hClimPushtool, 'Tag'), 'off')
if strcmp( get(hClimPushtool, 'UserData'), 'off')
% Climatology push button - Tag set to 'on'
% Climatology push button - UserData set to 'on'
% -----------------------------------------
set( hClimPushtool, 'Tag', 'on' );
set( hClimPushtool, 'UserData', 'on' );
% Test if the TSG and bucket files have been read
% -----------------------------------------------
if strcmp( get(hOpenMenu, 'Tag'), 'on' )
if strcmp( get(hOpenMenu, 'UserData'), 'on' )
% Get data
% -----------------------
......@@ -743,35 +794,36 @@ function tsgqc_GUI
% Read Climatology
% ----------------
if ~isfield( tsg, 'LEVITUS')
lev = read_file_woa01( 'woa01an.nc' );
if ~isstruct(lev)
if isempty( tsg.levitus.data)
levitus = read_file_woa01( 'woa01an.nc' );
if ~isstruct(levitus)
errordlg({'NetCDF climatology file not present in you path',...
'Check your matlab path or download it from',...
'ftp://ftp.ifremer.fr/ifremer/ird/us191/oceano/lib/matlab/woa01an.nc'},...
'NetCDF climatology file access error');
return;
else
tsg.LEVITUS = lev;
tsg.levitus.data = levitus;
tsg.levitus.type = 'woa01an';
end
setappdata( hMainFig, 'tsg_data', tsg );
end
% round positive latitude and Longitude toward zero
% -------------------------------------------------
ind = find(tsg.LATITUDE > 0);
lat(ind) = fix(tsg.LATITUDE(ind)) + 0.5;
ind = find(tsg.LATX > 0);
lat(ind) = fix(tsg.LATX(ind)) + 0.5;
ind = find(tsg.LONGITUDE > 0);
lon(ind) = fix(tsg.LONGITUDE(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.LATITUDE <= 0);
lat(ind) = floor(tsg.LATITUDE(ind)) + 0.5;
ind = find(tsg.LATX <= 0);
lat(ind) = floor(tsg.LATX(ind)) + 0.5;
ind = find(tsg.LONGITUDE <= 0);
lon(ind) = floor(tsg.LONGITUDE(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
......@@ -785,9 +837,9 @@ function tsgqc_GUI
ind = find(abs(lat_diff) == 1 | abs(lon_diff == 1));
lat2 = lat( ind );
lon2 = lon( ind );
time = tsg.TIME( ind );
temp = tsg.TEMP_TSG( ind );
psal = tsg.PSAL( ind );
time = tsg.DAYD( ind );
temp = tsg.SSJT( ind );
psal = tsg.SSPS( ind );
% Get Climatology
% LATX(80) = -0.5 et LATX(81) = 0.5
......@@ -799,12 +851,12 @@ function tsgqc_GUI
std_temp = zeros(size(ind));
std_psal = zeros(size(ind));
for i=1:length(ind)
ilat = find(tsg.LEVITUS.WOA01_LATX == lat2(i));
ilon = find(tsg.LEVITUS.WOA01_LONX == lon2(i));
mean_temp(i) = tsg.LEVITUS.WOA01_MEAN_TEMP(ilat,ilon,1);
mean_psal(i) = tsg.LEVITUS.WOA01_MEAN_PSAL(ilat,ilon,1);
std_temp(i) = tsg.LEVITUS.WOA01_STD_TEMP(ilat,ilon,1);
std_psal(i) = tsg.LEVITUS.WOA01_STD_PSAL(ilat,ilon,1);
ilat = find(tsg.levitus.data.WOA01_LATX == lat2(i));
ilon = find(tsg.levitus.data.WOA01_LONX == lon2(i));
mean_temp(i) = tsg.levitus.data.WOA01_MEAN_TEMP(ilat,ilon,1);
mean_psal(i) = tsg.levitus.data.WOA01_MEAN_PSAL(ilat,ilon,1);
std_temp(i) = tsg.levitus.data.WOA01_STD_TEMP(ilat,ilon,1);
std_psal(i) = tsg.levitus.data.WOA01_STD_PSAL(ilat,ilon,1);
end
% Plot mean salinity climatology
......@@ -832,7 +884,7 @@ function tsgqc_GUI
else
set( hClimPushtool, 'Tag', 'off' );
set( hClimPushtool, 'UserData', 'off' );
% The bucket pushbutton has been pressed again :
% Delete the bucket on figure
......@@ -852,31 +904,70 @@ function tsgqc_GUI
end
end
% -----------------------------------------------------------------
% -------------------------------------------------------------------
function HeaderMenuCallback(hObject, eventdata)
% Callback function run when the headerForm tool bar item is selected
% call header form function
% -------------------------
headerForm(hMainFig);
end
% -------------------------------------------------------------------
function SaveMenuCallback(hObject, eventdata)
% Callback function run when the Save menu item is selected
[fileName, pathName, filterIndex] = uiputfile('*.txt', ...
% 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');
% 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
% -----------------
fileName = [pathName fileName];
error = tsg_writeTsgData( hMainFig, fileName );
if ~error
%
error = tsg_writeTSGDataNetCDF( hMainFig, fileName );
% Pointer reset to arrow
% ----------------------
set( hMainFig, 'Pointer', 'arrow' );
% Check for a writing pb to NetCDF
% must to be rewriting
% --------------------------------
if error == -1
warning(['NetCDF writing error:' fileName]);
end
end
end
% -----------------------------------------------------------------
function QuitMenuCallback(hObject, eventdata)
% Callback function run when the Quit menu item is selected
% If the data have been modified and not save, the program
% propose to save the data
% --------------------------------------------------------
if strcmp( get( hSaveMenu, 'Tag' ), 'on')
if strcmp( get( hSaveMenu, 'UserData' ), 'on')
selection = ...
questdlg('The file has been modified. Do you want to save it ?',...
'Save before Quit?',...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment