Newer
Older
function [satfixEta] = calculateSatfixEta(pRfb, pSoundsources, pOffsets, pSoundvelocities, pLeapsecondsMatrix)
%CALCULATEGPSTOAS Calculates the SAT TOAs of all soundsources.
% Calculates the SAT TOAs by artoa.toa.predictFromGps. Adds the
% soundsource offset and drift if already selected.
%% Get all soundsources
fnames = fieldnames(pSoundsources);
satfixEta = struct();
%% Calculate GPS TOAs for every soundsource
for o = 1:length(fnames)
% initialize data storage
satfixEta.(fnames{o}) = struct();
% calculate rafos dates of soundsource
soundSourceBegin = artoa.convert.dmy2rd(pSoundsources.(fnames{o}).begemis(3), ...
pSoundsources.(fnames{o}).begemis(2), ...
pSoundsources.(fnames{o}).begemis(1));
soundSourceEnd = artoa.convert.dmy2rd(pSoundsources.(fnames{o}).endemis(3), ...
pSoundsources.(fnames{o}).endemis(2), ...
pSoundsources.(fnames{o}).endemis(1));
[gpsDates, predictedToas, launchDateToa] = artoa.toa.predictFromGps( ...
pRfb, pSoundsources.(fnames{o}), ...
leprob001
committed
pSoundvelocities.(fnames{o}), ...
pLeapsecondsMatrix ...
);
% add soundsource drift
if (~islogical(pOffsets)) ...
&& any(contains(pOffsets.Properties.RowNames, fnames{o}))
offset = pOffsets{fnames{o}, 'AppliedOffset'};
drift = pOffsets{fnames{o}, 'AppliedDrift'};
% check if Inf
if isinf(offset)
offset = 0;
end
if isinf(drift)
drift = 0;
end
% no sorting required, because fourth parameter contains timesteps
predictedToas = artoa.toa.addDrift( ...
predictedToas, ...
offset, ...
drift, ...
floor(gpsDates - soundSourceBegin) ...
);
% add offset and drift to launch toa
launchDateToa(2) = artoa.toa.addDrift( ...
launchDateToa(2), ...
offset, ...
drift ...
);
end
% remove gps dates that are past end mission of sound source
selection = (gpsDates > soundSourceEnd + 10);
gpsDates(selection) = NaN;
predictedToas(selection) = NaN;
% remove gps dates before deployment of soundsource
selection = (gpsDates < soundSourceBegin - 10);
gpsDates(selection) = NaN;
predictedToas(selection) = NaN;
clear selection;
% save to workspace
satfixEta.(fnames{o}).satDate = gpsDates;
satfixEta.(fnames{o}).satToa = predictedToas;
satfixEta.(fnames{o}).satLaunchDateToa = launchDateToa;
end
end