forked from Andre-lab/ZEAL_commandLine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChiCoeffs.m
71 lines (48 loc) · 2.3 KB
/
ChiCoeffs.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
classdef ChiCoeffs < handle
% Class to load the object-independent chi coefficients used for ZC
% moment computations.
% % used for the ZC moment computation. The folder path is taken from
% % obj.Settings.ChiCoeffPath and the files themself are assumed to
% % be mat-files with name 'chiCoeffs_order_X.mat', where X is the
% % ZC order.
properties ( SetAccess = private )
Values
Indices
Order
end
methods
function obj = ChiCoeffs()
obj.loadData(); % constructor
end
function loadData(obj, varargin)
% actual loading of data, decoupled from the construcyor so that we can reload if needed
persistent nQueries % keep track of how many times we call the load function
if isempty(nQueries)
nQueries = 1;
else
nQueries = nQueries + 1;
end
% get path from where this class is called
classFileFolderPath = fileparts(mfilename('fullpath'));
default_Order = 20;
default_ChiCoeffFolder = fullfile(classFileFolderPath,'chi_coefficients');
p = inputParser;
addOptional(p, 'Order', default_Order);
addOptional(p, 'ChiCoeffPath', default_ChiCoeffFolder);
parse(p, varargin{:});
obj.Order = p.Results.Order;
ChiCoeffFileName = sprintf('chiCoeffs_order_%d.mat', obj.Order);
ChiCoeffFilePath = fullfile(p.Results.ChiCoeffPath, ChiCoeffFileName);
fprintf('\n ChiCoeffs class queried %d time(s)\n\t Loading Chi coefficients for order %1.0f', nQueries, obj.Order);
try
data = load(ChiCoeffFilePath,'chi_coeff_cell','chi_nlm_rst_cell');
obj.Values = data.chi_coeff_cell;
obj.Indices = data.chi_nlm_rst_cell;
catch ME
warning(ME.message);
obj.Values = NaN;
obj.Indices = NaN;
end
end
end
end