Skip to content

Commit

Permalink
Merge pull request #98 from ImperialCollegeLondon/dev
Browse files Browse the repository at this point in the history
Update software to v7.1.0
  • Loading branch information
mfacchinelli authored Jan 6, 2025
2 parents 5d3bedc + e70d0dc commit b8030a8
Show file tree
Hide file tree
Showing 770 changed files with 2,849 additions and 1,046 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MAG_DATA_VISUALIZATION_VERSION=7.0.1
MAG_DATA_VISUALIZATION_VERSION=7.1.0
17 changes: 12 additions & 5 deletions app/DataVisualization.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,16 @@ function selectMission(app, mission)
% Ask which mission to load, if not provided.
if isempty(mission)

imap = mag.meta.Mission.IMAP;
mission = uiconfirm(app.UIFigure, "Select the mission to load.", "Select Mission", Icon = "question", ...
Options = string(enumeration(imap)), DefaultOption = string(imap));
selectMissionDialog = mag.app.internal.SelectMissionDialog(app.UIFigure);
mission = selectMissionDialog.waitForSelection();

closeProgressBar = app.AppNotificationHandler.overlayProgressBar("Initializing app..."); %#ok<NASGU>
if selectMissionDialog.Aborted
error("User aborted.");
else
selectMissionDialog.delete();
end

closeProgressBar = app.AppNotificationHandler.overlayProgressBar("Initializing mission..."); %#ok<NASGU>
end

switch mission
Expand All @@ -133,7 +138,7 @@ function selectMission(app, mission)
case mag.meta.Mission.SolarOrbiter
error("Solar Orbiter mission not yet supported.");
otherwise
error("User aborted.");
error("Unknown mission ""%s"".", mission);
end

% Set managers.
Expand All @@ -149,6 +154,8 @@ function selectMission(app, mission)
end

% Create components.
delete(app.GridLayout);

app.createComponents();

app.addlistener("Figures", "PostSet", @app.figuresChanged);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
classdef Field < mag.app.Control & mag.app.mixin.StartEndDate
% FIELD View-controller for generating "mag.bart.view.Field".
% FIELD View-controller for generating field view.

properties (Constant)
Name = "Field"
end

properties (SetAccess = immutable)
ViewType function_handle {mustBeScalarOrEmpty}
end

properties (SetAccess = private)
Layout matlab.ui.container.GridLayout
end

methods

function this = Field(viewType)

arguments
viewType (1, 1) function_handle
end

this.ViewType = viewType;
end

function instantiate(this, parent)

this.Layout = this.createDefaultGridLayout(parent);
Expand All @@ -15,6 +32,10 @@ function instantiate(this, parent)
this.addStartEndDateButtons(this.Layout, StartDateRow = 1, EndDateRow = 2);
end

function supported = isSupported(~, results)
supported = results.HasScience;
end

function command = getVisualizeCommand(this, results)

arguments (Input)
Expand All @@ -29,7 +50,7 @@ function instantiate(this, parent)
[startTime, endTime] = this.getStartEndTimes();
results = mag.app.internal.cropResults(results, startTime, endTime);

