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

Feature/add maximum snow albedo option #835

Merged

Conversation

dgergel
Copy link
Contributor

@dgergel dgergel commented Oct 1, 2018

This PR adds in a vegetation-dependent maximum snow albedo for new snow option called MAX_SNOW_ALBEDO. When set to True in the global parameter file, maximum snow albedo is read in from the parameters file and used throughout the snow routines for new snow albedo except for bare soil.

It also includes an unrelated bug fix to vic/drivers/shared_image/src/vic_restore.c which was necessary for being able to successfully compile the model.

Copy link
Member

@jhamman jhamman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just had time for a quick look. This mostly seems fine. I would like to some point simulations using this feature to confirm its doing what we think its doing. Do you have those alread?

@@ -2,7 +2,8 @@
from vic.vic import ffi
from vic import lib as vic_lib


# TODO: design new test to not only use the static parameter value
@pytest.mark.xfail
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be fixed before we merge this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK - we'll fix the test in future PR

@dgergel
Copy link
Contributor Author

dgergel commented Oct 2, 2018

@jhamman here is a point simulation for a gridcell that is in Siberia, with ~60% grassland (max snow albedo of 0.7) and ~35% bare soil:

max_albedo_example

Copy link
Member

@bartnijssen bartnijssen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same change as requested by Joe (test). Otherwise looks fine.

@@ -2,7 +2,8 @@
from vic.vic import ffi
from vic import lib as vic_lib


# TODO: design new test to not only use the static parameter value
@pytest.mark.xfail
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

@@ -970,7 +970,7 @@ check_init_state_file(void)
dimlen = get_nc_dimension(&(filenames.init_state), "lake_node");
if (dimlen != options.Nlakenode) {
log_err("Number of lake nodes in state file does not "
"match LAKE_NODES (%d) in global parameter file",
"match LAKE_NODES (%zu) in global parameter file",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's OK for now, but I would have preferred this as a separate PR to keep the individual PRs as focused as possible. Where this would break things is if we had to roll-back a PR for some reason. If we rolled back the MAX_SNOW_ALBEDO PR, that would also roll-back this unrelated bug fix. As said, leave this time.

@dgergel
Copy link
Contributor Author

dgergel commented Oct 3, 2018

@bartnijssen @jhamman I just took a stab at updating the unit test - not sure if this is the best way or not.

def test_snow_albedo_new_snow():
assert vic_lib.snow_albedo(
0.1, 1., 0.7, -77, 3600., 0,
ffi.cast('char', False)) == vic_lib.param.SNOW_NEW_SNOW_ALB
ffi.cast('char', False)) <= vic_lib.param.SNOW_NEW_SNOW_ALB
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you want to write a test that checks that the result of snow_albedo on timestep 0 is max_snow_albedo. You may also consider adding an additional test for when MAX_SNOW_ALBEDO is true or false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bartnijssen and I just discussed this and I'm going to update this test in a future PR just so we can go ahead and merge the PR. I just created an issue for it; see #843 for reference.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. It sounds like you two have a plan in place. I'll just say that I think the best time/place to write tests is in the PR that changes specific bits of code. Its why we have a checkbox in the PR template for new tests added.

@bartnijssen bartnijssen merged commit 0e84d6e into UW-Hydro:develop Oct 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants