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
function [error] = tsg_readTsgData( hTsgGUI, filename)
% Function to read the Bucket data. Should be in 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 : 'bucket_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 - skip 2 lines
% ----------------------------
fgetl( fid ); fgetl( fid );
bucketData = fscanf(fid,'%d %d %d %d %d %d %f %f %f', [9 Inf])';
% Every variable are put in a structure
% -------------------------------------
bucket.TIME_WS = datenum(bucketData(:,1), bucketData(:,2), ...
bucketData(:,3), bucketData(:,4), ...
bucketData(:,5), bucketData(:,6));
bucket.LATITUDE_WS = bucketData(:,7);
bucket.LONGITUDE_WS = bucketData(:,8);
bucket.PSAL_WS = bucketData(:,9);
bucket.PSAL_QC_WS = size(bucket.PSAL_WS);
% Save the data in the application GUI
% ------------------------------------
setappdata( hTsgGUI, 'bucket_data', bucket );
% Clear the Workspace
% -------------------
clear bucketData
% Close the file
% --------------
fclose( fid );
% Everything OK
% -------------
error = 1;
end