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

Added SATFIX-ETA to TOA plot.

parent 13cc525c
No related branches found
No related tags found
No related merge requests found
Showing
with 317 additions and 4 deletions
257
\ No newline at end of file
258
\ No newline at end of file
......@@ -3,9 +3,9 @@ function [] = updateAvailablePlots()
global artoaGui;
plotsToUpdate = {'editTemperature', 'editPressure', 'editTimeOfArrival', 'trajectoryOutput'};
controllerPackageNames = {'temperature', 'pressure', 'timeOfArrival', 'trajectoryOutput'};
controllerCategoryNames = {'edit', 'edit', 'edit', 'track'};
plotsToUpdate = {'editTemperature', 'editPressure', 'editTimeOfArrival', 'satfixEtaToToa', 'trajectoryOutput'};
controllerPackageNames = {'temperature', 'pressure', 'timeOfArrival', 'satfixEtaToToa', 'trajectoryOutput'};
controllerCategoryNames = {'edit', 'edit', 'edit', 'show', 'track'};
for i = 1:length(plotsToUpdate)
if ~isfield(artoaGui, plotsToUpdate{i})
......
......@@ -21,6 +21,7 @@ artoa.controller.edit.pressure.close();
artoa.controller.edit.temperature.close();
artoa.controller.edit.timeOfArrival.close();
artoa.controller.track.trajectoryOutput.close();
artoa.controller.show.satfixEtaToToa.close();
%% Load mat file
load(fullfile(pathname, filename), '-mat');
......
......@@ -30,6 +30,7 @@ artoa.controller.edit.pressure.close();
artoa.controller.edit.temperature.close();
artoa.controller.edit.timeOfArrival.close();
artoa.controller.track.trajectoryOutput.close();
artoa.controller.show.satfixEtaToToa.close();
%% Load file into memory
artoaDataInput.rfb = artoa.load.rfb(filepath);
......
......@@ -68,6 +68,9 @@ artoaWorkspace.editOffsets.offsets = artoa.offsets.generateOffsetTable( ...
artoa.controller.track.parameter.updateGui();
artoa.controller.edit.offsets.updateGui();
%% Update plots
artoa.controller.edit.updateAvailablePlots();
%% Update status text in main window
artoa.controller.main.updateLoadedFloatInformation();
......
......@@ -47,5 +47,8 @@ artoa.controller.edit.offsets.updateWorkspaceOffsetsTable(true);
artoa.controller.edit.offsets.updateGui();
artoa.controller.edit.offsets.updateMeasuredSoundspeed();
%% Replot
artoa.controller.edit.updateAvailablePlots();
end
......@@ -29,6 +29,7 @@ callbacks.reloadRfbFile = @artoa.controller.file.reloadRfb;
callbacks.openEditTemperature = @artoa.controller.edit.temperature.open;
callbacks.openEditPressure = @artoa.controller.edit.pressure.open;
callbacks.openEditTimeOfArrival = @artoa.controller.edit.timeOfArrival.open;
callbacks.openShowSatfixEtaToToa = @artoa.controller.show.satfixEtaToToa.open;
callbacks.openEditOffsets = @artoa.controller.edit.offsets.open;
callbacks.openTrackParameter = @artoa.controller.track.parameter.open;
callbacks.openTrackTrajectoryOutput = @artoa.controller.track.trajectoryOutput.open;
......
function [results] = calculateDifference()
%CALCULATE Summary of this function goes here
% Detailed explanation goes here
global artoaWorkspace artoaConfig artoaDataInput;
%% Calculate SATFIX ETA
[satfixEtas] = artoa.satdata.calculateSatfixEta( ...
artoaDataInput.rfb, ...
artoaWorkspace.filteredSoundsources, ...
artoaWorkspace.editOffsets.offsets, ...
artoa.controller.selectSoundspeed(), ...
artoaConfig.leapseconds);
%% Calculate difference
fnames = fieldnames(artoaWorkspace.filteredSoundsources);
results = struct();
for i = 1:length(fnames)
results.(fnames{i}) = struct();
results.(fnames{i}).difference = [];
selection = strcmp(artoaWorkspace.toaData.soundSource, fnames(i));
toas = artoaWorkspace.toaData.toa(selection);
toaDates = ceil(artoaWorkspace.toaData.toaDate(selection));
if length(toaDates) > 1
% interpolate toa data
[ ...
toaDates, ...
toas, ...
~ ...
] = artoa.data.interpolateRafosData( ...
toaDates, ...
toas, ...
artoaWorkspace.trackParameter.interpolationInterval, ...
artoaWorkspace.trackParameter.gapSize, ...
lower(artoaWorkspace.trackParameter.interpolationMethodString) ...
);
% interpolate
%toas = interp1(toaDates, toas, min(toaDates):1:max(toaDates))';
%toaDates = min(toaDates):1:max(toaDates)';
end
dates = intersect(toaDates, satfixEtas.(fnames{i}).satDate);
indicesToa = ismember(toaDates, dates);
indicesSatfix = ismember(satfixEtas.(fnames{i}).satDate, dates);
if all(isnan(dates)) | isempty(dates)
continue;
end
results.(fnames{i}).difference = toas(indicesToa) - satfixEtas.(fnames{i}).satToa(indicesSatfix);
results.(fnames{i}).date = dates;
end
end
function [ ] = close(pSource, ~)
%CLOSE Cleans up all variables that are used by the editPressure GUI.
% Changes to the data is not being modified.
global artoaGui artoaWorkspace;
%% Setup variables
figureName = 'satfixEtaToToa';
%% Close the figure
if nargin > 1 && isvalid(pSource)
delete(pSource);
elseif isfield(artoaGui.figures, figureName) && isvalid(artoaGui.figures.(figureName))
delete(artoaGui.figures.(figureName));
end
%% Clean up variables
if artoa.data.hasMember(artoaGui, {figureName})
artoaGui = rmfield(artoaGui, figureName);
end
if artoa.data.hasMember(artoaGui, {'figures', figureName})
artoaGui.figures = rmfield(artoaGui.figures, figureName);
end
if artoa.data.hasMember(artoaWorkspace, {figureName})
artoaWorkspace = rmfield(artoaWorkspace, figureName);
end
end
\ No newline at end of file
function [] = open(~, ~)
%OPENEDITTEMPERATURE Initializes the pressure editing gui.
% Detailed explanation goes here
global artoaGui;
%% Check if the gui is already opened
if isfield(artoaGui.figures, 'showSatfixEtaToToa')
figure(artoaGui.figures.satfixEtaToToa);
return
end
callbacks.CloseRequestFcn = @artoa.controller.show.satfixEtaToToa.close;
%% Open the gui
artoa.gui.show.satfixEtaToToa(callbacks);
end
function [] = plot()
%PLOT Summary of this function goes here
% Detailed explanation goes here
global artoaGui artoaWorkspace;
%% Calculate required variables
[results] = artoa.controller.show.satfixEtaToToa.calculateDifference();
%% Create plot
figureName = artoaGui.figures.satfixEtaToToa;
axes(figureName);
hold(figureName.CurrentAxes, 'on');
grid(figureName.CurrentAxes, 'on');
fnames = fieldnames(artoaWorkspace.filteredSoundsources);
legendNames = {};
for i = 1:length(fnames)
if isempty(results.(fnames{i}).difference)
continue;
end
color = artoa.soundsources.colorregister.getColor( ...
fnames{i}, ...
artoaWorkspace.soundsourceColorRegister, ...
artoaWorkspace.soundsourceColors ...
);
legendNames{end + 1} = fnames{i};
scatter( ...
figureName.CurrentAxes, ...
results.(fnames{i}).date, ...
results.(fnames{i}).difference, ...
[], ...
color, ...
'filled' ...
);
end
legend(figureName.CurrentAxes, legendNames);
title(figureName.CurrentAxes, 'Difference SATFIX-ETA - TOA');
xlabel(figureName.CurrentAxes, 'Rafos date');
ylabel(figureName.CurrentAxes, 'Difference [s]')
hold(figureName.CurrentAxes, 'off');
end
......@@ -18,8 +18,10 @@ end
%% If no pressure and temperature is selected, the time of arrival window should be disabled
if (any(artoaWorkspace.statusTemperature == 1) && any(artoaWorkspace.statusPressure == 1))
artoaGui.main.menus.editTimeOfArrival.Enable = 'on';
artoaGui.main.menus.showSatfixEtaToToa.Enable = 'on';
else
artoaGui.main.menus.editTimeOfArrival.Enable = 'off';
artoaGui.main.menus.showSatfixEtaToToa.Enable = 'off';
end
end
......
function [] = satfixEtaToToa(pCallbacks)
%EDITSATFIXETATOTOA Creates the SATFIX-ETA to TOA plot.
% Detailed explanation goes here
global artoaGui artoaWorkspace;
%% Initialize required variables
windowTitle = [ 'ARTOA4 - Float ' num2str(artoaWorkspace.float.floatname) ' - Difference SATFIX ETA to TOA' ];
availableCallbacks = { ...
'CloseRequestFcn' ...
};
for i = 1:length(availableCallbacks) % check if a callback is undefined
if ~isfield(pCallbacks, availableCallbacks{i})
pCallbacks.(availableCallbacks{i}) = @(~, ~) false;
end
end
%% Initialize offset details gui
artoaGui.figures.satfixEtaToToa = figure( ...
'Name', windowTitle, ...
'NumberTitle', 'off', ...
'Units', 'characters' ...
);
% adjust width
artoaGui.figures.satfixEtaToToa.Position(3) = 120;
artoaGui.figures.satfixEtaToToa.Position(4) = 35;
artoaGui.satfixEtaToToa = struct();
set( ...
artoaGui.figures.satfixEtaToToa, ...
'CloseRequestFcn', ...
@artoa.controller.show.satfixEtaToToa.close ...
);
%% Plot the values
artoa.controller.show.satfixEtaToToa.plot();
end
......@@ -23,6 +23,7 @@ availableCallbacks = { ...
'openEditTemperature', ...
'openEditPressure', ...
'openEditTimeOfArrival', ...
'openShowSatfixEtaToToa', ...
'openEditOffsets', ...
'openTrackParameter', ...
'openTrackTrajectoryOutput', ...
......@@ -224,6 +225,21 @@ artoaGui.main.menus.editTimeOfArrival = uimenu( ...
'Enable', 'off' ...
);
%% Show menu
artoaGui.main.menus.show = uimenu( ...
artoaGui.figures.main, ...
'Label', 'Show', ...
'Enable', 'on' ...
);
% SATFIX-ETA to TOA
artoaGui.main.menus.showSatfixEtaToToa = uimenu( ...
artoaGui.main.menus.show, ...
'Label', 'SATFIX-Eta to Toa', ...
'Callback', pCallbacks.openShowSatfixEtaToToa, ...
'Enable', 'off' ...
);
%% Initialize track menu
artoaGui.main.menus.track = uimenu( ...
......
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}), ...
pSoundvelocities{fnames{o}, 1}, ...
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);
gpsDates(selection) = NaN;
predictedToas(selection) = NaN;
% remove gps dates before deployment of soundsource
selection = (gpsDates < soundSourceBegin);
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
function [color] = getColor(pSoundsourceName, pRegister, pColors)
%GETCOLOR Summary of this function goes here
% Detailed explanation goes here
color = pColors( ...
artoa.soundsources.colorregister.getColorIndex(pSoundsourceName, pRegister), ...
: ...
);
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