Skip to content
Snippets Groups Projects
Commit 7d3f4d6a authored by leprob001's avatar leprob001
Browse files

The time divergence is now based on interpolated dates and positions.

parent 38d6c4af
No related branches found
No related tags found
No related merge requests found
......@@ -72,10 +72,9 @@ for i = 1:length(trajectories)
[ ...
artoaGui.trajectoryOutput.trajectoryHandles{i}.scatterSurfacePositions, ...
artoaGui.trajectoryOutput.trajectoryHandles{i}.textSurfacePositions ...
] = artoa.controller.track.trajectoryOutput.plotTrajectorySurfacePositions( ...
] = artoa.trajectory.plotTimeDivergenceToGpsPositions( ...
artoaGui.trajectoryOutput.axesTrajectoryOutput, ...
trajectories{i}, ...
artoaWorkspace.satData, ...
trajectoryColor, ...
pPlotAsMap ...
);
......@@ -124,7 +123,8 @@ for i = 1:length(trajectories)
end
artoa.controller.setPlotHandleVisibility( ...
{ ...
artoaGui.trajectoryOutput.trajectoryHandles{i}.textPositions ...
artoaGui.trajectoryOutput.trajectoryHandles{i}.textPositions, ...
artoaGui.trajectoryOutput.trajectoryHandles{i}.textSurfacePositions ...
}, ...
artoaWorkspace.trajectoryOutput.showPositionDates ...
);
......
......@@ -189,6 +189,9 @@ trajectoryDates = [];
trajectoryClockError = [];
trajectoryResiduals = struct();
trajectoryTimeDivergenceToGps = struct();
trajectoryTimeDivergenceToGps.latitude = [];
trajectoryTimeDivergenceToGps.longitude = [];
trajectoryTimeDivergenceToGps.date = [];
for i = 1:length(involvedSoundsourceNames)
trajectoryResiduals.(involvedSoundsourceNames{i}) = [];
trajectoryTimeDivergenceToGps.(involvedSoundsourceNames{i}) = [];
......@@ -284,14 +287,46 @@ for oCombination = 1:size(soundsourceCombinations, 1)
trajectoryVelocities.vertical = [trajectoryVelocities.vertical; segmentVerticalVelocity];
trajectoryVelocities.verticalDates = [trajectoryVelocities.verticalDates; segmentVerticalDates];
% calculate time divergence to gps
% get all sat dates
if isempty(segmentDates)
continue;
end
% Calculate time divergence to gps
% interpolate the trajectory linearly to have a position every day
[ ...
segmentInterpolatedDates, ...
segmentInterpolatedLat ...
] = artoa.data.interpolateRafosData( ...
segmentDates, ...
segmentPositions(:, 1), ...
24, ...
9999, ...
'linear' ...
);
[ ...
~, ...
segmentInterpolatedLon ...
] = artoa.data.interpolateRafosData( ...
segmentDates, ...
segmentPositions(:, 2), ...
24, ...
9999, ...
'linear' ...
);
segmentInterpolatedPositions = [ segmentInterpolatedLat, segmentInterpolatedLon];
% get all sat dates and positions
satDates = artoa.convert.dmy2rd(pSatData.day_sat, pSatData.month_sat, pSatData.year_sat);
satPositions = [pSatData.lat_sat(:), pSatData.lon_sat(:)];
tmpIndex = ~isnan(satDates) & ~any(isnan(satPositions), 2);
% remove nans
satDates = satDates(tmpIndex);
satPositions = satPositions(tmpIndex, :);
clear tmpIndex;
% get all dates that intersect with segment
[~, segmentDatesIndex, satIndex] = intersect(round(segmentDates), round(satDates));
intersectedSegmentPositions = segmentPositions(segmentDatesIndex, :);
intersectedSegmentDates = segmentDates(segmentDatesIndex, :);
satPositions = [pSatData.lat_sat(satIndex), pSatData.lon_sat(satIndex)];
[~, segmentDatesIndex, segmentSatIndex] = intersect(floor(segmentInterpolatedDates), satDates);
intersectedSegmentPositions = segmentInterpolatedPositions(segmentDatesIndex, :);
intersectedSegmentDates = round(segmentInterpolatedDates(segmentDatesIndex, :));
segmentSatPositions = satPositions(segmentSatIndex, :);
% get all soundsources of segment
segmentSoundsources = artoa.data.extractSoundsourcesFromStruct( ...
strsplit(soundsourceCombinations.soundsources{oCombination}), ...
......@@ -306,19 +341,24 @@ for oCombination = 1:size(soundsourceCombinations, 1)
pSoundVelocity(oCombination, oSoundsource) ...
);
[gpsDivergence, usedIndices] = artoa.data.calculateTimeDivergence( ...
repmat(currentSoundsource.position, size(satPositions, 1), 1), ...
satPositions, ...
repmat(currentSoundsource.position, size(segmentSatPositions, 1), 1), ...
segmentSatPositions, ...
pSoundVelocity(oCombination, oSoundsource) ...
);
if isempty(usedIndices) || isempty(soundsourceDivergence) || isempty(gpsDivergence)
continue;
end
difference = (soundsourceDivergence(usedIndices) - gpsDivergence);
difference = (soundsourceDivergence(usedIndices) - gpsDivergence(:));
trajectoryTimeDivergenceToGps.(currentSoundsource.sourcename) = [ ...
trajectoryTimeDivergenceToGps.(currentSoundsource.sourcename);
segmentDates(usedIndices), difference
intersectedSegmentDates(usedIndices), difference
];
end
% save positions and dates that have been interpolated and used for time divergence
trajectoryTimeDivergenceToGps.latitude = [trajectoryTimeDivergenceToGps.latitude; intersectedSegmentPositions(:, 1)];
trajectoryTimeDivergenceToGps.longitude = [trajectoryTimeDivergenceToGps.longitude; intersectedSegmentPositions(:, 2)];
trajectoryTimeDivergenceToGps.date = [trajectoryTimeDivergenceToGps.date; floor(intersectedSegmentDates)];
end
end
\ No newline at end of file
......@@ -16,6 +16,9 @@ cla(pAxesHandle);
hold(pAxesHandle, 'on');
counter = 1;
for i = 1:length(fnames)
if any(strcmp(fnames{i}, {'latitude', 'longitude', 'date'}))
continue;
end
current = pTrajectory.timeDivergenceToGps.(fnames{i});
if isempty(current)
continue;
......
function [scatterHandle, textHandles] = plotTrajectorySurfacePositions(pAxesHandle, pTrajectory, pSatData, pColor, pPlotAsMap)
function [scatterHandle, textHandles] = plotTimeDivergenceToGpsPositions(pAxesHandle, pTrajectory, pColor, pPlotAsMap)
%PLOTTRAJECTORYSURFACEPOSITIONS Summary of this function goes here
% Detailed explanation goes here
%% Get required data
satDates = artoa.convert.dmy2rd(pSatData.day_sat, pSatData.month_sat, pSatData.year_sat);
trajectoryDates = pTrajectory.date;
[~, ~, surfaceDates] = intersect(round(satDates), round(trajectoryDates));
x = pTrajectory.longitude(surfaceDates);
y = pTrajectory.latitude(surfaceDates);
x = pTrajectory.timeDivergenceToGps.longitude;
y = pTrajectory.timeDivergenceToGps.latitude;
dates = pTrajectory.timeDivergenceToGps.date;
%% Hold axes
......@@ -36,8 +34,8 @@ else
);
end
t = artoa.convert.rd2dmy(trajectoryDates(surfaceDates));
trd = round(trajectoryDates(surfaceDates));
t = artoa.convert.rd2dmy(dates);
trd = round(dates);
textHandles = cell(1, length(t));
if pPlotAsMap
for i = 1:length(x)
......
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