function [error] = readCoriolisData( hMainFig, filename) % Format : % 1,6 Date du profil ARGO : YYYY-MM-DD HH:MI:SS % 7 Longitude du profil ARGO % 8 Latitude du profil ARGO % 9 Numero du profileur % 10 Numero du cycle % 11 Pression de la mesure ARGO (*) % 12 Qualit� de la pression % 13 Salinit� ARGO % 14 Qualit� de la salinit� % 15 Temp�rature ARGO % 16 Qualit� de la temp�rature % 17 Diff�rence temporelle moyenne entre la mesure ARGO et les mesures TSG (**) (***) % 18 Distance moyenne entre les mesures TSG et le profil ARGO (***) % 19 Nombre de salinit�s TSG % 20 Moyenne des salinit�s TSG % 21 Ecart-type des salinit�s TSG % 22 Nombre de temp�ratures TSG % 23 Moyenne des temp�ratures TSG % 24 Ecart-type des temp�ratures TSG % (*) : par defaut la pression la plus proche de 5m comprise entre 0 et 10m et ayant une qualit� de mesure de '1' ou '2' % (**) : � moins de R km et � +/-J jours (par defaut R=50km et J=5jours) % (***) : interviennent toutes les mesures o� au moins la SSS ou la SST ont une qualit� de '1' ou '2' error = 1; % Get the tsg structure from application GUI % ------------------------------------------ tsg = getappdata( hMainFig, 'tsg_data'); % If External data already loaded ask for suppression or addition % --------------------------------------------------------------- replace = 1; if ~isempty( tsg.DAYD_EXT ) errmsg = {'External samples already loaded '; ' '; ... 'Do you want to replace the existing samples ?'}; button = questdlg(errmsg, 'Sample','Yes', 'No', 'No'); switch button case 'Yes' replace = 1; case 'No' replace = 0; end end if replace % Open the file % ------------- fid = fopen( filename, 'r' ); error = -1; if fid ~= -1 % Read the file % ------------- data = fscanf(fid,... '%d-%d-%d %d:%d:%d %f %f %d %d %f %d %f %d %f %d %f %f %d %f %f %d %f %f',... [24 Inf])'; %data = data'; % Every variable are put in a structure % ------------------------------------- argo.DAYD_EXT = datenum(data(:,1), data(:,2), data(:,3), data(:,4), ... data(:,5), data(:,6)); argo.DAYD_EXT = argo.DAYD_EXT + data(:,17); % save original date % ------------------ argo.DATE_EXT = datestr( argo.DAYD_EXT, 'yyyymmddHHMMSS' ); argo.LONX_EXT = data(:, 7); argo.LATX_EXT = data(:, 8); argo.SSPS_EXT = data(:, 13); %argo.SSPS_EXT_QC = data(:, 14); argo.SSTP_EXT = data(:, 15); %argo.SSTP_EXT_QC = data(:, 16); % get code value for 'NO_CONTROL' in hashtable % -------------------------------------------- code = get(tsg.qc.hash, 'NO_CONTROL', 'code'); % pre-allocate and fill SSPS_WS_QC with 'NO_CONTROL' code value % ------------------------------------------------------------- argo.SSPS_EXT_QC = castByteQC( code, argo.SSPS_EXT ); argo.SSTP_EXT_QC = castByteQC( code, argo.SSTP_EXT ); % Create a string matrix for the type of data % -------------------------------------------- [m, n] = size(data); label = 'ARGO'; argo.SSPS_EXT_TYPE = label( ones(m,1), :); argo.SSTP_EXT_TYPE = label( ones(m,1), :); % Only keep data within TSG data time-limit % ----------------------------------------- ind = find( argo.DAYD_EXT >= tsg.DAYD(1) & argo.DAYD_EXT <= tsg.DAYD(end)); tsg.DAYD_EXT = argo.DAYD_EXT(ind); tsg.DATE_EXT = argo.DATE_EXT(ind,:); tsg.LATX_EXT = argo.LATX_EXT(ind); tsg.LONX_EXT = argo.LONX_EXT(ind); tsg.SSPS_EXT = argo.SSPS_EXT(ind); tsg.SSPS_EXT_QC = argo.SSPS_EXT_QC(ind); tsg.SSTP_EXT = argo.SSTP_EXT(ind); tsg.SSTP_EXT_QC = argo.SSTP_EXT_QC(ind); tsg.SSPS_EXT_TYPE = argo.SSPS_EXT_TYPE(ind,:); tsg.SSTP_EXT_TYPE = argo.SSTP_EXT_TYPE(ind,:); % Sort the struct tsg - increasing time. % ----------------------------------------- if ~isempty(tsg.DAYD_EXT) [tsg.DAYD_EXT, iOrder] = sort(tsg.DAYD_EXT); tsg.DATE_EXT = tsg.DATE_EXT(iOrder,:); tsg.LATX_EXT = tsg.LATX_EXT(iOrder); tsg.LONX_EXT = tsg.LONX_EXT(iOrder); tsg.SSPS_EXT = tsg.SSPS_EXT(iOrder); tsg.SSPS_EXT_QC = tsg.SSPS_EXT_QC(iOrder); tsg.SSTP_EXT = tsg.SSTP_EXT(iOrder); tsg.SSTP_EXT_QC = tsg.SSTP_EXT_QC(iOrder); tsg.SSPS_EXT_TYPE = tsg.SSPS_EXT_TYPE(iOrder,:); tsg.SSTP_EXT_TYPE = tsg.SSTP_EXT_TYPE(iOrder,:); end % Keep the name of the file for the log file % ------------------------------------------ tsg.report.extfile = filename; % Save the data in the application GUI % ------------------------------------ setappdata( hMainFig, 'tsg_data', tsg ); % Clear the Workspace % ------------------- clear data % Close the file % -------------- fclose( fid ); % Everything OK % ------------- error = 1; end end