Newer
Older
function [errTsg, errSpl] = read_data( hMainFig, filterIndex, fullFileName)
%
% Read TSG file or Discrete data (Water sample, ARGO, etc.)
%
% Called by TSGQC.M
%
% Input
% hMainFig Handle to the Main figure - Defined in TSGQC.m
% filterIndex Integer - Type of file
% fullFileName file name to read - Directory+filename
%
% Output
% errTsg Error code for TSG files
% errSpl Error code for discrete data file
%
% Filter index values
% 1 - Argo file *.arg (G. Reverdin format)
% 2 - TSG Astrolabe text file *.ast
% 3 - WS ascii file *.btl (tsgqc ascci format)
% 4 - TSG labview file *.lbv
% 5 - TSG netcdf file *.nc
% 6 - TSG Oracle text file *.ora
% 7 - TSG SDF file *.sdf
% 8 - SPL ascii file *.spl (tsgqc ascci format)
% 9 - TSG Nuka transmit file *.transmit*
% 10 - TSG text file *.tsgqc (tsgqc ascci format)
% 11 - TSG XML file *.xml
% 12 - Seasave file .cnv
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
%
% errTsg, errSpl
% 1 - File read OK
% < 0 - An error occured
%
% $id:$
% Error code - Initialisation
% ---------------------------
errTsg = -2;
errSpl = -2;
% Retrieve named application data
% -------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
switch filterIndex
% Read discrete data (Water sample, Argo, etc.)
% ---------------------------------------------
case {1, 3, 8}
% A TSG file must have been uploaded before reading Water sample file
% --------------------------------------------------------------------
if isempty( tsg.SSPS )
msgbox('Load a TSG file before a Water sample file', 'Read Bucket');
return;
elseif filterIndex == 1
% Read Argo file *.arg (G. Reverdin format)
errSpl = readArgoLocean( hMainFig, fullFileName );
elseif filterIndex == 3 || filterIndex == 8
% Read sample file *.spl
errSpl = readAsciiSample( hMainFig, fullFileName, 'SPL');
end
% Read TSG data file
% ------------------
case {2, 4, 5, 6, 7, 9, 10, 11, 12}
% Save the TSG structure - Temporary variable
% -------------------------------------------
tsg_old = tsg;
% Initialisation of TSG data struct : tsg variable
% ------------------------------------------------
tsg_initialisation(hMainFig);
% Read the file. TSG values are stored in a tsg variable
% -------------
switch filterIndex
case 2 % read TSG Astrolabe text file *.ast
errTsg = readTsgDataAstrolabe(hMainFig, fullFileName);
case 4 % read TSG labview file *.lbv
errTsg = readTsgDataLabview(hMainFig, fullFileName );
case 5 % read TSG netcdf file *.nc
errTsg = readTsgDataNetCDF(hMainFig, fullFileName );
case 6 % read TSG Oracle text file *.ora
errTsg = readTsgDataOracle(hMainFig, fullFileName);
case 7 % read TSG SDF file *.sdf
errTsg = readTsgDataSDF(hMainFig, fullFileName );
case 9 % read TSG Nuka transmit file *.transmit*
errTsg = readTsgDataNuka(hMainFig, fullFileName);
case 10 % read TSG text file *.tsgqc
errTsg = readAsciiTsg(hMainFig, fullFileName);
case 11 % read TSG XML file *.xml
errTsg = readTsgDataXML(hMainFig, fullFileName );
case 12 % read TSG XML file *.xml
errTsg = readTsgSeasave(hMainFig, fullFileName );
end
% Problem to read the file - Back to tsgqc.m
% ------------------------------------------
if errTsg < 0
return
else
% update some fields in tsg structure
% -----------------------------------
updateTsgStruct(hMainFig );
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
end
% Test if a TSG file is already uploaded in TSGQC
% Give the possibility to concatenate new and old files
% -----------------------------------------------------
button = 'Replace';
if ~isempty( tsg.SSPS )
qstring = {'TSG data have already been uploaded in TSGQC '; ' '; ...
'Do you want to Replace or to Concatenate them?'};
title = 'Read TSG Data';
button = questdlg(qstring, title,'Replace','Concatenate','Cancel', 'Cancel');
end
switch button
case 'Replace'
return
case 'Concatenate'
if strcmp( button, 'Concatenate')
concatStructTSG( hMainFig, tsg_old );
end
case 'Cancel'
% reassign the structure array tsg_old to the application data
% tsg_data
% --------------------------------------------------------------
setappdata( hMainFig, 'tsg_data', tsg_old);
return;
otherwise
return;
end
otherwise
% Reset pointer to arrow
% ----------------------
set( hMainFig, 'Pointer', 'arrow' );
% diplay warning msgbox
% ---------------------
msgbox( {['Invalid TSG file: ' fileName],...
'Please select another file'},...
'Warning open file', 'warn', 'modal' );
return;
end % switch filterIndex
end % function