diff --git a/tsg_util/dev_correctBucket.m b/tsg_util/dev_correctBucket.m index 55cf27b3c31c6fafe03b642c4ebbbec22a9dd267..91a52cf9612fb95bb12cec9eb2338041cc8c4d56 100644 --- a/tsg_util/dev_correctBucket.m +++ b/tsg_util/dev_correctBucket.m @@ -61,8 +61,8 @@ sample = dev_mergesample( bucketNETCDF, bucketASCII); sample = dev_diffTsgSample(tsg, psal_smooth, sample, TSG_SAMPLING_TIME); -dateMin = tsg.TIME(1); -dateMax = tsg.TIME(end); +dateMin = tsg.TIME(5000); +dateMax = tsg.TIME(10000); tsg = dev_corMethod1(tsg, sample, dateMin, dateMax, COR_TIME_WINDOWS); diff --git a/tsg_util/dev_diffTsgSample.m b/tsg_util/dev_diffTsgSample.m index 5ae7569ff9decfdd15ceece19d76aab2062cf2d9..b5b5f66bf4c8f0d7f38a6f25b25dea3cfb8a09c4 100644 --- a/tsg_util/dev_diffTsgSample.m +++ b/tsg_util/dev_diffTsgSample.m @@ -32,8 +32,8 @@ for i= 1 : m end end -% Salinity difference Sample minus smoothed TSG -% --------------------------------------------- +% Salinity difference : Sample minus smoothed TSG +% ----------------------------------------------- indSample = find( sample.PSAL_QC == 1 ); sample.PSAL_DIF(indSample) = ... sample.PSAL(indSample) - sample.PSAL_SMOOTH(indSample); diff --git a/tsg_util/dev_nanmean.m b/tsg_util/dev_nanmean.m deleted file mode 100644 index a09b6c383a99103e2cb98dc56a8a9609923964ae..0000000000000000000000000000000000000000 --- a/tsg_util/dev_nanmean.m +++ /dev/null @@ -1,54 +0,0 @@ -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 $ diff --git a/tsg_util/dev_nanstd.m b/tsg_util/dev_nanstd.m deleted file mode 100644 index b8722696d9661393aac42020af2d6515288feff6..0000000000000000000000000000000000000000 --- a/tsg_util/dev_nanstd.m +++ /dev/null @@ -1,80 +0,0 @@ -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 $ diff --git a/tsg_util/tsg_readBucketData.m b/tsg_util/tsg_readBucketData.m index 0e881df6cfba0989d7e65abe209457b44b3a7f86..691301e05f7edeeaa560568b0c317011f20d2948 100644 --- a/tsg_util/tsg_readBucketData.m +++ b/tsg_util/tsg_readBucketData.m @@ -1,5 +1,5 @@ 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 % ----- @@ -10,9 +10,8 @@ function [error] = tsg_readBucketData( hTsgGUI, filename) % ------ % 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 % $Id$ @@ -30,17 +29,17 @@ if fid ~= -1 % Every variable are put in a structure % ------------------------------------- - bucket.TIME_WS = datenum(bucketData(:,1), bucketData(:,2), ... - bucketData(:,3), bucketData(:,4), ... - bucketData(:,5), bucketData(:,6)); - bucket.LATITUDE_WS = bucketData(:,7); - bucket.LONGITUDE_WS = bucketData(:,8); - bucket.PSAL_WS = bucketData(:,9); - bucket.PSAL_QC_WS = zeros(size(bucket.PSAL_WS)); + bucketASCII.TIME = datenum(bucketData(:,1), bucketData(:,2), ... + bucketData(:,3), bucketData(:,4), ... + bucketData(:,5), bucketData(:,6)); + bucketASCII.LATITUDE = bucketData(:,7); + bucketASCII.LONGITUDE = bucketData(:,8); + bucketASCII.PSAL = bucketData(:,9); + bucketASCII.PSAL_QC = zeros(size(bucketASCII.PSAL)); % Save the data in the application GUI % ------------------------------------ - setappdata( hTsgGUI, 'bucket_data', bucket ); + setappdata( hTsgGUI, 'bucketASCII', bucketASCII ); % Clear the Workspace % ------------------- diff --git a/tsg_util/tsg_readTsgDataNetCDF.m b/tsg_util/tsg_readTsgDataNetCDF.m index 33b89480e2a0a5786c4c2fdf5a0af884edb782ab..7bef87050e268d0e75a1c3e62e8a197b8997abc9 100644 --- a/tsg_util/tsg_readTsgDataNetCDF.m +++ b/tsg_util/tsg_readTsgDataNetCDF.m @@ -22,7 +22,7 @@ fid = fopen( filename, 'r' ); error = -1; if fid ~= -1 - disp('Read ASCII txt file, not yet implemeted ...'); + disp('Read NetCDF file, not yet implemeted ...'); % % % Read the file % % ------------- @@ -40,14 +40,25 @@ if fid ~= -1 % tsg.PSAL_QC = tsgData(:,11); % tsg.PSAL_ADJ = tsgData(:,12); % 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 % % ------------------------------------ % setappdata( hTsgGUI, 'tsg_data', tsg ); +% setappdata( hTsgGUI, 'bucketNETCDF', bucketNETCDF ); % % Clear the Workspace % ------------------- - clear tsgdata + % clear tsgdata % Close the file % -------------- diff --git a/tsgqc_GUI.m b/tsgqc_GUI.m index a00147cf8c8719b42e3a2f0d0cb450cf41125239..2086cd7659c59c962a23bcf4596f8ec70f9800c5 100644 --- a/tsgqc_GUI.m +++ b/tsgqc_GUI.m @@ -154,7 +154,7 @@ function tsgqc_GUI 'ClickedCallback', @ClimMenuCallback); hBottlePushtool = uipushtool(... % Open toolbar button 'Parent',hToolbar,... - 'TooltipString','Plot the Buckets',... + 'TooltipString','Plot the Samples',... 'Separator', 'on', ... 'Tag', 'off', ... 'CData',iconRead(... @@ -270,8 +270,10 @@ function tsgqc_GUI % This has to be made general for UNIX and WINDOWS system % --------------------------------------------------------- [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) % Read the data @@ -279,20 +281,24 @@ function tsgqc_GUI switch filterIndex case 1 - error = tsg_readTsgDataTxt( hMainFig, filename ); + error1 = tsg_readTsgDataTxt( hMainFig, filename ); case 2 - error = tsg_readTsgDataXML( hMainFig, filename ); + error1 = tsg_readTsgDataXML( hMainFig, filename ); case 3 - error = tsg_readTsgDataNetCDF( hMainFig, filename ); + error1 = tsg_readTsgDataNetCDF( hMainFig, filename ); + case 4 + error2 = tsg_readBucketData(hMainFig, filename ); otherwise return; - end - - if error ~= -1 + end + + % 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' ); % The callback to detect the mouse motion can be set to on @@ -308,6 +314,17 @@ function tsgqc_GUI tsg_plotmap( hMainFig, hPlotAxes) 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 % Pointer reset to arrow @@ -641,45 +658,26 @@ function tsgqc_GUI % Need to read them right now - but they will be soon in the NetCdf % 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') - % Bucket Push button - Tag set to 'on' + % Sample Push button - Tag set to '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 % ------------------------------- - bucket = getappdata( hMainFig, 'bucket_data'); + sample = getappdata( hMainFig, 'sample'); hLine = get( hPlotAxes(1), 'UserData'); - % Plot the bucket if the file has been read - % ----------------------------------------- - if ~isempty(bucket) + % Plot the samples if the TSG file has been read + % ---------------------------------------------- + if strcmp( get(hOpenMenu, 'Tag'), 'on' ) && ~isempty( sample ) axes( hPlotAxes(1) ); - hLine.Bucket = line( ... - bucket.TIME_WS, bucket.PSAL_WS,... + hLine.Sample = line( ... + sample.TIME, sample.PSAL,... 'Linestyle', 'none', 'Marker','o','MarkerSize',5, ... 'Color','r', 'MarkerFaceColor','r'); @@ -696,7 +694,9 @@ function tsgqc_GUI % Delete the bucket on figure % ---------------------------------------------- hLine = get( hPlotAxes(1), 'UserData'); - delete(hLine.Bucket); + if ~isempty( hLine ) && ishandle( hLine.Sample ) + delete(hLine.Sample); + end end end