Skip to content

Commit 2142fc5

Browse files
authored
Add unique index to label in fmuobs when converting from ResInsight format to be ERT compatible (#636)
1 parent d0f04a1 commit 2142fc5

File tree

5 files changed

+20
-2
lines changed

5 files changed

+20
-2
lines changed

src/subscript/fmuobs/parsers.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,11 @@ def resinsight_df2df(ri_dframe: pd.DataFrame) -> pd.DataFrame:
462462

463463
dframe = ri_dframe.copy()
464464
dframe.rename({"VECTOR": "KEY"}, axis="columns", inplace=True)
465-
dframe["LABEL"] = dframe["KEY"].astype(str) # + "-" + dframe["DATE"].astype(str)
465+
dframe["LABEL"] = (
466+
dframe["KEY"].astype(str)
467+
+ "-"
468+
+ (dframe.groupby("KEY").cumcount() + 1).astype(str)
469+
)
466470
dframe["CLASS"] = "SUMMARY_OBSERVATION"
467471
if "DATE" in dframe:
468472
dframe["DATE"] = pd.to_datetime(dframe["DATE"])

tests/testdata_fmuobs/ert-doc.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
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
22
SUMMARY_OBSERVATION,SEP_TEST_2005,100.0,5.0,2005-08-21,GOPR:BRENT,,,,,,,,,,,,,,,,
3+
SUMMARY_OBSERVATION,SEP_TEST_2006,100.0,5.0,2006-08-21,GOPR:BRENT,,,,,,,,,,,,,,,,
34
SUMMARY_OBSERVATION,SEP_TEST_RST_2005,100.0,5.0,,GOPR:BRENT,42.0,,,,,,,,,,,,,,,
45
SUMMARY_OBSERVATION,SEP_TEST_2008,213.0,10.0,,GOPR:NESS,,911.0,,,,,,,,,,,,,,
56
BLOCK_OBSERVATION,RFT_2006,100.0,5.0,2006-10-22,,,,P1,PRESSURE,1.0,1.0,1.0,,,,,,,,,

tests/testdata_fmuobs/ert-doc.obs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- These observation data are copied from the ERT docs,
1+
-- These observation data are mainly copied from the ERT docs,
22
-- https://github.com/equinor/ert/blob/master/docs/rst/manual/reference/configuration/observations.rst
33

44
SUMMARY_OBSERVATION SEP_TEST_2005
@@ -8,6 +8,14 @@
88
DATE = 21/08/2005;
99
KEY = GOPR:BRENT;
1010
};
11+
-- Duplicate key, but unique label and date.
12+
SUMMARY_OBSERVATION SEP_TEST_2006
13+
{
14+
VALUE = 100.0;
15+
ERROR = 5;
16+
DATE = 21/08/2006;
17+
KEY = GOPR:BRENT;
18+
};
1119

1220
-- Giving the observation time in terms of restart number.
1321
SUMMARY_OBSERVATION SEP_TEST_RST_2005

tests/testdata_fmuobs/ert-doc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ smry:
5353
error: 5.0
5454
label: SEP_TEST_2005
5555
value: 100.0
56+
- date: '2006-08-21'
57+
error: 5.0
58+
label: SEP_TEST_2006
59+
value: 100.0
5660
- error: 5.0
5761
label: SEP_TEST_RST_2005
5862
restart: 42.0

tests/testdata_fmuobs/ri-obs.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
DATE;VECTOR;VALUE;ERROR
22
2005-08-21;GOPR:BRENT;100.0;5.0
3+
2006-08-21;GOPR:BRENT;100.0;5.0

0 commit comments

Comments
 (0)