Skip to content

Commit

Permalink
Merge pull request #20 from daavid00/deb
Browse files Browse the repository at this point in the history
Option for faults
  • Loading branch information
daavid00 authored Oct 10, 2024
2 parents 16a2f2c + bc302e4 commit de5bd0e
Show file tree
Hide file tree
Showing 6 changed files with 286 additions and 168 deletions.
2 changes: 1 addition & 1 deletion src/plopm/core/plopm.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def load_parser():
"--variable",
default="poro,permx,permz,porv,fipnum,satnum",
help="Specify the name of the vairable to plot, e.g., 'pressure', in "
"addition to special variables such as 'grid', 'wells', "
"addition to special variables such as 'grid', 'wells', 'faults', "
"'gasm', 'dism', 'liqm', 'vapm', 'co2m', 'h2om', 'xco2l', 'xh2ov', "
"'xco2v', 'xh2ol', 'fwcdm', and 'fgipm', as well as operations, e.g "
"'pressure - 0pressure' to plot the pressure increase "
Expand Down
8 changes: 4 additions & 4 deletions src/plopm/utils/initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def ini_dic(cmdargs):
dic["rm"] = (cmdargs["remove"].strip()).split(",")
dic["rm"] = [int(val) for val in dic["rm"]]
dic["tunits"] = (cmdargs["tunits"].strip()).split(",")
# dic["skl"] = float(cmdargs["adjust"])
dic["avar"] = (cmdargs["adjust"].strip()).split(",")
dic["axgrid"] = (cmdargs["axgrid"].strip()).split(",")
dic["dpi"] = (cmdargs["dpi"].strip()).split(",")
Expand All @@ -101,7 +100,7 @@ def ini_dic(cmdargs):
dic["cbsfax"] = [float(val) for val in (cmdargs["cbsfax"].strip()).split(",")]
for i in ["x", "y"]:
dic[f"{i}units"] = cmdargs[f"{i}units"].strip()
dic[f"{i}label"] = (cmdargs[f"{i}label"].strip()).split(" ")
dic[f"{i}label"] = (cmdargs[f"{i}label"].strip()).split(" ")
dic[f"{i}format"] = (cmdargs[f"{i}format"].strip()).split(",")
dic[f"{i}lnum"] = (cmdargs[f"{i}lnum"].strip()).split(",")
dic[f"{i}log"] = (cmdargs[f"{i}log"].strip()).split(",")
Expand All @@ -113,6 +112,7 @@ def ini_dic(cmdargs):
"vsum",
"time",
"wells",
"faults",
]:
dic[name] = []
dic["dtitle"] = ""
Expand Down Expand Up @@ -394,8 +394,8 @@ def ini_properties(dic):
dic["cmaps"] = ["RdYlGn"]
elif dic["mask"]:
dic["cmaps"] = ["RdGy_r"]
if dic["vrs"]: # dic["well"] == 1
if dic["vrs"][0] == "wells":
if dic["vrs"]:
if dic["vrs"][0] == "wells" or dic["vrs"][0] == "faults" and not dic["colors"]:
dic["units"] = [" [-]"]
dic["cmaps"] = ["nipy_spectral"]
dic["cformat"] = [".0f"]
Expand Down
227 changes: 117 additions & 110 deletions src/plopm/utils/mapping.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2024 NORCE
# SPDX-License-Identifier: GPL-3.0
# pylint: disable=R1702,R0912
# pylint: disable=R1702,R0912,C0325

