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

On peut accéder au menu correction sans qu'un fichier bouteilles ait été chargé.

Suprression de fonctions inutiles
parent 584d1ec0
Branches
Tags
No related merge requests found
function [error] = readBucketData( hTsgGUI, filename)
% Function to read Bucket data in ASCII format.
%
% Input
% -----
% hTsgGUI ............ Handel to the main user interface
% filename ........... Data filename
%
% Output
% ------
% error .............. 1: OK - -1 : an error occured
%
% @The data are store using setappdata - Variable name : 'bucketASCII'
%
% Caution : replace the fill-value with NaN
% $Id$
% Open the file
% -------------
fid = fopen( filename, 'r' );
error = -1;
if fid ~= -1
% Get the tsg structure from application GUI
% ------------------------------------------
tsg = getappdata( hTsgGUI, 'tsg_data');
% Read the file - skip 2 lines
% ----------------------------
fgetl( fid );
fgetl( fid ); % Bottle type: OSI - tsg.PSAL_WS_BOTTLE = ;
% Read date of analysis. Convert to NetCdf format
% ------------------------------------------------
% tab = fscanf(fid,'Date of water sample analysis: %d/%d/%d\n');
% psal_ws_analdayd = datenum(tab(3), tab(2), tab(1), 0, 0, 0);
% tsg.PSAL_WS_ANALDATE = datestr( psal_ws_analdayd, 'yyyymmddHHMMSS' );
a = fscanf(fid,'%SSPS_WS_ANALDATE %s\n');
fgetl( fid );
% Read the data - prefer to read string with textscan because if some
% integer are replace with NaN fscanf read the NaN as 0
% -------------------------------------------------------------------
C = textscan(fid,'%s %s %s %s %s %s %s %s %s', [9 Inf])';
yy(:,1) = str2num( char( C{1} ) );
mm(:,1) = str2num( char( C{2} ) );
dd(:,1) = str2num( char( C{3} ) );
hh(:,1) = str2num( char( C{4} ) );
min(:,1) = str2num( char( C{5} ) );
lat(:,1) = str2num( char( C{6} ) );
lon(:,1) = str2num( char( C{7} ) );
sss(:,1) = str2num( char( C{8} ) );
code(:,1) = str2num( char( C{9} ) );
%bucketData = fscanf(fid,'%d %d %d %d %d %f %f %f %d', [9 Inf])';
% Eliminate records with no date
% ------------------------------
dayd = datenum(yy, mm, dd, hh, min, 0);
ind = find( isnan(dayd) == 1 );
yy(ind) = []; mm(ind) = []; dd(ind) = []; hh(ind) = []; min(ind) = [];
lat(ind) = []; lon(ind) = []; sss(ind) = []; code(ind) = [];
% Convert to numeric Matlab date
% ------------------------------
tsg.DAYD_WS = datenum(yy, mm, dd, hh, min, 0);
% save original date
% ------------------
tsg.DATE_WS = deblank( datestr( tsg.DAYD_WS, 'yyyymmddHHMMSS' ));
tsg.LATX_WS = lat;
tsg.LONX_WS = lon;
tsg.SSPS_WS = sss;
% QC codes are of type BYTE - conversion
% --------------------------------------
tsg.SSPS_WS_QC = int8(code);
% Sort the struct tsg - increasing time.
% -----------------------------------------
if ~isempty(tsg.DAYD_WS)
[tsg.DAYD_WS, iOrder] = sort(tsg.DAYD_WS);
tsg.DATE_WS = tsg.DATE_WS(iOrder,:);
tsg.LATX_WS = tsg.LATX_WS(iOrder);
tsg.LONX_WS = tsg.LONX_WS(iOrder);
tsg.SSPS_WS = tsg.SSPS_WS(iOrder);
tsg.SSPS_WS_QC = tsg.SSPS_WS_QC(iOrder);
end
% Keep the name of the file for the log file
% ------------------------------------------
tsg.report.wsfile = filename;
% Save the data in the application GUI
% ------------------------------------
setappdata( hTsgGUI, 'tsg_data', tsg );
% Clear the Workspace
% -------------------
clear bucketData
% Close the file
% --------------
fclose( fid );
% Everything OK
% -------------
error = 1;
end
function [error] = writeTsgDataTsg( hMainFig, filename)
function [error] = writeAsciiTsg( hMainFig, filename)
%
% Function to write the TSG data in an ASCII file
%
......
function [error] = writeTsgDataTxt( hMainFig, filename)
%
% Function to write the TSG data in an ASCII file
%
% Input
% -----
% hMainFig ............ Handel to the main user interface
% filename ........... Data filename
%
% Output
% ------
% error .............. 1: OK - -1 : an error occured
%
% The data are store using setappdata - Variable name : 'tsg_data'
%
PARA = ['SSPS'; 'SSJT'; 'SSTP'];
% Open the file
% -------------
fid = fopen( filename, 'wt' );
error = -1;
if fid ~= -1
% Display write file info on console
% ---------------------------------
fprintf('\nWRITE_TXT_FILE\n'); tic;
% Display more info about write file on console
% ---------------------------------------------
fprintf('...writing %s : ', filename);
% Get the data from the application GUI
% -------------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
nbRecords = length( tsg.DAYD );
if nbRecords ~= 0
[year, month, day, hour, min, sec] = datevec( tsg.DAYD );
for i = 1 : 3
para = PARA(i,:);
if isempty(tsg.(para))
tsg.(para) = NaN * ones( size( tsg.DAYD ) );
end
if isempty(tsg.([para '_QC']))
tsg.([para '_QC']) = zeros( size( tsg.DAYD ) );
end
end
tsg_data = [year month day hour min fix(sec), tsg.LATX tsg.LONX ...
tsg.SSPS tsg.SSPS_ADJUSTED tsg.SSPS_ADJUSTED_ERROR double(tsg.SSPS_ADJUSTED_QC)...
tsg.SSJT tsg.SSJT_ADJUSTED tsg.SSJT_ADJUSTED_ERROR double(tsg.SSJT_ADJUSTED_QC) ...
tsg.SSTP tsg.SSTP_ADJUSTED tsg.SSTP_ADJUSTED_ERROR double(tsg.SSTP_ADJUSTED_QC)];
% Write the file
% -------------
headDate = 'yyyy mm dd hh mm ss ';
headPos = 'LATX LONX ';
headSSPS = 'SSPS SSPS_ADJUSTED SSPS_ADJUSTED_ERROR SSPS_ADJUSTED_QC ';
headSSJT = 'SSJT SSJT_ADJUSTED SSJT_ADJUSTED_ERROR SSJT_ADJUSTED_QC ';
headSSTP = 'SSTP SSTP_ADJUSTED SSTP_ADJUSTED_ERROR SSTP_ADJUSTED_QC ';
fprintf( fid, ['<HEADER> ' headDate headPos headSSPS headSSJT headSSTP '\n']);
fprintf( fid, '<DATA>\n');
fprintf(fid,...
'%04d %02d %02d %02d %02d %02d %11.6f %11.6f %6.3f %6.3f %6.3f %1d %6.3f %6.3f %6.3f %1d %6.3f %6.3f %6.3f %1d \n',...
tsg_data');
% Clear the Workspace
% -------------------
clear tsgdata
% Everything OK
% -------------
error = 1;
end
% Close the file
% --------------
fclose( fid );
% Display time to write file on console
% -------------------------------------
t = toc; fprintf('...done (%6.2f sec).\n\n',t);
end
%% DOCUMENT TITLE
% INTRODUCTORY TEXT
%%
function tsgqc
% tsgqc
%
......@@ -1872,6 +1875,8 @@ end
% get index on selected zone
% --------------------------
if ~isempty(tsg.DAYD_SPL)
ind = find(tsg.DAYD_SPL > p1(1,1) &...
tsg.DAYD_SPL < p2(1,1) & ...
tsg.([PARA '_SPL_DIF']) > p1(1,2) &...
......@@ -1897,6 +1902,8 @@ end
% --------------------------------------
plot_Correction( hMainFig, hPlotAxes, PARA);
end
else
% get index on selected zone
......@@ -2382,18 +2389,14 @@ end
set( hbgParameter, 'Visible', 'off');
set( hbgQc, 'Visible', 'off');
% Test if tsg and sample data have been loaded
% --------------------------------------------
if ~isempty( tsg.([PARA '_SPL']) )
% % Running average of TSG time series
% % ----------------------------------
% tsg_moveaverage(hMainFig, PARA);
% Compute the sample-TSG differences
% ----------------------------------
diffTsgSample( hMainFig, PARA );
end
% Plot in the 3 axes
% ------------------
plot_Correction( hMainFig, hPlotAxes, PARA );
......@@ -2405,16 +2408,9 @@ end
set( hetDateMin, 'String', datestr(noNaN(1), 31));
set( hetDateMax, 'String', datestr(noNaN(end), 31));
else
% Desactivate the corretion module
% --------------------------------
set( hBottleToggletool, 'state', 'off' );
msgbox('Sample data not loaded in the program', 'modal');
msgbox('No sample data file has been read', 'modal');
end
end
%% Bottle_OffMenuCallback ............................... Correction module
%---------------------------------------------------------------------
......@@ -2452,16 +2448,11 @@ end
% ------------------------------------
PARA = tsg.preference.parameter;
% Drawing only necessary if the Correction moduel has been activated
% ------------------------------------------------------------------
if ~isempty( tsg.([PARA '_SPL']) )
% Draw the 3 plots of the validation figure
% -----------------------------------------
plot_Validation( hMainFig, hPlotAxes, 1, PARA );
plot_Validation( hMainFig, hPlotAxes, 2, 'SSJT' );
plot_Validation( hMainFig, hPlotAxes, 3, 'SPDC' );
end
% Set the pointer
% ---------------
......@@ -2529,6 +2520,8 @@ end
tsg = getappdata(hMainFig, 'tsg_data');
PARA = tsg.preference.parameter;
if ~isempty( tsg.([PARA '_SPL']) )
% Compute the sample-TSG differences
% ----------------------------------
diffTsgSample( hMainFig, PARA );
......@@ -2552,6 +2545,8 @@ end
end
end
%% CorMedianCallback .................................... Correction Module
function CorMedianCallback(hObject, eventdata)
% Callback function run when
......@@ -2573,6 +2568,8 @@ end
tsg = getappdata(hMainFig, 'tsg_data');
PARA = tsg.preference.parameter;
if ~isempty( tsg.([PARA '_SPL']) )
% Compute the sample-TSG differences
% ----------------------------------
diffTsgSample( hMainFig, PARA );
......@@ -2596,6 +2593,8 @@ end
end
end
%% SelectTime_OnMenuCallback
%---------------------------
function SelectTime_OnMenuCallback(hObject, eventdata)
......@@ -2956,7 +2955,7 @@ end
% Write a .TSG (ascii) file
% --------------------------
error = writeTsgDataTsg(hMainFig, strcat(pathName, fileName));
error = writeAsciiTsg(hMainFig, strcat(pathName, fileName));
% Pointer reset to arrow
% ----------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment