Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resurrect "vegetation establishment" #337

Merged
merged 9 commits into from
Jan 13, 2023
Merged

Resurrect "vegetation establishment" #337

merged 9 commits into from
Jan 13, 2023

Conversation

dschlaep
Copy link
Member

@dschlaep dschlaep commented Jan 9, 2023

- addressing #336

- note: "vegetation establishment" functionality must be activated and output turned on (see #336 for more details)

- "ERROR: Input/estab.in : Layers requested (estab_lyrs) > (# transpiration layers=0)." was produced because code previously tested `estab_lyrs` before `SW_Site.n_transp_lyrs[]` was initialized

-> this commit
* creates new `SW_VES_init_run()` to initialize vegetation establishment parameters of each species by `_spp_init()` and checked by `_sanity_check()` -- which now are called after `SW_SIT_init_run()` that initializes soil parameters (to fix above error message); previously, they were erroneously called by `SW_VegEstab_construct()`, i.e., before soil parameters were initialized
* struct `SW_VEGESTAB_INFO` gains new element `vegType` to encode to which vegetation type a species belongs; this is required to correctly check validity of `estab_lyrs` (previous code was from a time before `SOILWAT2` handled multiple vegetation types simultaneously)
* accordingly, species input files with establishment parameters gain one new input line to provide associated vegetation type, and `_read_spp()` is updated to read in value of `vegType`
* `_sanity_check()` now checks that `vegType` is implemented; now correctly checks `estab_lyrs` against `SW_Site.n_transp_lyrs[]` of the associated vegetation type; and error messages now include species name
* `SW_VegEstab_construct()` now allocates memory for `SW_VegEstab.p_oagg[eSW_Year]->days` (which is de-allocated by `SW_VES_deconstruct()` which previously errored because it was previously erroneously never allocated)
@codecov
Copy link

codecov bot commented Jan 9, 2023

Codecov Report

Merging #337 (b2cf0f8) into master (436bfeb) will increase coverage by 3.47%.
The diff coverage is 54.87%.

@@            Coverage Diff             @@
##           master     #337      +/-   ##
==========================================
+ Coverage   52.68%   56.16%   +3.47%     
==========================================
  Files          20       20              
  Lines        3625     3657      +32     
==========================================
+ Hits         1910     2054     +144     
+ Misses       1715     1603     -112     
Impacted Files Coverage Δ
SW_VegEstab.c 68.82% <54.32%> (+56.26%) ⬆️
SW_Control.c 96.20% <100.00%> (+1.33%) ⬆️
rands.c 61.40% <0.00%> (-0.34%) ⬇️
SW_Flow_lib.c 0.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

…_Estab

- we expect consistent output files, i.e., no special treatment of output period for vegetation establishment results (remove restriction to yearly output if `timeStep` is not set)
- `SW_OUT_read_onekey()` loses argument `period`
…ablishment parameters

- existing `SW_VES_read()` reads through "estab.in" and does not read input files with species establishment parameters if the use flag is turned off
- new `SW_VES_read2()` accepts two arguments that allow overriding the use flag read in from "estab.in" (e.g., to programmatically turn on/off the establishment functionality)
- previously, vegetation type inputs that were not implemented caused the fail due to `key2veg[v->vegType]`, i.e., out of bounds error
-> if `vegType` is misspecified, then error message cannot translate with `key2veg` to string, i.e., create error message with just `vegType` value
-> `vegType` is base0, thus any value >= NVEGTYPES is not implemented
- Organize input files for species establishment in subfolder "estab"
- add `_ProjDir` to file path of each species establishment file, e.g., utilized by STEPWAT2 to locate the files relative to the SOILWAT2 directory
…point

-  `min_swc_estab` is calculated across the top soil layers (n = `estab_lyrs`) but previously the checks compared it against the wilting point of the most shallow soil layer only
-> `min_swc_estab` is now checked against the average across `estab_lyrs` the same way as it is calculated and then utilized for establishment calculations
@dschlaep dschlaep requested a review from N1ckP3rsl3y January 12, 2023 13:58
@dschlaep dschlaep merged commit 0a11f71 into master Jan 13, 2023
@dschlaep dschlaep deleted the feature_vegestab branch January 13, 2023 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Resurrect functionality to calculate and output vegetation establishment
3 participants