Skip to content

Commit e23cbb8

Browse files
committed
Distinguish params from class attributes (only in_4d and ensemble). Could improve documentation for class attributes or just make them non-public since user shouldn't need them
1 parent fba0fab commit e23cbb8

5 files changed

Lines changed: 19 additions & 22 deletions

File tree

dabench/dacycler/_dacycler.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ class DACycler():
2222
system_dim: System dimension
2323
delta_t: The timestep of the model (assumed uniform)
2424
model_obj: Forecast model object.
25-
in_4d: True for 4D data assimilation techniques (e.g. 4DVar).
26-
Default is False.
27-
ensemble: True for ensemble-based data assimilation techniques
28-
(ETKF). Default is False
2925
B: Initial / static background error covariance. Shape:
3026
(system_dim, system_dim). If not provided, will be calculated
3127
automatically.
@@ -36,14 +32,19 @@ class DACycler():
3632
If not provided will be calculated automatically.
3733
h: Optional observation operator as function. More flexible
3834
(allows for more complex observation operator). Default is None.
35+
36+
Attributes:
37+
in_4d: True for 4D data assimilation techniques (e.g. 4DVar).
38+
ensemble: True for ensemble-based data assimilation techniques
39+
(ETKF).
3940
"""
41+
in_4d = False
42+
ensemble = False
4043

4144
def __init__(self,
4245
system_dim: int,
4346
delta_t: float,
4447
model_obj: Model,
45-
in_4d: bool = False,
46-
ensemble: bool = False,
4748
B: ArrayLike | None = None,
4849
R: ArrayLike | None = None,
4950
H: ArrayLike | None = None,
@@ -54,8 +55,6 @@ def __init__(self,
5455
self.H = H
5556
self.R = R
5657
self.B = B
57-
self.in_4d = in_4d
58-
self.ensemble = ensemble
5958
self.system_dim = system_dim
6059
self.delta_t = delta_t
6160
self.model_obj = model_obj

dabench/dacycler/_etkf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class ETKF(dacycler.DACycler):
2020
"""Class for building ETKF DA Cycler
2121
22-
Attributes:
22+
Args:
2323
system_dim: System dimension.
2424
delta_t: The timestep of the model (assumed uniform)
2525
model_obj: Forecast model object.
@@ -38,6 +38,8 @@ class ETKF(dacycler.DACycler):
3838
multiplicative_inflation: Scaling factor by which to multiply ensemble
3939
deviation. Default is 1.0 (no inflation).
4040
"""
41+
in_4d = False
42+
ensemble = True
4143

4244
def __init__(self,
4345
system_dim: int,
@@ -57,8 +59,6 @@ def __init__(self,
5759
super().__init__(system_dim=system_dim,
5860
delta_t=delta_t,
5961
model_obj=model_obj,
60-
in_4d=False,
61-
ensemble=True,
6262
B=B, R=R, H=H, h=h)
6363

6464
def _step_forecast(self,

dabench/dacycler/_var3d.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
class Var3D(dacycler.DACycler):
1919
"""Class for building 3DVar DA Cycler
2020
21-
Attributes:
21+
Args:
2222
system_dim: System dimension.
2323
delta_t: The timestep of the model (assumed uniform)
2424
model_obj: Forecast model object.
@@ -33,6 +33,8 @@ class Var3D(dacycler.DACycler):
3333
h: Optional observation operator as function. More flexible
3434
(allows for more complex observation operator). Default is None.
3535
"""
36+
in_4d = False
37+
ensemble = False
3638

3739
def __init__(self,
3840
system_dim: int,

dabench/dacycler/_var4d.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,10 @@
2727
class Var4D(dacycler.DACycler):
2828
"""Class for building 4D DA Cycler
2929
30-
Attributes:
30+
Args:
3131
system_dim: System dimension.
3232
delta_t: The timestep of the model (assumed uniform)
3333
model_obj: Forecast model object.
34-
in_4d: True for 4D data assimilation techniques (e.g. 4DVar).
35-
Always True for Var4D.
36-
ensemble: True for ensemble-based data assimilation techniques
37-
(ETKF). Always False for Var4D.
3834
B: Initial / static background error covariance. Shape:
3935
(system_dim, system_dim). If not provided, will be calculated
4036
automatically.
@@ -59,6 +55,8 @@ class Var4D(dacycler.DACycler):
5955
[0, 1, 2, 3, 4, 5]. If None (default), will calculate
6056
automatically.
6157
"""
58+
in_4d = True
59+
ensemble = False
6260

6361
def __init__(self,
6462
system_dim: int,

dabench/dacycler/_var4d_backprop.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,10 @@
2727
class Var4DBackprop(dacycler.DACycler):
2828
"""Class for building Backpropagation 4D DA Cycler
2929
30-
Attributes:
30+
Args:
3131
system_dim: System dimension.
3232
delta_t: The timestep of the model (assumed uniform)
3333
model_obj: Forecast model object.
34-
in_4d: True for 4D data assimilation techniques (e.g. 4DVar).
35-
Always True for Var4DBackprop.
36-
ensemble: True for ensemble-based data assimilation techniques
37-
(ETKF). Always False for Var4DBackprop.
3834
B: Initial / static background error covariance. Shape:
3935
(system_dim, system_dim). If not provided, will be calculated
4036
automatically.
@@ -65,6 +61,8 @@ class Var4DBackprop(dacycler.DACycler):
6561
return an error. This prevents it from hanging indefinitely
6662
when loss grows exponentionally. Default is 10.
6763
"""
64+
in_4d = True
65+
ensemble = False
6866

6967
def __init__(self,
7068
system_dim: int,

0 commit comments

Comments
 (0)