"""
Utiliy function for the grid and locations in the geological models.
Expand Down Expand Up @@ -34,9 +34,6 @@ def handle_slide_x(dic, n):
else:
dic["tslide"] = f", slide i={dic['slide'][n][0][0]+1}:{dic['slide'][n][0][1]}"
dic["nslide"] = f"{dic['slide'][n][0][0]+1}:{dic['slide'][n][0][1]},*,*"
for well in reversed(dic["wells"]):
if well[0] != dic["slide"][n][0][0]:
dic["wells"].remove(well)
if dic["use"] == "resdata":
get_yzcoords_resdata(dic, n)
else:
Expand All @@ -60,9 +57,6 @@ def handle_slide_y(dic, n):
else:
dic["tslide"] = f", slide j={dic['slide'][n][1][0]+1}:{dic['slide'][n][1][1]}"
dic["nslide"] = f"*,{dic['slide'][n][1][0]+1}:{dic['slide'][n][1][1]},*"
for well in reversed(dic["wells"]):
if well[1] != dic["slide"][n][1][0]:
dic["wells"].remove(well)
if dic["use"] == "resdata":
get_xzcoords_resdata(dic, n)
else:
Expand All @@ -86,9 +80,6 @@ def handle_slide_z(dic, n):
else:
dic["tslide"] = f", slide k={dic['slide'][n][2][0]+1}:{dic['slide'][n][2][1]}"
dic["nslide"] = f"*,*,{dic['slide'][n][2][0]+1}:{dic['slide'][n][2][1]}"
for well in reversed(dic["wells"]):
if dic["slide"][n][2][0] not in range(well[2], well[3] + 1):
dic["wells"].remove(well)
if dic["use"] == "resdata":
get_xycoords_resdata(dic, n)
else:
Expand Down Expand Up @@ -145,43 +136,48 @@ def map_xzcoords(dic, var, quan, n):
"""
for k in range(dic["nz"]):
for i in range(dic["nx"]):
ind = i + dic["slide"][n][1][0] * dic["nx"] + k * dic["nx"] * dic["ny"]
if var.lower() == "grid":
p_v, val = 0.0, 0.0
for sld in range(dic["slide"][n][1][0], dic["slide"][n][1][1]):
ind = i + sld * dic["nx"] + k * dic["nx"] * dic["ny"]
if dic["porv"][ind] > 0:
dic["grida"][2 * i + 2 * (dic["nz"] - k - 1) * dic["mx"]] = 1
elif var.lower() == "wells":
if dic["porv"][ind] > 0:
dic["wellsa"][2 * i + 2 * (dic["nz"] - k - 1) * dic["mx"]] = len(
dic["wells"]
)
elif var.lower() == "index_i":
if dic["porv"][ind] > 0:
dic["index_ia"][2 * i + 2 * (dic["nz"] - k - 1) * dic["mx"]] = i
elif var.lower() == "index_j":
if dic["porv"][ind] > 0:
dic["index_ja"][2 * i + 2 * (dic["nz"] - k - 1) * dic["mx"]] = dic[
"slide"
][n][1][0]
elif var.lower() == "index_k":
if dic["porv"][ind] > 0:
dic["index_ka"][2 * i + 2 * (dic["nz"] - k - 1) * dic["mx"]] = k
else:
p_v, val = 0.0, 0.0
for sld in range(dic["slide"][n][1][0], dic["slide"][n][1][1]):
ind = i + sld * dic["nx"] + k * dic["nx"] * dic["ny"]
if dic["porv"][ind] > 0:
if var.lower() in dic["mass"]:
p_v = 1.0
val += quan[dic["actind"][ind]]
else:
p_v += dic["porv"][ind]
val += quan[dic["actind"][ind]] * dic["porv"][ind]
dic[var + "a"][2 * i + 2 * (dic["nz"] - k - 1) * dic["mx"]] = (
np.nan if p_v == 0 else val / p_v
)
if var.lower() in dic["mass"] or var.lower() == "porv":
p_v = 1.0
val += quan[dic["actind"][ind]]
elif var.lower() == "grid":
p_v = 1
val = 1
elif var.lower() == "wells":
p_v = 1
val = len(dic["wells"])
elif var.lower() == "index_i":
p_v = 1
val = i
elif var.lower() == "index_j":
p_v = 1
val = sld
elif var.lower() == "index_k":
p_v = 1
val = k
elif var.lower() == "faults":
p_v = 1
val = dic["nfaults"]
else:
p_v += dic["porv"][ind]
val += quan[dic["actind"][ind]] * dic["porv"][ind]
dic[var + "a"][2 * i + 2 * (dic["nz"] - k - 1) * dic["mx"]] = (
np.nan if p_v == 0 else val / p_v
)
for i, well in enumerate(dic["wells"]):
for k in range(well[2], well[3] + 1):
dic["wellsa"][2 * well[0] + 2 * (dic["nz"] - k - 1) * dic["mx"]] = i
if well:
for k in range(well[2], well[3] + 1):
dic["wellsa"][2 * well[0] + 2 * (dic["nz"] - k - 1) * dic["mx"]] = i
for i, faults in enumerate(dic["faults"]):
for fault in faults:
if fault:
for k in range(fault[2], fault[3] + 1):
dic["faultsa"][
2 * fault[0] + 2 * (dic["nz"] - k - 1) * dic["mx"]
] = (i + 1)


