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

Updated edit offsets and solve function.

parent 6aae5e61
No related branches found
No related tags found
No related merge requests found
109
\ No newline at end of file
110
\ No newline at end of file
......@@ -5,7 +5,7 @@ function [] = buttonCalculateOffsets(~, ~)
global artoaWorkspace artoaDataInput;
%% Initialize required variables
soundsources = artoa.controller.getSoundsourcesWithAppliedToa();
soundsources = artoaDataInput.soundsources;
satData = artoaWorkspace.satData;
%% Calculate offsets
......@@ -17,38 +17,29 @@ satData = artoaWorkspace.satData;
] = artoa.offsets.solve( ...
artoaDataInput.rfb, ...
soundsources, ...
artoaWorkspace.trackParameter, ...
artoaWorkspace.toaData, ...
satData, ...
artoaWorkspace.temperature(artoaWorkspace.statusTemperature == 1), ...
artoaWorkspace.pressure(artoaWorkspace.statusPressure == 1), ...
artoaWorkspace.trackParameter.soundspeedMethodString, ...
artoa.data.getMember(artoaDataInput, {'ini', 'leapseconds'}) ...
);
%% Store offsets in table
[offsets, drifts] = artoa.offsets.extractOffsetsDriftsFromSolved(artoaWorkspace.editOffsets.calculatedMatrixX);
artoaWorkspace.editOffsets.soundsourceOffsets.OptimumTotalOffset = offsets;
artoaWorkspace.editOffsets.soundsourceOffsets.OptimumTotalDrift = drifts;
%% Update TOA
% combine initial toa and current applied soundsources
toaData = artoaWorkspace.toaData;
toaData.toa = artoaDataInput.toaData.toa;
soundsourceNames = fieldnames(soundsources);
for o = 1:length(soundsourceNames)
if ~any(contains(artoaWorkspace.editOffsets.soundsourceOffsets.Properties.RowNames, soundsourceNames{o}))
continue;
end
artoaWorkspace.editOffsets.soundsourceOffsets{soundsourceNames{o}, 'OptimumTotalOffset'} = offsets(o);
artoaWorkspace.editOffsets.soundsourceOffsets{soundsourceNames{o}, 'OptimumTotalDrift'} = drifts(o);
end
%% Recalculate drift
artoa.controller.edit.offsets.updateWorkspaceOffsetsTable();
artoa.controller.edit.offsets.updateGui();
artoa.controller.edit.offsets.tableSoundsourceOffsetsEdit();
%% Select offset and drift from the table
artoa.controller.edit.offsets.selectOffsetsAndDrift();
artoaWorkspace.toaData = artoa.toa.recalculate( ...
artoaWorkspace.float, ...
toaData, ...
artoaWorkspace.editOffsets.selectedOffsets ...
);
artoa.controller.edit.timeOfArrival.plot();
......
......@@ -10,6 +10,8 @@ try
selectedColumn = event.Indices(2);
catch
selectedColumn = NaN;
artoa.controller.edit.offsets.updateGui();
return;
end
%% Check if the column that has been edited is locked
......@@ -18,12 +20,15 @@ if 1 <= selectedColumn & selectedColumn <= 7
return;
end
if ~artoa.data.hasMember(artoaWorkspace, {'editOffsets', 'soundsourceOffsets'})
return;
end
%% Save to workspace
artoaWorkspace.editOffsets.soundsourceOffsets(:, :) = artoaGui.editOffsets.tableSoundsourceOffsets.Data;
%% Recalculate drift
artoa.controller.edit.offsets.updateWorkspaceOffsetsTable();
artoa.controller.edit.offsets.updateGui();
%% Select offset and drift from the table
artoa.controller.edit.offsets.selectOffsetsAndDrift();
......@@ -40,6 +45,10 @@ artoaWorkspace.toaData = artoa.toa.recalculate( ...
%% Calculate GPS TOAs
artoa.controller.edit.timeOfArrival.calculateGpsToas();
%% Update GUI
artoa.controller.edit.offsets.updateGui();
%% Replot TOA window
artoa.controller.edit.timeOfArrival.plot();
end
function [a, b, x] = solve(pRfb, pSoundsources, pSatData, pAppliedTemperature, pAppliedPressure, pSoundspeedMethod, pLeapsecondsMatrix)
function [a, b, x] = solve(pRfb, pSoundsources, pTrackingParameter, pToaData, pSatData, pAppliedTemperature, pAppliedPressure, pLeapsecondsMatrix)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
......@@ -14,7 +14,7 @@ floatDetails = pRfb.FLOAT;
%% Create table
results = struct();
%% Calculate SAT TOAs for every soundsource
%% Calculate SAT TOAs for every soundsource and get nearest neighbor measured toa
fnames = fieldnames(pSoundsources);
for i = 1:length(fnames)
results.(fnames{i}) = table();
......@@ -24,7 +24,7 @@ for i = 1:length(fnames)
struct( ...
'temperature', pAppliedTemperature, ...
'pressure', pAppliedPressure, ...
'method', pSoundspeedMethod, ...
'method', pTrackingParameter.soundspeedMethodString, ...
'soundSource', NaN ...
), ...
pLeapsecondsMatrix ...
......@@ -54,6 +54,39 @@ for i = 1:length(fnames)
];
end
results.(fnames{i}).satDistances = tmpDistances;
% find nearest neighbor toa
tmpMeasuredToas = NaN(size(results.(fnames{i}).satDate));
tmpIndexBelongingToSoso = strcmp(pToaData.soundSource, fnames{i});
if ~any(tmpIndexBelongingToSoso)
results.(fnames{i}).measuredToa = tmpMeasuredToas;
continue;
end
tmpIndexBelongingToSoso = tmpIndexBelongingToSoso & (pToaData.status ~= 2);
tmpToaDate = pToaData.toaDate(tmpIndexBelongingToSoso);
tmpToa = pToaData.toa(tmpIndexBelongingToSoso);
% interpolate toa data
[ ...
tmpToaDate, ...
tmpToa, ...
~ ...
] = artoa.data.interpolateRafosData( ...
tmpToaDate, ...
tmpToa, ...
pTrackingParameter.interpolationInterval, ...
pTrackingParameter.gapSize, ...
lower(pTrackingParameter.interpolationMethodString) ...
);
% find nearest neighbor
for oSatDates = 1:length(results.(fnames{i}).satDate)
neighborDate = artoa.data.findNearestNeighbor( ...
tmpToaDate, ...
results.(fnames{i}).satDate(oSatDates) ...
);
tmpMeasuredToas(oSatDates) = tmpToa(tmpToaDate == neighborDate);
end
results.(fnames{i}).measuredToa = tmpMeasuredToas;
clear tmpDistances;
end
......@@ -65,12 +98,6 @@ aCore = zeros(rowCount, 2 * length(fnames));
b = zeros(rowCount, 1);
distances = zeros(rowCount, 1);
daysSinceFloatStart = NaN(rowCount, 1);
soundVelocity = NaN(rowCount, 1);
soundVelocity(:) = artoa.data.calculateSoundVelocity( ...
pAppliedTemperature, ...
pAppliedPressure, ...
pSoundspeedMethod ...
);
for i = 1:length(fnames)
rowIndices = ((i - 1) * length(satDates) + 1):i * length(satDates);
......@@ -78,7 +105,7 @@ for i = 1:length(fnames)
distances(rowIndices, 1) = results.(fnames{i}).satDistances;
aCore(rowIndices, startColIndex) = 1;
aCore(rowIndices, startColIndex + 1) = results.(fnames{i}).daysSinceStart;
b(rowIndices, 1) = results.(fnames{i}).satToa;
b(rowIndices, 1) = results.(fnames{i}).measuredToa;
daysSinceFloatStart(rowIndices, 1) = ...
results.(fnames{i}).satDate ...
- artoa.convert.dmy2rd( ...
......@@ -86,6 +113,8 @@ for i = 1:length(fnames)
floatDetails.launchtime(2), ...
floatDetails.launchtime(1) ...
);
% construct b
% foundToas = findCorrespondingToas(fnames{i}, results.(fnames{i}).satDate);
end
a = [ ...
......@@ -93,13 +122,23 @@ a = [ ...
];
% remove all NaN from matrix
indicesToUse = all(~isnan(a), 2) & all(aCore >= 0, 2);
indicesToUse = all(~isnan(a), 2) & all(aCore >= 0, 2) & ~isnan(b);
%x = a(indicesToUse, :) * flipud(b(indicesToUse, :));
a = a(indicesToUse, :);
b = b(indicesToUse, :);
x = pinv(a(indicesToUse, :)) * b(indicesToUse, :);
x = pinv(a) * b;
% function [toas] = findCorrespondingToas(soundsourceName, satDate)
% toas = NaN(size(satDate));
% for o = 1:length(satDate)
% if isnan(satDate(o))
% continue;
% end
% neighbor = artoa.data.findNearestNeighbor(pToaData.date, satDate(o));
% 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