Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
function [error] = writeTsgDataTsg( 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 );
sec = fix( sec );
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
if isempty(tsg.([para '_ADJUSTED']))
tsg.([para '_ADJUSTED']) = NaN * ones( size( tsg.DAYD ) );
end
if isempty(tsg.([para '_ADJUSTED_ERROR']))
tsg.([para '_ADJUSTED_ERROR']) = NaN * ones( size( tsg.DAYD ) );
end
if isempty(tsg.([para '_ADJUSTED_QC']))
tsg.([para '_ADJUSTED_QC']) = zeros( size( tsg.DAYD ) );
end
end
tsg_data = [year month day hour min sec tsg.LATX tsg.LONX ...
tsg.SSPS double(tsg.SSPS_QC) ...
tsg.SSPS_ADJUSTED tsg.SSPS_ADJUSTED_ERROR double(tsg.SSPS_ADJUSTED_QC)...
tsg.SSJT double(tsg.SSJT_QC) ...
tsg.SSJT_ADJUSTED tsg.SSJT_ADJUSTED_ERROR double(tsg.SSJT_ADJUSTED_QC) ...
tsg.SSTP double(tsg.SSTP_QC) ...
tsg.SSTP_ADJUSTED tsg.SSTP_ADJUSTED_ERROR double(tsg.SSTP_ADJUSTED_QC)];
% Write some information
% ----------------------
if ~isempty( tsg.CYCLE_MESURE )
fprintf( fid, '%%CYCLE_MESURE %s\n', tsg.CYCLE_MESURE);
end
if ~isempty( tsg.PLATFORM_NAME )
fprintf( fid, '%%PLATFORM_NAME %s\n', tsg.PLATFORM_NAME);
end
% Write the header
% ----------------
headDate = 'yyyy mm dd hh mm ss ';
headPos = 'LATX LONX ';
headSSPS = 'SSPS SSPS_QC SSPS_ADJUSTED SSPS_ADJUSTED_ERROR SSPS_ADJUSTED_QC ';
headSSJT = 'SSJT SSJT_QC SSJT_ADJUSTED SSJT_ADJUSTED_ERROR SSJT_ADJUSTED_QC ';
headSSTP = 'SSTP SSTP_QC 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 %12.7f %12.7f %6.3f %1d %6.3f %6.3f %1d %6.3f %1d %6.3f %6.3f %1d %6.3f %1d %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