diff --git a/changelog.rst b/changelog.rst index 0ba34c1d6cc32c446cfbfd8ac9fd13111ac34235..77a0200986e07071d4b451e6c09b5f197bf1049c 100644 --- a/changelog.rst +++ b/changelog.rst @@ -9,7 +9,7 @@ Yet to be versioned and released. Only available from *dev* branch until then. * remove `"WSS"` and `"AWI"` as probabilistic evaluation metric because of the arbitrary nature of using the sample climatology as reference/benchmark - (`#7-CPP <https://gitlab.irstea.fr/HYCAR-Hydro/evalhyd/evalhyd-cpp/-/issues/7>`_) + (`CPP#7 <https://gitlab.irstea.fr/HYCAR-Hydro/evalhyd/evalhyd-cpp/-/issues/7>`_) .. rubric:: Bug fixes @@ -21,6 +21,8 @@ Yet to be versioned and released. Only available from *dev* branch until then. to the presence of square brackets in the regular expressions that do not seem supported (`R#6 <https://gitlab.irstea.fr/HYCAR-Hydro/evalhyd/evalhyd-r/-/issues/6>`_) +* fix bug when using calendar year as block for the bootstrapping functionality + (`CPP#8 <https://gitlab.irstea.fr/HYCAR-Hydro/evalhyd/evalhyd-cpp/-/issues/8>`_) v0.1.0 ------ diff --git a/include/evalhyd/detail/uncertainty.hpp b/include/evalhyd/detail/uncertainty.hpp index 25b13af0957e7552f52fe648564f2abc67be0054..af55fc2425c19b68bdaba70488d9305b60478825 100644 --- a/include/evalhyd/detail/uncertainty.hpp +++ b/include/evalhyd/detail/uncertainty.hpp @@ -76,7 +76,16 @@ namespace evalhyd int start_yr = v_tm.front().tm_year + 1900; int end_yr = v_tm.back().tm_year + 1900; - // assume start of year block as start of time series + // deal with special case with a start on 1st of January + // (note: use string rather than *tm_yday* member of time_point + // because *tm_yday* is not set when using `std::get_time`) + if (datetimes[0].substr(5, 5) == "01-01") + { + // add one year to make sure last year is included in loop + end_yr += 1; + } + + // take start of year block as start of time series std::tm start_hy = v_tm.front(); xt::xtensor<int, 1> year_blocks = xt::zeros<int>({v_tm.size()}); @@ -100,7 +109,7 @@ namespace evalhyd if ((n_days != 365) && (n_days != 366)) { throw std::runtime_error( - "year starting in " + std::to_string(y) + "year starting in " + std::to_string(y - 400) + " is incomplete" ); }