Skip to content

Commit

Permalink
Add save/load utility class
Browse files Browse the repository at this point in the history
  • Loading branch information
mfacchinelli committed Feb 5, 2024
1 parent c26dac1 commit 40f8877
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
1 change: 1 addition & 0 deletions resources/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

- Add method to `mag.Instrument` to fill warm-up with `missing` data
- Add method to `mag.Science` to replace periods with a filler variable
- Add save/load utility class
- Separate calculation of spectrogram in separate function
- Replace last element of file with `missing` to improve plot where data is missing
- Science object with no data is considered empty in `mag.Instrument`
Expand Down
13 changes: 6 additions & 7 deletions src/analyze/+mag/@IMAPTestingAnalysis/IMAPTestingAnalysis.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
classdef (Sealed) IMAPTestingAnalysis < matlab.mixin.Copyable & mag.mixin.SetGet
classdef (Sealed) IMAPTestingAnalysis < matlab.mixin.Copyable & mag.mixin.SetGet & mag.mixin.SaveLoad
% IMAPTESTINGANALYSIS Automate analysis of an IMAP CPT or SFT folder.

properties (Constant, Hidden)
% VERSION Version number.
Version (1, 1) string = mag.version()
properties (Constant)
Version = mag.version()
end

properties
Expand Down Expand Up @@ -418,7 +417,7 @@ function load(this)
elseif isa(object, "struct")

% Recreate object based on version.
if isfield(object, "Outboard")
if isequal(object.OriginalVersion, 1.0)

% Convert object to version 2.0 and recursively
% dispatch it.
Expand All @@ -441,9 +440,9 @@ function load(this)
end

loadedObject = mag.IMAPTestingAnalysis.loadobj(loadedObject);
elseif isfield(object, "PrimaryRamp")
elseif isequal(object.OriginalVersion, 2.0)

% Convert object directly to version 3.0.
% Convert object directly to version 2.5.
loadedObject = mag.IMAPTestingAnalysis();
loadedObject.Results = mag.Instrument();

Expand Down
22 changes: 22 additions & 0 deletions src/utility/+mag/+mixin/SaveLoad.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
classdef (Abstract, HandleCompatible) SaveLoad
% SAVELOAD Utility class to aid saving and loading to MAT files.

properties (Abstract, Constant)
% VERSION Version number.
Version (1, 1) string
end

properties (GetAccess = protected, SetAccess = private)
% ORIGINALVERSION Original version for save/load compatibility.
OriginalVersion (1, 1) string
end

methods (Hidden)

function savedObject = saveobj(this)

savedObject = this;
savedObject.OriginalVersion = this.Version;
end
end
end

0 comments on commit 40f8877

Please sign in to comment.