-
Notifications
You must be signed in to change notification settings - Fork 52
/
time_series_interface.jl
81 lines (76 loc) · 2.11 KB
/
time_series_interface.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
function get_time_series_values!(
time_series_type::Type{T},
model::DecisionModel,
component,
name,
multiplier_id::Int,
initial_time,
horizon::Int;
ignore_scaling_factors = true,
) where {T <: PSY.Forecast}
if !use_time_series_cache(get_settings(model))
return IS.get_time_series_values(
T,
component,
name;
start_time = initial_time,
len = horizon,
ignore_scaling_factors = ignore_scaling_factors,
)
end
cache = get_time_series_cache(model)
key = TimeSeriesCacheKey(IS.get_uuid(component), T, name, multiplier_id)
if haskey(cache, key)
ts_cache = cache[key]
else
ts_cache = make_time_series_cache(
time_series_type,
component,
name,
initial_time,
horizon;
ignore_scaling_factors = ignore_scaling_factors,
)
cache[key] = ts_cache
end
ts = IS.get_time_series_array!(ts_cache, initial_time)
return TimeSeries.values(ts)
end
function get_time_series_values!(
::Type{T},
model::EmulationModel,
component::U,
name,
multiplier_id::Int,
initial_time,
len::Int = 1;
ignore_scaling_factors = true,
) where {T <: PSY.StaticTimeSeries, U <: PSY.Component}
if !use_time_series_cache(get_settings(model))
return IS.get_time_series_values(
T,
component,
name;
start_time = initial_time,
len = len,
ignore_scaling_factors = ignore_scaling_factors,
)
end
cache = get_time_series_cache(model)
key = TimeSeriesCacheKey(IS.get_uuid(component), T, name, multiplier_id)
if haskey(cache, key)
ts_cache = cache[key]
else
ts_cache = make_time_series_cache(
T,
component,
name,
initial_time,
len;
ignore_scaling_factors = ignore_scaling_factors,
)
cache[key] = ts_cache
end
ts = IS.get_time_series_array!(ts_cache, initial_time)
return TimeSeries.values(ts)
end