Newer
Older
gael.alory_legos.obs-mip.fr
committed
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
function [error] = readTsgDataOracle( hMainFig, filename )
% readTsgDataOracle( hMainFig, filename )
% Function to read TSG data a
%
% Input
% -----
% hMainFig ........... Handle to the main user interface
% filename ........... Data filename
%
% Output
% ------
% error .............. 1: OK - -1 : an error occured
%
% Get the data from the application GUI
% -------------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
% Get the fieldnames of tsg structure
% -----------------------------------
tsgNames = fieldnames(tsg);
nbFieldNames = length( tsgNames );
% Get NO_CONTROL, GOOD, PROBABLY_GOOD codes
% -----------------------------------------
NO_CONTROL = tsg.qc.hash.NO_CONTROL.code;
GOOD = tsg.qc.hash.GOOD.code;
PROBABLY_GOOD = tsg.qc.hash.PROBABLY_GOOD.code;
% Display read file info on console
% ---------------------------------
fprintf('\nREAD_ASCII_FILE\n'); tic;
% Open the file
% -------------
fid = fopen( filename, 'rt' );
% Check file
% -----------
if fid == -1
msg_error = ['TSG_GOSUD file_lecture : Open file error : ' filename];
warndlg( msg_error, 'ASCII error dialog');
sprintf('...cannot locate %s\n', filename);
error = -1;
return;
end
% Display more info about read file on console
% --------------------------------------------
fprintf('...reading %s : ', filename);
% Oracle format has no header
% Columns are:
gael.alory_legos.obs-mip.fr
committed
% yyyy/mm/dd HH:MM(:SS) latx lonx ssjt ssps ?
% -------------------------------------------
theFormat = '%s %s %f %f %f %f %d';
gael.alory_legos.obs-mip.fr
committed
% Read the data in a cell
% -----------------------
cellData = textscan( fid, theFormat );
gael.alory_legos.obs-mip.fr
committed
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
nrecords=length(cellData{1});
% Fill TSG attributes (extracted from filename)
% ---------------------------------------------
tsg.report.tsgfile = filename;
%remove path and extension from filename
%---------------------------------------
whereSeparator=find(filename=='/' | filename=='\');
if ~isempty(whereSeparator)
shortname=filename(max(whereSeparator)+1:end);
else
shortname=filename;
end
shortname=shortname(1:max(find(shortname=='.'))-1);
tsg.CYCLE_MESURE = lower(shortname);
%deduce PLATFORM_NAME and CALL_SIGN from 4-letter code
%-----------------------------------------------------
switch lower(shortname(1:4))
case 'ante'
tsg.PLATFORM_NAME= 'antea';
tsg.SHIP_CALL_SIGN = 'FNUR';
case 'atal'
tsg.PLATFORM_NAME= 'atalante';
tsg.SHIP_CALL_SIGN = 'FNCM';
case 'cave'
tsg.PLATFORM_NAME= 'cap verde';
tsg.SHIP_CALL_SIGN = 'ELVO3';
case 'coli'
tsg.PLATFORM_NAME= 'colibri';
tsg.SHIP_CALL_SIGN = 'FNHO';
case {'cons','wate'}
tsg.PLATFORM_NAME= 'waterberg';
tsg.SHIP_CALL_SIGN = 'ZSUY';
case 'lape'
tsg.PLATFORM_NAME= 'la perouse';
tsg.SHIP_CALL_SIGN = 'FNDH';
case 'nuka'
tsg.PLATFORM_NAME= 'nuka arctica';
tsg.SHIP_CALL_SIGN = 'OXYH2';
case 'past'
tsg.PLATFORM_NAME= 'pasteur';
tsg.SHIP_CALL_SIGN = 'ELWT7';
case 'thal'
tsg.PLATFORM_NAME= 'thalassa';
tsg.SHIP_CALL_SIGN = 'FNFP';
case 'touc'
tsg.PLATFORM_NAME= 'toucan';
tsg.SHIP_CALL_SIGN = 'FNAV';
otherwise
tsg.PLATFORM_NAME= '';
tsg.SHIP_CALL_SIGN = '';
end
% Fill TSG variables
% ------------------
datechar = char(cellData{1});
gael.alory_legos.obs-mip.fr
committed
timechar = char(cellData{2});
yyyy = str2num(datechar(:,1:4));
mm = str2num(datechar(:,6:7));
dd = str2num(datechar(:,9:10));
HH = str2num(timechar(:,1:2));
MM = str2num(timechar(:,4:5));
if size(timechar,2)>5
SS = str2num(timechar(:,7:8));
else
SS = zeros(nrecords,1);
end

jacques.grelet_ird.fr
committed
tsg.DATE = datestr([yyyy mm dd HH MM SS],...
tsg.preference.date_format_variable);
tsg.DAYD = datenum(tsg.DATE, tsg.preference.date_format_variable);
gael.alory_legos.obs-mip.fr
committed
tsg.LATX = cellData{3};
tsg.LONX = cellData{4};
tsg.SSJT = cellData{5};
tsg.SSPS = cellData{6};
gael.alory_legos.obs-mip.fr
committed
% by default, SSPS before correction flagged GOOD
% -----------------------------------------------
tsg.SSPS_QC=GOOD*ones(nrecords,1,'int32');
% populate tsg.file structure
% ---------------------------
[tsg.file.pathstr, tsg.file.name, tsg.file.ext] = ...
gael.alory_legos.obs-mip.fr
committed
fileparts(filename);
% Perform some automatic tests
% -----------------------------
automaticQC( hMainFig );
tsg.file.type = 'ASCII';
% Save the data in the application GUI
% ------------------------------------
setappdata( hMainFig, 'tsg_data', tsg );
% Close the file
% --------------
fclose( fid );
% Display time to read file on console
% ------------------------------------
t = toc; fprintf('...done (%6.2f sec).\n\n',t);
% Everything OK
% -------------
error = 1;
end