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
function [error] = tsg_readTsgData( hTsgGUI, filename)
% Function to read the TSG data. Should be a NetCDF file
%
% 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 : 'tsg_data'
%
% Function to be rewritten when the NetCDF format will be in use
% Caution : replace the fill-value with NaN
%
% Open the file
% -------------
fid = fopen( filename, 'r' );
error = -1;
if fid ~= -1
% Read the file
% -------------
tsgData = fscanf(fid, '%d/%d/%d %d:%d:%d %f %f %f %f %d %f %f', ...
[13 Inf])';
% Every variable are put in a structure
% -------------------------------------
tsg.TIME = datenum(tsgData(:,3), tsgData(:,2),tsgData(:,1), ...
tsgData(:,4),tsgData(:,5),tsgData(:,6));
tsg.LATITUDE = tsgData(:,7);
tsg.LONGITUDE = tsgData(:,8);
tsg.TEMP_TSG = tsgData(:,9);
tsg.PSAL = tsgData(:,10);
tsg.PSAL_QC = tsgData(:,11);
tsg.PSAL_ADJ = tsgData(:,12);
tsg.PSAL_ERR = tsgData(:,13);
% Save the data in the application GUI
% ------------------------------------
setappdata( hTsgGUI, 'tsg_data', tsg );
% Clear the Workspace
% -------------------
clear tsgdata
% Close the file
% --------------
fclose( fid );
% Everything OK
% -------------
error = 1;
end