From db0bd5e1fdb6892f727a9917281cd3cfd35487dd Mon Sep 17 00:00:00 2001 From: "Jan C. Rivenaes" Date: Thu, 16 May 2019 08:49:18 +0200 Subject: [PATCH 1/2] Added develop mode in Makefile --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index ff4e765..b2d2b34 100644 --- a/Makefile +++ b/Makefile @@ -86,6 +86,8 @@ clean-test: ## remove test and coverage artifacts rm -fr htmlcov/ rm -fr TMP/ +develop: ## make develop mode (for pure python only) + ${PIP} install -e . lint: ## check style with flake8 flake8 ${APPLICATION} tests From 43677ab59ae6baee926c6d6a675ea2231fb9c28c Mon Sep 17 00:00:00 2001 From: "Jan C. Rivenaes" Date: Tue, 30 Jul 2019 16:07:05 +0200 Subject: [PATCH 2/2] Fix in behaviour of prefix, issue #15 --- src/xtgeo_utils2/avghc/_compute_avg.py | 260 +++++++++++++------------ src/xtgeo_utils2/avghc/_hc_plotmap.py | 253 ++++++++++++------------ src/xtgeo_utils2/avghc/_loader.py | 2 +- tests/yaml/avg1a.yml | 3 +- tests/yaml/hc_thickness1b.yml | 5 +- 5 files changed, 267 insertions(+), 256 deletions(-) diff --git a/src/xtgeo_utils2/avghc/_compute_avg.py b/src/xtgeo_utils2/avghc/_compute_avg.py index d552cef..7a7af3b 100644 --- a/src/xtgeo_utils2/avghc/_compute_avg.py +++ b/src/xtgeo_utils2/avghc/_compute_avg.py @@ -23,32 +23,34 @@ def get_avg(config, specd, propd, dates, zonation, zoned, filterarray): avgd = OrderedDict() - myavgzon = config['computesettings']['tuning']['zone_avg'] - mycoarsen = config['computesettings']['tuning']['coarsen'] + myavgzon = config["computesettings"]["tuning"]["zone_avg"] + mycoarsen = config["computesettings"]["tuning"]["coarsen"] - if 'templatefile' in config['mapsettings']: - xmap = RegularSurface(config['mapsettings']['templatefile']) + if "templatefile" in config["mapsettings"]: + xmap = RegularSurface(config["mapsettings"]["templatefile"]) xmap.values = 0.0 else: - ncol = config['mapsettings'].get('ncol') - nrow = config['mapsettings'].get('nrow') - - xmap = RegularSurface(xori=config['mapsettings'].get('xori'), - yori=config['mapsettings'].get('yori'), - ncol=ncol, - nrow=nrow, - xinc=config['mapsettings'].get('xinc'), - yinc=config['mapsettings'].get('yinc'), - values=np.zeros((ncol, nrow))) - - logger.debug('Flags of xmap is {}'.format(xmap.values.flags)) - xtg.say('Mapping ...') + ncol = config["mapsettings"].get("ncol") + nrow = config["mapsettings"].get("nrow") + + xmap = RegularSurface( + xori=config["mapsettings"].get("xori"), + yori=config["mapsettings"].get("yori"), + ncol=ncol, + nrow=nrow, + xinc=config["mapsettings"].get("xinc"), + yinc=config["mapsettings"].get("yinc"), + values=np.zeros((ncol, nrow)), + ) + + logger.debug("Flags of xmap is {}".format(xmap.values.flags)) + xtg.say("Mapping ...") if len(propd) == 0 or len(zoned) == 0: - raise RuntimeError('The dictionary or is zero. Stop') + raise RuntimeError("The dictionary or is zero. Stop") for zname, zrange in zoned.items(): - logger.info('ZNAME and ZRANGE are {}: {}'.format(zname, zrange)) + logger.info("ZNAME and ZRANGE are {}: {}".format(zname, zrange)) usezonation = zonation usezrange = zrange @@ -58,54 +60,54 @@ def get_avg(config, specd, propd, dates, zonation, zoned, filterarray): usezonation[:, :, :] = 0 logger.debug(usezonation) for zr in zrange: - logger.info('ZR is {}'.format(zr)) + logger.info("ZR is {}".format(zr)) usezonation[zonation == zr] = 888 usezrange = 888 - if zname == 'all': + if zname == "all": usezonation = zonation.copy() usezonation[:, :, :] = 999 usezrange = 999 - if config['computesettings']['all'] is not True: - logger.info('Skip <{}> (cf. computesettings: all)'. - format(zname)) + if config["computesettings"]["all"] is not True: + logger.info("Skip <{}> (cf. computesettings: all)".format(zname)) continue else: - if config['computesettings']['zone'] is not True: - logger.info('Skip <{}> (cf. computesettings: zone)'. - format(zname)) + if config["computesettings"]["zone"] is not True: + logger.info("Skip <{}> (cf. computesettings: zone)".format(zname)) continue for propname, pvalues in propd.items(): # filters get into effect by multyplying with DZ weight - usedz = specd['idz'] * filterarray - - xmap.avg_from_3dprop(xprop=specd['ixc'], - yprop=specd['iyc'], - mprop=pvalues, - dzprop=usedz, - zoneprop=usezonation, - zone_minmax=[usezrange, usezrange], - zone_avg=myavgzon, - coarsen=mycoarsen) - - filename = _avg_filesettings(config, zname, propname, mode='map') + usedz = specd["idz"] * filterarray + + xmap.avg_from_3dprop( + xprop=specd["ixc"], + yprop=specd["iyc"], + mprop=pvalues, + dzprop=usedz, + zoneprop=usezonation, + zone_minmax=[usezrange, usezrange], + zone_avg=myavgzon, + coarsen=mycoarsen, + ) + + filename = _avg_filesettings(config, zname, propname, mode="map") usename = (zname, propname) - if config['computesettings']['mask_zeros']: + if config["computesettings"]["mask_zeros"]: xmap.values = ma.masked_inside(xmap.values, -1e-30, 1e-30) - logger.debug('XMAP updated after mask: \n{}\n'.format(xmap.values)) - logger.debug('XMAP flags {}'.format(xmap.values.flags)) + logger.debug("XMAP updated after mask: \n{}\n".format(xmap.values)) + logger.debug("XMAP flags {}".format(xmap.values.flags)) avgd[usename] = xmap.copy() - logger.debug('Saved as copy...\n{}\n'.format(avgd[usename].values)) + logger.debug("Saved as copy...\n{}\n".format(avgd[usename].values)) - xtg.say('Map file to {}'.format(filename)) + xtg.say("Map file to {}".format(filename)) avgd[usename].to_file(filename) return avgd @@ -114,7 +116,7 @@ def get_avg(config, specd, propd, dates, zonation, zoned, filterarray): def do_avg_plotting(config, avgd): """Do plotting via matplotlib to PNG (etc) (if requested)""" - xtg.say('Plotting ...') + xtg.say("Plotting ...") for names, xmap in avgd.items(): @@ -122,70 +124,72 @@ def do_avg_plotting(config, avgd): zname = names[0] pname = names[1] - plotfile = _avg_filesettings(config, zname, pname, mode='plot') + plotfile = _avg_filesettings(config, zname, pname, mode="plot") pcfg = _avg_plotsettings(config, zname, pname) - xtg.say('Plot to {}'.format(plotfile)) + xtg.say("Plot to {}".format(plotfile)) - usevrange = pcfg['valuerange'] + usevrange = pcfg["valuerange"] faults = None - if pcfg['faultpolygons'] is not None: - xtg.say('Try: {}'.format(pcfg['faultpolygons'])) + if pcfg["faultpolygons"] is not None: + xtg.say("Try: {}".format(pcfg["faultpolygons"])) try: - fau = Polygons(pcfg['faultpolygons'], fformat='guess') - faults = {'faults': fau} - xtg.say('Use fault polygons') + fau = Polygons(pcfg["faultpolygons"], fformat="guess") + faults = {"faults": fau} + xtg.say("Use fault polygons") except Exception as e: xtg.say(e) faults = None - xtg.say('No fault polygons') + xtg.say("No fault polygons") - xmap.quickplot(filename=plotfile, - title=pcfg['title'], - subtitle=pcfg['subtitle'], - infotext=pcfg['infotext'], - xlabelrotation=pcfg['xlabelrotation'], - minmax=usevrange, - colortable=pcfg['colortable'], - faults=faults) + xmap.quickplot( + filename=plotfile, + title=pcfg["title"], + subtitle=pcfg["subtitle"], + infotext=pcfg["infotext"], + xlabelrotation=pcfg["xlabelrotation"], + minmax=usevrange, + colortable=pcfg["colortable"], + faults=faults, + ) -def _avg_filesettings(config, zname, pname, mode='root'): +def _avg_filesettings(config, zname, pname, mode="root"): """Local function for map or plot file root name""" - delim = '--' + delim = "--" - if config['output']['lowercase']: + if config["output"]["lowercase"]: zname = zname.lower() pname = pname.lower() # pname may have a single '-' if it contains a date; replace with '_' # need to trick a bit by first replacing '--' (if delim = '--') # with '~~', then back again... - pname = pname.replace(delim, '~~').replace('-', '_').replace('~~', delim) + pname = pname.replace(delim, "~~").replace("-", "_").replace("~~", delim) - tag = '' - if config['output']['tag']: - tag = config['output']['tag'] + '_' + tag = "" + if config["output"]["tag"]: + tag = config["output"]["tag"] + "_" - prefix = config['output'].get('prefix', zname) - if prefix is None: - prefix = zname + prefix = zname + if prefix == "all" and config["output"]["prefix"]: + prefix = config["output"]["prefix"] - xfil = prefix + delim + tag + 'average' + '_' + pname + xfil = prefix + delim + tag + "average" + "_" + pname - if mode == 'root': + if mode == "root": return xfil - elif mode == 'map': - path = config['output']['mapfolder'] + '/' - xfil = xfil + '.gri' + elif mode == "map": + path = config["output"]["mapfolder"] + "/" + xfil = xfil + ".gri" - elif mode == 'plot': - path = config['output']['plotfolder'] + '/' - xfil = xfil + '.png' + elif mode == "plot": + path = config["output"]["plotfolder"] + "/" + xfil = xfil + ".png" return path + xfil @@ -193,88 +197,88 @@ def _avg_filesettings(config, zname, pname, mode='root'): def _avg_plotsettings(config, zname, pname): """Local function for plot additional info for AVG maps.""" - title = 'Weighted average for ' + pname + ', zone ' + zname + title = "Weighted average for " + pname + ", zone " + zname showtime = strftime("%Y-%m-%d %H:%M:%S", localtime()) - infotext = config['title'] + ' - ' - infotext += getpass.getuser() + ' ' + showtime - if config['output']['tag']: - infotext += ' (tag: ' + config['output']['tag'] + ')' + infotext = config["title"] + " - " + infotext += getpass.getuser() + " " + showtime + if config["output"]["tag"]: + infotext += " (tag: " + config["output"]["tag"] + ")" xlabelrotation = None valuerange = (None, None) diffvaluerange = (None, None) - colortable = 'rainbow' + colortable = "rainbow" xlabelrotation = 0 fpolyfile = None - if 'xlabelrotation' in config['plotsettings']: - xlabelrotation = config['plotsettings']['xlabelrotation'] + if "xlabelrotation" in config["plotsettings"]: + xlabelrotation = config["plotsettings"]["xlabelrotation"] # better perhaps: # xlabelrotation = config['plotsettings'].get('xlabelrotation', None) - if 'valuerange' in config['plotsettings']: - valuerange = tuple(config['plotsettings']['valuerange']) + if "valuerange" in config["plotsettings"]: + valuerange = tuple(config["plotsettings"]["valuerange"]) - if 'diffvaluerange' in config['plotsettings']: - diffvaluerange = tuple(config['plotsettings']['diffvaluerange']) + if "diffvaluerange" in config["plotsettings"]: + diffvaluerange = tuple(config["plotsettings"]["diffvaluerange"]) - if 'faultpolygons' in config['plotsettings']: - fpolyfile = config['plotsettings']['faultpolygons'] + if "faultpolygons" in config["plotsettings"]: + fpolyfile = config["plotsettings"]["faultpolygons"] # there may be individual plotsettings per property per zone... - if pname is not None and pname in config['plotsettings']: + if pname is not None and pname in config["plotsettings"]: - pfg = config['plotsettings'][pname] + pfg = config["plotsettings"][pname] - if 'valuerange' in pfg: - valuerange = tuple(pfg['valuerange']) + if "valuerange" in pfg: + valuerange = tuple(pfg["valuerange"]) - if 'diffvaluerange' in pfg: - diffvaluerange = tuple(pfg['diffvaluerange']) + if "diffvaluerange" in pfg: + diffvaluerange = tuple(pfg["diffvaluerange"]) - if 'xlabelrotation' in pfg: - xlabelrotation = pfg['xlabelrotation'] + if "xlabelrotation" in pfg: + xlabelrotation = pfg["xlabelrotation"] - if 'colortable' in pfg: - colortable = pfg['colortable'] + if "colortable" in pfg: + colortable = pfg["colortable"] - if 'faultpolygons' in pfg: - fpolyfile = pfg['faultpolygons'] + if "faultpolygons" in pfg: + fpolyfile = pfg["faultpolygons"] - if zname is not None and zname in config['plotsettings'][pname]: + if zname is not None and zname in config["plotsettings"][pname]: - zfg = config['plotsettings'][pname][zname] + zfg = config["plotsettings"][pname][zname] - if 'valuerange' in zfg: - valuerange = tuple(zfg['valuerange']) + if "valuerange" in zfg: + valuerange = tuple(zfg["valuerange"]) - if 'diffvaluerange' in zfg: - diffvaluerange = tuple(zfg['diffvaluerange']) + if "diffvaluerange" in zfg: + diffvaluerange = tuple(zfg["diffvaluerange"]) - if 'xlabelrotation' in zfg: - xlabelrotation = zfg['xlabelrotation'] + if "xlabelrotation" in zfg: + xlabelrotation = zfg["xlabelrotation"] - if 'colortable' in zfg: - colortable = zfg['colortable'] + if "colortable" in zfg: + colortable = zfg["colortable"] - if 'faultpolygons' in zfg: - fpolyfile = zfg['faultpolygons'] + if "faultpolygons" in zfg: + fpolyfile = zfg["faultpolygons"] subtitle = None - if '_filterinfo' in config and config['_filterinfo']: - subtitle = config['_filterinfo'] + if "_filterinfo" in config and config["_filterinfo"]: + subtitle = config["_filterinfo"] # assing settings to a dictionary which is returned plotcfg = {} - plotcfg['title'] = title - plotcfg['subtitle'] = subtitle - plotcfg['infotext'] = infotext - plotcfg['valuerange'] = valuerange - plotcfg['diffvaluerange'] = diffvaluerange - plotcfg['xlabelrotation'] = xlabelrotation - plotcfg['colortable'] = colortable - plotcfg['faultpolygons'] = fpolyfile + plotcfg["title"] = title + plotcfg["subtitle"] = subtitle + plotcfg["infotext"] = infotext + plotcfg["valuerange"] = valuerange + plotcfg["diffvaluerange"] = diffvaluerange + plotcfg["xlabelrotation"] = xlabelrotation + plotcfg["colortable"] = colortable + plotcfg["faultpolygons"] = fpolyfile return plotcfg diff --git a/src/xtgeo_utils2/avghc/_hc_plotmap.py b/src/xtgeo_utils2/avghc/_hc_plotmap.py index fd28030..def09a7 100644 --- a/src/xtgeo_utils2/avghc/_hc_plotmap.py +++ b/src/xtgeo_utils2/avghc/_hc_plotmap.py @@ -22,26 +22,26 @@ def do_hc_mapping(config, initd, hcpfzd, zonation, zoned, hcmode): mapzd = OrderedDict() - if 'templatefile' in config['mapsettings']: - basemap = RegularSurface(config['mapsettings']['templatefile']) + if "templatefile" in config["mapsettings"]: + basemap = RegularSurface(config["mapsettings"]["templatefile"]) basemap.values = 0.0 else: - ncol = config['mapsettings'].get('ncol') - nrow = config['mapsettings'].get('nrow') + ncol = config["mapsettings"].get("ncol") + nrow = config["mapsettings"].get("nrow") basemap = RegularSurface( - xori=config['mapsettings'].get('xori'), - yori=config['mapsettings'].get('yori'), - ncol=config['mapsettings'].get('ncol'), - nrow=config['mapsettings'].get('nrow'), - xinc=config['mapsettings'].get('xinc'), - yinc=config['mapsettings'].get('yinc'), - values=np.zeros((ncol, nrow)) + xori=config["mapsettings"].get("xori"), + yori=config["mapsettings"].get("yori"), + ncol=config["mapsettings"].get("ncol"), + nrow=config["mapsettings"].get("nrow"), + xinc=config["mapsettings"].get("xinc"), + yinc=config["mapsettings"].get("yinc"), + values=np.zeros((ncol, nrow)), ) - mycoarsen = config['computesettings']['tuning']['coarsen'] - myavgzon = config['computesettings']['tuning']['zone_avg'] - mymaskoutside = config['computesettings']['mask_outside'] + mycoarsen = config["computesettings"]["tuning"]["coarsen"] + myavgzon = config["computesettings"]["tuning"]["zone_avg"] + mymaskoutside = config["computesettings"]["mask_outside"] for zname, zrange in zoned.items(): @@ -54,44 +54,44 @@ def do_hc_mapping(config, initd, hcpfzd, zonation, zoned, hcmode): usezonation[:, :, :] = 0 logger.debug(usezonation) for zr in zrange: - logger.debug('ZR is {}'.format(zr)) + logger.debug("ZR is {}".format(zr)) usezonation[zonation == zr] = 888 usezrange = 888 - if zname == 'all': + if zname == "all": usezonation = zonation.copy() usezonation[:, :, :] = 999 usezrange = 999 - if config['computesettings']['all'] is not True: - logger.info('Skip <{}> (cf. computesettings: all)'. - format(zname)) + if config["computesettings"]["all"] is not True: + logger.info("Skip <{}> (cf. computesettings: all)".format(zname)) continue else: - if config['computesettings']['zone'] is not True: - logger.info('Skip <{}> (cf. computesettings: zone)'. - format(zname)) + if config["computesettings"]["zone"] is not True: + logger.info("Skip <{}> (cf. computesettings: zone)".format(zname)) continue mapd = dict() for date, hcpfz in hcpfzd.items(): - logger.info('Mapping <{}> for date <{}> ...'.format(zname, date)) + logger.info("Mapping <{}> for date <{}> ...".format(zname, date)) xmap = basemap.copy() - xmap.hc_thickness_from_3dprops(xprop=initd['xc'], - yprop=initd['yc'], - hcpfzprop=hcpfz, - zoneprop=usezonation, - zone_minmax=(usezrange, usezrange), - coarsen=mycoarsen, - dzprop=initd['dz'], - zone_avg=myavgzon, - mask_outside=mymaskoutside) + xmap.hc_thickness_from_3dprops( + xprop=initd["xc"], + yprop=initd["yc"], + hcpfzprop=hcpfz, + zoneprop=usezonation, + zone_minmax=(usezrange, usezrange), + coarsen=mycoarsen, + dzprop=initd["dz"], + zone_avg=myavgzon, + mask_outside=mymaskoutside, + ) filename = _hc_filesettings(config, zname, date, hcmode) - xtg.say('Map file to {}'.format(filename)) + xtg.say("Map file to {}".format(filename)) xmap.to_file(filename) mapd[date] = xmap @@ -100,7 +100,7 @@ def do_hc_mapping(config, initd, hcpfzd, zonation, zoned, hcmode): # return the map dictionary: {zname: {date1: map_object1, ...}} - logger.debug('The map objects: {}'.format(mapzd)) + logger.debug("The map objects: {}".format(mapzd)) return mapzd @@ -108,80 +108,80 @@ def do_hc_mapping(config, initd, hcpfzd, zonation, zoned, hcmode): def do_hc_plotting(config, mapzd, hcmode, filtermean=None): """Do plotting via matplotlib to PNG (etc) (if requested)""" - xtg.say('Plotting ...') + xtg.say("Plotting ...") for zname, mapd in mapzd.items(): for date, xmap in mapd.items(): - plotfile = _hc_filesettings(config, zname, date, - hcmode, mode='plot') + plotfile = _hc_filesettings(config, zname, date, hcmode, mode="plot") pcfg = _hc_plotsettings(config, zname, date, hcmode, filtermean) - xtg.say('Plot to {}'.format(plotfile)) + xtg.say("Plot to {}".format(plotfile)) - usevrange = pcfg['valuerange'] + usevrange = pcfg["valuerange"] if len(date) > 10: - usevrange = pcfg['diffvaluerange'] + usevrange = pcfg["diffvaluerange"] faults = None - if pcfg['faultpolygons'] is not None: + if pcfg["faultpolygons"] is not None: try: - fau = Polygons(pcfg['faultpolygons'], fformat='guess') - faults = {'faults': fau} + fau = Polygons(pcfg["faultpolygons"], fformat="guess") + faults = {"faults": fau} except Exception as e: xtg.say(e) faults = None - xmap.quickplot(filename=plotfile, - title=pcfg['title'], - subtitle=pcfg['subtitle'], - infotext=pcfg['infotext'], - xlabelrotation=pcfg['xlabelrotation'], - minmax=usevrange, - colormap=pcfg['colortable'], - faults=faults) + xmap.quickplot( + filename=plotfile, + title=pcfg["title"], + subtitle=pcfg["subtitle"], + infotext=pcfg["infotext"], + xlabelrotation=pcfg["xlabelrotation"], + minmax=usevrange, + colormap=pcfg["colortable"], + faults=faults, + ) -def _hc_filesettings(config, zname, date, hcmode, mode='map'): +def _hc_filesettings(config, zname, date, hcmode, mode="map"): """Local function for map or plot file name""" - delim = '--' + delim = "--" - if config['output']['lowercase']: + if config["output"]["lowercase"]: zname = zname.lower() - date = date.replace('unknowndate', '') + date = date.replace("unknowndate", "") - if config['output']['legacydateformat']: + if config["output"]["legacydateformat"]: date = _dates_oldformat(date) phase = hcmode - if phase == 'comb': - phase = 'hc' + if phase == "comb": + phase = "hc" - tag = '' - if config['output']['tag']: - tag = config['output']['tag'] + '_' + tag = "" + if config["output"]["tag"]: + tag = config["output"]["tag"] + "_" prefix = zname - if config['output']['prefix']: - prefix = config['output']['prefix'] + if prefix == "all" and config["output"]["prefix"]: + prefix = config["output"]["prefix"] - date = date.replace('-', '_') + date = date.replace("-", "_") - path = config['output']['mapfolder'] + '/' + path = config["output"]["mapfolder"] + "/" if not date: - xfil = (prefix + delim + tag + phase + 'thickness' + '.gri') + xfil = prefix + delim + tag + phase + "thickness" + ".gri" else: - xfil = (prefix + delim + tag + phase + 'thickness' + delim + - str(date) + '.gri') + xfil = prefix + delim + tag + phase + "thickness" + delim + str(date) + ".gri" - if mode == 'plot': - path = config['output']['plotfolder'] + '/' - xfil = xfil.replace('gri', 'png') + if mode == "plot": + path = config["output"]["plotfolder"] + "/" + xfil = xfil.replace("gri", "png") return path + xfil @@ -190,21 +190,27 @@ def _dates_oldformat(date): """Get dates on legacy format with underscore, 19910101 --> 1991_01_01.""" if not date: # empty string or None - return '' + return "" date = str(date) newdate = date if len(date) == 8: year, month, day = (date[0:4], date[4:6], date[6:8]) - newdate = year + '_' + month + '_' + day + newdate = year + "_" + month + "_" + day elif len(date) == 17: year1, month1, day1, year2, month2, day2 = ( - date[0:4], date[4:6], date[6:8], - date[9:13], date[13:15], date[15:17]) + date[0:4], + date[4:6], + date[6:8], + date[9:13], + date[13:15], + date[15:17], + ) - newdate = year1 + '_' + month1 + '_' + day1 + '_' + \ - year2 + '_' + month2 + '_' + day2 + newdate = ( + year1 + "_" + month1 + "_" + day1 + "_" + year2 + "_" + month2 + "_" + day2 + ) else: raise ValueError('Could not convert date to "old format"') @@ -214,82 +220,81 @@ def _dates_oldformat(date): def _hc_plotsettings(config, zname, date, hcmode, filtermean): """Local function for plot additional info.""" - phase = config['computesettings']['mode'] + phase = config["computesettings"]["mode"] - if phase == 'comb': - phase = 'oil + gas' + if phase == "comb": + phase = "oil + gas" - rock = 'net' - modecfg = config['computesettings']['mode'] - if modecfg == 'dz_only' or modecfg == 'rock': - rock = 'bulk' + rock = "net" + modecfg = config["computesettings"]["mode"] + if modecfg == "dz_only" or modecfg == "rock": + rock = "bulk" - title = (phase.capitalize() + ' ' + rock + ' thickness for ' + - zname) - if date and date != 'unknowndate': - title = title + ' ' + date + title = phase.capitalize() + " " + rock + " thickness for " + zname + if date and date != "unknowndate": + title = title + " " + date showtime = strftime("%Y-%m-%d %H:%M:%S", localtime()) - infotext = config['title'] + ' - ' - infotext += ' ' + getpass.getuser() + ' ' + showtime - if config['output']['tag']: - infotext += ' (tag: ' + config['output']['tag'] + ')' + infotext = config["title"] + " - " + infotext += " " + getpass.getuser() + " " + showtime + if config["output"]["tag"]: + infotext += " (tag: " + config["output"]["tag"] + ")" subtitle = None if filtermean < 1.0: - subtitle = 'Property filter: ' + config['_filterinfo'] + subtitle = "Property filter: " + config["_filterinfo"] xlabelrotation = None valuerange = (None, None) diffvaluerange = (None, None) - colortable = 'rainbow' + colortable = "rainbow" xlabelrotation = 0 fpolyfile = None - if 'xlabelrotation' in config['plotsettings']: - xlabelrotation = config['plotsettings']['xlabelrotation'] + if "xlabelrotation" in config["plotsettings"]: + xlabelrotation = config["plotsettings"]["xlabelrotation"] - if 'valuerange' in config['plotsettings']: - valuerange = tuple(config['plotsettings']['valuerange']) + if "valuerange" in config["plotsettings"]: + valuerange = tuple(config["plotsettings"]["valuerange"]) - if 'diffvaluerange' in config['plotsettings']: - diffvaluerange = tuple(config['plotsettings']['diffvaluerange']) + if "diffvaluerange" in config["plotsettings"]: + diffvaluerange = tuple(config["plotsettings"]["diffvaluerange"]) - if 'faultpolygons' in config['plotsettings']: - fpolyfile = config['plotsettings']['faultpolygons'] + if "faultpolygons" in config["plotsettings"]: + fpolyfile = config["plotsettings"]["faultpolygons"] - if 'colortable' in config['plotsettings']: - colortable = config['plotsettings']['colortable'] + if "colortable" in config["plotsettings"]: + colortable = config["plotsettings"]["colortable"] # there may be individual plotsettings for zname - if zname is not None and zname in config['plotsettings']: + if zname is not None and zname in config["plotsettings"]: - zfg = config['plotsettings'][zname] + zfg = config["plotsettings"][zname] - if 'valuerange' in zfg: - valuerange = tuple(zfg['valuerange']) + if "valuerange" in zfg: + valuerange = tuple(zfg["valuerange"]) - if 'diffvaluerange' in zfg: - diffvaluerange = tuple(zfg['diffvaluerange']) + if "diffvaluerange" in zfg: + diffvaluerange = tuple(zfg["diffvaluerange"]) - if 'xlabelrotation' in zfg: - xlabelrotation = zfg['xlabelrotation'] + if "xlabelrotation" in zfg: + xlabelrotation = zfg["xlabelrotation"] - if 'colortable' in zfg: - colortable = zfg['colortable'] + if "colortable" in zfg: + colortable = zfg["colortable"] - if 'faultpolygons' in zfg: - fpolyfile = zfg['faultpolygons'] + if "faultpolygons" in zfg: + fpolyfile = zfg["faultpolygons"] # assing settings to a dictionary which is returned plotcfg = {} - plotcfg['title'] = title - plotcfg['subtitle'] = subtitle - plotcfg['infotext'] = infotext - plotcfg['valuerange'] = valuerange - plotcfg['diffvaluerange'] = diffvaluerange - plotcfg['xlabelrotation'] = xlabelrotation - plotcfg['colortable'] = colortable - plotcfg['faultpolygons'] = fpolyfile + plotcfg["title"] = title + plotcfg["subtitle"] = subtitle + plotcfg["infotext"] = infotext + plotcfg["valuerange"] = valuerange + plotcfg["diffvaluerange"] = diffvaluerange + plotcfg["xlabelrotation"] = xlabelrotation + plotcfg["colortable"] = colortable + plotcfg["faultpolygons"] = fpolyfile return plotcfg diff --git a/src/xtgeo_utils2/avghc/_loader.py b/src/xtgeo_utils2/avghc/_loader.py index 563d172..22ec4da 100644 --- a/src/xtgeo_utils2/avghc/_loader.py +++ b/src/xtgeo_utils2/avghc/_loader.py @@ -91,7 +91,7 @@ def include_from(self, node): if isinstance(node, yaml.ScalarNode): filename, val = self.construct_scalar(node).split('::') - result = yaml.load(open(filename, 'r')) + result = yaml.full_load(open(filename, 'r')) self._root = oldroot fields = val.strip().split('.') diff --git a/tests/yaml/avg1a.yml b/tests/yaml/avg1a.yml index a1fcf47..7336f51 100644 --- a/tests/yaml/avg1a.yml +++ b/tests/yaml/avg1a.yml @@ -19,7 +19,7 @@ zonation: computesettings: zone: Yes - all: No + all: Yes mask_zeros: Yes # means that ouput maps will be set to undef where zero # map definition (not rotated maps only) @@ -36,3 +36,4 @@ output: # z1--avg1a_average_poro.gri mapfolder: TMP plotfolder: TMP + prefix: xxx diff --git a/tests/yaml/hc_thickness1b.yml b/tests/yaml/hc_thickness1b.yml index 99fb036..759a7e9 100644 --- a/tests/yaml/hc_thickness1b.yml +++ b/tests/yaml/hc_thickness1b.yml @@ -21,8 +21,8 @@ computesettings: critmode: No shc_interval: [0.001, 1] # saturation interval method: use_poro - zone: Yes - all: No + zone: No + all: Yes # map definition (not rotated maps only) mapsettings: @@ -62,3 +62,4 @@ output: mapfolder: TMP plotfolder: TMP tag: hc1b + prefix: replace_all_with_x