EcohydrologyTeam / ClearWater-modules

A collection of water quality and vegetation process simulation modules designed to couple with water transport models.
MIT License
5 stars 1 forks source link

49 create convert static to state function #51

Closed xaviernogueira closed 1 year ago

xaviernogueira commented 1 year ago

Closes #49

Changes:

@sjordan29 @jrutyna You can now proceed as discussed.

For example, imagine a model with a 1 state variable called "state_variable_1" and two static variables "static_1" and "static_2". Despite the static variables not being changed by the model itself (hence why they are called static), one might want to alter "static_1" between running timesteps via another model like Clearwater-Riverine. To do so you simply init the model as shown below:

import clearwater_modules.base as base

my_model_instance: base.Model = Model(
     initial_state_values={'state_variable_1': 1.0},
     updateable_static_variables=['static_1']
)

then when running a timestep you can use the update_state_values argument, which takes a dictionary with variable names as keys, and xr.DataArrays as values. For now, this requires data arrays, but I am going to open a new issue to support just passing in a number, and having that number broadcast to the shape of our xr.Dataset, see #52 .

codecov[bot] commented 1 year ago

Codecov Report

Merging #51 (c38c6b6) into main (5772cf2) will increase coverage by 1.54%. Report is 1 commits behind head on main. The diff coverage is 80.00%.

@@            Coverage Diff             @@
##             main      #51      +/-   ##
==========================================
+ Coverage   36.18%   37.72%   +1.54%     
==========================================
  Files          33       33              
  Lines        1133     1153      +20     
==========================================
+ Hits          410      435      +25     
+ Misses        723      718       -5     
Files Coverage Δ
src/clearwater_modules/tsm/processes.py 71.42% <100.00%> (+0.37%) :arrow_up:
src/clearwater_modules/utils.py 58.82% <0.00%> (ø)
src/clearwater_modules/base.py 87.29% <85.71%> (+4.57%) :arrow_up:
aufdenkampe commented 1 year ago

@xaviernogueira, thanks for moving this forward! I only did a quick scan, but it generally looks good!