An error occurred while loading the file. Please try again.
-
Thibault Hallouin authoredb1554f4b
#ifndef EVALHYD_DETERMINIST_HPP
#define EVALHYD_DETERMINIST_HPP
#include <unordered_map>
#include <unordered_set>
#include <xtensor/xexpression.hpp>
#include "utils.hpp"
#include "determinist/evaluator.hpp"
namespace eh = evalhyd;
namespace evalhyd
{
namespace determinist {
/// Function allowing the evaluation of streamflow simulations using a
/// range of relevant metrics.
///
/// \param [in] metrics:
/// Vector of strings for the metric(s) to be computed.
/// \param [in] q_obs:
/// 2D array of streamflow observations.
/// shape: (1+, time)
/// \param [in] q_sim:
/// 2D array of streamflow simulations.
/// shape: (1+, time)
/// \return
/// Vector of 1D array of metrics for each time series.
template <class A>
std::vector<A> evaluate(
const std::vector<std::string>& metrics,
const xt::xexpression<A>& q_obs,
const xt::xexpression<A>& q_sim
)
{
const A& obs = q_obs.derived_cast();
const A& sim = q_sim.derived_cast();
eh::determinist::Evaluator<A> evaluator(obs, sim);
// declare maps for memoisation purposes
std::unordered_map<std::string, std::vector<std::string>> elt;
std::unordered_map<std::string, std::vector<std::string>> dep;
// register potentially recurring computation elt across metrics
// TODO
// register nested metrics (i.e. metric dependent on another metric)
// TODO
// determine required elt/dep to be pre-computed
std::unordered_set<std::string> req_elt = {};
std::unordered_set<std::string> req_dep = {};
eh::utils::find_requirements(metrics, elt, dep, req_elt, req_dep);
// pre-compute required elt
for ( const auto& element : req_elt )
{
// TODO
}
// pre-compute required dep
for ( const auto& dependency : req_dep )
{
// TODO
}
// retrieve or compute requested metrics
std::vector<A> r;
717273747576777879808182838485868788
for ( const auto& metric : metrics )
{
if ( metric == "nse" )
{
if ( req_dep.find(metric) == req_dep.end() )
evaluator.calc_nse();
r.emplace_back(evaluator.nse);
}
}
return r;
}
}
}
#endif //EVALHYD_DETERMINIST_HPP