@@ -83,14 +83,14 @@ def __add__(self, other: "SystemParticipantsResultContainer"):
83
83
def p (self ) -> DataFrame :
84
84
p_series = {
85
85
participants .entity_type ().value : participants .p_sum () # type: ignore
86
- for participants in self .to_list ( include_flex = False )
86
+ for participants in self .participants_to_list ( )
87
87
}
88
88
return pd .DataFrame (p_series ).sort_index ().ffill ().fillna (0 )
89
89
90
90
def q (self ) -> DataFrame :
91
91
q_series = {
92
92
participants .entity_type ().value : participants .q_sum () # type: ignore
93
- for participants in self .to_list ( include_flex = False )
93
+ for participants in self .participants_to_list ( )
94
94
}
95
95
return pd .DataFrame (q_series ).sort_index ().ffill ().fillna (0 )
96
96
@@ -109,31 +109,31 @@ def get_participants(
109
109
return self .to_dict ().get (sp_type )
110
110
111
111
def find_participant_result (self , uuid : str ):
112
- for participants_res in self .to_list (include_flex = False ):
112
+ for participants_res in self .to_list ():
113
113
if uuid in participants_res :
114
114
return participants_res .get (uuid )
115
115
return ValueError (f"No participant result with uuid: { uuid } " )
116
116
117
117
def energies (self ) -> dict [SystemParticipantsEnum , float ]:
118
118
return {
119
119
sp_type : res .energy ()
120
- for sp_type , res in self .to_dict (include_empty = False ).items ()
120
+ for sp_type , res in self .participants_to_dict (include_empty = False ).items ()
121
121
if sp_type != SystemParticipantsEnum .FLEX_OPTIONS
122
122
}
123
123
124
124
def load_and_generation_energies (self ) -> dict [EntitiesEnum , Tuple [float , float ]]:
125
125
return {
126
126
sp_type : res .load_and_generation ()
127
- for sp_type , res in self .to_dict (include_empty = False ).items ()
127
+ for sp_type , res in self .participants_to_dict (include_empty = False ).items ()
128
128
}
129
129
130
130
def sum (self ) -> ComplexPower :
131
131
participant_res = []
132
- for participant in self .to_list (include_em = False , include_flex = False ):
132
+ for participant in self .participants_to_list (include_em = False ):
133
133
participant_res .append (participant .sum ())
134
134
return ComplexPower .sum (participant_res )
135
135
136
- def to_dict (
136
+ def participants_to_dict (
137
137
self , include_empty : bool = False
138
138
) -> dict [SystemParticipantsEnum , ComplexPowerDict ]:
139
139
dct = {
@@ -146,20 +146,38 @@ def to_dict(
146
146
SystemParticipantsEnum .EV_CHARGING_STATION : self .evcs ,
147
147
SystemParticipantsEnum .ELECTRIC_VEHICLE : self .evs ,
148
148
SystemParticipantsEnum .HEAT_PUMP : self .hps ,
149
- SystemParticipantsEnum .FLEX_OPTIONS : self .flex ,
150
149
}
151
150
if not include_empty :
152
151
dct = {k : v for k , v in dct .items () if len (v ) > 0 }
153
152
return dct
154
153
155
- def to_list (
156
- self , include_em : bool = True , include_flex = True , include_empty = True
154
+ def participants_to_list (
155
+ self , include_em : bool = True , include_empty = True
157
156
) -> list [ComplexPowerDict ]: # type: ignore
157
+ dct = self .participants_to_dict (include_empty )
158
+ if not include_em :
159
+ del dct [SystemParticipantsEnum .ENERGY_MANAGEMENT ]
160
+ return list (dct .values ())
161
+
162
+ def to_dict (
163
+ self , include_empty : bool = False
164
+ ) -> dict [SystemParticipantsEnum , TimeSeriesDict ]:
165
+ dct : dict [SystemParticipantsEnum , TimeSeriesDict ] = self .participants_to_dict (
166
+ include_empty = True
167
+ )
168
+
169
+ dct [SystemParticipantsEnum .FLEX_OPTIONS ] = self .flex
170
+
171
+ if not include_empty :
172
+ dct = {k : v for k , v in dct .items () if len (v ) > 0 }
173
+ return dct
174
+
175
+ def to_list (
176
+ self , include_em : bool = True , include_empty = True
177
+ ) -> list [TimeSeriesDict ]: # type: ignore
158
178
dct = self .to_dict (include_empty )
159
179
if not include_em :
160
180
del dct [SystemParticipantsEnum .ENERGY_MANAGEMENT ]
161
- if not include_flex :
162
- del dct [SystemParticipantsEnum .FLEX_OPTIONS ]
163
181
return list (dct .values ())
164
182
165
183
def filter_by_date_time (self , time : Union [datetime , list [datetime ]]):
@@ -199,7 +217,7 @@ def concat(
199
217
)
200
218
201
219
def to_csv (self , path : str , delimiter : str = "," , mkdirs = False ):
202
- for participant in self .to_list (include_empty = False , include_flex = True ):
220
+ for participant in self .to_list (include_empty = False ):
203
221
participant .to_csv (path , delimiter , mkdirs = mkdirs )
204
222
205
223
@classmethod
0 commit comments