Skip to content

Commit

Permalink
Customize display of "mag.Instrument" class
Browse files Browse the repository at this point in the history
  • Loading branch information
mfacchinelli committed Jan 12, 2024
1 parent 26e858e commit 6dbfcd7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions resources/ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- Customize display of "mag.Instrument" class
- Move PNG export before FIG save
- Fix multiple small issues with HK view
35 changes: 34 additions & 1 deletion src/data/+mag/Instrument.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
classdef (Sealed) Instrument < handle & matlab.mixin.Copyable & mag.mixin.SetGet
classdef (Sealed) Instrument < handle & matlab.mixin.Copyable & matlab.mixin.CustomDisplay & mag.mixin.SetGet
% INSTRUMENT Class containing MAG instrument data.

properties
Expand Down Expand Up @@ -223,5 +223,38 @@ function downsample(this, targetFrequency)
copiedThis.Secondary = copy(this.Secondary);
copiedThis.HK = copy(this.HK);
end

function header = getHeader(this)

if isscalar(this)

if this.HasScience && this.HasMetaData && ...
~isempty(this.Primary.MetaData) && ~ismissing(this.Primary.MetaData.DataFrequency) && ~isequal(this.Primary.MetaData.Mode, "Hybrid") && ...
~isempty(this.Secondary.MetaData) && ~ismissing(this.Secondary.MetaData.DataFrequency) && ~isequal(this.Secondary.MetaData.Mode, "Hybrid")

tag = char(compose(" in %s (%d, %d)", this.Primary.MetaData.Mode, this.Primary.MetaData.DataFrequency, this.Secondary.MetaData.DataFrequency));
else
tag = char.empty();
end

className = matlab.mixin.CustomDisplay.getClassNameForHeader(this);
header = [' ', className, tag, ' with properties:'];
else
header = [email protected](this);
end
end

function groups = getPropertyGroups(this)

if isscalar(this)

propertyList = ["HasData", "HasMetaData", "HasScience", "HasHK", "TimeRange", ...
"Primary", "Secondary", ...
"MetaData", "Events", "HK"];
groups = matlab.mixin.util.PropertyGroup(propertyList, "");
else
groups = [email protected](this);
end
end
end
end

0 comments on commit 6dbfcd7

Please sign in to comment.