Skip to content

Commit

Permalink
Add unique index to label in fmuobs when converting from ResInsight f…
Browse files Browse the repository at this point in the history
…ormat to be ERT compatible
  • Loading branch information
asnyv committed Dec 6, 2023
1 parent d0f04a1 commit 83a321a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/subscript/fmuobs/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,11 @@ def resinsight_df2df(ri_dframe: pd.DataFrame) -> pd.DataFrame:

dframe = ri_dframe.copy()
dframe.rename({"VECTOR": "KEY"}, axis="columns", inplace=True)
dframe["LABEL"] = dframe["KEY"].astype(str) # + "-" + dframe["DATE"].astype(str)
dframe["LABEL"] = (
dframe["KEY"].astype(str)
+ "-"
+ (dframe.groupby("KEY").cumcount() + 1).astype(str)
)
dframe["CLASS"] = "SUMMARY_OBSERVATION"
if "DATE" in dframe:
dframe["DATE"] = pd.to_datetime(dframe["DATE"])
Expand Down
2 changes: 2 additions & 0 deletions tests/testdata_fmuobs/ri-obs.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
DATE;VECTOR;VALUE;ERROR
2005-08-21;GOPR:BRENT;100.0;5.0
2005-08-21;GWPR:BRENT;50.0;5.0
2006-08-21;GOPR:BRENT;200.0;5.0

0 comments on commit 83a321a

Please sign in to comment.