Skip to content

Commit 7af552f

Browse files
authored
Merge pull request #161 from ImperialCollegeLondon/task/hs-field-events
task: Add support for HelioSwarm events in field view
2 parents 196cc7f + e357090 commit 7af552f

File tree

6 files changed

+117
-5
lines changed

6 files changed

+117
-5
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
MAG_DATA_VISUALIZATION_VERSION=7.7.1
1+
MAG_DATA_VISUALIZATION_VERSION=7.8.0

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"**/*~": true
1313
},
1414
"cSpell.words": [
15+
"AGROW",
1516
"Bartington",
1617
"cspice",
1718
"downsample",
@@ -20,6 +21,8 @@
2021
"IMAP",
2122
"Plottable",
2223
"signedness",
23-
"SOLARORBITER"
24+
"SOLARORBITER",
25+
"Stackedplot",
26+
"SUPPORTEDEVENTS"
2427
]
2528
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
classdef Field < mag.app.Control & mag.app.mixin.StartEndDate
2+
% FIELD View-controller for generating "mag.hs.view.Field".
3+
4+
properties (Constant)
5+
Name = "Field"
6+
end
7+
8+
properties (Constant, Access = private)
9+
% SUPPORTEDEVENTS Events supported by "mag.hs.view.Field".
10+
SupportedEvents (1, 1) string = "Range"
11+
end
12+
13+
properties (SetAccess = private)
14+
Layout matlab.ui.container.GridLayout
15+
EventsTree matlab.ui.container.CheckBoxTree
16+
end
17+
18+
methods
19+
20+
function instantiate(this, parent)
21+
22+
this.Layout = this.createDefaultGridLayout(parent);
23+
24+
% Start and end dates.
25+
this.addStartEndDateButtons(this.Layout, StartDateRow = 1, EndDateRow = 2);
26+
27+
% Events.
28+
eventsLabel = uilabel(this.Layout, Text = "Events:");
29+
eventsLabel.Layout.Row = 3;
30+
eventsLabel.Layout.Column = 1;
31+
32+
this.EventsTree = uitree(this.Layout, "checkbox");
33+
this.EventsTree.Layout.Row = [3, 4];
34+
this.EventsTree.Layout.Column = [2, 3];
35+
36+
for e = this.SupportedEvents
37+
uitreenode(this.EventsTree, Text = e);
38+
end
39+
end
40+
41+
function supported = isSupported(~, results)
42+
supported = results.HasScience;
43+
end
44+
45+
function command = getVisualizeCommand(this, results)
46+
47+
arguments (Input)
48+
this
49+
results (1, 1) mag.Instrument
50+
end
51+
52+
arguments (Output)
53+
command (1, 1) mag.app.Command
54+
end
55+
56+
[startTime, endTime] = this.getStartEndTimes();
57+
58+
if isempty(this.EventsTree.CheckedNodes)
59+
events = string.empty();
60+
else
61+
events = {this.EventsTree.CheckedNodes.Text};
62+
end
63+
64+
results = mag.app.internal.cropResults(results, startTime, endTime);
65+
66+
command = mag.app.Command(Functional = @(varargin) mag.hs.view.Field(varargin{:}).visualizeAll(), ...
67+
PositionalArguments = {results}, ...
68+
NamedArguments = struct(Events = string(events)));
69+
end
70+
end
71+
end

app/mission/hs/+mag/+app/+hs/VisualizationManager.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
function supportedVisualizations = getSupportedVisualizations(~, ~)
1111

12-
supportedVisualizations = [mag.app.control.Field(@mag.hs.view.Field), ...
12+
supportedVisualizations = [mag.app.hs.control.Field(), ...
1313
mag.app.control.HK(@mag.hs.view.HK), ...
1414
mag.app.control.PSD(@mag.hs.view.PSD), ...
1515
mag.app.control.Spectrogram(@mag.hs.view.Spectrogram), ...

resources/release-notes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## App
2+
3+
- (HelioSwarm) Add support for visualizing Range events with field
4+
15
## Software
26

37
- (All) Add option to specify PNG resolution when saving figures

src/mission/hs/+mag/+hs/+view/Field.m

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
classdef Field < mag.graphics.view.View
22
% FIELD Show magnetic field and optional HK for HelioSwarm.
33

4+
properties
5+
% EVENTS Event names to show.
6+
Events (1, :) string {mustBeMember(Events, "Range")} = string.empty()
7+
end
8+
49
methods
510

611
function this = Field(results, options)
@@ -22,23 +27,27 @@ function visualize(this)
2227
science = this.Results.Science;
2328
hk = this.Results.HK;
2429

30+
[numEvents, eventData] = this.getEventData(science);
31+
2532
if this.Results.HasHK
2633

2734
this.Figures = this.Factory.assemble( ...
2835
science, mag.graphics.style.Stackedplot(Title = this.getFieldTitle(science), YLabels = ["x [nT]", "y [nT]", "z [nT]", "|B| [nT]"], Layout = [3, 1], Charts = mag.graphics.chart.Stackedplot(YVariables = ["X", "Y", "Z", "B"], Filter = science.Quality.isPlottable())), ...
36+
eventData{:}, ...
2937
hk, mag.graphics.style.Default(Title = "Temperatures", YLabel = this.TLabel, Legend = ["Board", "Sensor"], Charts = mag.graphics.chart.Plot(YVariables = ["Board", "Sensor"] + "Temperature")), ...
3038
Title = this.getFigureTitle(science), ...
3139
Name = this.getFigureName(science), ...
32-
Arrangement = [4, 1], ...
40+
Arrangement = [4 + numEvents, 1], ...
3341
LinkXAxes = true, ...
3442
WindowState = "maximized");
3543
else
3644

3745
this.Figures = this.Factory.assemble( ...
3846
science, mag.graphics.style.Stackedplot(Title = this.getFieldTitle(science), YLabels = ["x [nT]", "y [nT]", "z [nT]", "|B| [nT]"], Layout = [3, 1], Charts = mag.graphics.chart.Stackedplot(YVariables = ["X", "Y", "Z", "B"], Filter = science.Quality.isPlottable())), ...
47+
eventData{:}, ...
3948
Title = this.getFigureTitle(science), ...
4049
Name = this.getFigureName(science), ...
41-
Arrangement = [3, 1], ...
50+
Arrangement = [3 + numEvents, 1], ...
4251
LinkXAxes = true, ...
4352
WindowState = "maximized");
4453
end
@@ -47,6 +56,31 @@ function visualize(this)
4756

4857
methods (Access = private)
4958

59+
function [numEvents, eventData] = getEventData(this, science)
60+
61+
numEvents = 0;
62+
eventData = {};
63+
64+
if ~science.HasData
65+
return;
66+
end
67+
68+
for e = this.Events
69+
70+
switch e
71+
case "Range"
72+
73+
% TODO: This should not rely on mag.imap.chart.Event, which is IMAP-specific.
74+
numEvents = numEvents + 1;
75+
ed = {science, mag.graphics.style.Default(Title = "Ranges", YLabel = "range [-]", YLimits = "manual", Charts = mag.imap.chart.Event(EventOfInterest = "Range", IgnoreMissing = false, YOffset = 0.25))};
76+
otherwise
77+
error("Unrecognized event ""%s"".", e);
78+
end
79+
80+
eventData = [eventData, ed]; %#ok<AGROW>
81+
end
82+
end
83+
5084
function value = getFigureTitle(this, data)
5185
value = compose("%s (%s)", data.Metadata.getDisplay("Mode"), this.getDataFrequency(data.Metadata));
5286
end

0 commit comments

Comments
 (0)