Skip to content

Commit

Permalink
tmp: work
Browse files Browse the repository at this point in the history
  • Loading branch information
sondreso committed Oct 26, 2023
1 parent f03aca8 commit 8bd231a
Showing 1 changed file with 40 additions and 23 deletions.
63 changes: 40 additions & 23 deletions src/ert/gui/tools/plot/plot_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,30 +228,47 @@ def observations_for_key(self, case_name, key):

case = self._get_case(case_name)
ensemble = self._storage.get_ensemble(case["id"])
ensemble.experiment.observations[key]
val = None
for v in ensemble.experiment.observations.values():
if v.attrs["response"] == key:
val = v

with StorageService.session() as client:
response = client.get(
f"/ensembles/{case['id']}/records/{key}/observations",
timeout=self._timeout,
)
self._check_response(response)
try:
obs = response.json()[0]
except (KeyError, IndexError, JSONDecodeError) as e:
raise httpx.RequestError("Observation schema might have changed") 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,
}
return pd.DataFrame(data_struct).T

print(val)
print(val["errors"])
print(val.indexes)
data_struct = {
"STD": val["errors"],
"OBS": val["values"],
"key_index": val.indexes["index"],
}
return pd.DataFrame(data_struct).T
# ensemble.experiment.observations[key]



# with StorageService.session() as client:
# response = client.get(
# f"/ensembles/{case['id']}/records/{key}/observations",
# timeout=self._timeout,
# )
# self._check_response(response)
# try:
# obs = response.json()[0]
# except (KeyError, IndexError, JSONDecodeError) as e:
# raise httpx.RequestError("Observation schema might have changed") 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,
# }
# return pd.DataFrame(data_struct).T

def history_data(self, key, case=None) -> pd.DataFrame:
"""Returns a pandas DataFrame with the data points for the history for a
Expand Down

0 comments on commit 8bd231a

Please sign in to comment.