malcolmSQ commited on
Commit ·
17da2d1
1
Parent(s): 8d81017
fix: use year_1 to year_10 and subsequent for mortality inputs, matching YAML structure
Browse files- dashboard/app.py +11 -17
dashboard/app.py
CHANGED
|
@@ -265,12 +265,11 @@ This version is smoother and may yield slightly different results than the discr
|
|
| 265 |
tm_dbh_B = model_inputs['tm_dbh_B']
|
| 266 |
r0_height_B = model_inputs['r0_height_B']
|
| 267 |
tm_height_B = model_inputs['tm_height_B']
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
mort_sub = model_inputs['mort_sub']
|
| 274 |
project_duration = model_inputs['project_duration']
|
| 275 |
buffer_pct = model_inputs['buffer_pct']
|
| 276 |
soil_carbon = model_inputs['soil_carbon']
|
|
@@ -278,8 +277,7 @@ This version is smoother and may yield slightly different results than the discr
|
|
| 278 |
def update_declining_increment(y1, y2, y3, y4, y5,
|
| 279 |
planting_density_A, r0_dbh_A, tm_dbh_A, r0_height_A, tm_height_A,
|
| 280 |
planting_density_B, r0_dbh_B, tm_dbh_B, r0_height_B, tm_height_B,
|
| 281 |
-
|
| 282 |
-
project_duration, buffer_pct, soil_carbon):
|
| 283 |
config = update_planting_schedule(MODEL_CONFIGS["Declining Increment"], [y1, y2, y3, y4, y5])
|
| 284 |
# Update species_A params
|
| 285 |
config['species'][0]['planting_density'] = planting_density_A
|
|
@@ -293,14 +291,11 @@ This version is smoother and may yield slightly different results than the discr
|
|
| 293 |
config['species'][1]['declining_increment']['dbh']['T_m'] = tm_dbh_B
|
| 294 |
config['species'][1]['declining_increment']['height']['r0'] = r0_height_B
|
| 295 |
config['species'][1]['declining_increment']['height']['T_m'] = tm_height_B
|
| 296 |
-
# Update mortality for BOTH species from the same UI values
|
| 297 |
for i in [0, 1]:
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
config['species'][i]['mortality_rates']['
|
| 301 |
-
config['species'][i]['mortality_rates']['year_4'] = mort_4
|
| 302 |
-
config['species'][i]['mortality_rates']['year_5'] = mort_5
|
| 303 |
-
config['species'][i]['mortality_rates']['subsequent'] = mort_sub
|
| 304 |
# Update project/carbon params
|
| 305 |
config['project']['duration_years'] = project_duration
|
| 306 |
config['carbon']['buffer_percentage'] = buffer_pct
|
|
@@ -342,8 +337,7 @@ This version is smoother and may yield slightly different results than the discr
|
|
| 342 |
inputs=[year_1, year_2, year_3, year_4, year_5,
|
| 343 |
planting_density_A, r0_dbh_A, tm_dbh_A, r0_height_A, tm_height_A,
|
| 344 |
planting_density_B, r0_dbh_B, tm_dbh_B, r0_height_B, tm_height_B,
|
| 345 |
-
|
| 346 |
-
project_duration, buffer_pct, soil_carbon],
|
| 347 |
outputs=[carbon_plot, biomass_plot, annual_plot, growth_plot, summary_box, results_box, species_box, survival_box, biomass_debug_table, key_metrics]
|
| 348 |
)
|
| 349 |
# Show initial results
|
|
|
|
| 265 |
tm_dbh_B = model_inputs['tm_dbh_B']
|
| 266 |
r0_height_B = model_inputs['r0_height_B']
|
| 267 |
tm_height_B = model_inputs['tm_height_B']
|
| 268 |
+
# Mortality years 1-10 + subsequent
|
| 269 |
+
mort_vars = []
|
| 270 |
+
for yr in range(1, 11):
|
| 271 |
+
mort_vars.append(model_inputs[f'year_{yr}'])
|
| 272 |
+
mort_sub = model_inputs['subsequent']
|
|
|
|
| 273 |
project_duration = model_inputs['project_duration']
|
| 274 |
buffer_pct = model_inputs['buffer_pct']
|
| 275 |
soil_carbon = model_inputs['soil_carbon']
|
|
|
|
| 277 |
def update_declining_increment(y1, y2, y3, y4, y5,
|
| 278 |
planting_density_A, r0_dbh_A, tm_dbh_A, r0_height_A, tm_height_A,
|
| 279 |
planting_density_B, r0_dbh_B, tm_dbh_B, r0_height_B, tm_height_B,
|
| 280 |
+
*mortality_inputs, project_duration, buffer_pct, soil_carbon):
|
|
|
|
| 281 |
config = update_planting_schedule(MODEL_CONFIGS["Declining Increment"], [y1, y2, y3, y4, y5])
|
| 282 |
# Update species_A params
|
| 283 |
config['species'][0]['planting_density'] = planting_density_A
|
|
|
|
| 291 |
config['species'][1]['declining_increment']['dbh']['T_m'] = tm_dbh_B
|
| 292 |
config['species'][1]['declining_increment']['height']['r0'] = r0_height_B
|
| 293 |
config['species'][1]['declining_increment']['height']['T_m'] = tm_height_B
|
| 294 |
+
# Update mortality for BOTH species from the same UI values (years 1-10 + subsequent)
|
| 295 |
for i in [0, 1]:
|
| 296 |
+
for yr_idx, yr in enumerate(range(1, 11)):
|
| 297 |
+
config['species'][i]['mortality_rates'][f'year_{yr}'] = mortality_inputs[yr_idx]
|
| 298 |
+
config['species'][i]['mortality_rates']['subsequent'] = mortality_inputs[10]
|
|
|
|
|
|
|
|
|
|
| 299 |
# Update project/carbon params
|
| 300 |
config['project']['duration_years'] = project_duration
|
| 301 |
config['carbon']['buffer_percentage'] = buffer_pct
|
|
|
|
| 337 |
inputs=[year_1, year_2, year_3, year_4, year_5,
|
| 338 |
planting_density_A, r0_dbh_A, tm_dbh_A, r0_height_A, tm_height_A,
|
| 339 |
planting_density_B, r0_dbh_B, tm_dbh_B, r0_height_B, tm_height_B,
|
| 340 |
+
*mort_vars, mort_sub, project_duration, buffer_pct, soil_carbon],
|
|
|
|
| 341 |
outputs=[carbon_plot, biomass_plot, annual_plot, growth_plot, summary_box, results_box, species_box, survival_box, biomass_debug_table, key_metrics]
|
| 342 |
)
|
| 343 |
# Show initial results
|