Skip to content
Snippets Groups Projects
Commit 036b1a3e authored by jacques.grelet_ird.fr's avatar jacques.grelet_ird.fr
Browse files

G. Alory

Adapté aux navires de recherche en station: l'alerte n'est maintenant émise que si la position du navire à la date de la donnée externe est à plus de 5 km de la position de la donnée externe
parent a6b4a4c1
No related branches found
No related tags found
No related merge requests found
function compDateLocBtlShip( hMainFig, data ) function compDateLocBtlShip( hMainFig, data )
% Function that compares noted date of bottle sampling with % Function that compares noted date of bottle sampling with
% date when the ship was closest to sampling location % date when the ship was closest to sampling location
% %
% %
% input % input
% hMainFig .... handle to the tsgqc main program % hMainFig .... handle to the tsgqc main program
% data ........ structure of _EXT data whose dates are compared with ship location % data ........ structure of _EXT data whose dates are compared with ship location
% %
% %
% Get the data from the application GUI % Get the data from the application GUI
% ------------------------------------- % -------------------------------------
tsg = getappdata( hMainFig, 'tsg_data'); tsg = getappdata( hMainFig, 'tsg_data');
% time/space limits for "good" bottle/ship colocation % time/space limits for "good" bottle/ship colocation
%---------------------------------------------------- %----------------------------------------------------
%A PASSER dans tsg.cst %A PASSER dans tsg.cst?
WS_SHIPTRAJ_TIMEDIFF=datenum(0,0,0,0,30,0); WS_SHIPTRAJ_TIMEDIFF=datenum(0,0,0,0,30,0);
%WS_SHIPTRAJ_DISTDIFF=15; WS_SHIPTRAJ_DISTDIFF=5;
WS_SHIPTRAJ_COLOC_TIMEMAX=1.5; WS_SHIPTRAJ_COLOC_TIMEMAX=1.5;
% find bottles within the ship trip % find bottles within the ship trip
%---------------------------------- %----------------------------------
btlTrip=find((data.DAYD_EXT>=(tsg.DAYD(1)-WS_SHIPTRAJ_COLOC_TIMEMAX))... btlTrip=find((data.DAYD_EXT>=(tsg.DAYD(1)-WS_SHIPTRAJ_COLOC_TIMEMAX))...
& (data.DAYD_EXT<=(tsg.DAYD(end)+WS_SHIPTRAJ_COLOC_TIMEMAX))... & (data.DAYD_EXT<=(tsg.DAYD(end)+WS_SHIPTRAJ_COLOC_TIMEMAX)));
& strcmp(data.SSPS_EXT_TYPE,'WS')); % & (data.DAYD_EXT<=(tsg.DAYD(end)+WS_SHIPTRAJ_COLOC_TIMEMAX))...
% & strcmp(data.SSPS_EXT_TYPE,'WS'));
if isempty(btlTrip)
message = { 'WARNING: No Water Sample within ship trip is detected'}; if isempty(btlTrip)
message = { 'WARNING: No Water Sample within ship trip is detected'};
% Display the message box and blocks execution until the msgbox is deleted.
% ------------------------------------------------------------------------- % Display the message box and blocks execution until the msgbox is deleted.
hMsg1 = msgbox(message,'No useful Water Sample','warn', 'modal'); % -------------------------------------------------------------------------
uiwait(hMsg1); hMsg1 = msgbox(message,'No useful Water Sample','warn', 'modal');
uiwait(hMsg1);
else
else
% indices with colocation problem
%-------------------------------- % indices with colocation problem
nprob=0; %--------------------------------
indBtlProb=[]; nprob=0;
indTsgBestLoc=[]; indBtlProb=[];
indTsgAtSampling=[]; indTsgBestLoc=[];
indTsgAtSampling=[];
for ibtl=min(btlTrip):max(btlTrip)
dateTsgAround=find((tsg.DAYD>=(data.DAYD_EXT(ibtl)-WS_SHIPTRAJ_COLOC_TIMEMAX))... for ibtl=min(btlTrip):max(btlTrip)
& (tsg.DAYD<=(data.DAYD_EXT(ibtl)+WS_SHIPTRAJ_COLOC_TIMEMAX))); 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 % geographical distance between sampling location and ship position
%------------------------------------------------------------------ % within colocation window
dist=nan*ones(1,length(dateTsgAround)); %------------------------------------------------------------------
for it=1:length(dateTsgAround) dist=nan*ones(1,length(dateTsgAround));
dist(it)=m_lldist([data.LONX_EXT(ibtl) tsg.LONX(dateTsgAround(it))],[data.LATX_EXT(ibtl) tsg.LATX(dateTsgAround(it))]); for it=1:length(dateTsgAround)
end 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
%---------------------------------------------------- % look for ship location nearest to sampling location
locNearest=find(dist==min(dist)); %----------------------------------------------------
if ~isempty(locNearest) locNearest=find(dist==min(dist));
locNearest=locNearest(1); if ~isempty(locNearest)
end locNearest=locNearest(1);
end
% look for ship location at time of sampling % time lag between time of sampling and
%------------------------------------------- % time when ship is nearest to sampling location
timeDiffTsgBtl=abs(tsg.DAYD-data.DAYD_EXT(ibtl)); %-----------------------------------------------
timeNearest=find(timeDiffTsgBtl==min(timeDiffTsgBtl)); timeDiff=abs(tsg.DAYD(dateTsgAround(locNearest))-data.DAYD_EXT(ibtl));
if ~isempty(timeNearest)
timeNearest=timeNearest(1); % look for ship location at time of sampling
end %-------------------------------------------
timeDiffTsgBtl=abs(tsg.DAYD-data.DAYD_EXT(ibtl));
timeDiff=abs(tsg.DAYD(dateTsgAround(locNearest))-data.DAYD_EXT(ibtl)); timeNearest=find(timeDiffTsgBtl==min(timeDiffTsgBtl));
if ~isempty(timeNearest)
%warning for lag > 30 minutes timeNearest=timeNearest(1);
%---------------------------- end
if timeDiff>WS_SHIPTRAJ_TIMEDIFF %& dist(nearest)<=WS_SHIPTRAJ_DISTDIFF % distance between ship location nearest to sampling location
nprob=nprob+1; % and ship location at time of sampling
indBtlProb=[indBtlProb,ibtl]; %------------------------------------------------------------
indTsgBestLoc=[indTsgBestLoc,dateTsgAround(locNearest)]; distDiff=m_lldist([tsg.LONX(timeNearest) tsg.LONX(dateTsgAround(locNearest))],...
indTsgAtSampling=[indTsgAtSampling,timeNearest]; [tsg.LATX(timeNearest) tsg.LATX(dateTsgAround(locNearest))]);
end
%warning for lag > 30 minutes (and distance > 5km between
%ship location nearest to sampling location & at time of sampling)
end %-----------------------------------------------------------------
if timeDiff>WS_SHIPTRAJ_TIMEDIFF & distDiff>=WS_SHIPTRAJ_DISTDIFF
if nprob>0 nprob=nprob+1;
indBtlProb=[indBtlProb,ibtl];
% Create the message text to display indTsgBestLoc=[indTsgBestLoc,dateTsgAround(locNearest)];
% ---------------------------------- indTsgAtSampling=[indTsgAtSampling,timeNearest];
MDhm_TsgAtSampling=datevec(tsg.DAYD(indTsgAtSampling,:)); end
MDhm_TsgAtSampling=MDhm_TsgAtSampling(:,2:5);
MDhm_TsgBestLoc=datevec(tsg.DAYD(indTsgBestLoc,:));
MDhm_TsgBestLoc=MDhm_TsgBestLoc(:,2:5); end
message = { 'WARNING: bottle/ship colocation problems are detected'; ' ';...
[num2str(nprob),' bottles location disagree with ship trajectory']; ' ';... if nprob>0
'BTL date/lat/lon TSG date/lat/lon '; ' ';...
[reshape(sprintf('%02d/',data.MNTH(indBtlProb)),3,nprob)',... % Create the message text to display
reshape(sprintf('%02d ',data.DAYX(indBtlProb,:)),3,nprob)',... % ----------------------------------
reshape(sprintf('%2d:',data.hh(indBtlProb,:)),3,nprob)',... MDhm_TsgAtSampling=datevec(tsg.DAYD(indTsgAtSampling,:));
reshape(sprintf('%02d ',data.mi(indBtlProb,:)),3,nprob)',... MDhm_TsgAtSampling=MDhm_TsgAtSampling(:,2:5);
reshape(sprintf('%7.2f',data.LATX_EXT(indBtlProb,:)),7,nprob)',... MDhm_TsgBestLoc=datevec(tsg.DAYD(indTsgBestLoc,:));
reshape(sprintf('%8.2f ',data.LONX_EXT(indBtlProb,:)),9,nprob)',... MDhm_TsgBestLoc=MDhm_TsgBestLoc(:,2:5);
reshape(sprintf('%02d/',MDhm_TsgBestLoc(:,1)),3,nprob)',... message = { 'WARNING: bottle/ship colocation problems are detected'; ' ';...
reshape(sprintf('%02d ',MDhm_TsgBestLoc(:,2)),3,nprob)',... [num2str(nprob),' bottles location disagree with ship trajectory']; ' ';...
reshape(sprintf('%2d:',MDhm_TsgBestLoc(:,3)),3,nprob)',... % 'BTL date/lat/lon TSG date1/lat1/lon1 TSG date2/lat2/lon2 '; ' ';...
reshape(sprintf('%02d ',MDhm_TsgBestLoc(:,4)),3,nprob)',... 'BTL date/lat/lon TSG date/lat/lon '; ' ';...
reshape(sprintf('%7.2f',tsg.LATX(indTsgBestLoc,:)),7,nprob)',... [reshape(sprintf('%02d/',data.MNTH(indBtlProb)),3,nprob)',...
reshape(sprintf('%8.2f',mod(tsg.LONX(indTsgBestLoc,:)+180,360)-180),8,nprob)'] }; reshape(sprintf('%02d ',data.DAYX(indBtlProb,:)),3,nprob)',...
% reshape(sprintf('%02d/',MDhm_TsgAtSampling(:,1)),3,nprob)',... reshape(sprintf('%2d:',data.hh(indBtlProb,:)),3,nprob)',...
% reshape(sprintf('%02d ',MDhm_TsgAtSampling(:,2)),3,nprob)',... reshape(sprintf('%02d ',data.mi(indBtlProb,:)),3,nprob)',...
% reshape(sprintf('%2d:',MDhm_TsgAtSampling(:,3)),3,nprob)',... reshape(sprintf('%7.2f',data.LATX_EXT(indBtlProb,:)),7,nprob)',...
% reshape(sprintf('%02d ',MDhm_TsgAtSampling(:,4)),3,nprob)',... reshape(sprintf('%8.2f ',data.LONX_EXT(indBtlProb,:)),9,nprob)',...
% reshape(sprintf('%7.2f',tsg.LATX(indTsgAtSampling,:)),7,nprob)',... reshape(sprintf('%02d/',MDhm_TsgBestLoc(:,1)),3,nprob)',...
% reshape(sprintf('%8.2f ',mod(tsg.LONX(indTsgAtSampling,:)+180,360)-180),9,nprob)',... reshape(sprintf('%02d ',MDhm_TsgBestLoc(:,2)),3,nprob)',...
reshape(sprintf('%2d:',MDhm_TsgBestLoc(:,3)),3,nprob)',...
% Display the message box and blocks execution until the msgbox is deleted. reshape(sprintf('%02d ',MDhm_TsgBestLoc(:,4)),3,nprob)',...
% ------------------------------------------------------------------------- reshape(sprintf('%7.2f',tsg.LATX(indTsgBestLoc,:)),7,nprob)',...
hMsg1 = msgbox(message,'Test bottle/ship colocation, ','warn', 'modal'); reshape(sprintf('%8.2f',mod(tsg.LONX(indTsgBestLoc,:)+180,360)-180),8,nprob)'] };
uiwait(hMsg1); % reshape(sprintf('%8.2f ',mod(tsg.LONX(indTsgBestLoc,:)+180,360)-180),9,nprob)',...
% reshape(sprintf('%02d/',MDhm_TsgAtSampling(:,1)),3,nprob)',...
end % reshape(sprintf('%02d ',MDhm_TsgAtSampling(:,2)),3,nprob)',...
end % reshape(sprintf('%2d:',MDhm_TsgAtSampling(:,3)),3,nprob)',...
% reshape(sprintf('%02d ',MDhm_TsgAtSampling(:,4)),3,nprob)',...
% Save tsg structure % reshape(sprintf('%7.2f',tsg.LATX(indTsgAtSampling,:)),7,nprob)',...
% ------------------ % reshape(sprintf('%8.2f ',mod(tsg.LONX(indTsgAtSampling,:)+180,360)-180),9,nprob)'] };
setappdata( hMainFig, 'tsg_data', tsg);
% Display the message box and blocks execution until the msgbox is deleted.
end % -------------------------------------------------------------------------
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.
Finish editing this message first!
Please register or to comment