Newer
Older
function testDoubleDate(hMainFig)
%
% Test if there are records with identical date and time.
% Suppress records with the same date (keep only one record)
%
% Test only consecutive date :
% very simple test made because of a bug in the acquisition
% software used on IRD VOS
%
% Input
% -----
% hMainFig ............ Handel to the main user interface
%
% Function called by 'OpenMenuCallback' in tqgqc.m
%
% $Id$
% Get the data from the application GUI
% -------------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
% Find indices of consecutive identical dates
% -------------------------------------------
indIdentRec = find( diff(tsg.DAYD) == 0);
% If there are identical records ...
% ----------------------------------
if ~isempty(indIdentRec)
% Number of indentical dates - Conversion in String
% -------------------------------------------------
nIdentRec = size(indIdentRec, 1);
StrnIdentRec = sprintf( '%d', nIdentRec);
% Create the message text to display the 10 first identical dates
% ---------------------------------------------------------------
nMaxRec = min(10, nIdentRec);
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
message = { 'ATTENTION: consecutive identical dates are detected'; ' ';...
[StrnIdentRec ' records will be supressed']; ' ';...
'yyyymmddhhmmss'; ' '; tsg.DATE(indIdentRec(1:nMaxRec), :);...
'etc.' };
% Display the message box and blocks execution until the msgbox is deleted.
% -------------------------------------------------------------------------
hMsg1 = msgbox(message,'Test identical date','warn', 'modal');
uiwait(hMsg1);
% returns a cell array of strings containing the structure field names
% associated with the structure tsg.
% --------------------------------------------------------------------
tsgNames = fieldnames(tsg);
% Number of structure field names in 'tsg'
% ----------------------------------------
nMembers = size(tsgNames,1);
% Number of total records/dates
% -----------------------------
nRecords = size(tsg.DAYD,1);
% Loop on the members of the tsg structure
% ----------------------------------------
for i = 1 : nMembers
% Some members of the tsg structure are also structures. We do not
% need to check them
% ----------------------------------------------------------------
if ~isstruct(tsg.(char(tsgNames(i))))
% Size of a member of tsg structure
% ---------------------------------
[n] = size(tsg.(char(tsgNames(i))),1);
% If the member is the same size as tsg.DAYD ..
% --------------------------------------------
if n == nRecords
% Identical records are suppressed only for numeric and character
% arrays
% ---------------------------------------------------------------
if isnumeric(tsg.(char(tsgNames(i))))
tsg.(char(tsgNames(i)))(indIdentRec) = [];
elseif ischar(tsg.(char(tsgNames(i))))
tsg.(char(tsgNames(i)))(indIdentRec, :) = [];
else
% Display the message box and blocks execution until
% the msgbox is deleted.
% --------------------------------------------------
hMsg2 = msgbox('ATTENTION: type of matrix unknown - CHECK testDoubleDate.m',...
'SCRIPT : testDoubleDate.m', 'modal');
uiwait(hMsg2);
end
end
end
end
end
% Save tsg structure
% ------------------
setappdata( hMainFig, 'tsg_data', tsg);
% Very simple test to check if there are still identical dates
% ------------------------------------------------------------
sortDayd = sort( tsg.DAYD );
indIdentRec = find( diff(sortDayd) == 0);
% If there are identical records ...
% ----------------------------------
if ~isempty(indIdentRec)
message = { 'Function : testDoubleDate.m ';' ';...
'ATTENTION: Identical dates are detected'; ' ';...
'Check you file'};
hMsg3 = msgbox( message,'SCRIPT : testDoubleDate.m', 'modal');
uiwait(hMsg3);
end