Skip to content

Commit

Permalink
Make plot_api return all observations
Browse files Browse the repository at this point in the history
  • Loading branch information
yngve-sk committed Oct 30, 2024
1 parent 5a220c7 commit 203dc18
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions src/ert/gui/tools/plot/plot_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,29 +200,37 @@ def observations_for_key(self, ensemble_ids: List[str], key: str) -> pd.DataFram
timeout=self._timeout,
)
self._check_response(response)

observations = response.json()
observations_dfs = []

if not response.json():
continue
try:
obs = response.json()[0]
response.json()[0]
except (KeyError, IndexError, JSONDecodeError) as e:
raise httpx.RequestError(
f"Observation schema might have changed key={key}, ensemble_name={ensemble.name}, e={e}"
) from e
try:
int(obs["x_axis"][0])
key_index = [int(v) for v in obs["x_axis"]]
except ValueError:
key_index = [pd.Timestamp(v) for v in obs["x_axis"]]

data_struct = {
"STD": obs["errors"],
"OBS": obs["values"],
"key_index": key_index,
}

all_observations = pd.concat(
[all_observations, pd.DataFrame(data_struct)]
)

for obs in observations:
try:
int(obs["x_axis"][0])
key_index = [int(v) for v in obs["x_axis"]]
except ValueError:
key_index = [pd.Timestamp(v) for v in obs["x_axis"]]

observations_dfs.append(
pd.DataFrame(
{
"STD": obs["errors"],
"OBS": obs["values"],
"key_index": key_index,
}
)
)

all_observations = pd.concat([all_observations, *observations_dfs])

return all_observations.T

Expand Down

0 comments on commit 203dc18

Please sign in to comment.