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