def map_yzcoords(dic, var, quan, n):
Expand All @@ -197,43 +193,48 @@ def map_yzcoords(dic, var, quan, n):
"""
for k in range(dic["nz"]):
for j in range(dic["ny"]):
ind = dic["slide"][n][0][0] + j * dic["nx"] + k * dic["nx"] * dic["ny"]
if var.lower() == "grid":
if dic["porv"][ind] > 0:
dic["grida"][2 * j + 2 * (dic["nz"] - k - 1) * dic["mx"]] = 1
elif var.lower() == "wells":
if dic["porv"][ind] > 0:
dic["wellsa"][2 * j + 2 * (dic["nz"] - k - 1) * dic["mx"]] = len(
dic["wells"]
)
elif var.lower() == "index_i":
if dic["porv"][ind] > 0:
dic[var + "a"][2 * j + 2 * (dic["nz"] - k - 1) * dic["mx"]] = dic[
"slide"
][n][0][0]
elif var.lower() == "index_j":
p_v, val = 0.0, 0.0
for sld in range(dic["slide"][n][0][0], dic["slide"][n][0][1]):
ind = sld + j * dic["nx"] + k * dic["nx"] * dic["ny"]
if dic["porv"][ind] > 0:
dic[var + "a"][2 * j + 2 * (dic["nz"] - k - 1) * dic["mx"]] = j
elif var.lower() == "index_k":
if dic["porv"][ind] > 0:
dic[var + "a"][2 * j + 2 * (dic["nz"] - k - 1) * dic["mx"]] = k
else:
p_v, val = 0.0, 0.0
for sld in range(dic["slide"][n][0][0], dic["slide"][n][0][1]):
ind = sld + j * dic["nx"] + k * dic["nx"] * dic["ny"]
if dic["porv"][ind] > 0:
if var.lower() in dic["mass"]:
p_v = 1.0
val += quan[dic["actind"][ind]]
else:
p_v += dic["porv"][ind]
val += quan[dic["actind"][ind]] * dic["porv"][ind]
dic[var + "a"][2 * j + 2 * (dic["nz"] - k - 1) * dic["mx"]] = (
np.nan if p_v == 0 else val / p_v
)
if var.lower() in dic["mass"] or var.lower() == "porv":
p_v = 1.0
val += quan[dic["actind"][ind]]
elif var.lower() == "grid":
p_v = 1
val = 1
elif var.lower() == "wells":
p_v = 1
val = len(dic["wells"])
elif var.lower() == "index_i":
p_v = 1
val = sld
elif var.lower() == "index_j":
p_v = 1
val = j
elif var.lower() == "index_k":
p_v = 1
val = k
elif var.lower() == "faults":
p_v = 1
val = dic["nfaults"]
else:
p_v += dic["porv"][ind]
val += quan[dic["actind"][ind]] * dic["porv"][ind]
dic[var + "a"][2 * j + 2 * (dic["nz"] - k - 1) * dic["mx"]] = (
np.nan if p_v == 0 else val / p_v
)
for i, well in enumerate(dic["wells"]):
for k in range(well[2], well[3] + 1):
dic["wellsa"][2 * well[1] + 2 * (dic["nz"] - k - 1) * dic["mx"]] = i
if well:
for k in range(well[2], well[3] + 1):
dic["wellsa"][2 * well[1] + 2 * (dic["nz"] - k - 1) * dic["mx"]] = i
for i, faults in enumerate(dic["faults"]):
for fault in faults:
if fault:
for k in range(fault[2], fault[3] + 1):
dic["faultsa"][
2 * fault[1] + 2 * (dic["nz"] - k - 1) * dic["mx"]
] = (i + 1)


def map_xycoords(dic, var, quan, n):
Expand All @@ -249,35 +250,41 @@ def map_xycoords(dic, var, quan, n):
"""
for j in range(dic["ny"]):
for i in range(dic["nx"]):
ind = i + j * dic["nx"] + dic["slide"][n][2][0] * dic["nx"] * dic["ny"]
if var.lower() == "grid":
if dic["porv"][ind] > 0:
dic["grida"][2 * i + 2 * j * dic["mx"]] = 1
elif var.lower() == "wells":
if dic["porv"][ind] > 0:
dic["wellsa"][2 * i + 2 * j * dic["mx"]] = len(dic["wells"])
elif var.lower() == "index_i":
p_v, val = 0.0, 0.0
for sld in range(dic["slide"][n][2][0], dic["slide"][n][2][1]):
ind = i + j * dic["nx"] + sld * dic["nx"] * dic["ny"]
if dic["porv"][ind] > 0:
dic[var + "a"][2 * i + 2 * j * dic["mx"]] = i
elif var.lower() == "index_j":
if dic["porv"][ind] > 0:
dic[var + "a"][2 * i + 2 * j * dic["mx"]] = j
elif var.lower() == "index_k":
if dic["porv"][ind] > 0:
dic[var + "a"][2 * i + 2 * j * dic["mx"]] = dic["slide"][n][2][0]
else:
p_v, val = 0.0, 0.0
for sld in range(dic["slide"][n][2][0], dic["slide"][n][2][1]):
ind = i + j * dic["nx"] + sld * dic["nx"] * dic["ny"]
if dic["porv"][ind] > 0:
if var.lower() in dic["mass"]:
p_v = 1.0
val += quan[dic["actind"][ind]]
else:
p_v += dic["porv"][ind]
val += quan[dic["actind"][ind]] * dic["porv"][ind]
dic[var + "a"][2 * i + 2 * j * dic["mx"]] = (
np.nan if p_v == 0 else val / p_v
)
if var.lower() in dic["mass"] or var.lower() == "porv":
p_v = 1.0
val += quan[dic["actind"][ind]]
elif var.lower() == "grid":
p_v = 1
val = 1
elif var.lower() == "wells":
p_v = 1
val = len(dic["wells"])
elif var.lower() == "index_i":
p_v = 1
val = i
elif var.lower() == "index_j":
p_v = 1
val = j
elif var.lower() == "index_k":
p_v = 1
val = sld
elif var.lower() == "faults":
p_v = 1
val = dic["nfaults"]
else:
p_v += dic["porv"][ind]
val += quan[dic["actind"][ind]] * dic["porv"][ind]
dic[var + "a"][2 * i + 2 * j * dic["mx"]] = (
np.nan if p_v == 0 else val / p_v
)
for i, well in enumerate(dic["wells"]):
dic["wellsa"][2 * well[0] + 2 * well[1] * dic["mx"]] = i
if well:
dic["wellsa"][2 * well[0] + 2 * well[1] * dic["mx"]] = i
for i, faults in enumerate(dic["faults"]):
for fault in faults:
if fault:
dic["faultsa"][2 * fault[0] + 2 * fault[1] * dic["mx"]] = i + 1
Loading

0 comments on commit de5bd0e

Please sign in to comment.