-
Notifications
You must be signed in to change notification settings - Fork 397
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
Fix time precision issue for long VIC runs #668
Fix time precision issue for long VIC runs #668
Conversation
@tbohn , could you take a look at this PR? If you are able to use the new code to test on your data that originally caused error, that'd be great. Thanks! |
@jhamman : Could you take a quick look at this on travis? The build is failing because of an HDF library issue (is this the same problem someone else mentioned in the past week - it vaguely rings a bell). |
The failing tests are all due to an issue with Anaconda, not VIC. I'll look into why this is happening. @yixinmao - did the test suite pass locally? |
@yixinmao sure, I'm testing it out now. |
@yixinmao - can we get a what's new note? |
@jhamman I'm running the tests locally now (I haven't run the test locally for a while so ran into some issues that are probably not due to this PR...). Do you mean a release note? |
yes, a release note. |
@yixinmao The code works correctly for me now. Thanks! |
Can be merged after travis build passes (issue #669) |
Before this fix, the timestamps of long VIC runs were incorrect in some cases. This PR is in response to issue #663.
Reason: The reason of this issue is that during the step where timestamps are made (in
make_dmy
), the length of a timestep is first converted into the specified time unit, denoted asdt_time_units
; then a series of timestamps for the whole running period is determined by incrementally increase the timestamp bydt_time_units
. Whendt_time_units
is not precise, the incremented timestamp will accumulate the small error ofdt_time_units
, potentially resulting in incorrect timestamp after a long simulation time.Example: for example, say the time unit is day, and the model timestep is hourly. In this case,
dt_time_units = 1/24
, which is stored as a finite number in the computer with a very small cut-off error. The accumulated error due to this results in an incorrect timestamp shift after ~14 years, and eventually terminates model outputs afeter ~31 years.Solution: when generating the timestamp for each timestep, calculate the accumulating time length from the simulating start time precisely, then store the time. In this way, there is only one cut-off error ofr all timestamps without error accumulation.