Skip to content

Commit c53bcf9

Browse files
authored
Merge pull request #210 from ImperialCollegeLondon/fix/small-app-fixes
fix: Small app fixes
2 parents f258913 + 00001b6 commit c53bcf9

File tree

10 files changed

+52
-35
lines changed

10 files changed

+52
-35
lines changed

resources/mpackage.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "MAGDataVisualization",
3-
"version": "8.5.0",
3+
"version": "8.5.1",
44
"id": "69962df8-e93e-47cd-a1d6-766ad3e9da8a",
55
"formerNames": [],
66
"displayName": "MAG Data Visualization",

resources/release-notes.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
## App
2-
3-
- (All) Add "Health" tab to display health check results
4-
- (All) Exported MAT file is renamed to "Analysis (dd-MMM-yyyy HHmmss).mat"
5-
- (All) Issue a warning if an analysis generated with older release is imported
6-
71
## Software
82

9-
- (IMAP) Add health checks for secondary currents and voltages, temperatures, saturation, missed ITFs, and activation
10-
- (IMAP) HK figure names include first timestamp date and time
11-
- (All) `mag.Instrument/crop` method crops data based on input timerange, not science timerange
12-
- (All) `mag.version` should not return a `datetime`-like string
3+
- (All) Fix issue with loading events from `mag.TimeSeries` in `mag.graphics.chart.Stackedplot` (when `EventsVisible = true`)
4+
- (IMAP) Support old IMAP science file format (file time defined as `HH'h'` instead of `HH'h'mm`)
5+
- (IMAP) Fix typos is power health check descriptions

src/analyze/+mag/+process/Timestamp.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
end
5252

5353
% Add time offset to all timestamps.
54-
timeStamp = coarseAndFineTime(:, 1) + (coarseAndFineTime(:, 2) / double(intmax("uint16")));
55-
time = timeStamp + timeOffset;
54+
timestamp = coarseAndFineTime(:, 1) + (coarseAndFineTime(:, 2) / double(intmax("uint16")));
55+
time = timestamp + timeOffset;
5656
end
5757
end
5858
end

src/data/+mag/Science.m

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
CompressionWidth (:, 1) double
3030
% QUALITY Quality flag denoting whether data is of high quality.
3131
Quality (:, 1) mag.meta.Quality
32-
% EVENTS Events detected.
33-
Events eventtable
3432
end
3533

3634
properties (SetAccess = immutable)
@@ -109,10 +107,6 @@
109107
quality = this.Data.(this.Settings.Quality);
110108
end
111109

112-
function events = get.Events(this)
113-
events = this.Data.Properties.Events;
114-
end
115-
116110
function crop(this, timeFilter)
117111

118112
arguments

src/data/+mag/TimeSeries.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
Time (:, 1) datetime
1414
% DT Time derivative.
1515
dT (:, 1) duration
16+
% EVENTS Events detected.
17+
Events eventtable
1618
IndependentVariable
1719
DependentVariables
1820
end
@@ -31,6 +33,10 @@
3133
dt = this.computeDerivative(this.Time);
3234
end
3335

36+
function events = get.Events(this)
37+
events = this.Data.Properties.Events;
38+
end
39+
3440
function independentVariable = get.IndependentVariable(this)
3541
independentVariable = this.Time;
3642
end

src/mission/imap/+mag/+imap/+health/Power.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,11 @@ function checkMissedITFFrames(this, pwr)
226226
limit = limits{v};
227227

228228
if any(value < limit(1))
229-
results(end + 1) = mag.health.Result(Name = v, Status = status, Description = compose("Exceeds %s low limits (%.5g < %.5g).", type, min(value), limit(1)));
229+
results(end + 1) = mag.health.Result(Name = v, Status = status, Description = compose("Exceeds %s low limit (%.5g < %.5g).", type, min(value), limit(1)));
230230
end
231231

232232
if any(value > limit(2))
233-
results(end + 1) = mag.health.Result(Name = v, Status = status, Description = compose("Exceeds %s high limits (%.5g > %.5g).", type, max(value), limit(2)));
233+
results(end + 1) = mag.health.Result(Name = v, Status = status, Description = compose("Exceeds %s high limit (%.5g > %.5g).", type, max(value), limit(2)));
234234
end
235235
end
236236
end

src/mission/imap/+mag/+imap/+in/ScienceCSV.m

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,26 @@
3333
rawSecondary = rawData(:, regexpPattern(".*(sec|sequence|compression).*"));
3434

3535
% Extract file metadata.
36-
[mode, primaryFrequency, secondaryFrequency, packetFrequency, timeStamp] = this.extractFileMetadata(fileName);
36+
[mode, primaryFrequency, secondaryFrequency, packetFrequency, timestamp] = this.extractFileMetadata(fileName);
3737

3838
% Process science data.
39-
data = [this.processScience(rawPrimary, "pri", Sensor = mag.meta.Sensor.FOB, Mode = mode, DataFrequency = primaryFrequency, PacketFrequency = packetFrequency, Timestamp = timeStamp), ...
40-
this.processScience(rawSecondary, "sec", Sensor = mag.meta.Sensor.FIB, Mode = mode, DataFrequency = secondaryFrequency, PacketFrequency = packetFrequency, Timestamp = timeStamp)];
39+
data = [this.processScience(rawPrimary, "pri", Sensor = mag.meta.Sensor.FOB, Mode = mode, DataFrequency = primaryFrequency, PacketFrequency = packetFrequency, Timestamp = timestamp), ...
40+
this.processScience(rawSecondary, "sec", Sensor = mag.meta.Sensor.FIB, Mode = mode, DataFrequency = secondaryFrequency, PacketFrequency = packetFrequency, Timestamp = timestamp)];
4141
end
4242
end
4343

