Commit d87af253 authored by Thibault Hallouin's avatar Thibault Hallouin
Browse files

add support for minute and hourly time step for bootstrapping

fixes #9
1 merge request!7release v0.1.2
Pipeline #49690 passed with stage
in 3 minutes and 37 seconds
Showing with 49 additions and 8 deletions
+49 -8
.. 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
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment