# solarforecastarbiter.metrics.deterministic.time_of_day_cost¶

solarforecastarbiter.metrics.deterministic.time_of_day_cost(obs, fx, cost_params, error_fnc=<function error>)[source]

Compute cost using a time-of-day varying cost value. First, a pandas.Series of costs is constructed to match the index of obs and fx: cost_params.cost specifies the value to assign to each time of day in cost_params.times. The cost_params.fill attribute specifies how to fill (forward or backward) the cost for times in the observation/forecast index but not in cost_params.times. This cost series, along with the attributes net and aggregation from cost_params are used to perform the following calculation depending on (net, aggregation):

$\begin{split}\text{cost} = \begin{cases} 1/n \sum_{i=1}^n C_i * S(\text{obs}_i, \text{fx}_i) & \text{True, mean} \\ \sum_{i=1}^n C_i * S(\text{obs}_i, \text{fx}_i) & \text{True, sum} \\ 1/n \sum_{i=1}^n C_i * |S(\text{obs}_i, \text{fx}_i)| & \text{False, mean} \\ \sum_{i=1}^n C_i * |S(\text{obs}_i, \text{fx}_i)| & \text{False, sum} \end{cases}\end{split}$

where $$S$$ is the error function defined by error_fnc and $$C$$ is the computed cost series.

Parameters: obs ((n,) pandas.Series) – Observed values with a pandas.DatetimeIndex. fx ((n,) pandas.Series) – Forecasted values with a pandas.DatetimeIndex matching obs. cost_params (solarforecastarbiter.datamodel.TimeOfDayCost) – Parameters that the define the cost value along with how to aggregate the costs. error_fnc (function) – A function that returns the error, default fx - obs. First argument is obs, second argument is fx. cost (float) – The cost of the forecast errors.