Skip to content

Commit

Permalink
Add script to generate new petro logs from original logs
Browse files Browse the repository at this point in the history
Added test and testdata
  • Loading branch information
oddvarlia committed Dec 10, 2024
1 parent 3b001d3 commit 5d9c62d
Show file tree
Hide file tree
Showing 6 changed files with 523 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/fmu/tools/rms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
Processing of volumetrics from RMS
"""

from .generate_bw_per_facies import create_bw_per_facies
from .import_localmodules import import_localmodule
from .volumetrics import rmsvolumetrics_txt2df

__all__ = ["rmsvolumetrics_txt2df", "import_localmodule"]
__all__ = ["rmsvolumetrics_txt2df", "import_localmodule", "create_bw_per_facies"]
121 changes: 121 additions & 0 deletions src/fmu/tools/rms/generate_bw_per_facies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import copy
from typing import Dict, List

import numpy as np
import xtgeo


def create_bw_per_facies(
project,
grid_name: str,
bw_name: str,
original_petro_log_names: List[str],
facies_log_name: str,
facies_code_names: Dict[int, str],
debug_print: bool = False,
) -> None:
"""Script to be used as RMS python job to create new petrophysical
logs from original logs, but with one log per facies.
All grid blocks for the blocked wells not belonging to the facies
is set to undefined.
Purpose
Create the blocked well logs to be used to condition
petrophysical realizations where all grid cells are
assumed to belong to only one facies. This script will
not modify any of the original logs, only create new logs where only
petrophysical log values for one facies is selected
and all other are set ot undefined.
Input
grid model name,
blocked well set name,
list of original log names to use,
facies log name,
facies code with facies name dictionary
Output
One new petro log per facies per petro variables in the
input list of original log names. The output will be saved in
the given blocked well set specified in the input.
"""

if debug_print:
print(f"Petro lognames to use: {original_petro_log_names}")
print(f"Facies logname: {facies_log_name}")
original_log_names = copy.copy(original_petro_log_names)
original_log_names.append(facies_log_name)
bw = xtgeo.blockedwells_from_roxar(
project, grid_name, bw_name, lognames=original_log_names
)

for well in bw.wells:
if debug_print:
print(f"Wellname: {well.name}")

# Update the new logs by only keeping petro variables
# belonging to the current facies
df = well.get_dataframe()
new_log_names = []
for facies_code, fname in facies_code_names.items():
filtered_rows = df[facies_log_name] != int(facies_code)
for petro_name in original_petro_log_names:
if petro_name in well.lognames:
new_log_name = fname + "_" + petro_name
well.create_log(new_log_name)

df[new_log_name] = df[petro_name]
df[new_log_name][filtered_rows] = np.nan
if debug_print:
print(f" Create new log: {new_log_name}")
new_log_names.append(new_log_name)

well.set_dataframe(df)
if debug_print:
print(f"Well: {well.name}")
print(f"All logs: {well.lognames_all}")
print("Dataframe for facies log and new logs:")
df_updated = well.get_dataframe()
selected_log_names = []
selected_log_names.append(facies_log_name)
selected_log_names.extend(new_log_names)
print(f"{df_updated[selected_log_names]}")
print("-" * 100)
print(f"Create new logs for well {well.name}: {new_log_names}")
well.to_roxar(
project,
grid_name,
bw_name,
well.name,
lognames=new_log_names,
update_option="overwrite",
)


if __name__ == "__main__":
DEBUG_PRINT = False
PRJ = project # noqa
GRID_MODEL = "Geogrid_Valysar"
BW_SET = "BW_copy"
ORIGINAL_PETRO_LOGS = ["PHIT", "KLOGH"]
FACIES_LOG = "Facies"
FACIES_CODE_NAMES = {
0: "Floodplain",
1: "Channel",
2: "Crevasse",
5: "Coal",
}

create_bw_per_facies(
PRJ,
GRID_MODEL,
BW_SET,
ORIGINAL_PETRO_LOGS,
FACIES_LOG,
FACIES_CODE_NAMES,
debug_print=DEBUG_PRINT,
)
37 changes: 37 additions & 0 deletions tests/rms/generate_bw_testdata/Wtest_0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
1.0
Unknown
Wtest_0 None None 100.0
13
I_INDEX CONT linear
J_INDEX CONT linear
K_INDEX CONT linear
ZONELOG DISC 1 Zone1 2 Zone2 3 Zone3
PORO CONT linear
PERM CONT linear
FACIES DISC 0 F1 1 F2 2 F3
F1_PORO CONT linear
F1_PERM CONT linear
F2_PORO CONT linear
F2_PERM CONT linear
F3_PORO CONT linear
F3_PERM CONT linear
125.0000 125.0000 1002.5000 0.0000 0.0000 0.0000 1 0.1816 162.5061 0 0.1816 162.5061 -999.0000 -999.0000 -999.0000 -999.0000
125.0000 125.0000 1007.5000 0.0000 0.0000 1.0000 1 0.1816 162.5061 0 0.1816 162.5061 -999.0000 -999.0000 -999.0000 -999.0000
125.0000 125.0000 1012.5000 0.0000 0.0000 2.0000 1 0.1184 37.4939 1 -999.0000 -999.0000 0.1184 37.4939 -999.0000 -999.0000
125.0000 125.0000 1017.5000 0.0000 0.0000 3.0000 1 0.1184 37.4939 0 0.1184 37.4939 -999.0000 -999.0000 -999.0000 -999.0000
125.0000 125.0000 1022.5000 0.0000 0.0000 4.0000 1 0.1816 162.5061 0 0.1816 162.5061 -999.0000 -999.0000 -999.0000 -999.0000
125.0000 125.0000 1027.5000 0.0000 0.0000 5.0000 1 0.1816 162.5061 1 -999.0000 -999.0000 0.1816 162.5061 -999.0000 -999.0000
125.0000 125.0000 1032.5000 0.0000 0.0000 6.0000 1 0.1184 37.4939 0 0.1184 37.4939 -999.0000 -999.0000 -999.0000 -999.0000
125.0000 125.0000 1037.5000 0.0000 0.0000 7.0000 2 0.1184 37.4939 0 0.1184 37.4939 -999.0000 -999.0000 -999.0000 -999.0000
125.0000 125.0000 1042.5000 0.0000 0.0000 8.0000 2 0.1816 162.5061 1 -999.0000 -999.0000 0.1816 162.5061 -999.0000 -999.0000
125.0000 125.0000 1047.5000 0.0000 0.0000 9.0000 2 0.1816 162.5061 0 0.1816 162.5061 -999.0000 -999.0000 -999.0000 -999.0000
125.0000 125.0000 1052.5000 0.0000 0.0000 10.0000 2 0.1184 37.4939 0 0.1184 37.4939 -999.0000 -999.0000 -999.0000 -999.0000
125.0000 125.0000 1057.5000 0.0000 0.0000 11.0000 2 0.1184 37.4939 1 -999.0000 -999.0000 0.1184 37.4939 -999.0000 -999.0000
125.0000 125.0000 1062.5000 0.0000 0.0000 12.0000 2 0.1816 162.5061 0 0.1816 162.5061 -999.0000 -999.0000 -999.0000 -999.0000
125.0000 125.0000 1067.5000 0.0000 0.0000 13.0000 3 0.1816 162.5061 0 0.1816 162.5061 -999.0000 -999.0000 -999.0000 -999.0000
125.0000 125.0000 1072.5000 0.0000 0.0000 14.0000 3 0.1184 37.4939 1 -999.0000 -999.0000 0.1184 37.4939 -999.0000 -999.0000
125.0000 125.0000 1077.5000 0.0000 0.0000 15.0000 3 0.1184 37.4939 0 0.1184 37.4939 -999.0000 -999.0000 -999.0000 -999.0000
125.0000 125.0000 1082.5000 0.0000 0.0000 16.0000 3 0.1816 162.5061 0 0.1816 162.5061 -999.0000 -999.0000 -999.0000 -999.0000
125.0000 125.0000 1087.5000 0.0000 0.0000 17.0000 3 0.1816 162.5061 1 -999.0000 -999.0000 0.1816 162.5061 -999.0000 -999.0000
125.0000 125.0000 1092.5000 0.0000 0.0000 18.0000 3 0.1184 37.4939 0 0.1184 37.4939 -999.0000 -999.0000 -999.0000 -999.0000
125.0000 125.0000 1097.5000 0.0000 0.0000 19.0000 3 0.1125 25.6914 2 -999.0000 -999.0000 -999.0000 -999.0000 0.1125 25.6914
37 changes: 37 additions & 0 deletions tests/rms/generate_bw_testdata/Wtest_1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
1.0
Unknown
Wtest_1 None None 100.0
13
I_INDEX CONT linear
J_INDEX CONT linear
K_INDEX CONT linear
ZONELOG DISC 1 Zone1 2 Zone2 3 Zone3
PORO CONT linear
PERM CONT linear
FACIES DISC 0 F1 1 F2 2 F3
F1_PORO CONT linear
F1_PERM CONT linear
F2_PORO CONT linear
F2_PERM CONT linear
F3_PORO CONT linear
F3_PERM CONT linear
875.0000 875.0000 1002.5000 3.0000 3.0000 0.0000 1 0.1816 162.5061 0 0.1816 162.5061 -999.0000 -999.0000 -999.0000 -999.0000
875.0000 875.0000 1007.5000 3.0000 3.0000 1.0000 1 0.1816 162.5061 0 0.1816 162.5061 -999.0000 -999.0000 -999.0000 -999.0000
875.0000 875.0000 1012.5000 3.0000 3.0000 2.0000 1 0.1184 37.4939 1 -999.0000 -999.0000 0.1184 37.4939 -999.0000 -999.0000
875.0000 875.0000 1017.5000 3.0000 3.0000 3.0000 1 0.1184 37.4939 0 0.1184 37.4939 -999.0000 -999.0000 -999.0000 -999.0000
875.0000 875.0000 1022.5000 3.0000 3.0000 4.0000 1 0.1816 162.5061 0 0.1816 162.5061 -999.0000 -999.0000 -999.0000 -999.0000
875.0000 875.0000 1027.5000 3.0000 3.0000 5.0000 1 0.1816 162.5061 1 -999.0000 -999.0000 0.1816 162.5061 -999.0000 -999.0000
875.0000 875.0000 1032.5000 3.0000 3.0000 6.0000 1 0.1184 37.4939 0 0.1184 37.4939 -999.0000 -999.0000 -999.0000 -999.0000
875.0000 875.0000 1037.5000 3.0000 3.0000 7.0000 2 0.1184 37.4939 0 0.1184 37.4939 -999.0000 -999.0000 -999.0000 -999.0000
875.0000 875.0000 1042.5000 3.0000 3.0000 8.0000 2 0.1816 162.5061 1 -999.0000 -999.0000 0.1816 162.5061 -999.0000 -999.0000
875.0000 875.0000 1047.5000 3.0000 3.0000 9.0000 2 0.1816 162.5061 0 0.1816 162.5061 -999.0000 -999.0000 -999.0000 -999.0000
875.0000 875.0000 1052.5000 3.0000 3.0000 10.0000 2 0.1184 37.4939 0 0.1184 37.4939 -999.0000 -999.0000 -999.0000 -999.0000
875.0000 875.0000 1057.5000 3.0000 3.0000 11.0000 2 0.1184 37.4939 1 -999.0000 -999.0000 0.1184 37.4939 -999.0000 -999.0000
875.0000 875.0000 1062.5000 3.0000 3.0000 12.0000 2 0.1816 162.5061 0 0.1816 162.5061 -999.0000 -999.0000 -999.0000 -999.0000
875.0000 875.0000 1067.5000 3.0000 3.0000 13.0000 3 0.1816 162.5061 0 0.1816 162.5061 -999.0000 -999.0000 -999.0000 -999.0000
875.0000 875.0000 1072.5000 3.0000 3.0000 14.0000 3 0.1184 37.4939 1 -999.0000 -999.0000 0.1184 37.4939 -999.0000 -999.0000
875.0000 875.0000 1077.5000 3.0000 3.0000 15.0000 3 0.1184 37.4939 0 0.1184 37.4939 -999.0000 -999.0000 -999.0000 -999.0000
875.0000 875.0000 1082.5000 3.0000 3.0000 16.0000 3 0.1816 162.5061 0 0.1816 162.5061 -999.0000 -999.0000 -999.0000 -999.0000
875.0000 875.0000 1087.5000 3.0000 3.0000 17.0000 3 0.1816 162.5061 1 -999.0000 -999.0000 0.1816 162.5061 -999.0000 -999.0000
875.0000 875.0000 1092.5000 3.0000 3.0000 18.0000 3 0.1184 37.4939 0 0.1184 37.4939 -999.0000 -999.0000 -999.0000 -999.0000
875.0000 875.0000 1097.5000 3.0000 3.0000 19.0000 3 0.1125 25.6914 2 -999.0000 -999.0000 -999.0000 -999.0000 0.1125 25.6914
37 changes: 37 additions & 0 deletions tests/rms/generate_bw_testdata/Wtest_2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
1.0
Unknown
Wtest_2 None None 100.0
13
I_INDEX CONT linear
J_INDEX CONT linear
K_INDEX CONT linear
ZONELOG DISC 1 Zone1 2 Zone2 3 Zone3
PORO CONT linear
PERM CONT linear
FACIES DISC 0 F1 1 F2 2 F3
F1_PORO CONT linear
F1_PERM CONT linear
F2_PORO CONT linear
F2_PERM CONT linear
F3_PORO CONT linear
F3_PERM CONT linear
1625.0000 1625.0000 1002.5000 6.0000 6.0000 0.0000 1 0.1816 162.5061 0 0.1816 162.5061 -999.0000 -999.0000 -999.0000 -999.0000
1625.0000 1625.0000 1007.5000 6.0000 6.0000 1.0000 1 0.1816 162.5061 0 0.1816 162.5061 -999.0000 -999.0000 -999.0000 -999.0000
1625.0000 1625.0000 1012.5000 6.0000 6.0000 2.0000 1 0.1184 37.4939 1 -999.0000 -999.0000 0.1184 37.4939 -999.0000 -999.0000
1625.0000 1625.0000 1017.5000 6.0000 6.0000 3.0000 1 0.1184 37.4939 0 0.1184 37.4939 -999.0000 -999.0000 -999.0000 -999.0000
1625.0000 1625.0000 1022.5000 6.0000 6.0000 4.0000 1 0.1816 162.5061 0 0.1816 162.5061 -999.0000 -999.0000 -999.0000 -999.0000
1625.0000 1625.0000 1027.5000 6.0000 6.0000 5.0000 1 0.1816 162.5061 1 -999.0000 -999.0000 0.1816 162.5061 -999.0000 -999.0000
1625.0000 1625.0000 1032.5000 6.0000 6.0000 6.0000 1 0.1184 37.4939 0 0.1184 37.4939 -999.0000 -999.0000 -999.0000 -999.0000
1625.0000 1625.0000 1037.5000 6.0000 6.0000 7.0000 2 0.1184 37.4939 0 0.1184 37.4939 -999.0000 -999.0000 -999.0000 -999.0000
1625.0000 1625.0000 1042.5000 6.0000 6.0000 8.0000 2 0.1816 162.5061 1 -999.0000 -999.0000 0.1816 162.5061 -999.0000 -999.0000
1625.0000 1625.0000 1047.5000 6.0000 6.0000 9.0000 2 0.1816 162.5061 0 0.1816 162.5061 -999.0000 -999.0000 -999.0000 -999.0000
1625.0000 1625.0000 1052.5000 6.0000 6.0000 10.0000 2 0.1184 37.4939 0 0.1184 37.4939 -999.0000 -999.0000 -999.0000 -999.0000
1625.0000 1625.0000 1057.5000 6.0000 6.0000 11.0000 2 0.1184 37.4939 1 -999.0000 -999.0000 0.1184 37.4939 -999.0000 -999.0000
1625.0000 1625.0000 1062.5000 6.0000 6.0000 12.0000 2 0.1816 162.5061 0 0.1816 162.5061 -999.0000 -999.0000 -999.0000 -999.0000
1625.0000 1625.0000 1067.5000 6.0000 6.0000 13.0000 3 0.1816 162.5061 0 0.1816 162.5061 -999.0000 -999.0000 -999.0000 -999.0000
1625.0000 1625.0000 1072.5000 6.0000 6.0000 14.0000 3 0.1184 37.4939 1 -999.0000 -999.0000 0.1184 37.4939 -999.0000 -999.0000
1625.0000 1625.0000 1077.5000 6.0000 6.0000 15.0000 3 0.1184 37.4939 0 0.1184 37.4939 -999.0000 -999.0000 -999.0000 -999.0000
1625.0000 1625.0000 1082.5000 6.0000 6.0000 16.0000 3 0.1816 162.5061 0 0.1816 162.5061 -999.0000 -999.0000 -999.0000 -999.0000
1625.0000 1625.0000 1087.5000 6.0000 6.0000 17.0000 3 0.1816 162.5061 1 -999.0000 -999.0000 0.1816 162.5061 -999.0000 -999.0000
1625.0000 1625.0000 1092.5000 6.0000 6.0000 18.0000 3 0.1184 37.4939 0 0.1184 37.4939 -999.0000 -999.0000 -999.0000 -999.0000
1625.0000 1625.0000 1097.5000 6.0000 6.0000 19.0000 3 0.1125 25.6914 2 -999.0000 -999.0000 -999.0000 -999.0000 0.1125 25.6914
Loading

0 comments on commit 5d9c62d

Please sign in to comment.