Skip to content

Commit

Permalink
Observation get forecast from dict instread of action to fix issue #131
Browse files Browse the repository at this point in the history
Use private attribute _forecasted_inj to get values instead of using the action built from _forecasted_inj in simulate; which removes the need to call simulate
  • Loading branch information
Tezirg committed Jul 22, 2020
1 parent d89b8aa commit b32d1c5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Change Log
- [FIXED] `Issue #129<https://github.com/rte-france/Grid2Op/issues/129>`_: game over count for env_actions
- [FIXED] `Issue #127 <https://github.com/rte-france/Grid2Op/issues/127>`_: Removed no longer existing attribute docstring `indisponibility`
- [FIXED] `Issue #133 <https://github.com/rte-france/Grid2Op/issues/133>`_: Missing positional argument `space_prng` in `Action.SerializableActionSpace`
- [FIXED] `Issue #131 <https://github.com/rte-france/Grid2Op/issues/131>`_: Forecast values are accessible without needing to call `obs.simulate` beforehand.

[1.1.1] - 2020-07-07
---------------------
Expand Down
18 changes: 9 additions & 9 deletions grid2op/Observation/BaseObservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,20 +661,20 @@ def get_forecasted_inj(self, time_step=1):
"""
if time_step >= len(self._forecasted_inj):
raise NoForecastAvailable("Forecast for {} timestep ahead is not possible with your chronics.".format(time_step))
a = self._forecasted_grid_act[time_step]["inj_action"]
t, a = self._forecasted_inj[time_step]
prod_p_f = np.full(self.n_gen, fill_value=np.NaN, dtype=dt_float)
prod_v_f = np.full(self.n_gen, fill_value=np.NaN, dtype=dt_float)
load_p_f = np.full(self.n_load, fill_value=np.NaN, dtype=dt_float)
load_q_f = np.full(self.n_load, fill_value=np.NaN, dtype=dt_float)

if "prod_p" in a._dict_inj:
prod_p_f = a._dict_inj["prod_p"]
if "prod_v" in a._dict_inj:
prod_v_f = a._dict_inj["prod_v"]
if "load_p" in a._dict_inj:
load_p_f = a._dict_inj["load_p"]
if "load_q" in a._dict_inj:
load_q_f = a._dict_inj["load_q"]
if "prod_p" in a["injection"]:
prod_p_f = a["injection"]["prod_p"]
if "prod_v" in a["injection"]:
prod_v_f = a["injection"]["prod_v"]
if "load_p" in a["injection"]:
load_p_f = a["injection"]["load_p"]
if "load_q" in a["injection"]:
load_q_f = a["injection"]["load_q"]
tmp_arg = ~np.isfinite(prod_p_f)
prod_p_f[tmp_arg] = self.prod_p[tmp_arg]
tmp_arg = ~np.isfinite(prod_v_f)
Expand Down

0 comments on commit b32d1c5

Please sign in to comment.