-
Notifications
You must be signed in to change notification settings - Fork 0
/
DefineInfrastructure.jl
46 lines (43 loc) · 1.71 KB
/
DefineInfrastructure.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
## Define reservoirs: This file adds the various demand nodes to the reservoir_nodes
## list, which is ordered randomly. Units are assumed to be monthly values.
reservoir_nodes = []
###----- Create Reservoir 1 -----###
push!(reservoir_nodes, create_reservoir(
name = "Lake Merritt",
storage_capacity = 400.,
init_storage = 250.,
top_of_conservation = [400.,400.,400.,400.,400.,400.,400.,400.,400.,400.,400.,400.],
storage_units = "MM3",
Loc = 1)
)
###---------------------------###
# Create Data Frame of All Reservoirs
function rdf(reservoir_nodes, start_year, stop_year)
dictcopy = deepcopy(reservoir_nodes)
nyears = stop_year - start_year + 1
dates = Date.(sort(repmat(start_year:stop_year,12)),repmat(1:12,nyears))
out=[]
for i in 1:length(dictcopy)
if (i == 1)
out = DataFrame(
Date = copy(dates),
Name = dictcopy[i]["name"],
StorageCap = fill(dictcopy[i]["storage_capacity"],length(dates)),
TOC = repmat(dictcopy[i]["top_of_conservation"],nyears),
RESULTS_Storage = fill(0,length(dates)),
Units = dictcopy[i]["storage_units"],
Loc = dictcopy[i]["Loc"])
else
add = DataFrame(
Date = copy(dates),
Name = dictcopy[i]["name"],
StorageCap = fill(dictcopy[i]["storage_capacity"],length(dates)),
TOC = repmat(dictcopy[i]["top_of_conservation"],nyears),
RESULTS_Storage = fill(0,length(dates)),
Units = dictcopy[i]["storage_units"],
Loc = dictcopy[i]["Loc"])
out = append!(out,add)
end
end
return out
end