@@ -45,6 +45,45 @@ drop sequence id
45
45
create sequence id start 1
46
46
;
47
47
48
+ create table var_electricity_angle as
49
+ select
50
+ nextval(' id' ) as id,
51
+ atr .asset ,
52
+ atr .year ,
53
+ atr .rep_period ,
54
+ atr .time_block_start ,
55
+ any_value(atr .time_block_end ) as time_block_end,
56
+ from
57
+ -- The angle resolution is the same as the time resolution of the asset
58
+ asset_time_resolution_rep_period as atr
59
+ -- We need to check if the asset has any connecting flows that are transport
60
+ -- We only get the assets that have outgoing flows OR incoming flows
61
+ -- With the condition that the flows are transport
62
+ left join flow on flow .from_asset = atr .asset
63
+ or flow .to_asset = atr .asset
64
+ -- After that we need to also check if the flows have dc_opf method
65
+ -- This is by joining the flow_milestone table
66
+ -- Here we use AND because we need to match flow_milestone with flow
67
+ left join flow_milestone on flow_milestone .from_asset = flow .from_asset
68
+ and flow_milestone .to_asset = flow .to_asset
69
+ and flow_milestone .milestone_year = atr .year
70
+ where
71
+ flow .is_transport
72
+ and flow_milestone .dc_opf
73
+ -- We may end up with duplicates because an asset can have both incoming and outgoing flows
74
+ -- Or it can have multiple flows
75
+ -- GROUP BY is used to remove duplicates
76
+ -- Note SELECT only happens after the GROUP BY, so id is unique for each row.
77
+ group by
78
+ atr .asset , atr .year , atr .rep_period , atr .time_block_start
79
+ ;
80
+
81
+ drop sequence id
82
+ ;
83
+
84
+ create sequence id start 1
85
+ ;
86
+
48
87
create table var_is_charging as
49
88
select
50
89
nextval(' id' ) as id,
0 commit comments