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

Le module de rapport des actions effectuées est finalisé

parent 0807314f
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@ if fid ~= -1
% Read dfate of analysis. Convert to NetCdf format
% ------------------------------------------------
tab = fscanf(fid,'Date of water sample analysis: %d/%d/%d\r\n');
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' );
......
......@@ -187,10 +187,6 @@ if fid ~= -1
% -------------------
clear date time lat lon sst sss cond condRaw sog cog
% Perform somme automatic tests
% -----------------------------
automaticQC( hMainFig )
% Keep somme information for the log file
% ---------------------------------------
tsg.report.tsgfile = filename;
......@@ -199,6 +195,10 @@ if fid ~= -1
% Save the data in the application GUI
% ------------------------------------
setappdata( hMainFig, 'tsg_data', tsg );
% Perform somme automatic tests
% -----------------------------
automaticQC( hMainFig )
% Close the file
% --------------
......
......@@ -106,10 +106,6 @@ for i=1:length(variables)
end
end
% Perform somme automatic tests
% -----------------------------
automaticQC( hMainFig )
% Keep somme information for the log file
% ---------------------------------------
tsg.report.tsgfile = filename;
......@@ -118,6 +114,10 @@ tsg.report.tsgfile = filename;
% ------------------------------------
setappdata( hMainFig, 'tsg_data', tsg );
% Perform somme automatic tests
% -----------------------------
automaticQC( hMainFig )
% Close the file
% --------------
close(nc);
......
......@@ -71,26 +71,26 @@ tsg.SSJT_QC = tsg.SSPS_QC;
%tsg.file.name = filename;
tsg.file.type = 'ASCII';
% Keep somme information for the log file
% ---------------------------------------
tsg.report.tsgfile = filename;
% Save the data in the application GUI
% ------------------------------------
setappdata( hMainFig, 'tsg_data', tsg );
% Clear the Workspace
% -------------------
clear tsgdata
% Perform somme automatic tests
% -----------------------------
automaticQC( hMainFig );
% Keep somme information for the log file
% ---------------------------------------
tsg.report.tsgfile = filename;
% Close the file
% --------------
fclose( fid );
% Clear the Workspace
% -------------------
clear tsgdata
% Display time to read file on console
% ------------------------------------
t = toc; fprintf('...done (%6.2f sec).\n\n',t);
......
......@@ -29,25 +29,16 @@ VALUE_CHANGED = get(tsg.qc.hash, 'VALUE_CHANGED', 'code');
HARBOUR = get(tsg.qc.hash, 'HARBOUR', 'code');
INTERPOLATED_VALUE = get(tsg.qc.hash, 'INTERPOLATED_VALUE', 'code');
% Get the prefix of the TSG filename
% Delete the path
% ----------------------------------
[token, remain] = strtok(tsg.report.tsgfile, filesep);
while ~isempty( remain )
[token, remain] = strtok(remain, filesep);
end
[token, remain] = strtok(token, '.');
% Open the dialog box to choose the Directory and name of the file
% ----------------------------------------------------------------
[FileName, PathName, FilterIndex] = ...
uiputfile('*.log','Save the log file', [token '.log'] );
uiputfile('*.log','Save the log file', strcat(tsg.file.name, '.log') );
if FileName ~= 0
% Open the file
% -------------
fid = fopen( [PathName FileName], 'w' );
fid = fopen( [PathName FileName], 'wt' );
if fid ~= -1
......@@ -85,7 +76,7 @@ if FileName ~= 0
% Records deleted because date is not increasing
% -------------------------------------------------
fprintf( fid, ...
'%d records deleted because its date is not increasing\n\n',...
'%d records deleted because their date are not increasing\n\n',...
tsg.report.nodate);
% Records calibrated ?
......@@ -118,7 +109,7 @@ if FileName ~= 0
fprintf( fid, '\t\tSlope : %f\n', tsg.([para '_LINCOEF'])(1));
fprintf( fid, '\t\tOffset : %f\n\n', tsg.([para '_LINCOEF'])(2));
if ~isempty( para_old )
para= para_old;
para = para_old;
end
else
......@@ -126,6 +117,11 @@ if FileName ~= 0
fprintf( fid, 'Time series not calibrated \n\n' );
end % if ~isempty( tsg.([para '_CAL'])) & isempty( noNaN )
% Number of records
% -----------------
nbRecords = length( tsg.DAYD );
fprintf( fid, 'Number of measurements : %d\n\n', nbRecords );
% ---------------
% Validation code
% ---------------
......@@ -148,32 +144,56 @@ if FileName ~= 0
% --------------------------------------------
ind = find(tsg.([para '_QC']) == code);
fprintf( fid, '%07d %s code \n', length( ind ), key );
fprintf( fid, '%07d - %05.2f %% %s code \n', ...
length( ind ), length(ind)/nbRecords * 100 , key);
end
% --------------------------------------------
% Number of record corrected versus calibrated
% --------------------------------------------
% ind = find( tsg.([para '_QC']) == VALUE_CHANGED );
% if ~isempty( ind )
% ind = find( tsg.([para '_ADJUSTED_ERROR']) );
% if ~isempty( ind )
% printf( fid, '%d records have been adjusted\n\n', length( ind ));
% end
% end
% ----------------------
% Number of Water sample
% ----------------------
% -------------------------------
% Number of External Water sample
% -------------------------------
% --------------------------
% Number of record corrected
% --------------------------
ind = find( tsg.([para '_QC']) == VALUE_CHANGED );
if ~isempty( ind )
ind = find( tsg.([para '_ADJUSTED_ERROR']) );
if ~isempty( ind )
fprintf( fid, '\n %07d - %05.2f records have been adjusted\n\n',...
length( ind ), length(ind)/nbRecords * 100);
end
else
fprintf( fid, '\n No records have been adjusted\n\n');
end
% Number of Water sample
% no water sample for SSJT and SSTP
% ----------------------
if strcmp( para, 'SSPS')
if ~isempty( tsg.([para '_WS']) )
fprintf( fid, '%4d Water samples in the file\n\n', ...
length(tsg.([para '_WS'])));
else
fprintf( fid, 'No water sample\n\n');
end
end
% ------------------------------------
% Count water sample and external data
% No external data for SSJT
% ------------------------------------
para2 = para;
if strcmp( para, 'SSJT' )
para2 = 'SSTP';
end
% Number of External Water sample
% ---------------------------------
if ~isempty( tsg.([para2 '_EXT']) )
fprintf( fid, '%4d external samples in the file\n\n', ...
length(tsg.([para2 '_EXT'])));
else
fprintf( fid, 'No external sample\n\n');
end
else
fprintf( fid, 'no time series \n\n' );
end % ~isempty( tsg.para )
end % for ipar
......
......@@ -16,6 +16,15 @@ function [] = automaticQC( hMainFig )
% --------------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
% Get tsg fieldnames
% ------------------
tsgNames = fieldnames(tsg);
nbFieldNames = length( tsgNames );
% Get the size of the times series array
% --------------------------------------
tsgLength = length( tsg.DAYD );
MISSING_VALUE = get(tsg.qc.hash, 'MISSING_VALUE', 'code');
% ************************** TEST 1 ***********************************
......@@ -32,28 +41,37 @@ MISSING_VALUE = get(tsg.qc.hash, 'MISSING_VALUE', 'code');
% Find negative differences between successive dates
nbBadDate = 0;
difDate = diff( tsg.DAYD );
ind = find( difDate < 0 ) + 1;
ind = find( difDate < 0 );
while ~isempty( ind )
nbBadDate = nbBadDate + length( nbBadDate );
% if DAYD is of length N, DIFF is of length N-1
% Need to add one to the indices
% ---------------------------------------------
ind = ind + 1;
% Store the number of bad date
% -----------------------------
nbBadDate = nbBadDate + length( ind );
% Delete bad records
% ------------------
for i = 1 : nbFieldNames
para = char( tsgNames{i} );
% Find array of length DAYD in the TSG structure
% ----------------------------------------------
if length( tsg.(para) ) == tsgLength
tsg.(para)(ind) = [];
end
end
% Tsg length has been modified
% ----------------------------
tsgLength = tsgLength - length( ind );
if ~isempty( tsg.DAYD ); tsg.DAYD(ind) = []; end;
if ~isempty( tsg.DATE ); tsg.DATE(ind, :) = []; end;
if ~isempty( tsg.LATX ); tsg.LATX(ind) = []; end;
if ~isempty( tsg.LONX ); tsg.LONX(ind) = []; end;
if ~isempty( tsg.SSPS ); tsg.SSPS(ind) = []; end;
if ~isempty( tsg.SSPS_QC ); tsg.SSPS_QC(ind) = []; end;
if ~isempty( tsg.SSJT ); tsg.SSJT(ind) = []; end;
if ~isempty( tsg.SSJT_QC ); tsg.SSJT_QC(ind) = []; end;
if ~isempty( tsg.SSTP ); tsg.SSTP(ind) = []; end;
if ~isempty( tsg.SSTP_QC ); tsg.SSTP_QC(ind) = []; end;
if ~isempty( tsg.CNDC ); tsg.CNDC(ind) = []; end;
if ~isempty( tsg.SPDC ); tsg.SPDC(ind) = []; end;
if ~isempty( tsg.CNDC_FREQ ); tsg.CNDC_FREQ(ind) = []; end;
if ~isempty( tsg.SSJT_FREQ ); tsg.SSJT_FREQ(ind) = []; end;
difDate = diff( tsg.DAYD );
ind = find( difDate < 0 ) + 1;
ind = find( difDate < 0 );
end
% Keep the number of data not in increasing date
......
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