Skip to content

Commit 0e9cde0

Browse files
committed
Make in_4d and uses_ensemble non-public class attributes, user doesn't need them
1 parent 3c505be commit 0e9cde0

5 files changed

Lines changed: 13 additions & 18 deletions

File tree

dabench/dacycler/_dacycler.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,9 @@ class DACycler():
3232
If not provided will be calculated automatically.
3333
h: Optional observation operator as function. More flexible
3434
(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).
4035
"""
41-
in_4d = False
42-
ensemble = False
36+
_in_4d: bool = False
37+
_uses_ensemble: bool = False
4338

4439
def __init__(self,
4540
system_dim: int,
@@ -229,7 +224,7 @@ def cycle(self,
229224

230225
# If don't specify analysis_time_in_window, is assumed to be middle
231226
if analysis_time_in_window is None:
232-
if self.in_4d:
227+
if self._in_4d:
233228
analysis_time_in_window = 0
234229
else:
235230
analysis_time_in_window = self.analysis_window/2
@@ -256,7 +251,7 @@ def cycle(self,
256251
obs_times=jnp.array(obs_vector.time.values),
257252
analysis_times=all_times+_time_offset,
258253
start_inclusive=True,
259-
end_inclusive=self.in_4d,
254+
end_inclusive=self._in_4d,
260255
analysis_window=analysis_window
261256
)
262257
input_state = input_state.assign(_cur_time=start_time)
@@ -272,7 +267,7 @@ def cycle(self,
272267
obs_vector[self._observed_vars].to_array().data)
273268
self._obs_vector=self._obs_vector.fillna(0)
274269

275-
if self.in_4d:
270+
if self._in_4d:
276271
cur_state, all_values = jax.lax.scan(
277272
self._cycle_and_forecast_4d,
278273
xj.from_xarray(input_state),

dabench/dacycler/_etkf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +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
41+
_in_4d: bool = False
42+
_uses_ensemble: bool = True
4343

4444
def __init__(self,
4545
system_dim: int,

dabench/dacycler/_var3d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +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
36+
_in_4d: bool = False
37+
_uses_ensemble: bool = False
3838

3939
def __init__(self,
4040
system_dim: int,

dabench/dacycler/_var4d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class Var4D(dacycler.DACycler):
5555
[0, 1, 2, 3, 4, 5]. If None (default), will calculate
5656
automatically.
5757
"""
58-
in_4d = True
59-
ensemble = False
58+
_in_4d: bool = True
59+
_uses_ensemble: bool = False
6060

6161
def __init__(self,
6262
system_dim: int,

dabench/dacycler/_var4d_backprop.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ class Var4DBackprop(dacycler.DACycler):
6161
return an error. This prevents it from hanging indefinitely
6262
when loss grows exponentionally. Default is 10.
6363
"""
64-
in_4d = True
65-
ensemble = False
64+
_in_4d: bool = True
65+
_uses_ensemble: bool = False
6666

6767
def __init__(self,
6868
system_dim: int,

0 commit comments

Comments
 (0)