From 90c99ef585a47a2992ff3ba9e5dd9b8a6d4ab1ff Mon Sep 17 00:00:00 2001 From: Yves Gouriou <yves.gouriou@ird.fr> Date: Fri, 18 Jan 2008 18:38:04 +0000 Subject: [PATCH] =?UTF-8?q?1=20-=20Modification=20du=20PANEL=20QC=20-=20Aj?= =?UTF-8?q?out=20a=20gauche=20des=20trac=C3=A9s=202=20-=20force=20les=20li?= =?UTF-8?q?mites=20en=20X=20des=20trac=C3=A9s=20:=20ajust=C3=A9es=20aux=20?= =?UTF-8?q?limites=20en=20temps=20des=20s=C3=A9ries.=203=20-=20Ajout=20des?= =?UTF-8?q?=20callback=20:=20Bottle=5FOffMenuCallback=20et=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?Bottle=5FOnMenuCallback=204=20-=20Cr=C3=A9ation=20du'ne=20routi?= =?UTF-8?q?ne=20plot=5Fsample.=20Encore=20incomplete=204=20-=20TODOS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TODOS | 18 +++++- tsg_util/dev_diffTsgSample.m | 25 +++---- tsg_util/plot_SalTempVel.m | 13 ++-- tsg_util/tsg_initialisation.m | 10 +-- tsg_util/tsg_mergesample.m | 67 +++++++++++-------- tsgqc_GUI.m | 118 ++++++++++++++++------------------ 6 files changed, 139 insertions(+), 112 deletions(-) diff --git a/TODOS b/TODOS index 95fe639..a4fd495 100644 --- a/TODOS +++ b/TODOS @@ -23,4 +23,20 @@ fichiers LabView (codes avec des NaN) Donnees Externes (colocalisation avec le trajet des navires) 1 - écrire la routine de lecture de ces fichiers et conserver - les données qui correspondent au trajet analysé \ No newline at end of file + les données qui correspondent au trajet analysé + +18/01/2000 +---------- +Bug sur l'affichage du signe 'degre' sous Windows : +label de l'axe des Y : Temperature (°C) + +18/01/2000 +---------- +Incorporer les donnees de surface externe. +trier le fichier par date +Selectionner les donnees correspondant aux dates du voyage. + +18/01/2000 +---------- +Corriger la lecture des fichiers LABVIEW. Troncature des valeurs +du SOG a la lecture : Budg : Lecture d'un entier au lieu d'un float ? \ No newline at end of file diff --git a/tsg_util/dev_diffTsgSample.m b/tsg_util/dev_diffTsgSample.m index b5b5f66..9ff631a 100644 --- a/tsg_util/dev_diffTsgSample.m +++ b/tsg_util/dev_diffTsgSample.m @@ -1,17 +1,20 @@ -function [sample] = tsg_diffTsgSample(tsg, psal_smooth, sample, dt) +function [sample] = tsg_diffTsgSample(tsg, psal_smooth, sample) % % function [sample] = tsg_diffTsgSample(tsg, psal_smooth, sample, dt) % -% Co-location of bucket and TSG meausrements +% Co-location of bucket and TSG measurements % Compute the bucket-TSG difference % % tsg ........... structure of TSG data % psal_smooth ... smooth TSG timeseries % sample ........ structure of samples -% dt ............ time series interval % -[m, n] = size(sample.PSAL); +[m, n] = size(sample.SSPS); + +% time difference between 2 succesive TSG measurements +% ---------------------------------------------------- +dt = tsg.DAYD(2) - tsg.DAYD(1); % Loop on the samples % ------------------- @@ -19,21 +22,21 @@ for i= 1 : m % Indice of the TSG measurement the closest to the sample % -------------------------------------------------------- - timeDiff = abs(tsg.TIME - sample.TIME(i)); + timeDiff = abs(tsg.DAYD - sample.DAYD(i)); [timeMin, indMin] = min(timeDiff); if timeDiff(indMin) < dt && ~isnan(psal_smooth(indMin)) - sample.PSAL_SMOOTH(i) = psal_smooth(indMin); - sample.PSAL_QC(i) = 1; + sample.SSPS_SMOOTH(i) = psal_smooth(indMin); + sample.SSPS_QC(i) = 1; else - sample.PSAL_QC(i) = 0; + sample.SSPS_QC(i) = 0; end end % Salinity difference : Sample minus smoothed TSG % ----------------------------------------------- -indSample = find( sample.PSAL_QC == 1 ); -sample.PSAL_DIF(indSample) = ... - sample.PSAL(indSample) - sample.PSAL_SMOOTH(indSample); +indSample = find( sample.SSPS_QC == 1 ); +sample.SSPS_DIF(indSample) = ... + sample.SSPS(indSample) - sample.SSPS_SMOOTH(indSample); diff --git a/tsg_util/plot_SalTempVel.m b/tsg_util/plot_SalTempVel.m index 8bb112c..13dc268 100644 --- a/tsg_util/plot_SalTempVel.m +++ b/tsg_util/plot_SalTempVel.m @@ -49,8 +49,7 @@ for i=1:numel(qc_list) % plot tsg salinity sample with right code/color % ---------------------------------------------- ind = find(tsg.SSPS_QC == code ); - plot(hAxes(1), tsg.DAYD(ind), tsg.SSPS(ind), ... - strcat('.', color)); + plot(hAxes(1), tsg.DAYD(ind), tsg.SSPS(ind), strcat('.', color)); end end @@ -71,9 +70,13 @@ plot(hAxes(3), tsg.DAYD, tsg.SPDC, '.k'); % Formatted x-TIME axes % --------------------- -datetick(hAxes(1), 'x'); -datetick(hAxes(2), 'x'); -datetick(hAxes(3), 'x'); +set(hAxes(1), 'Xlim', [tsg.DAYD(1)-1 tsg.DAYD(end)+1]); +set(hAxes(2), 'Xlim', [tsg.DAYD(1)-1 tsg.DAYD(end)+1]); +set(hAxes(3), 'Xlim', [tsg.DAYD(1)-1 tsg.DAYD(end)+1]); + +datetick(hAxes(1), 'x', 'keeplimits'); +datetick(hAxes(2), 'x', 'keeplimits'); +datetick(hAxes(3), 'x', 'keeplimits'); % Write some 'Y' label % ------------------ diff --git a/tsg_util/tsg_initialisation.m b/tsg_util/tsg_initialisation.m index 67382e1..166f6a6 100644 --- a/tsg_util/tsg_initialisation.m +++ b/tsg_util/tsg_initialisation.m @@ -73,23 +73,19 @@ tsg.qc.active.Color = get(tsg.qc.hash, 'NO_CONTROL', 'color'); % Smoothing of tsg time series over 1 hour interval % 1 hour interval expressed in MATLAB serial Number % ------------------------------------------------- -cst.TSG_DT_SMOOTH = datenum(0, 0, 0, 1, 0 , 0); +tsg.cst.TSG_DT_SMOOTH = datenum(0, 0, 0, 1, 0 , 0); % Smoothing of tsg time series : % Salinity, in one 1 hour interval, should not depart the average for more % than SAL_STD_MAX standard deviation % ----------------------------------------------------------------------- -cst.TSG_STDMAX = 0.1; +tsg.cst.TSG_STDMAX = 0.1; % Correction is estimated by computing the median value of X tsg-sample % differences % Amount of days used to compute the correction % --------------------------------------------------------------------- -cst.COR_TIME_WINDOWS = 10; - -% store the 'const' structure as an application data -% -------------------------------------------------- -setappdata( hTsgGUI, 'constante', cst); +tsg.cst.COR_TIME_WINDOWS = 10; % Get variables list codes from class tsg_nc with file 'tsg_ncvar.csv' % -------------------------------------------------------------------- diff --git a/tsg_util/tsg_mergesample.m b/tsg_util/tsg_mergesample.m index 9186ee0..941caa5 100644 --- a/tsg_util/tsg_mergesample.m +++ b/tsg_util/tsg_mergesample.m @@ -17,24 +17,26 @@ function [] = tsg_mergesample( hTsgGUI ) % --------------------------------------------------------------------- tsg = getappdata( hTsgGUI, 'tsg_data'); -% Create an empty structure with no fields -% ---------------------------------------- -sample = struct('DAYD',{} ,'LATX',{} ,'LONX',{} ,'SSPS',{} , ... - 'SSPS_QC',{} ,'SSPS_DIF',{} ,'SSPS_SMOOTH',{} ,'SSPS_TYPE', {}); +% Create a structure with an NaN +% No other solution as I can't add a structure to an empty one +% ------------------------------------------------------------ +sample = struct('DAYD',NaN , 'LATX',NaN , 'LONX',NaN , ... + 'SSPS',NaN , 'SSPS_QC',NaN , 'SSPS_DIF',NaN ,... + 'SSPS_SMOOTH',NaN , 'SSPS_TYPE', NaN); % Fill the structure sample with the bucket data. % This measurements are of TYPE 1 % ------------------------------------------------ if ~isempty(tsg.SSPS_WS) - sample.DAYD = tsg.DAYD_WS; - sample.LATX = tsg.LATX_WS; - sample.LONX = tsg.LONX_WS; - sample.SSPS = tsg.SSPS_WS; - sample.SSPS_QC = tsg.SSPS_WS_QC; - sample.SSPS_DIF = zeros(size(sample.DAYD)); - sample.SSPS_SMOOTH = zeros(size(sample.DAYD)); - sample.SSPS_TYPE = ones(size(sample.DAYD)); + sample.DAYD = [sample.DAYD; tsg.DAYD_WS]; + sample.LATX = [sample.LATX; tsg.LATX_WS]; + sample.LONX = [sample.LONX; tsg.LONX_WS]; + sample.SSPS = [sample.SSPS; tsg.SSPS_WS]; + sample.SSPS_QC = [sample.SSPS_QC; tsg.SSPS_WS_QC]; + sample.SSPS_DIF = [sample.SSPS_DIF; zeros(size(sample.DAYD))]; + sample.SSPS_SMOOTH = [sample.SSPS_SMOOTH; zeros(size(sample.DAYD))]; + sample.SSPS_TYPE = [sample.SSPS_TYPE; ones(size(sample.DAYD))]; end @@ -43,28 +45,41 @@ end % -------------------------------------------------- if ~isempty(tsg.SSPS_EXT) - sample.DAYD = [sample.DAYD; tsg.DAYD_WS]; - sample.LATX = [sample.LATX; tsg.LATX_WS]; - sample.LONX = [sample.LONX; tsg.LONX_WS]; - sample.SSPS = [sample.SSPS; tsg.SSPS_WS]; - sample.SSPS_QC = [sample.SSPS_QC; tsg.SSPS_WS_QC]; - sample.SSPS_DIF = [sample.SSPS_DIF; zeros(size(tsg.DAYD_WS))]; - sample.SSPS_SMOOTH = [sample.SSPS_SMOOTH; zeros(size(tsg.DAYD_WS))]; + sample.DAYD = [sample.DAYD; tsg.DAYD_EXT]; + sample.LATX = [sample.LATX; tsg.LATX_EXT]; + sample.LONX = [sample.LONX; tsg.LONX_EXT]; + sample.SSPS = [sample.SSPS; tsg.SSPS_EXT]; + sample.SSPS_QC = [sample.SSPS_QC; tsg.SSPS_EXT_QC]; + sample.SSPS_DIF = [sample.SSPS_DIF; zeros(size(tsg.DAYD_EXT))]; + sample.SSPS_SMOOTH = [sample.SSPS_SMOOTH; zeros(size(tsg.DAYD_EXT))]; sample.SSPS_TYPE = [sample.SSPS_TYPE; tsg.SSPS_EXT_TYPE]; end +% Eliminate the first element if NaN +% ---------------------------------- +if isnan(sample.DAYD(1)) + sample.DAYD(1) = []; + sample.LATX(1) = []; + sample.LONX(1) = []; + sample.SSPS(1) = []; + sample.SSPS_QC(1) = []; + sample.SSPS_DIF(1) = []; + sample.SSPS_SMOOTH(1) = []; + sample.SSPS_TYPE(1) = []; +end + % Sort the struct sample - increasing time. % ----------------------------------------- if ~isempty(sample) [sample.DAYD, iOrder] = sort(sample.DAYD); - sample.LATX = sample.LATITUDE(iOrder); - sample.LONX = sample.LONGITUDE(iOrder); - sample.SSPS = sample.PSAL(iOrder); - sample.SSPS_QC = sample.PSAL_QC(iOrder); - sample.SSPS_DIF = sample.PSAL_DIF(iOrder); - sample.SSPS_SMOOTH = sample.PSAL_SMOOTH(iOrder); - sample.SSPS_TYPE = sample.TYPE(iOrder); + sample.LATX = sample.LATX(iOrder); + sample.LONX = sample.LONX(iOrder); + sample.SSPS = sample.SSPS(iOrder); + sample.SSPS_QC = sample.SSPS_QC(iOrder); + sample.SSPS_DIF = sample.SSPS_DIF(iOrder); + sample.SSPS_SMOOTH = sample.SSPS_SMOOTH(iOrder); + sample.SSPS_TYPE = sample.SSPS_TYPE(iOrder); end % Update application data sample diff --git a/tsgqc_GUI.m b/tsgqc_GUI.m index df3f3ce..8e05288 100644 --- a/tsgqc_GUI.m +++ b/tsgqc_GUI.m @@ -66,10 +66,10 @@ end % ------------------------- set(0,'Units','normalized'); guiLimits = get(0,'ScreenSize'); -guiLimits(1) = guiLimits(1) + 0.05; -guiLimits(2) = guiLimits(2) + 0.1; -guiLimits(3) = guiLimits(3) - 0.1; -guiLimits(4) = guiLimits(4) - 0.2; +guiLimits(1) = guiLimits(1) + 0.01; +guiLimits(2) = guiLimits(2) + 0.05; +guiLimits(3) = guiLimits(3) - 0.02; +guiLimits(4) = guiLimits(4) - 0.15; %% Create and then hide the GUI as it is being constructed. % -------------------------------------------------------- @@ -206,16 +206,20 @@ hClimToggletool = uitoggletool(... % Open Climatology toolbar button 'Enable', 'off',... 'OffCallback', @Clim_OffMenuCallback,... 'ONCallback', @Clim_OnMenuCallback); -hBottlePushtool = uipushtool(... % Open toolbar button + +hBottlePushtool = uitoggletool(... % Open toolbar button 'Parent',hToolbar,... - 'TooltipString','Plot the Samples',... + 'TooltipString','Correct the SSS TSG data',... 'Separator', 'on', ... 'CData',iconRead(... [DEFAULT_PATH_FILE 'tsg_icon' filesep 'bottleicon.mat']),... 'HandleVisibility','callback', ... 'Tag','PUSHTOOL_BOTTLE',... + 'UserData', 'off',... 'Enable', 'off',... - 'ClickedCallback', @BottleMenuCallback); + 'OffCallback', @Bottle_OffMenuCallback,... + 'ONCallback', @Bottle_OnMenuCallback); + hHeaderPushtool = uipushtool(... % Open headerForm button 'Parent',hToolbar,... 'TooltipString','Fill the header form',... @@ -399,37 +403,37 @@ hInfoSSTPText = uicontrol(... hPlotsPanel = uipanel( ... 'Parent', hMainFig, ... 'Units', 'normalized', ... - 'BorderType', 'none',... + 'BorderType', 'etchedin',... 'Visible', 'on', ... - 'Position',[0, 0, 1, .93]); + 'Position',[0.15, 0, .85, .95]); hPlotAxes(1) = axes(... % the axes for plotting Salinity 'Parent', hPlotsPanel, ... 'Units', 'normalized', ... 'Visible', 'off', ... 'HandleVisibility','on', ... % set to callback after first plot - 'Position',[.05, .64, .9, .35]); + 'Position',[.05, .64, .93, .35]); hPlotAxes(2) = axes(... % the axes for plotting temperature 'Parent', hPlotsPanel, ... 'Units', 'normalized', ... 'Visible', 'off', ... 'HandleVisibility','callback', ... - 'Position',[.05, .32, .9, .27]); + 'Position',[.05, .32, .93, .27]); hPlotAxes(3) = axes(... % the axes for plotting ship velocity 'Parent', hPlotsPanel, ... 'Units', 'normalized', ... 'Visible', 'off', ... 'HandleVisibility','callback', ... - 'Position',[.05, .06, .9, .22]); + 'Position',[.05, .06, .93, .22]); % The map will be plot in a uipanel hMapPanel = uipanel( ... 'Parent', hMainFig, ... 'Units', 'normalized', ... 'Visible', 'off', ... - 'Position',[0, 0, 1, .57]); + 'Position',[0.15, 0, .85, .57]); hPlotAxes(4) = axes(... % the axes for plotting ship track map 'Parent', hMapPanel, ... @@ -448,8 +452,8 @@ hQcPanel = uipanel(... 'tag', 'TAG_QC_DISPLAY_PANEL',... 'HandleVisibility','on',... 'Visible', 'on',... - 'BorderType', 'none',... - 'Position', [.01, .92, .98, .03]); + 'BorderType', 'etchedin',... + 'Position', [.0, .70, .15, .25]); % Construct the context menu for the Quality control codes % ------------------------------------------------------- @@ -497,12 +501,12 @@ for i=1:numel(qc_list) 'Style', 'text',... 'Units', 'normalized', ... 'Style', 'Text', ... - 'Fontsize', fontSize, ... + 'Fontsize', fontSize-1, ... 'HorizontalAlignment', 'left', ... 'HandleVisibility','on', ... 'String', label,... 'ForegroundColor', color,... - 'Position', [.01+count*.12, .35, .07, 0.5]); + 'Position', [.01, .85-count*.12, .6, 0.08]); % add text QC display statistic on hQcPanel % ----------------------------------------- @@ -511,13 +515,13 @@ for i=1:numel(qc_list) 'Style', 'text',... 'Units', 'normalized', ... 'Style', 'Text', ... - 'Fontsize', fontSize, ... + 'Fontsize', fontSize-1, ... 'HorizontalAlignment', 'right', ... 'HandleVisibility','on', ... 'String', 'N/A',... 'ForegroundColor', color,... 'Tag', ['TAG_QC_TEXT_' key],... - 'Position', [.09+count*.12, .35, .03, 0.5]); + 'Position', [.61, .85-count*.12, .37, 0.08]); % increment count % --------------- @@ -950,9 +954,9 @@ end end %--------------------------------------------------------------------- - % Callback function run when the bootle push tool is pressed + % Callback function run when the bootle push tool is selected %--------------------------------------------------------------------- - function BottleMenuCallback(hObject, eventdata) + function Bottle_OnMenuCallback(hObject, eventdata) % Callback function run when the Bottle tool bar item is selected % Get the tsg data structure @@ -963,6 +967,26 @@ end % -------------------------------------------- if ~isempty( tsg.SSPS_WS ) || ~isempty( tsg.SSPS_EXT ) + % Merge bucket and external samples + % --------------------------------- + tsg_mergesample( hMainFig ); + + % Running average of TSG time series over TSG_DT_SMOOTH hour + % ---------------------------------------------------------- + [psal_smooth, nval] = ... + dev_moveaverage(tsg.DAYD, tsg.SSPS, ... + tsg.cst.TSG_DT_SMOOTH, tsg.cst.TSG_STDMAX); + + % Compute the sample-TSG differences + % ---------------------------------- + sample = getappdata( hMainFig, 'sample'); + sample = dev_diffTsgSample(tsg, psal_smooth, sample); + setappdata(hMainFig, 'sample', sample); + + % plot Salinity Difference + % ------------------------ + plot_Sample( hMainFig, hPlotAxes ); + % Call the GUI for tsg correction % ------------------------------- msgbox('Correction module not yet implemented', 'modal'); @@ -970,49 +994,19 @@ end else msgbox('TSG or Sample data not loaded in the program', 'modal'); end - - % Vieux bout de code pour le trace et la suppression des bouteilles - % Plot or Delete the buckets measurements on the Salinity graph - % - % Need to read them right now - but they will be soon in the NetCdf - % file - - % Test if the sample Push button has been pressed - % ----------------------------------------------- - % if strcmp( get(hBottlePushtool, 'UserData'), 'off') - - % Sample Push button - UserData set to 'on' - % ------------------------------------ - % set( hBottlePushtool, 'UserData', 'on' ); - - % Plot the samples if the TSG file has been read - % ---------------------------------------------- - % if strcmp( get(hOpenMenu, 'UserData'), 'on' ) && ~isempty( sample ) - % axes( hPlotAxes(1) ); - % hLine.Sample = line( ... - % sample.TIME, sample.PSAL,... - % 'Linestyle', 'none', 'Marker','o','MarkerSize',5, ... - % 'Color','r', 'MarkerFaceColor','r'); - - % Store the handle of the bucketline - % ---------------------------------- - % set( hPlotAxes(1), 'UserData', hLine ); - % end - - % else - - % set( hBottlePushtool, 'UserData', 'off' ); - - % The bucket pushbutton has been pressed again : - % Delete the bucket on figure - % ---------------------------------------------- - % hLine = get( hPlotAxes(1), 'UserData'); - % if ~isempty( hLine ) && ishandle( hLine.Sample ) - % delete(hLine.Sample); - % end end - %------------------------------------------------------------------------ + %--------------------------------------------------------------------- + % Callback function run when the bootle push tool is selected + %--------------------------------------------------------------------- + function Bottle_OffMenuCallback(hObject, eventdata) + + plot_SalTempVel( hMainFig, hPlotAxes ); + plot_WS( hMainFig, hPlotAxes ); + plot_EXT( hMainFig, hPlotAxes ); + + end + %------------------------------------------------------------------------ % Callback function run when the Levitus climatology toolbar is unselected %------------------------------------------------------------------------ function Clim_OffMenuCallback(hObject, eventdata) -- GitLab