RVIC icon indicating copy to clipboard operation
RVIC copied to clipboard

Coupling Timestep not calculating correct for hourly data

Open PhilippBuehler opened this issue 7 years ago • 1 comments

I'm getting this error running RVIC in hourly timesteps.

INFO:get_time_mode>> Coupling Timestep is (seconds): 3599.99999665 INFO:get_time_mode>> RVIC Timestep is (seconds): 86400.0

This problem seems to be (another) floating-point problem since the internal calculation does compute 1/24*8640 which ends up being an double instead of an int: https://github.com/UW-Hydro/RVIC/blob/622f45d2d92532db6dd92a887492d6e37d9fcc9e/rvic/core/read_forcing.py#L168

I worked around it by rounding the result whoch gives me 3600 seconds :

        self.secs_per_step = round((t1 - t0) * SECSPERDAY)

See thecommit in my fork: https://github.com/PhilippBuehler/RVIC/commit/8f333ce039a5bc3f693c144b3790f2a921c6d35c

I also created a pull request: https://github.com/UW-Hydro/RVIC/pull/104

I have to do additional testing of any of the other errors are related to my tweak (right now I'm getting ERROR:write>> local variable 'end_timestamp' referenced before assignment)

Philipp

PhilippBuehler avatar Nov 27 '17 21:11 PhilippBuehler

I tried to make it work out, but the problem is deep within the code and the use of datenum which is not working out. One fix could be to change the internal time format to "hours since xxx" instead of "days since xxx", but this is marked in the function as "DO NOT CHANGE".. So there probably needs to be a bigger fix for this.

PhilippBuehler avatar Dec 07 '17 18:12 PhilippBuehler