function [error] = readBucketData( hTsgGUI, filename) % Function to read Bucket data in ASCII format. % % 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 : 'bucketASCII' % % Caution : replace the fill-value with NaN % $Id$ % Open the file % ------------- fid = fopen( filename, 'r' ); error = -1; if fid ~= -1 % Get the tsg structure from application GUI % ------------------------------------------ tsg = getappdata( hTsgGUI, 'tsg_data'); % 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 % ------------------------------------- tsg.DAYD_WS = datenum(bucketData(:,1), bucketData(:,2), ... bucketData(:,3), bucketData(:,4), ... bucketData(:,5), bucketData(:,6)); % save original date % ------------------ tsg.DATE_WS = datestr( tsg.DAYD_WS, 'yyyymmddHHMMSS' ); tsg.LATX_WS = bucketData(:,7); tsg.LONX_WS = bucketData(:,8); tsg.SSPS_WS = bucketData(:,9); tsg.SSPS_WS_QC = tsg.qc.Code.NO_CONTROL * ones(size(tsg.SSPS_WS)); %@ completer ces 2 champs !!!!!!!! %tsg.PSAL_WS_ANALDATE = ; %tsg.PSAL_WS_BOTTLE = ; % remplace pour l'instant sample.TYPE !!!!!! %tsg.SSPS_WS_TYPE = ones(size(tsg.SSPS_WS)); % Save the data in the application GUI % ------------------------------------ setappdata( hTsgGUI, 'tsg_data', tsg ); % Clear the Workspace % ------------------- clear bucketData % Close the file % -------------- fclose( fid ); % Everything OK % ------------- error = 1; end