Skip to content
Snippets Groups Projects
Commit 529f45ea authored by Yves Gouriou's avatar Yves Gouriou
Browse files

tsgqc_GUI modifie pour :

1 - lecture du fichier bucket ASCII a partir du menu open. Extension '.btl'
2 - fusionner les buckets de type NETCDF et ASCII dans une structure unique 'sample'
parent 6bc9143c
No related branches found
No related tags found
No related merge requests found
...@@ -61,8 +61,8 @@ sample = dev_mergesample( bucketNETCDF, bucketASCII); ...@@ -61,8 +61,8 @@ sample = dev_mergesample( bucketNETCDF, bucketASCII);
sample = dev_diffTsgSample(tsg, psal_smooth, sample, TSG_SAMPLING_TIME); sample = dev_diffTsgSample(tsg, psal_smooth, sample, TSG_SAMPLING_TIME);
dateMin = tsg.TIME(1); dateMin = tsg.TIME(5000);
dateMax = tsg.TIME(end); dateMax = tsg.TIME(10000);
tsg = dev_corMethod1(tsg, sample, dateMin, dateMax, COR_TIME_WINDOWS); tsg = dev_corMethod1(tsg, sample, dateMin, dateMax, COR_TIME_WINDOWS);
......
...@@ -32,8 +32,8 @@ for i= 1 : m ...@@ -32,8 +32,8 @@ for i= 1 : m
end end
end end
% Salinity difference Sample minus smoothed TSG % Salinity difference : Sample minus smoothed TSG
% --------------------------------------------- % -----------------------------------------------
indSample = find( sample.PSAL_QC == 1 ); indSample = find( sample.PSAL_QC == 1 );
sample.PSAL_DIF(indSample) = ... sample.PSAL_DIF(indSample) = ...
sample.PSAL(indSample) - sample.PSAL_SMOOTH(indSample); sample.PSAL(indSample) - sample.PSAL_SMOOTH(indSample);
function y = nanmean(x,dim)
% FORMAT: Y = NANMEAN(X,DIM)
%
% Average or mean value ignoring NaNs
%
% This function enhances the functionality of NANMEAN as distributed in
% the MATLAB Statistics Toolbox and is meant as a replacement (hence the
% identical name).
%
% NANMEAN(X,DIM) calculates the mean along any dimension of the N-D
% array X ignoring NaNs. If DIM is omitted NANMEAN averages along the
% first non-singleton dimension of X.
%
% Similar replacements exist for NANSTD, NANMEDIAN, NANMIN, NANMAX, and
% NANSUM which are all part of the NaN-suite.
%
% See also MEAN
% -------------------------------------------------------------------------
% author: Jan Gläscher
% affiliation: Neuroimage Nord, University of Hamburg, Germany
% email: glaescher@uke.uni-hamburg.de
%
% $Revision: 1.1 $ $Date: 2004/07/15 22:42:13 $
if isempty(x)
y = NaN;
return
end
if nargin < 2
dim = min(find(size(x)~=1));
if isempty(dim)
dim = 1;
end
end
% Replace NaNs with zeros.
nans = isnan(x);
x(isnan(x)) = 0;
% denominator
count = size(x,dim) - sum(nans,dim);
% Protect against a all NaNs in one dimension
i = find(count==0);
count(i) = ones(size(i));
y = sum(x,dim)./count;
y(i) = i + NaN;
% $Id: nanmean.m,v 1.1 2004/07/15 22:42:13 glaescher Exp glaescher $
function y = nanstd(x,dim,flag)
% FORMAT: Y = NANSTD(X,DIM,FLAG)
%
% Standard deviation ignoring NaNs
%
% This function enhances the functionality of NANSTD as distributed in
% the MATLAB Statistics Toolbox and is meant as a replacement (hence the
% identical name).
%
% NANSTD(X,DIM) calculates the standard deviation along any dimension of
% the N-D array X ignoring NaNs.
%
% NANSTD(X,DIM,0) normalizes by (N-1) where N is SIZE(X,DIM). This make
% NANSTD(X,DIM).^2 the best unbiased estimate of the variance if X is
% a sample of a normal distribution. If omitted FLAG is set to zero.
%
% NANSTD(X,DIM,1) normalizes by N and produces the square root of the
% second moment of the sample about the mean.
%
% If DIM is omitted NANSTD calculates the standard deviation along first
% non-singleton dimension of X.
%
% Similar replacements exist for NANMEAN, NANMEDIAN, NANMIN, NANMAX, and
% NANSUM which are all part of the NaN-suite.
%
% See also STD
% -------------------------------------------------------------------------
% author: Jan Gläscher
% affiliation: Neuroimage Nord, University of Hamburg, Germany
% email: glaescher@uke.uni-hamburg.de
%
% $Revision: 1.1 $ $Date: 2004/07/15 22:42:15 $
if isempty(x)
y = NaN;
return
end
if nargin < 3
flag = 0;
end
if nargin < 2
dim = min(find(size(x)~=1));
if isempty(dim)
dim = 1;
end
end
% Find NaNs in x and nanmean(x)
nans = isnan(x);
avg = nanmean(x,dim);
% create array indicating number of element
% of x in dimension DIM (needed for subtraction of mean)
tile = ones(1,max(ndims(x),dim));
tile(dim) = size(x,dim);
% remove mean
x = x - repmat(avg,tile);
count = size(x,dim) - sum(nans,dim);
% Replace NaNs with zeros.
x(isnan(x)) = 0;
% Protect against a all NaNs in one dimension
i = find(count==0);
if flag == 0
y = sqrt(sum(x.*x,dim)./max(count-1,1));
else
y = sqrt(sum(x.*x,dim)./max(count,1));
end
y(i) = i + NaN;
% $Id: nanstd.m,v 1.1 2004/07/15 22:42:15 glaescher Exp glaescher $
function [error] = tsg_readBucketData( hTsgGUI, filename) function [error] = tsg_readBucketData( hTsgGUI, filename)
% Function to read the Bucket data. Should be in a NetCDF file % Function to read Bucket data in ASCII format.
% %
% Input % Input
% ----- % -----
...@@ -10,9 +10,8 @@ function [error] = tsg_readBucketData( hTsgGUI, filename) ...@@ -10,9 +10,8 @@ function [error] = tsg_readBucketData( hTsgGUI, filename)
% ------ % ------
% error .............. 1: OK - -1 : an error occured % error .............. 1: OK - -1 : an error occured
% %
% The data are store using setappdata - Variable name : 'bucket_data' % The data are store using setappdata - Variable name : 'bucketASCII'
% %
% Function to be rewritten when the NetCDF format will be in use
% Caution : replace the fill-value with NaN % Caution : replace the fill-value with NaN
% $Id$ % $Id$
...@@ -30,17 +29,17 @@ if fid ~= -1 ...@@ -30,17 +29,17 @@ if fid ~= -1
% Every variable are put in a structure % Every variable are put in a structure
% ------------------------------------- % -------------------------------------
bucket.TIME_WS = datenum(bucketData(:,1), bucketData(:,2), ... bucketASCII.TIME = datenum(bucketData(:,1), bucketData(:,2), ...
bucketData(:,3), bucketData(:,4), ... bucketData(:,3), bucketData(:,4), ...
bucketData(:,5), bucketData(:,6)); bucketData(:,5), bucketData(:,6));
bucket.LATITUDE_WS = bucketData(:,7); bucketASCII.LATITUDE = bucketData(:,7);
bucket.LONGITUDE_WS = bucketData(:,8); bucketASCII.LONGITUDE = bucketData(:,8);
bucket.PSAL_WS = bucketData(:,9); bucketASCII.PSAL = bucketData(:,9);
bucket.PSAL_QC_WS = zeros(size(bucket.PSAL_WS)); bucketASCII.PSAL_QC = zeros(size(bucketASCII.PSAL));
% Save the data in the application GUI % Save the data in the application GUI
% ------------------------------------ % ------------------------------------
setappdata( hTsgGUI, 'bucket_data', bucket ); setappdata( hTsgGUI, 'bucketASCII', bucketASCII );
% Clear the Workspace % Clear the Workspace
% ------------------- % -------------------
......
...@@ -22,7 +22,7 @@ fid = fopen( filename, 'r' ); ...@@ -22,7 +22,7 @@ fid = fopen( filename, 'r' );
error = -1; error = -1;
if fid ~= -1 if fid ~= -1
disp('Read ASCII txt file, not yet implemeted ...'); disp('Read NetCDF file, not yet implemeted ...');
% %
% % Read the file % % Read the file
% % ------------- % % -------------
...@@ -40,14 +40,25 @@ if fid ~= -1 ...@@ -40,14 +40,25 @@ if fid ~= -1
% tsg.PSAL_QC = tsgData(:,11); % tsg.PSAL_QC = tsgData(:,11);
% tsg.PSAL_ADJ = tsgData(:,12); % tsg.PSAL_ADJ = tsgData(:,12);
% tsg.PSAL_ERR = tsgData(:,13); % tsg.PSAL_ERR = tsgData(:,13);
%
% % Bucket
% % ------
% bucketNETCDF.LATITUDE_WS = tsgData(:,7);
% bucketNETCDF.LONGITUDE_WS = tsgData(:,8);
% bucketNETCDF.TEMP_TSG_WS = tsgData(:,9);
% bucketNETCDF.PSAL_WS = tsgData(:,10);
% bucketNETCDF.PSAL_QC_WS = tsgData(:,11);
% bucketNETCDF.PSAL_ADJ_WS = tsgData(:,12);
% bucketNETCDF.PSAL_ERR_WS = tsgData(:,13);
% %
% % Save the data in the application GUI % % Save the data in the application GUI
% % ------------------------------------ % % ------------------------------------
% setappdata( hTsgGUI, 'tsg_data', tsg ); % setappdata( hTsgGUI, 'tsg_data', tsg );
% setappdata( hTsgGUI, 'bucketNETCDF', bucketNETCDF );
% %
% Clear the Workspace % Clear the Workspace
% ------------------- % -------------------
clear tsgdata % clear tsgdata
% Close the file % Close the file
% -------------- % --------------
......
...@@ -154,7 +154,7 @@ function tsgqc_GUI ...@@ -154,7 +154,7 @@ function tsgqc_GUI
'ClickedCallback', @ClimMenuCallback); 'ClickedCallback', @ClimMenuCallback);
hBottlePushtool = uipushtool(... % Open toolbar button hBottlePushtool = uipushtool(... % Open toolbar button
'Parent',hToolbar,... 'Parent',hToolbar,...
'TooltipString','Plot the Buckets',... 'TooltipString','Plot the Samples',...
'Separator', 'on', ... 'Separator', 'on', ...
'Tag', 'off', ... 'Tag', 'off', ...
'CData',iconRead(... 'CData',iconRead(...
...@@ -270,8 +270,10 @@ function tsgqc_GUI ...@@ -270,8 +270,10 @@ function tsgqc_GUI
% This has to be made general for UNIX and WINDOWS system % This has to be made general for UNIX and WINDOWS system
% --------------------------------------------------------- % ---------------------------------------------------------
[filename, pathname, filterIndex] = uigetfile( ... [filename, pathname, filterIndex] = uigetfile( ...
{'*.txt';'*.xml';'*.nc'}, 'Pick a file'); {'*.txt';'*.xml';'*.nc';'*.btl'}, 'Pick a file');
error1 = -1;
error2 = -1;
if ~isequal(filename, 0) if ~isequal(filename, 0)
% Read the data % Read the data
...@@ -279,20 +281,24 @@ function tsgqc_GUI ...@@ -279,20 +281,24 @@ function tsgqc_GUI
switch filterIndex switch filterIndex
case 1 case 1
error = tsg_readTsgDataTxt( hMainFig, filename ); error1 = tsg_readTsgDataTxt( hMainFig, filename );
case 2 case 2
error = tsg_readTsgDataXML( hMainFig, filename ); error1 = tsg_readTsgDataXML( hMainFig, filename );
case 3 case 3
error = tsg_readTsgDataNetCDF( hMainFig, filename ); error1 = tsg_readTsgDataNetCDF( hMainFig, filename );
case 4
error2 = tsg_readBucketData(hMainFig, filename );
otherwise otherwise
return; return;
end end
if error ~= -1 % A TSG file has been read. Plot the data.
% ----------------------------------------
if error1 ~= -1
% The file has been open and read % A TSG file has been open and read
% ------------------------------- % ---------------------------------
set( hOpenMenu, 'Tag', 'on' ); set( hOpenMenu, 'Tag', 'on' );
% The callback to detect the mouse motion can be set to on % The callback to detect the mouse motion can be set to on
...@@ -308,6 +314,17 @@ function tsgqc_GUI ...@@ -308,6 +314,17 @@ function tsgqc_GUI
tsg_plotmap( hMainFig, hPlotAxes) tsg_plotmap( hMainFig, hPlotAxes)
end end
% Merge the different water sample (NetCdf or ASCII files) in
% a unique structure : 'sample'
% -----------------------------------------------------------
if error2 ~= -1
[sample] = tsg_mergesample( hMainFig );
% Save the 'sample' struct. as an application data
% ------------------------------------------------
setappdata( hMainFig, 'sample', sample );
end
end end
% Pointer reset to arrow % Pointer reset to arrow
...@@ -641,45 +658,26 @@ function tsgqc_GUI ...@@ -641,45 +658,26 @@ function tsgqc_GUI
% Need to read them right now - but they will be soon in the NetCdf % Need to read them right now - but they will be soon in the NetCdf
% file % file
% Test if the bucket Push button has been pressed % Test if the sample Push button has been pressed
% ----------------------------------------------- % -----------------------------------------------
if strcmp( get(hBottlePushtool, 'Tag'), 'off') if strcmp( get(hBottlePushtool, 'Tag'), 'off')
% Bucket Push button - Tag set to 'on' % Sample Push button - Tag set to 'on'
% ------------------------------------ % ------------------------------------
set( hBottlePushtool, 'Tag', 'on' ); set( hBottlePushtool, 'Tag', 'on' );
% Test if the TSG and bucket files have been read
% -----------------------------------------------
if strcmp( get(hOpenMenu, 'Tag'), 'on' ) && ...
isempty(getappdata( hMainFig, 'bucket_data'))
% Build the filename
% ------------------
[filename, pathname] = uigetfile( ...
[DEFAULT_PATH_FILE '*.btl'], 'Pick a bottle file');
if ~isequal(filename, 0)
% Read the data
% -------------
error = tsg_readBucketData(hMainFig, filename );
end
end
% Retrieve named application data % Retrieve named application data
% ------------------------------- % -------------------------------
bucket = getappdata( hMainFig, 'bucket_data'); sample = getappdata( hMainFig, 'sample');
hLine = get( hPlotAxes(1), 'UserData'); hLine = get( hPlotAxes(1), 'UserData');
% Plot the bucket if the file has been read % Plot the samples if the TSG file has been read
% ----------------------------------------- % ----------------------------------------------
if ~isempty(bucket) if strcmp( get(hOpenMenu, 'Tag'), 'on' ) && ~isempty( sample )
axes( hPlotAxes(1) ); axes( hPlotAxes(1) );
hLine.Bucket = line( ... hLine.Sample = line( ...
bucket.TIME_WS, bucket.PSAL_WS,... sample.TIME, sample.PSAL,...
'Linestyle', 'none', 'Marker','o','MarkerSize',5, ... 'Linestyle', 'none', 'Marker','o','MarkerSize',5, ...
'Color','r', 'MarkerFaceColor','r'); 'Color','r', 'MarkerFaceColor','r');
...@@ -696,7 +694,9 @@ function tsgqc_GUI ...@@ -696,7 +694,9 @@ function tsgqc_GUI
% Delete the bucket on figure % Delete the bucket on figure
% ---------------------------------------------- % ----------------------------------------------
hLine = get( hPlotAxes(1), 'UserData'); hLine = get( hPlotAxes(1), 'UserData');
delete(hLine.Bucket); if ~isempty( hLine ) && ishandle( hLine.Sample )
delete(hLine.Sample);
end
end end
end end
......
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