PecanProject / pecan

The Predictive Ecosystem Analyzer (PEcAn) is an integrated ecological bioinformatics toolbox.
www.pecanproject.org
Other
199 stars 231 forks source link

[met downscaling] Fix for non-hour timesteps in cfmet.downscale.daily #3270

Closed infotroph closed 3 months ago

infotroph commented 3 months ago

I think this was a flipped multiply/divide -- the now-replaced 0:(23 * output.dt)/output.dt (which has been there for a looong time!) works when output.dt == 1, but gives too many rows for larger timesteps.

I assume the original intention was to write 0:(23/output.dt)*output.dt, but I replaced it with seq(0, 23, by = output.dt) -- that behaves identically and is a lot clearer to me.

Motivation and Context

Noticed while reviewing #3218

Review Time Estimate

Types of changes

Checklist:

infotroph commented 3 months ago

Bonus points for adding a unit test!

This one was a poster child for test-driven development: I saw some funny behavior, wrote the test to decide whether it was a bug, and the answer was yes. I wish they were all this easy to test!