Skip to content
Snippets Groups Projects
Commit 421454d8 authored by gael.alory_legos.obs-mip.fr's avatar gael.alory_legos.obs-mip.fr
Browse files

Test de colocation echantillon bouteille/trajectoire du navire a la lecture du...

Test de colocation echantillon bouteille/trajectoire du navire a la lecture du fichier bouteille et alerte si plus de 30 min d'ecart entre heure echantillon et passage du navire aux lon/lat notees a la prise d'echantilllon
parent 766a8c89
No related branches found
No related tags found
No related merge requests found
...@@ -189,6 +189,11 @@ mi = num2str( s.(char(header(5))), '%02d' ); ...@@ -189,6 +189,11 @@ mi = num2str( s.(char(header(5))), '%02d' );
ss = num2str( s.(char(header(6))), '%02d' ); ss = num2str( s.(char(header(6))), '%02d' );
s.DATE_EXT = [yy mm dd hh mi ss]; s.DATE_EXT = [yy mm dd hh mi ss];
% Check if bottle/ship colocation is OK
% -------------------------------------
compDateLocBtlShip( hMainFig, s );
% Transfer the 's' structure to the 'tsg' structure % Transfer the 's' structure to the 'tsg' structure
% ------------------------------------------------- % -------------------------------------------------
error = concatSample( hMainFig, s ); error = concatSample( hMainFig, s );
......
function compDateLocBtlShip( hMainFig, data )
% Function that compares noted date of bottle sampling with
% date when the ship was closest to sampling location
%
%
% input
% hMainFig .... handle to the tsgqc main program
% data ........ structure of _EXT data whose dates are compared with ship location
%
%
% Get the data from the application GUI
% -------------------------------------
tsg = getappdata( hMainFig, 'tsg_data');
% time/space limits for "good" bottle/ship colocation
%----------------------------------------------------
%A PASSER dans tsg.cst
WS_SHIPTRAJ_TIMEDIFF=datenum(0,0,0,0,30,0);
%WS_SHIPTRAJ_DISTDIFF=15;
WS_SHIPTRAJ_COLOC_TIMEMAX=1.5;
% find bottles within the ship trip
%----------------------------------
btlTrip=find((data.DAYD_EXT>=(tsg.DAYD(1)-WS_SHIPTRAJ_COLOC_TIMEMAX))...
& (data.DAYD_EXT<=(tsg.DAYD(end)+WS_SHIPTRAJ_COLOC_TIMEMAX))...
& strcmp(data.SSPS_EXT_TYPE,'WS'));
if isempty(btlTrip)
message = { 'ATTENTION: No Water Sample within ship trip is detected'};
% Display the message box and blocks execution until the msgbox is deleted.
% -------------------------------------------------------------------------
hMsg1 = msgbox(message,'No useful Water Sample','warn', 'modal');
uiwait(hMsg1);
else
% indices with colocation problem
%--------------------------------
nprob=0;
indBtlProb=[];
indTsgBestLoc=[];
indTsgAtSampling=[];
for ibtl=min(btlTrip):max(btlTrip)
dateTsgAround=find((tsg.DAYD>=(data.DAYD_EXT(ibtl)-WS_SHIPTRAJ_COLOC_TIMEMAX))...
& (tsg.DAYD<=(data.DAYD_EXT(ibtl)+WS_SHIPTRAJ_COLOC_TIMEMAX)));
% geographical distance between sampling location and ship position
% within colocation window
%------------------------------------------------------------------
dist=nan*ones(1,length(dateTsgAround));
for it=1:length(dateTsgAround)
dist(it)=m_lldist([data.LONX_EXT(ibtl) tsg.LONX(dateTsgAround(it))],[data.LATX_EXT(ibtl) tsg.LATX(dateTsgAround(it))]);
end
% look for ship location nearest to sampling location
%----------------------------------------------------
locNearest=find(dist==min(dist));
if ~isempty(locNearest)
locNearest=locNearest(1);
end
% look for ship location at time of sampling
%-------------------------------------------
timeDiffTsgBtl=abs(tsg.DAYD-data.DAYD_EXT(ibtl));
timeNearest=find(timeDiffTsgBtl==min(timeDiffTsgBtl));
if ~isempty(timeNearest)
timeNearest=timeNearest(1);
end
timeDiff=abs(tsg.DAYD(dateTsgAround(locNearest))-data.DAYD_EXT(ibtl));
%warning for lag > 30 minutes
%----------------------------
if timeDiff>WS_SHIPTRAJ_TIMEDIFF %& dist(nearest)<=WS_SHIPTRAJ_DISTDIFF
nprob=nprob+1;
indBtlProb=[indBtlProb,ibtl];
indTsgBestLoc=[indTsgBestLoc,dateTsgAround(locNearest)];
indTsgAtSampling=[indTsgAtSampling,timeNearest];
end
end
if nprob>0
% Create the message text to display
% ----------------------------------
MDhm_TsgAtSampling=datevec(tsg.DAYD(indTsgAtSampling,:));
MDhm_TsgAtSampling=MDhm_TsgAtSampling(:,2:5);
MDhm_TsgBestLoc=datevec(tsg.DAYD(indTsgBestLoc,:));
MDhm_TsgBestLoc=MDhm_TsgBestLoc(:,2:5);
message = { 'ATTENTION: bottle/ship colocation problems are detected'; ' ';...
[num2str(nprob),' bottles location disagree with ship trajectory']; ' ';...
'BTL date/lat/lon TSG date/lat/lon '; ' ';...
[reshape(sprintf('%02d/',data.MNTH(indBtlProb)),3,nprob)',...
reshape(sprintf('%02d ',data.DAYX(indBtlProb,:)),3,nprob)',...
reshape(sprintf('%2d:',data.hh(indBtlProb,:)),3,nprob)',...
reshape(sprintf('%02d ',data.mi(indBtlProb,:)),3,nprob)',...
reshape(sprintf('%7.2f',data.LATX_EXT(indBtlProb,:)),7,nprob)',...
reshape(sprintf('%8.2f ',data.LONX_EXT(indBtlProb,:)),9,nprob)',...
reshape(sprintf('%02d/',MDhm_TsgBestLoc(:,1)),3,nprob)',...
reshape(sprintf('%02d ',MDhm_TsgBestLoc(:,2)),3,nprob)',...
reshape(sprintf('%2d:',MDhm_TsgBestLoc(:,3)),3,nprob)',...
reshape(sprintf('%02d ',MDhm_TsgBestLoc(:,4)),3,nprob)',...
reshape(sprintf('%7.2f',tsg.LATX(indTsgBestLoc,:)),7,nprob)',...
reshape(sprintf('%8.2f',mod(tsg.LONX(indTsgBestLoc,:)+180,360)-180),8,nprob)'] };
% reshape(sprintf('%02d/',MDhm_TsgAtSampling(:,1)),3,nprob)',...
% reshape(sprintf('%02d ',MDhm_TsgAtSampling(:,2)),3,nprob)',...
% reshape(sprintf('%2d:',MDhm_TsgAtSampling(:,3)),3,nprob)',...
% reshape(sprintf('%02d ',MDhm_TsgAtSampling(:,4)),3,nprob)',...
% reshape(sprintf('%7.2f',tsg.LATX(indTsgAtSampling,:)),7,nprob)',...
% reshape(sprintf('%8.2f ',mod(tsg.LONX(indTsgAtSampling,:)+180,360)-180),9,nprob)',...
% Display the message box and blocks execution until the msgbox is deleted.
% -------------------------------------------------------------------------
hMsg1 = msgbox(message,'Test bottle/ship colocation, ','warn', 'modal');
uiwait(hMsg1);
end
end
% Save tsg structure
% ------------------
setappdata( hMainFig, 'tsg_data', tsg);
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment