Skip to content

Commit 5cad9b7

Browse files
committed
Distribute - Albedo - Follow up fixes after merge with latest in main
The main branch had an overhaul of the init method, changing a few pieces of the logic in this branch with was developed in parallel. This now also adds the accessor to veg_type from the topo with the ImageData base class.
1 parent 65f5187 commit 5cad9b7

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

smrf/distribute/variable_base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ def veg_tau(self):
128128
def veg_k(self):
129129
return self.topo.veg_k
130130

131+
@property
132+
def veg_type(self):
133+
return self.topo.veg_type
134+
131135
# END - Topo accessor methods
132136

133137
# START - config accessors

smrf/tests/distribute/test_albedo.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@
77
from smrf.distribute.albedo import Albedo
88

99
CONFIG = {
10-
"decay_method": "date_method",
11-
"decay_start": pd.to_datetime("2025-04-01"),
12-
"decay_end": pd.to_datetime("2025-07-01"),
13-
"grain_size": 100.0,
14-
"max_grain": 800.0,
15-
"max": 1.0,
16-
"min": 0.0,
17-
"dirt": 2,
18-
"date_method_veg_default": 0.2,
10+
"albedo": {
11+
"decay_method": "date_method",
12+
"decay_start": pd.to_datetime("2025-04-01"),
13+
"decay_end": pd.to_datetime("2025-07-01"),
14+
"grain_size": 100.0,
15+
"max_grain": 800.0,
16+
"max": 1.0,
17+
"min": 0.0,
18+
"dirt": 2,
19+
"date_method_veg_default": 0.2,
20+
}
1921
}
2022
DECAY_TIME = pd.to_datetime("2025-04-30")
2123
NO_DECAY_TIME = pd.to_datetime("2025-03-01")
@@ -32,8 +34,8 @@
3234

3335
class TestAlbedo(unittest.TestCase):
3436
def setUp(self):
35-
self.subject = Albedo(CONFIG)
36-
self.subject.initialize(TOPO, DATA)
37+
self.subject = Albedo(CONFIG, TOPO)
38+
self.subject.initialize(DATA)
3739

3840
def test_before_decay_window(self):
3941
current, decay = self.subject.decay_window(NO_DECAY_TIME)
@@ -51,7 +53,11 @@ def test_distribute_date_method_not_in_window(self, decay_alb_power, envphys_alb
5153

5254
envphys_albedo.assert_called()
5355
envphys_albedo.assert_called_with(
54-
STORM_DAYS, COS_Z, CONFIG["grain_size"], CONFIG["max_grain"], CONFIG["dirt"]
56+
STORM_DAYS,
57+
COS_Z,
58+
CONFIG["albedo"]["grain_size"],
59+
CONFIG["albedo"]["max_grain"],
60+
CONFIG["albedo"]["dirt"]
5561
)
5662
decay_alb_power.assert_not_called()
5763

@@ -74,7 +80,11 @@ def test_distribute_post_fire_not_in_window(self, decay_burned, envphys_albedo):
7480

7581
envphys_albedo.assert_called()
7682
envphys_albedo.assert_called_with(
77-
STORM_DAYS, COS_Z, CONFIG["grain_size"], CONFIG["max_grain"], CONFIG["dirt"]
83+
STORM_DAYS,
84+
COS_Z,
85+
CONFIG["albedo"]["grain_size"],
86+
CONFIG["albedo"]["max_grain"],
87+
CONFIG["albedo"]["dirt"]
7888
)
7989
decay_burned.assert_not_called()
8090

0 commit comments

Comments
 (0)