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 147
\ No newline at end of file \ No newline at end of file
...@@ -18,6 +18,15 @@ results = struct(); ...@@ -18,6 +18,15 @@ results = struct();
fnames = fieldnames(pSoundsources); fnames = fieldnames(pSoundsources);
for i = 1:length(fnames) for i = 1:length(fnames)
results.(fnames{i}) = table(); 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( ... [date, toa] = artoa.toa.predictFromGps( ...
pRfb, ... pRfb, ...
pSoundsources.(fnames{i}), ... pSoundsources.(fnames{i}), ...
...@@ -38,26 +47,33 @@ for i = 1:length(fnames) ...@@ -38,26 +47,33 @@ for i = 1:length(fnames)
pSoundsources.(fnames{i}).begemis(2), ... pSoundsources.(fnames{i}).begemis(2), ...
pSoundsources.(fnames{i}).begemis(1) ... pSoundsources.(fnames{i}).begemis(1) ...
); );
tmpDistances = []; tmpDistances = NaN(size(satPositions, 1), 1);
% calculate distances % calculate distances
for oDistance = 1:length(toa) for oDistance = 1:length(toa)
if isnan(toa(oDistance)) | any(isnan(satPositions(oDistance, :))) if isnan(toa(oDistance)) | any(isnan(satPositions(oDistance, :)))
tmpDistances = [tmpDistances; NaN]; %tmpDistances = [tmpDistances; NaN];
continue; continue;
end end
tmpDistances = [ ... tmpDistances(oDistance) = artoa.data.calculateGeodist( ...
tmpDistances; ...
artoa.data.calculateGeodist( ...
satPositions(oDistance, :), ... satPositions(oDistance, :), ...
pSoundsources.(fnames{i}).position ... pSoundsources.(fnames{i}).position ...
) ... );
];
end end
results.(fnames{i}).satDistances = tmpDistances; 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 % find nearest neighbor toa
tmpMeasuredToas = NaN(size(results.(fnames{i}).satDate)); tmpMeasuredToas = NaN(size(results.(fnames{i}).satDate));
tmpIndexBelongingToSoso = strcmp(pToaData.soundSource, fnames{i}); tmpIndexBelongingToSoso = strcmp(pToaData.soundSource, fnames{i});
if ~any(tmpIndexBelongingToSoso) if ~any(tmpIndexBelongingToSoso) % no toa available so save NaN
results.(fnames{i}).measuredToa = tmpMeasuredToas; results.(fnames{i}).measuredToa = tmpMeasuredToas;
continue; continue;
end end
...@@ -78,18 +94,23 @@ for i = 1:length(fnames) ...@@ -78,18 +94,23 @@ for i = 1:length(fnames)
lower(pTrackingParameter.interpolationMethodString) ... 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 % find nearest neighbor
for oSatDates = 1:length(results.(fnames{i}).satDate) % for oSatDates = 1:length(results.(fnames{i}).satDate)
tmpSatDate = results.(fnames{i}).satDate(oSatDates); % tmpSatDate = results.(fnames{i}).satDate(oSatDates);
neighborDate = artoa.data.findNearestNeighbor( ... % neighborDate = artoa.data.findNearestNeighbor( ...
tmpToaDate, ... % tmpToaDate, ...
tmpSatDate ... % tmpSatDate ...
); % );
if abs(neighborDate - tmpSatDate) <= pTrackingParameter.gapSize % if abs(neighborDate - tmpSatDate) <= pTrackingParameter.gapSize
tmpMeasuredToas(oSatDates) = tmpToa(tmpToaDate == neighborDate); % tmpMeasuredToas(oSatDates) = tmpToa(tmpToaDate == neighborDate);
end % end
end % end
results.(fnames{i}).measuredToa = tmpMeasuredToas; % results.(fnames{i}).measuredToa = tmpMeasuredToas;
clear tmpDistances; clear tmpDistances;
end end
......
...@@ -48,7 +48,7 @@ if pOffsetsParameter.useFixedSoundspeed ...@@ -48,7 +48,7 @@ if pOffsetsParameter.useFixedSoundspeed
end end
%% Solve it! %% Solve it!
X = B.toa \ A{:, :}; X = A{:, :} \ B.toa;
%% Apply row names to X %% Apply row names to X
if isrow(X) if isrow(X)
...@@ -60,6 +60,7 @@ varNames = X.Properties.RowNames; ...@@ -60,6 +60,7 @@ varNames = X.Properties.RowNames;
for i = 1:length(varNames) for i = 1:length(varNames)
if strcmp(varNames{i}, 'Distances') if strcmp(varNames{i}, 'Distances')
X.Properties.RowNames{i} = 'Soundspeed'; X.Properties.RowNames{i} = 'Soundspeed';
X{'Soundspeed', 'Value'} = 1 / X{'Soundspeed', 'Value'};
end end
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