Skip to content

Commit faaf1f7

Browse files
author
Abhinab Bhattacharjee
committed
Minor comments and refactoring
1 parent 826d6dc commit faaf1f7

File tree

24 files changed

+181
-67
lines changed

24 files changed

+181
-67
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
*.fig
55
*.pdf
66
*.mat
7+
*.html

docs/CONTRIBUTING.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Contributing to DATools
2+
3+
General Guidelines for adding new filters/algorithms to DATools
4+
5+
## Submitting new pull requests
6+
7+
To request a pull request, please follow the steps below
8+
9+
* Create your own branch if you are starting new or modify the existing one
10+
* Commit your changes to local branch and push to Github
11+
* Create a draft pull request
12+
* Do not merge or modify the master branch
13+
14+
## Style Conventions
15+
16+
In order to prevent confusions and maintain a consistent coding style, the following styles should be strictly followed. The conventions match most of the MATLAB's own conventions. Failing to follow the conventions can delay in processing and approving new pull requests.
17+

src/+datools/+error/Gaussian.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
end
2323

2424
function xp = adderr(obj, ~, x)
25-
A = obj.CovarianceSqrt * randn(size(x, 1), size(x, 2));
25+
A = obj.CovarianceSqrt * randn(size(x), 'like', x);
2626
xp = x + A + obj.Bias;
2727
end
2828

src/+datools/+error/Laplace.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
end
2121

2222
function xp = adderr(obj, ~, x)
23-
X = obj.CovarianceSqrt * randn(size(x, 1), size(x, 2));
23+
X = obj.CovarianceSqrt * randn(size(x), 'like', x);
2424
Z = exprnd(1, 1, size(x, 2));
2525
Y = sqrt(Z) .* X;
2626
xp = x + Y + obj.Bias;

src/+datools/+observation/+operator/Indexed.m renamed to src/+datools/+observation/+operator/IndexedObservation.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
classdef Indexed < datools.observation.operator.Observation
1+
classdef IndexedObservation < datools.observation.operator.Observation
22
%INDEXED Defines the indexed observation operator
33

44
properties
@@ -7,7 +7,7 @@
77

88
methods
99

10-
function obj = Indexed(nvars, varargin)
10+
function obj = IndexedObservation(nvars, varargin)
1111
p = inputParser;
1212
p.KeepUnmatched = true;
1313
addParameter(p, 'Indices', 1);

src/+datools/+observation/+operator/Linear.m renamed to src/+datools/+observation/+operator/LinearObservation.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
classdef Linear < datools.observation.operator.Observation
1+
classdef LinearObservation < datools.observation.operator.Observation
22
%LINEAR Defines the linear observation operator
33
% H is already linearized
44

@@ -8,7 +8,7 @@
88

99
methods
1010

11-
function obj = Linear(nvars, varargin)
11+
function obj = LinearObservation(nvars, varargin)
1212
p = inputParser;
1313
p.KeepUnmatched = true;
1414
addParameter(p, 'H', speye(nvars));

src/+datools/+observation/+operator/Nonlinear.m renamed to src/+datools/+observation/+operator/NonlinearObservation.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
classdef Nonlinear < datools.observation.operator.Observation
1+
classdef NonlinearObservation < datools.observation.operator.Observation
22
%NONLINEAR Defines the non linear observation operator
33

44
properties
@@ -9,7 +9,7 @@
99

1010
methods
1111

12-
function obj = Nonlinear(nvars, varargin)
12+
function obj = NonlinearObservation(nvars, varargin)
1313
p = inputParser;
1414
p.KeepUnmatched = true;
1515
addParameter(p, 'F', @(~, x) x);

src/+datools/+observation/StateObservation.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
% Observed state are noisy snapshots of reality (truth)
44

55
properties
6-
Y % Current Observation of States (maybe sparse)
7-
R % Observation Error Covariance
8-
Noise % Noise
9-
NumObs % Number of Observations(Make sure > 0)
6+
Y % Current Observation of States (maybe sparse)
7+
Covariance % Observation Error Covariance
8+
Noise % Noise
9+
NumObs % Number of Observations(Make sure > 0)
1010
end
1111

1212
methods
@@ -30,11 +30,11 @@
3030
unMatched = p.Unmatched;
3131

3232
p = inputParser;
33-
addParameter(p, 'R', speye(obj.NumObs));
33+
addParameter(p, 'Covariance', speye(obj.NumObs));
3434

3535
parse(p, unMatched);
3636
s = p.Results;
37-
obj.R = s.R;
37+
obj.Covariance = s.Covariance;
3838
end
3939

4040
function updateY(obj, y)

src/+datools/+statistical/+ensemble/DEnKF.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
methods
44

5-
function analysis(obj, R, y)
5+
function analysis(obj)
66

77
inflation = obj.Inflation;
88

99
tc = obj.Model.TimeSpan(1);
1010

1111
xf = obj.Ensemble;
1212
ensN = obj.NumEnsemble;
13+
14+
R = obj.Observation.Covariance;
1315

1416
xfm = mean(xf, 2);
1517

@@ -43,7 +45,7 @@ function analysis(obj, R, y)
4345

4446
Aa = Af - 0.5 * (PfHt * (dS \ HAf));
4547

46-
d = y - Hxfm;
48+
d = obj.Observation.Y - Hxfm;
4749
xam = xfm + (PfHt * (dS \ d));
4850

4951
obj.Ensemble = repmat(xam, 1, ensN) + Aa;

src/+datools/+statistical/+ensemble/ETKF.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
methods
44

55
function analysis(obj)
6-
6+
%ANALYSIS Method to overload the analysis function
7+
%
8+
% ANALYSIS(OBJ) assimilates the current observation with the
9+
% background/prior information to get a better estimate
10+
% (analysis/posterior)
11+
712
inflation = obj.Inflation;
813

914
tc = obj.Model.TimeSpan(1);
1015

1116
xf = obj.Ensemble;
1217
ensN = obj.NumEnsemble;
1318

14-
R = obj.Observation.R;
19+
R = obj.Observation.Covariance;
1520

1621
xfm = mean(xf, 2);
1722
Af = xf - repmat(xfm, 1, ensN);

0 commit comments

Comments
 (0)