4444
methods (Access = private)
4545

46-
function [mode, primaryFrequency, secondaryFrequency, packetFrequency, timeStamp] = extractFileMetadata(this, fileName)
46+
function [mode, primaryFrequency, secondaryFrequency, packetFrequency, timestamp] = extractFileMetadata(this, fileName)
4747
% EXTRACTMETADATA Extract metadata information from file name.
4848

4949
rawData = regexp(fileName, this.FileNamePattern, "names");
5050

5151
% If no metadata was found, assume default values.
5252
if isempty(rawData)
5353

54-
timeStamp = regexp(fileName, "(?<date>\d+)-(?<time>\w+)", "names");
55-
timeStamp = datetime(timeStamp.date + timeStamp.time, InputFormat = "uuuuMMddHH'h'mm", TimeZone = mag.time.Constant.TimeZone, Format = mag.time.Constant.Format);
54+
timestamp = regexp(fileName, "(?<date>\d+)-(?<time>\w+)", "names");
55+
timestamp = mag.time.decodeDate(timestamp.date + timestamp.time, ExtraFormats = "uuuuMMdd" + ["HH'h'mm", "HH'h'"]);
5656

5757
if contains(fileName, "ialirt", IgnoreCase = true)
5858

@@ -84,7 +84,8 @@
8484
primaryFrequency = rawData.primaryFrequency;
8585
secondaryFrequency = rawData.secondaryFrequency;
8686
packetFrequency = rawData.packetFrequency;
87-
timeStamp = datetime(rawData.date + rawData.time, InputFormat = "uuuuMMddHH'h'mm", TimeZone = mag.time.Constant.TimeZone, Format = mag.time.Constant.Format);
87+
88+
timestamp = mag.time.decodeDate(rawData.date + rawData.time, ExtraFormats = "uuuuMMdd" + ["HH'h'mm", "HH'h'"]);
8889
end
8990
end
9091

src/utility/+mag/+time/decodeDate.m

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
function date = decodeDate(date)
1+
function date = decodeDate(date, options)
22
% DECODEDATE Decode a date string as a duration.
33

44
arguments (Input)
55
date string {mustBeScalarOrEmpty}
6+
options.ExtraFormats (1, :) string = string.empty()
7+
options.TimeZone (1, 1) string = mag.time.Constant.TimeZone
8+
options.DisplayFormat (1, 1) string = mag.time.Constant.Format
69
end
710

811
arguments (Output)
@@ -13,6 +16,10 @@
1316
formats = horzcat(formats, replace(formats, "-", "/"));
1417
formats = horzcat(formats, replace(formats, "-", " "));
1518

19+
if ~isempty(options.ExtraFormats)
20+
formats = [formats, options.ExtraFormats];
21+
end
22+
1623
conversion = @(f) datetime(date, InputFormat = f);
1724

1825
for f = formats
@@ -21,8 +28,8 @@
2128

2229
date = conversion(f);
2330

24-
date.TimeZone = mag.time.Constant.TimeZone;
25-
date.Format = mag.time.Constant.Format;
31+
date.TimeZone = options.TimeZone;
32+
date.Format = options.DisplayFormat;
2633
return;
2734
catch exception
2835

src/utility/+mag/+time/decodeTime.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1-
function time = decodeTime(time)
1+
function time = decodeTime(time, options)
22
% DECODETIME Decode a time string as a duration.
33

44
arguments (Input)
55
time string {mustBeScalarOrEmpty}
6+
options.ExtraFormats (1, :) string = string.empty()
67
end
78

89
arguments (Output)
910
time duration {mustBeScalarOrEmpty}
1011
end
1112

1213
formats = ["hh:mm", "hh:mm:ss", "hh:mm:ss.SSS"];
14+
15+
if ~isempty(options.ExtraFormats)
16+
formats = [formats, options.ExtraFormats];
17+
end
18+
1319
conversion = @(f) duration(time, InputFormat = f);
1420

1521
for f = formats

src/visualize/+mag/+graphics/+chart/Stackedplot.m

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
graph(y) = plot(ax, xData, yData(:, y), this.MarkerStyle{:}, this.LineCustomization{:}, Color = colors(y, :));
6969

70-
if this.EventsVisible && ~isempty(data.Properties.Events)
70+
if this.EventsVisible
7171
this.addEventsData(ax, data);
7272
end
7373
end
@@ -78,11 +78,21 @@
7878

7979
function addEventsData(ax, data)
8080

81+
if isa(data, "mag.TimeSeries")
82+
events = data.Events;
83+
elseif istimetable(data)
84+
events = data.Properties.Events;
85+
else
86+
events = [];
87+
end
88+
89+
if isempty(events)
90+
return;
91+
end
92+
8193
hold(ax, "on");
8294
resetAxesHold = onCleanup(@() hold(ax, "off"));
8395

84-
events = data.Properties.Events;
85-
8696
eventTimes = events.Properties.RowTimes;
8797
eventLabels = events.(events.Properties.EventLabelsVariable);
8898

0 commit comments

Comments
 (0)