diff --git a/changelog.rst b/changelog.rst index d47ce60b53d322c48ef57e5f4bb0af60165a7a96..bbe328ec72bcc1c908864407c4b031ce7b55425d 100644 --- a/changelog.rst +++ b/changelog.rst @@ -1,10 +1,14 @@ .. default-role:: obj -.. - latest - ------ +latest +------ + +Yet to be versioned and released. Only available from *dev* branch until then. + +.. rubric:: Scope changes - Yet to be versioned and released. Only available from *dev* branch until then. +* add support for minute and hourly time steps in bootstrapping functionality + (`CPP#9 <https://gitlab.irstea.fr/HYCAR-Hydro/evalhyd/evalhyd-cpp/-/issues/9>`_) v0.1.1 diff --git a/include/evalhyd/detail/uncertainty.hpp b/include/evalhyd/detail/uncertainty.hpp index af55fc2425c19b68bdaba70488d9305b60478825..3ea64e7a632db25f4fb59e564525993a617993a5 100644 --- a/include/evalhyd/detail/uncertainty.hpp +++ b/include/evalhyd/detail/uncertainty.hpp @@ -105,8 +105,41 @@ namespace evalhyd (x_timepoints >= start) && (x_timepoints < end); // check that year is complete (without a rigorous leap year check) - int n_days = xt::sum(wdw)(); - if ((n_days != 365) && (n_days != 366)) + bool complete_yr = true; + if (std::chrono::minutes(ti).count() == 1) + { + // minute timestep + int n_minutes = xt::sum(wdw)(); + if ((n_minutes != 60 * 24 * 365) && (n_minutes != 60 * 24 * 366)) + { + complete_yr = false; + } + } + else if (std::chrono::minutes(ti).count() == 60) + { + // hourly timestep + int n_hours = xt::sum(wdw)(); + if ((n_hours != 24 * 365) && (n_hours != 24 * 366)) + { + complete_yr = false; + } + } + else if (std::chrono::minutes(ti).count() == 60 * 24) + { + // daily timestep + int n_days = xt::sum(wdw)(); + if ((n_days != 365) && (n_days != 366)) + { + complete_yr = false; + } + } + else + { + throw std::runtime_error( + "time step must be minute, hourly, or daily" + ); + } + if (!complete_yr) { throw std::runtime_error( "year starting in " + std::to_string(y - 400) diff --git a/include/evalhyd/evald.hpp b/include/evalhyd/evald.hpp index 9ddeeadf1ddb42ba5caed1bc54748ce24b351be2..580b4f0c3ad99dacc2d09a37d06c79dca21b89f2 100644 --- a/include/evalhyd/evald.hpp +++ b/include/evalhyd/evald.hpp @@ -132,7 +132,9 @@ namespace evalhyd /// The date and time must be specified in a string following the /// ISO 8601-1:2019 standard, i.e. "YYYY-MM-DD hh:mm:ss" (e.g. the /// 21st of May 2007 at 4 in the afternoon is "2007-05-21 16:00:00"). - /// If provided, it is only used if *bootstrap* is also provided. + /// The time series must feature complete years. Only minute, hourly, + /// and daily time steps are supported. If provided, it is only used + /// if *bootstrap* is also provided. /// /// seed: ``int``, optional /// A value for the seed used by random generators. This parameter diff --git a/include/evalhyd/evalp.hpp b/include/evalhyd/evalp.hpp index c04412097f925f675cb5750037086c421dceda9e..3b5f831d26cb72966f325f9ba5a8468778b680c9 100644 --- a/include/evalhyd/evalp.hpp +++ b/include/evalhyd/evalp.hpp @@ -123,7 +123,9 @@ namespace evalhyd /// The date and time must be specified in a string following the /// ISO 8601-1:2019 standard, i.e. "YYYY-MM-DD hh:mm:ss" (e.g. the /// 21st of May 2007 at 4 in the afternoon is "2007-05-21 16:00:00"). - /// If provided, it is only used if *bootstrap* is also provided. + /// The time series must feature complete years. Only minute, hourly, + /// and daily time steps are supported. If provided, it is only used + /// if *bootstrap* is also provided. /// /// seed: ``int``, optional /// A value for the seed used by random generators. This parameter