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

Bugfix and calculation update of matrices A, B and X.

parent bb49614b
No related branches found
No related tags found
No related merge requests found
146
\ No newline at end of file
147
\ No newline at end of file
......@@ -18,6 +18,15 @@ results = struct();
fnames = fieldnames(pSoundsources);
for i = 1:length(fnames)
results.(fnames{i}) = table();
% get start and end date of soundsource
soundSourceBegin = artoa.convert.dmy2rd(pSoundsources.(fnames{i}).begemis(3), ...
pSoundsources.(fnames{i}).begemis(2), ...
pSoundsources.(fnames{i}).begemis(1));
soundSourceEnd = artoa.convert.dmy2rd(pSoundsources.(fnames{i}).endemis(3), ...
pSoundsources.(fnames{i}).endemis(2), ...
pSoundsources.(fnames{i}).endemis(1));
[date, toa] = artoa.toa.predictFromGps( ...
pRfb, ...
pSoundsources.(fnames{i}), ...
......@@ -38,26 +47,33 @@ for i = 1:length(fnames)
pSoundsources.(fnames{i}).begemis(2), ...
pSoundsources.(fnames{i}).begemis(1) ...
);
tmpDistances = [];
tmpDistances = NaN(size(satPositions, 1), 1);
% calculate distances
for oDistance = 1:length(toa)
if isnan(toa(oDistance)) | any(isnan(satPositions(oDistance, :)))
tmpDistances = [tmpDistances; NaN];
%tmpDistances = [tmpDistances; NaN];
continue;
end
tmpDistances = [ ...
tmpDistances; ...
artoa.data.calculateGeodist( ...
tmpDistances(oDistance) = artoa.data.calculateGeodist( ...
satPositions(oDistance, :), ...
pSoundsources.(fnames{i}).position ...
) ...
];
);
end
results.(fnames{i}).satDistances = tmpDistances;
% set all sat dates to NaN that are not in soundsource mission range
satDatesInRangeIndex = ...
(results.(fnames{i}).satDate >= soundSourceBegin) ...
& (results.(fnames{i}).satDate <= soundSourceEnd);
results.(fnames{i}).satDate(~satDatesInRangeIndex) = NaN;
results.(fnames{i}).satToa(~satDatesInRangeIndex) = NaN;
results.(fnames{i}).daysSinceStart(~satDatesInRangeIndex) = NaN;
results.(fnames{i}).satDistances(~satDatesInRangeIndex) = NaN;
% find nearest neighbor toa
tmpMeasuredToas = NaN(size(results.(fnames{i}).satDate));
tmpIndexBelongingToSoso = strcmp(pToaData.soundSource, fnames{i});
if ~any(tmpIndexBelongingToSoso)
if ~any(tmpIndexBelongingToSoso) % no toa available so save NaN
results.(fnames{i}).measuredToa = tmpMeasuredToas;
continue;
end
......@@ -78,18 +94,23 @@ for i = 1:length(fnames)
lower(pTrackingParameter.interpolationMethodString) ...
);
results.(fnames{i}).measuredToa = NaN(size(results.(fnames{i}).satDate));
% find measured toa dates that belong to a sat date
[values, satIndex, toaIndex] = intersect(results.(fnames{i}).satDate, ceil(tmpToaDate));
results.(fnames{i}).measuredToa(satIndex) = tmpToa(toaIndex);
% find nearest neighbor
for oSatDates = 1:length(results.(fnames{i}).satDate)
tmpSatDate = results.(fnames{i}).satDate(oSatDates);
neighborDate = artoa.data.findNearestNeighbor( ...
tmpToaDate, ...
tmpSatDate ...
);
if abs(neighborDate - tmpSatDate) <= pTrackingParameter.gapSize
tmpMeasuredToas(oSatDates) = tmpToa(tmpToaDate == neighborDate);
end
end
results.(fnames{i}).measuredToa = tmpMeasuredToas;
% for oSatDates = 1:length(results.(fnames{i}).satDate)
% tmpSatDate = results.(fnames{i}).satDate(oSatDates);
% neighborDate = artoa.data.findNearestNeighbor( ...
% tmpToaDate, ...
% tmpSatDate ...
% );
% if abs(neighborDate - tmpSatDate) <= pTrackingParameter.gapSize
% tmpMeasuredToas(oSatDates) = tmpToa(tmpToaDate == neighborDate);
% end
% end
% results.(fnames{i}).measuredToa = tmpMeasuredToas;
clear tmpDistances;
end
......
......@@ -48,7 +48,7 @@ if pOffsetsParameter.useFixedSoundspeed
end
%% Solve it!
X = B.toa \ A{:, :};
X = A{:, :} \ B.toa;
%% Apply row names to X
if isrow(X)
......@@ -60,6 +60,7 @@ varNames = X.Properties.RowNames;
for i = 1:length(varNames)
if strcmp(varNames{i}, 'Distances')
X.Properties.RowNames{i} = 'Soundspeed';
X{'Soundspeed', 'Value'} = 1 / X{'Soundspeed', 'Value'};
end
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