Vegetation#

Growth, seasonal vegetation and nutrient uptake.

smew.vegetation.get_stage_boundaries(stage_array, target_stage)[source]#

Extracts start and stop indices target_stage of the list stage_array

Parameters:
  • stage_array (ndarray[tuple[Any, ...], dtype[int8]])

  • target_stage (int)

Return type:

tuple[ndarray[tuple[Any, …], dtype[int32]], ndarray[tuple[Any, …], dtype[int32]]]

smew.vegetation.get_season_boundaries(stage_array)[source]#

Extracts start and stop indices for the entire growing season (any stage > 0)

Parameters:

stage_array (ndarray[tuple[Any, ...], dtype[int8]])

Return type:

tuple[ndarray[tuple[Any, …], dtype[int32]], ndarray[tuple[Any, …], dtype[int32]]]

smew.vegetation.veg(v_in, T_v, k_v, t0_v, temp_soil, dt)[source]#
smew.vegetation.veg_seasonal(growing_stage, k_v, f_v_in)[source]#

Calculates the seasonal vegetation growth and harvest with a logistic growth curve based on the carrying capacity k_v and the growing seasons provided by growing_stage. This Python entry point raises after the compiled calculation returns; Numba callers should use veg_seasonal_numba and propagate its error code.

Parameters:
  • growing_stage (ndarray[tuple[Any, ...], dtype[int8]]) – A 1D NumPy array representing the sequential stages of the crop season (0 for off-season, 1 - 4 for active stages). The function uses stage 2 to define the growth period and emergence and the end of stage 4 for the harvesting. The calendar is assumed valid: stages must not decrease within a season, and stage 0 separates seasons. Seasons without stage 2 produce no biomass. Growth uses the same explicit Euler logistic update as veg, with time measured in simulation steps.

  • k_v (float) – Finite, nonnegative vegetation carrying capacity. Zero capacity produces zero biomass and harvest.

  • f_v_in (float) – Finite initial vegetation fraction in (0, 1) (v_in = f_v_in * k_v).

Returns:

A tuple containing two 1D NumPy arrays, both matching the length of the input growing_stage mask: * v: The vegetation value/biomass amount calculated via the logistic growth curve. * harvest_out: The harvested vegetation values, recorded exactly on the time step following the end of each growing season (all other time steps are 0.0).

Return type:

tuple[ndarray[tuple[Any, …], dtype[float32]], ndarray[tuple[Any, …], dtype[float32]]]

smew.vegetation.veg_seasonal_numba(growing_stage, k_v, f_v_in)#

Return ((biomass, harvest) or None, code, message).

growing_stage must be a valid one-dimensional calendar; it is not validated here. Compiled parents must propagate a nonzero code and raise only after returning to Python.

smew.vegetation.up_act(v, delta_v, xi, dt, T, Ca, Mg, K, Si, Dw, Zr, k_v, RAI, root_d)[source]#