Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fmuobs - Add unique index to label when converting from ResInsight format #636

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 1 addition & 0 deletions tests/testdata_fmuobs/ert-doc.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
CLASS,LABEL,VALUE,ERROR,DATE,KEY,RESTART,DAYS,OBS,FIELD,I,J,K,SOURCE,DATA,OBS_FILE,INDEX_LIST,ERROR_MODE,ERROR_MIN,SEGMENT,START,STOP
SUMMARY_OBSERVATION,SEP_TEST_2005,100.0,5.0,2005-08-21,GOPR:BRENT,,,,,,,,,,,,,,,,
SUMMARY_OBSERVATION,SEP_TEST_2006,100.0,5.0,2006-08-21,GOPR:BRENT,,,,,,,,,,,,,,,,
SUMMARY_OBSERVATION,SEP_TEST_RST_2005,100.0,5.0,,GOPR:BRENT,42.0,,,,,,,,,,,,,,,
SUMMARY_OBSERVATION,SEP_TEST_2008,213.0,10.0,,GOPR:NESS,,911.0,,,,,,,,,,,,,,
BLOCK_OBSERVATION,RFT_2006,100.0,5.0,2006-10-22,,,,P1,PRESSURE,1.0,1.0,1.0,,,,,,,,,
Expand Down
10 changes: 9 additions & 1 deletion tests/testdata_fmuobs/ert-doc.obs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- These observation data are copied from the ERT docs,
-- These observation data are mainly copied from the ERT docs,
-- https://github.com/equinor/ert/blob/master/docs/rst/manual/reference/configuration/observations.rst

SUMMARY_OBSERVATION SEP_TEST_2005
Expand All @@ -8,6 +8,14 @@
DATE = 21/08/2005;
KEY = GOPR:BRENT;
};
-- Duplicate key, but unique label and date.
SUMMARY_OBSERVATION SEP_TEST_2006
{
VALUE = 100.0;
ERROR = 5;
DATE = 21/08/2006;
KEY = GOPR:BRENT;
};

-- Giving the observation time in terms of restart number.
SUMMARY_OBSERVATION SEP_TEST_RST_2005
Expand Down
4 changes: 4 additions & 0 deletions tests/testdata_fmuobs/ert-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ smry:
error: 5.0
label: SEP_TEST_2005
value: 100.0
- date: '2006-08-21'
error: 5.0
label: SEP_TEST_2006
value: 100.0
- error: 5.0
label: SEP_TEST_RST_2005
restart: 42.0
Expand Down
1 change: 1 addition & 0 deletions tests/testdata_fmuobs/ri-obs.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
DATE;VECTOR;VALUE;ERROR
2005-08-21;GOPR:BRENT;100.0;5.0
2006-08-21;GOPR:BRENT;100.0;5.0