command = mag.app.Command(Functional = @(varargin) mag.bart.view.Field(varargin{:}).visualizeAll(), ...
command = mag.app.Command(Functional = @(varargin) this.ViewType(varargin{:}).visualizeAll(), ...
PositionalArguments = {results});
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
classdef PSD < mag.app.Control
% PSD View-controller for generating "mag.hs.view.PSD".
% PSD View-controller for generating PSD view.

properties (Constant)
Name = "PSD"
end

properties (SetAccess = immutable)
ViewType function_handle {mustBeScalarOrEmpty}
end

properties (SetAccess = private)
Layout matlab.ui.container.GridLayout
Expand All @@ -10,6 +18,15 @@

methods

function this = PSD(viewType)

arguments
viewType (1, 1) function_handle
end

this.ViewType = viewType;
end

function instantiate(this, parent)

this.Layout = this.createDefaultGridLayout(parent);
Expand Down Expand Up @@ -38,6 +55,10 @@ function instantiate(this, parent)
this.DurationSpinner.Layout.Column = [2, 3];
end

function supported = isSupported(~, results)
supported = results.HasScience;
end

function command = getVisualizeCommand(this, results)

arguments (Input)
Expand All @@ -52,7 +73,7 @@ function instantiate(this, parent)
startTime = mag.app.internal.combineDateAndTime(this.StartDatePicker.Value, this.StartTimeField.Value);
duration = hours(this.DurationSpinner.Value);

command = mag.app.Command(Functional = @(varargin) mag.hs.view.PSD(varargin{:}).visualizeAll(), ...
command = mag.app.Command(Functional = @(varargin) this.ViewType(varargin{:}).visualizeAll(), ...
PositionalArguments = {results}, ...
NamedArguments = struct(Start = startTime, Duration = duration));
end
Expand Down
77 changes: 77 additions & 0 deletions app/core/+mag/+app/+control/SignalAnalyzer.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
classdef SignalAnalyzer < mag.app.Control
% SIGNALANALYZER View-controller for opening Signal Analyzer.

properties (Constant)
Name = "Signal Analyzer"
end

properties (SetAccess = immutable)
SelectableInputs (1, :) string
end

properties (SetAccess = private)
Layout matlab.ui.container.GridLayout
InputDropDown matlab.ui.control.DropDown
SignalDropDown matlab.ui.control.DropDown
end

methods

function this = SignalAnalyzer(selectableInputs)
this.SelectableInputs = selectableInputs;
end

function instantiate(this, parent)

this.Layout = this.createDefaultGridLayout(parent);

% Input.
inputLabel = uilabel(this.Layout, Text = "Input:");
inputLabel.Layout.Row = 1;
inputLabel.Layout.Column = 1;

this.InputDropDown = uidropdown(this.Layout, Items = this.SelectableInputs);
this.InputDropDown.Layout.Row = 1;
this.InputDropDown.Layout.Column = [2, 3];

% Signal.
signalLabel = uilabel(this.Layout, Text = "Signal:");
signalLabel.Layout.Row = 2;
signalLabel.Layout.Column = 1;

this.SignalDropDown = uidropdown(this.Layout, Items = ["X", "Y", "Z"]);
this.SignalDropDown.Layout.Row = 2;
this.SignalDropDown.Layout.Column = [2, 3];

% Note.
noteLabel = uilabel(this.Layout, Text = "Note: opens Signal Analyzer app.");
noteLabel.Layout.Row = 5;
noteLabel.Layout.Column = [1, 3];
end

function supported = isSupported(~, results)
supported = exist("signalAnalyzer", "file") && results.HasScience;
end

function command = getVisualizeCommand(this, results)

arguments (Input)
this
results (1, 1) mag.Instrument
end

arguments (Output)
command (1, 1) mag.app.Command
end

selectedInput = string(this.InputDropDown.Value);
selectedSignal = string(this.SignalDropDown.Value);

data = results.(selectedInput);
selectedData = timetable(data.Time - data.Time(1), data.(selectedSignal), VariableNames = selectedInput + "_" + selectedSignal);

command = mag.app.Command(Functional = @(varargin) signalAnalyzer(varargin{:}), ...
PositionalArguments = {selectedData});
end
end
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
classdef Spectrogram < mag.app.Control & mag.app.mixin.StartEndDate
% SPECTROGRAM View-controller for generating "mag.bart.view.Spectrogram".
% SPECTROGRAM View-controller for generating spectrogram view.

properties (Constant)
Name = "Spectrogram"
end

properties (SetAccess = immutable)
ViewType function_handle {mustBeScalarOrEmpty}
end

properties (SetAccess = private)
Layout matlab.ui.container.GridLayout
Expand All @@ -10,6 +18,15 @@

methods

function this = Spectrogram(viewType)

arguments
viewType (1, 1) function_handle
end

this.ViewType = viewType;
end

function instantiate(this, parent)

this.Layout = this.createDefaultGridLayout(parent);
Expand Down Expand Up @@ -54,6 +71,10 @@ function instantiate(this, parent)
this.WindowSpinner.Layout.Column = [2, 3];
end

function supported = isSupported(~, results)
supported = results.HasScience;
end

function command = getVisualizeCommand(this, results)

arguments (Input)
Expand Down Expand Up @@ -82,7 +103,7 @@ function instantiate(this, parent)

results = mag.app.internal.cropResults(results, startTime, endTime);

command = mag.app.Command(Functional = @(varargin) mag.bart.view.Spectrogram(varargin{:}).visualizeAll(), ...
command = mag.app.Command(Functional = @(varargin) this.ViewType(varargin{:}).visualizeAll(), ...
PositionalArguments = {results}, ...
NamedArguments = struct(FrequencyPoints = frequencyPoints, Overlap = overlap, Window = window));
end
Expand Down
119 changes: 119 additions & 0 deletions app/core/+mag/+app/+control/WaveletAnalyzer.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
classdef WaveletAnalyzer < mag.app.Control
% WAVELETANALYZER View-controller for opening Wavelet Time-Frequency
% Analyzer.

properties (Constant)
Name = "Wavelet Analyzer"
end

properties (SetAccess = immutable)
SelectableInputs (1, :) string
end

properties (SetAccess = private)
Layout matlab.ui.container.GridLayout
AppDropDown matlab.ui.control.DropDown
InputDropDown matlab.ui.control.DropDown
SignalDropDown matlab.ui.control.DropDown
NoteLabel matlab.ui.control.Label
end

methods

function this = WaveletAnalyzer(selectableInputs)
this.SelectableInputs = selectableInputs;
end

function instantiate(this, parent)

this.Layout = this.createDefaultGridLayout(parent);

% App.
appLabel = uilabel(this.Layout, Text = "App:");
appLabel.Layout.Row = 1;
appLabel.Layout.Column = 1;

this.AppDropDown = uidropdown(this.Layout, Items = ["Signal Analyzer", "Time-Frequency Analyzer"]);
this.AppDropDown.ValueChangedFcn = @(~, ~) this.appDropDownValueChanged();
this.AppDropDown.Layout.Row = 1;
this.AppDropDown.Layout.Column = [2, 3];

% Input.
inputLabel = uilabel(this.Layout, Text = "Input:");
inputLabel.Layout.Row = 2;
inputLabel.Layout.Column = 1;

this.InputDropDown = uidropdown(this.Layout, Items = this.SelectableInputs);
this.InputDropDown.Layout.Row = 2;
this.InputDropDown.Layout.Column = [2, 3];

% Signal.
signalLabel = uilabel(this.Layout, Text = "Signal:");
signalLabel.Layout.Row = 3;
signalLabel.Layout.Column = 1;

this.SignalDropDown = uidropdown(this.Layout, Items = ["X", "Y", "Z"]);
this.SignalDropDown.Layout.Row = 3;
this.SignalDropDown.Layout.Column = [2, 3];

% Note.
this.NoteLabel = uilabel(this.Layout, Text = "");
this.NoteLabel.Layout.Row = 5;
this.NoteLabel.Layout.Column = [1, 3];

this.appDropDownValueChanged();
end

function supported = isSupported(~, results)
supported = exist("waveletTimeFrequencyAnalyzer", "file") && results.HasScience;
end

function command = getVisualizeCommand(this, results)

arguments (Input)
this
results (1, 1) mag.Instrument
end

arguments (Output)
command (1, 1) mag.app.Command
end

selectedInput = string(this.InputDropDown.Value);
selectedSignal = string(this.SignalDropDown.Value);

data = results.(selectedInput);
propertyName = selectedInput + "_" + selectedSignal;

selectedData = timetable(data.Time - data.Time(1), data.(selectedSignal), VariableNames = propertyName);

if ~isregular(selectedData)

frequencies = 1 ./ seconds(data.dT);
warning("Resampling data as not uniformely sampled (%.3f ± %.3g Hz).", mode(frequencies), std(frequencies, 0, "omitmissing"));

selectedData = resample(selectedData);
end

switch this.AppDropDown.Value
case "Signal Analyzer"

command = mag.app.Command(Functional = @(varargin) waveletSignalAnalyzer(varargin{:}), ...
PositionalArguments = {selectedData.(propertyName)});
case "Time-Frequency Analyzer"

command = mag.app.Command(Functional = @(varargin) waveletTimeFrequencyAnalyzer(varargin{:}), ...
PositionalArguments = {selectedData});
otherwise
error("Unknown Wavelet Toolbox app ""%s"".", this.AppDropDown.Value);
end
end
end

methods (Access = private)

function appDropDownValueChanged(this)
this.NoteLabel.Text = compose("Note: opens Wavelet %s app.", this.AppDropDown.Value);
end
end
end
Loading

0 comments on commit b8030a8

Please sign in to comment.