Newer
Older
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 Temprature ARGO
% 16 Qualit de la temprature
% 17 Diffrence temporelle moyenne entre la mesure ARGO et les mesures TSG (**) (***)
% 18 Distance moyenne entre les mesures TSG et le profil ARGO (***)
% 19 Nombre de salinits TSG
% 20 Moyenne des salinits TSG
% 21 Ecart-type des salinits TSG
% 22 Nombre de tempratures TSG
% 23 Moyenne des tempratures TSG
% 24 Ecart-type des tempratures 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'
% Open the file
% -------------
fid = fopen( filename, 'r' );
error = -1;
if fid ~= -1
% Get the tsg structure from application GUI
% ------------------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
% 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
% -------------------------------------
tsg.DAYD_EXT = datenum(data(:,1), data(:,2), data(:,3), data(:,4), ...
data(:,5), data(:,6));
tsg.DAYD_EXT = tsg.DAYD_EXT + data(:,17);
Yves Gouriou
committed
tsg.DATE_EXT = datestr( tsg.DAYD_EXT, 'yyyymmddHHMMSS' );
tsg.LONX_EXT = data(:, 7);
tsg.LATX_EXT = data(:, 8);
tsg.SSPS_EXT = data(:, 13);
Yves Gouriou
committed
%tsg.SSPS_EXT_QC = data(:, 14);
Yves Gouriou
committed
%tsg.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
% -------------------------------------------------------------
% tsg.SSPS_EXT_QC = code * ones(size(tsg.SSPS_EXT));
% tsg.SSTP_EXT_QC = code * ones(size(tsg.SSTP_EXT));
tsg.SSPS_EXT_QC = castByteQC( code, tsg.SSPS_EXT );
tsg.SSTP_EXT_QC = castByteQC( code, tsg.SSTP_EXT );
% Create a string matrix for the type of data
% --------------------------------------------
[m, n] = size(data);
label = 'ARGO';
tsg.SSPS_EXT_TYPE = label( ones(m,1), :);
tsg.SSTP_EXT_TYPE = label( ones(m,1), :);
% Only keep data within TSG data time-limit
% -----------------------------------------
ind = find( tsg.DAYD_EXT < tsg.DAYD(1) | tsg.DAYD_EXT > tsg.DAYD(end));
tsg.DAYD_EXT(ind) = [];
tsg.DATE_EXT(ind, :) = [];
tsg.LONX_EXT(ind) = [];
tsg.LATX_EXT(ind) = [];
tsg.SSPS_EXT(ind) = [];
tsg.SSPS_EXT_QC(ind) = [];
tsg.SSTP_EXT(ind) = [];
tsg.SSTP_EXT_QC(ind) = [];
tsg.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,:);
% 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 );