Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: StandardTimeSeriesParameterValue don't calculate the write value for time-varying parameters #76

Open
mihlema opened this issue Sep 29, 2021 · 1 comment
Assignees

Comments

@mihlema
Copy link
Contributor

mihlema commented Sep 29, 2021

The current SpineInterface access function for StandardTimeSeriesParameterValue does not adequately retrieve time-varying parameter values, as the averaging seems to assume equidistant values. The following example illustrates the problem:

julia> my_test_parameter = parameter_value(TimeSeries([DateTime(2000),DateTime(2001),DateTime(2008), DateTime(2009)],[5,5,0,0], false, false))
julia> my_test_parameter(t=TimeSlice(DateTime(2000),DateTime(2009)))
3.3333333333333335

In this example, we have a time-varying testparameter (distances: 1Y, 7Y,1Y). What we would expect when calling the value for the Timeslice(2000~>2009) would be the weighted average:

(5*1 + 5*7 + 5*0)/ 3

but we effectively get:

(5+5+0)/3

The source problem part is function (p::TimePatternParameterValue)(t::TimeSlice), where an unweighted mean is called

@mihlema
Copy link
Contributor Author

mihlema commented Sep 29, 2021

I'd propose to just explicitly integrate the averaging in the function:
sum(p.values[a]*(p.indexes[a+1]-p.indexes[a]) for x = a:b)/sum(p.indexes[a+1]-p.indexes[a]) for x = a:b)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants