MCPcopy Create free account
hub / github.com/ahalev/python-microgrid / append

Method append

src/pymgrid/algos/Control.py:131–200  ·  view source on GitHub ↗
(self, other_output, actual_load=None, actual_pv=None, actual_grid = None, slice_to_use=0)

Source from the content-addressed store, hash-verified

129 self.microgrid = microgrid
130
131 def append(self, other_output, actual_load=None, actual_pv=None, actual_grid = None, slice_to_use=0):
132 if isinstance(other_output, ControlOutput):
133 for name in self.keys():
134 if name not in other_output.keys():
135 raise KeyError('name {} not founds in other_output keys'.format(name))
136
137 self[name].append(other_output[name].iloc[slice_to_use], ignore_index=True)
138
139 elif isinstance(other_output, HorizonOutput):
140 action = self['action']
141 production = self['production']
142 cost = self['cost']
143 status = self['status']
144 co2 = self['co2']
145
146 action = self.microgrid._record_action(other_output.first_dict, action)
147 production = self.microgrid._record_production(other_output.first_dict, production, status)
148
149 last_prod = dict([(key, production[key][-1]) for key in production])
150
151 i = other_output.current_step
152
153 if self.microgrid.architecture['grid'] == 1:
154 co2 = self.microgrid._record_co2(
155 last_prod,
156 co2,
157 self.microgrid._grid_co2.iloc[i].values[0]
158 )
159
160 status = self.microgrid._update_status(
161 last_prod,
162 status,
163 actual_load,
164 actual_pv,
165 actual_grid,
166 self.microgrid._grid_price_import.iloc[i + 1].values[0],
167 self.microgrid._grid_price_export.iloc[i + 1].values[0],
168 self.microgrid._grid_co2.iloc[i + 1].values[0]
169 )
170
171 cost = self.microgrid._record_cost(
172 last_prod,
173 cost,
174 co2,
175 self.microgrid._grid_price_import.iloc[i, 0],
176 self.microgrid._grid_price_export.iloc[i, 0])
177 else:
178
179 co2 = self.microgrid._record_co2(
180 last_prod,
181 co2,
182 )
183
184 status = self.microgrid._update_status(
185 last_prod,
186 status,
187 actual_load,
188 actual_pv

Callers 15

run_mpc_on_groupMethod · 0.95
generate_microgridMethod · 0.45
_create_microgridMethod · 0.45
print_mg_parametersMethod · 0.45
print_all_costsMethod · 0.45
_add_feature_columnsMethod · 0.45
most_light_curve_evalMethod · 0.45
_sample_parabolaMethod · 0.45
sample_from_forecastsMethod · 0.45
update_with_mapeMethod · 0.45

Calls 5

_record_actionMethod · 0.80
_record_productionMethod · 0.80
_record_co2Method · 0.80
_update_statusMethod · 0.80
_record_costMethod · 0.80