| 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 |