-
Notifications
You must be signed in to change notification settings - Fork 282
SIPNET Initialization Code (carbon and nitrogen pool calculations) #3683
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
base: develop
Are you sure you want to change the base?
Conversation
mdietze
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove xlsx and Rdata files
|
|
||
| # File that will initialize SIPNET. Takes in the UniqueID(polygon), the date (year and day), | ||
| # CLASS and SUBCLASS (ex. C2), and LAI | ||
| initialize_SIPNET <- function(UniqueID, Date, Event, CLASS_SUBCLASS, LAI) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
planting and harvest have different columns, so should be returned as different data frames
| # Map CLASS and SUBCLASS | ||
| group_name <- get_crop_name(CLASS_SUBCLASS) | ||
|
|
||
| LAI = LAI * 10000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not following this undocumented multiplication of a dimensionless variable by an arbitrary constant
| if (Event == "planting") { | ||
| planting_params <- initialize_planting(group_name, LAI) | ||
|
|
||
| # Extract values with explicit NA handling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All this seems superfluous. Just put planting_params directly into the returned dataframe, no need to create all these temporary variables.
| group_name <- get_crop_name(CLASS_SUBCLASS) | ||
|
|
||
|
|
||
| val_3446 <- get_fallback_value(group_name, 3446) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend using meaningful variable names, not all these undocumented codes (e.g. 3446)
| LAI = LAI * 10000 | ||
|
|
||
| #val_601 <- get_fallback_value(group_name, trait_id = 601) | ||
| val_3441 <- get_fallback_value(group_name, trait_id = 3441) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
separate the calculation of parameters from there use in calculating pools. Parameters should all be precalculated into a simple static lookup table based on group_name
| C_coarseRoot.fraction <- 0.5 | ||
| CN_root <- val_1055 | ||
| CN_stem <- 70 #placeholder | ||
| SLA <- (val_3115 + val_3116 + val_3117) / 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's going on here? SLA is a single pre-calculated value, not the average of three things
| coarseroot_nitrogen = N_coarseRoot | ||
| ) | ||
|
|
||
| C_leaf <- planting_params[["leaf_carbon"]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not following this chunk of code and the one above it. The first seems to take the calculated pools and puts them into a list, the second seems to take those values out of the list and put them back into constants, in the end achieving nothing.
…pools)
Description
Motivation and Context
Review Time Estimate
Types of changes
Checklist: