Skip to content

Commit

Permalink
Various fixed related to fmu-dataio integrations
Browse files Browse the repository at this point in the history
Integrates issues from #83 along with rebasing to main and some other
code fixes
From #83:

When running with config example file example from jriv the example fails when running command:
grid3d_average_map --config \
/project/fmu/tutorial/drogon/resmod/ff/users/jriv/dev/dev_20230426/\
ert/input/config/ecl_avg_map.yml --eclroot eclipse/model/DROGON-0

Fix so that this command runs and produces results as expected.
  • Loading branch information
jcrivenaes committed Sep 29, 2023
1 parent ecbee0e commit 7dfbee6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 31 deletions.
7 changes: 3 additions & 4 deletions src/xtgeoapp_grd3dmaps/avghc/_get_grid_props.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def files_to_import(config, appname):
return gfile, initlist, restartlist, dates


def import_data(_, appname, gfile, initlist, restartlist, dates):
def import_data(appname, gfile, initlist, restartlist, dates):
"""Get the grid and the props data.
Well get the grid and the propsdata for data to be plotted,
zonation (if required), filters (if required)
Expand All @@ -137,9 +137,7 @@ def import_data(_, appname, gfile, initlist, restartlist, dates):
appname(str): Name of application
"""

logger.info("Import data for %s", appname)

# get the grid data + some geometrics
grd = xtgeo.grid_from_file(gfile)

Expand All @@ -159,7 +157,8 @@ def import_data(_, appname, gfile, initlist, restartlist, dates):

initdict = defaultdict(list)
for ipar, ifile in initlist.items():

if ipar == "fmu_global_config":
continue
if isinstance(ifile, dict):
lookfor, usefile = list(ifile.keys()), list(ifile.values())
initdict[usefile[0]].append([ipar, lookfor[0]])
Expand Down
2 changes: 1 addition & 1 deletion src/xtgeoapp_grd3dmaps/avghc/grid3d_average_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def import_pdata(config, gfile, initlist, restartlist, dates):
"""Import the data, and represent datas as numpies"""

grd, initobjects, restobjects, dates = _get_grid_props.import_data(
config, APPNAME, gfile, initlist, restartlist, dates
APPNAME, gfile, initlist, restartlist, dates
)
specd, averaged = _get_grid_props.get_numpies_avgprops(
config, grd, initobjects, restobjects
Expand Down
6 changes: 1 addition & 5 deletions src/xtgeoapp_grd3dmaps/avghc/grid3d_hc_thickness.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@


def do_parse_args(args):

args = _configparser.parse_args(args, APPNAME, APPDESCR)

return args
Expand Down Expand Up @@ -102,7 +101,7 @@ def import_pdata(config, gfile, initlist, restartlist, dates):
"""Import the data, and represent datas as numpies"""

grd, initobjects, restobjects, dates = _get_grid_props.import_data(
config, APPNAME, gfile, initlist, restartlist, dates
APPNAME, gfile, initlist, restartlist, dates
)

# get the numpies
Expand Down Expand Up @@ -145,7 +144,6 @@ def get_zranges(config, grd):


def compute_hcpfz(config, initd, restartd, dates, hcmode, filterarray):

hcpfzd = _compute_hcpfz.get_hcpfz(
config, initd, restartd, dates, hcmode, filterarray
)
Expand Down Expand Up @@ -174,7 +172,6 @@ def plotmap(config, grd, initd, hcpfzd, zonation, zoned, hcmode, filtermean=None


def main(args=None):

XTGeoDialog.print_xtgeo_header(APPNAME, __version__)

xtg.say("Parse command line")
Expand Down Expand Up @@ -218,7 +215,6 @@ def main(args=None):
hcmodelist = [config["computesettings"]["mode"]]

for hcmode in hcmodelist:

xtg.say("Compute HCPFZ property for {}".format(hcmode))
hcpfzd = compute_hcpfz(config, initd, restartd, dates, hcmode, filterarray)

Expand Down
5 changes: 2 additions & 3 deletions src/xtgeoapp_grd3dmaps/contact/_get_grid_props.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# from xtgeo.common.exceptions import KeywordNotFoundError
from xtgeo.common import XTGeoDialog
from xtgeo.common.exceptions import DateNotFoundError, KeywordFoundNoDateError
from xtgeo.grid3d import GridProperties

xtg = XTGeoDialog()

Expand Down Expand Up @@ -64,7 +63,7 @@ def files_to_import(config, appname):
return gfile, initlist, restartlist, dates


def import_data(config, appname, gfile, initlist, restartlist, dates):
def import_data(appname, gfile, initlist, restartlist, dates):
"""Get the grid and the props data.
Well get the grid and the propsdata for data to be plotted,
zonation (if required), filters (if required)
Expand Down Expand Up @@ -132,7 +131,7 @@ def import_data(config, appname, gfile, initlist, restartlist, dates):
usenames.append(usename)

xtg.say("Import <{}> from <{}> ...".format(lookfornames, inifile))
tmp = gridproperties_from_file(
tmp = xtgeo.gridproperties_from_file(
inifile, names=lookfornames, fformat="init", grid=grd
)
for i, name in enumerate(lookfornames):
Expand Down
32 changes: 14 additions & 18 deletions src/xtgeoapp_grd3dmaps/contact/grid3d_contact_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@

from xtgeo.common import XTGeoDialog

from xtgeoapp_grd3dmaps.avghc import _configparser
from xtgeoapp_grd3dmaps.contact import _get_grid_props
from xtgeoapp_grd3dmaps.avghc import _get_zonation_filters
from xtgeoapp_grd3dmaps.contact import _compute_contact
from xtgeoapp_grd3dmaps.avghc import _configparser, _get_zonation_filters
from xtgeoapp_grd3dmaps.contact import _compute_contact, _get_grid_props

try:
from ..theversion import version as __version__
from .._theversion import version as __version__
except ImportError:
__version__ = "0.0.0"


appname = "grid3d_get_contact"
APPNAME = "grid3d_get_contact"

appdescr = (
APPDESCR = (
"Estimate contact maps directly from 3D grids. Docs:\n"
+ "https://fmu-docs.equinor.com/docs/xtgeoapp-grd3dmaps/"
)
Expand All @@ -28,8 +26,7 @@


def do_parse_args(args):

args = _configparser.parse_args(args, appname, appdescr)
args = _configparser.parse_args(args, APPNAME, APPDESCR)

return args

Expand All @@ -39,12 +36,12 @@ def yamlconfig(inputfile, args):
config = _configparser.yconfig(inputfile)

# override with command line args
config = _configparser.yconfig_override(config, args, appname)
config = _configparser.yconfig_override(config, args, APPNAME)

config = _configparser.yconfig_set_defaults(config, appname)
config = _configparser.yconfig_set_defaults(config, APPNAME)

# in case of YAML input (e.g. zonation from file)
config = _configparser.yconfig_addons(config, appname)
config = _configparser.yconfig_addons(config, APPNAME)

logger.info("Updated config:")
for name, val in config.items():
Expand Down Expand Up @@ -85,7 +82,7 @@ def import_pdata(config, appname, gfile, initlist, restartlist, dates):
"""Import the data, and represent datas as numpies"""

grd, initobjects, restobjects, dates = _get_grid_props.import_data(
config, appname, gfile, initlist, restartlist, dates
appname, gfile, initlist, restartlist, dates
)
# get the numpies
initd, restartd = _get_grid_props.get_numpies_contact(
Expand Down Expand Up @@ -124,8 +121,7 @@ def compute_contact(config, initd, restartd, dates):


def main(args=None):

XTGeoDialog.print_xtgeo_header(appname, __version__)
XTGeoDialog.print_xtgeo_header(APPNAME, __version__)

xtg.say("Parse command line")
args = do_parse_args(args)
Expand All @@ -143,16 +139,16 @@ def main(args=None):

# get the files
xtg.say("Collect files...")
gfile, initlist, restartlist, dates = get_grid_props_data(config, appname)
gfile, initlist, restartlist, dates = get_grid_props_data(config, APPNAME)

# import data from files and return releavnt numpies
xtg.say("Import files...")
grd, initd, restartd, dates = import_pdata(
config, appname, gfile, initlist, restartlist, dates
config, APPNAME, gfile, initlist, restartlist, dates
)

# Get the zonations
zonation, zoned = get_zranges(config, grd)
# zonation, zoned = get_zranges(config, grd)

xtg.say("Grid contact map...")
compute_contact(config, initd, restartd, dates)
Expand Down

0 comments on commit 7dfbee6

Please sign in to comment.