Skip to content

Commit

Permalink
modified output of scaling function for QC purpose
Browse files Browse the repository at this point in the history
  • Loading branch information
oddvarlia committed Oct 29, 2023
1 parent aa7ab86 commit def119e
Showing 1 changed file with 45 additions and 22 deletions.
67 changes: 45 additions & 22 deletions semeio/workflows/localisation/local_script_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from ecl.util.geometry import Surface
from ert.analysis.row_scaling import RowScaling
from ert.config import Field, GenDataConfig, GenKwConfig, SurfaceConfig
from ert.field_utils import save_field
from ert.field_utils.field_file_format import FieldFileFormat
from numpy import ma

from semeio.workflows.localisation.localisation_debug_settings import (
Expand Down Expand Up @@ -932,35 +934,56 @@ def write_qc_parameter(
grid,
param_for_field,
log_level=LogLevel.OFF,
file_format=FieldFileFormat.GRDECL,
):
# pylint: disable=too-many-arguments

if param_for_field is None or field_scale is None:
return

scaling_values = np.reshape(
param_for_field, (grid.getNX(), grid.getNY(), grid.getNZ()), "F"
# Write scaling parameter once per corr_name
if corr_name == cls.corr_name:
return

cls.corr_name = corr_name

# Need a parameter name <= 8 character long for GRDECL format
scaling_kw_name = "S_" + str(cls.scaling_param_number)
file_name_without_suffix = (
cls.corr_name + "_" + node_name + "_" + scaling_kw_name
)

# Write scaling parameter once per corr_name
if corr_name != cls.corr_name:
cls.corr_name = corr_name
# Need a parameter name <= 8 character long
scaling_kw_name = "S_" + str(cls.scaling_param_number)
scaling_kw = grid.create_kw(scaling_values, scaling_kw_name, False)
filename = (
cls.corr_name + "_" + node_name + "_" + scaling_kw_name + ".GRDECL"
)
print(
"Write calculated scaling factor with name: "
f"{scaling_kw_name} to file: {filename}"
)
debug_print(
f"Write calculated scaling factor with name: "
f"{scaling_kw_name} to file: {filename}",
LogLevel.LEVEL3,
log_level,
if file_format.upper() == FieldFileFormat.GRDECL:
scaling_values = np.reshape(
param_for_field, (grid.getNX(), grid.getNY(), grid.getNZ()), "F"
)

scaling_kw = grid.create_kw(scaling_values, scaling_kw_name, False)
filename = file_name_without_suffix + ".GRDECL"

with cwrap.open(filename, "w") as file:
grid.write_grdecl(scaling_kw, file)
# Increase parameter number to define unique parameter name
cls.scaling_param_number = cls.scaling_param_number + 1
# For testing
name = scaling_kw_name + "_use_save_field"
save_field(scaling_values, name, filename, FieldFileFormat.GRDECL)

elif file_format.upper() == FieldFileFormat.ROFF:
scaling_values = np.reshape(
param_for_field, (grid.getNX(), grid.getNY(), grid.getNZ()), "C"
)
filename = file_name_without_suffix + ".roff"
save_field(scaling_values, scaling_kw_name, filename, FieldFileFormat.ROFF)

print(
"Write calculated scaling factor with name: "
f"{scaling_kw_name} to file: {filename}"
)
debug_print(
f"Write calculated scaling factor with name: "
f"{scaling_kw_name} to file: {filename}",
LogLevel.LEVEL3,
log_level,
)

# Increase parameter number to define unique parameter name
cls.scaling_param_number = cls.scaling_param_number + 1

0 comments on commit def119e

Please sign in to comment.