diff --git a/src/xtgeo/common/__init__.py b/src/xtgeo/common/__init__.py index 049094384..b58baea9b 100644 --- a/src/xtgeo/common/__init__.py +++ b/src/xtgeo/common/__init__.py @@ -2,8 +2,23 @@ """The XTGeo common package""" +from xtgeo.common._xyz_data import _XYZData +from xtgeo.common._xyz_enum import _AttrName, _AttrType, _XYZType from xtgeo.common.exceptions import WellNotFoundError from xtgeo.common.sys import _XTGeoFile, inherit_docstring # flake8: noqa from xtgeo.common.xtgeo_dialog import XTGDescription, XTGeoDialog, XTGShowProgress + +__all__ = [ + "_XYZData", + "_AttrName", + "_AttrType", + "_XYZType", + "WellNotFoundError", + "_XTGeoFile", + "inherit_docstring", + "XTGDescription", + "XTGeoDialog", + "XTGShowProgress", +] diff --git a/src/xtgeo/xyz_common/_xyz_data.py b/src/xtgeo/common/_xyz_data.py similarity index 97% rename from src/xtgeo/xyz_common/_xyz_data.py rename to src/xtgeo/common/_xyz_data.py index 341e035ce..9d833b723 100644 --- a/src/xtgeo/xyz_common/_xyz_data.py +++ b/src/xtgeo/common/_xyz_data.py @@ -41,10 +41,10 @@ from joblib import hash as jhash import xtgeo.common.constants as const -from xtgeo import XTGeoCLibError # type: ignore[attr-defined] -from xtgeo.common import XTGeoDialog from xtgeo.common.sys import _convert_carr_double_np, _get_carray +from xtgeo.common.xtgeo_dialog import XTGeoDialog from xtgeo.cxtgeo import _cxtgeo +from xtgeo.cxtgeo._cxtgeo import XTGeoCLibError # type: ignore[attr-defined] from ._xyz_enum import _AttrName, _AttrType, _XYZType @@ -82,7 +82,7 @@ def __init__( zname: str = _AttrName.ZNAME.value, idname: Optional[str] = None, # Well, Polygon, ... undef: Union[float, Sequence[float, float]] = -999.0, - xyztype: str = "well", + xyztype: Literal["well", "points", "polygons"] = "well", floatbits: Literal["float32", "float64"] = "float64", ): logger.info("Running init for: %s", __name__) @@ -291,7 +291,7 @@ def _ensure_consistency_df_dtypes(self): self._df[col[3:]] = self._df.iloc[:, 3:].astype(self._floatbits) for name, attr_type in self._attr_types.items(): - if attr_type == "CONT": + if attr_type == _AttrType.CONT.value: logger.debug("Replacing CONT undef...") self._df[name].replace( self._undef_cont, @@ -364,9 +364,9 @@ def set_attr_type(self, name: str, attrtype: str) -> None: apply_attrtype = attrtype.upper() if "FLOAT" in apply_attrtype: - apply_attrtype = "CONT" + apply_attrtype = _AttrType.CONT.value if "INT" in apply_attrtype: - apply_attrtype = "DISC" + apply_attrtype = _AttrType.DISC.value if name not in self._attr_types: raise ValueError(f"No such log name present: {name}") @@ -436,7 +436,7 @@ def get_dataframe_copy( dfr = self._df.copy() if infer_dtype: for name, attrtype in self._attr_types.items(): - if attrtype.name == "DISC": + if attrtype.name == _AttrType.DISC.value: dfr[name] = dfr[name].fillna(fill_value_int) dfr[name] = dfr[name].astype("int32") @@ -485,7 +485,10 @@ def rename_attr(self, attrname: str, newname: str): def create_attr( self, attrname: str, - attr_type: str = Literal["CONT", "DISC"], + attr_type: str = Literal[ + _AttrType.CONT.value, # type: ignore + _AttrType.DISC.value, # type: ignore + ], attr_record: Optional[dict] = None, value: float = 0.0, force: bool = True, diff --git a/src/xtgeo/xyz_common/_xyz_enum.py b/src/xtgeo/common/_xyz_enum.py similarity index 95% rename from src/xtgeo/xyz_common/_xyz_enum.py rename to src/xtgeo/common/_xyz_enum.py index 4575422e9..5e348466e 100644 --- a/src/xtgeo/xyz_common/_xyz_enum.py +++ b/src/xtgeo/common/_xyz_enum.py @@ -30,8 +30,8 @@ class _AttrName(ExtendedEnum): class _AttrType(ExtendedEnum): """Enumerate type of attribute/log""" - CONT = 1 - DISC = 2 + CONT = "CONT" + DISC = "DISC" @unique diff --git a/src/xtgeo/common/sys.py b/src/xtgeo/common/sys.py index eb2354109..51e1362df 100644 --- a/src/xtgeo/common/sys.py +++ b/src/xtgeo/common/sys.py @@ -19,6 +19,7 @@ from xtgeo.cxtgeo import _cxtgeo +from ._xyz_enum import _AttrType from .xtgeo_dialog import XTGeoDialog xtg = XTGeoDialog() @@ -740,7 +741,7 @@ def _get_carray(dataframe, attributes, attrname: str): return None nlen = len(dataframe.index) - if attributes[attrname] == "DISC": + if attributes[attrname] == _AttrType.DISC.value: carr = _convert_np_carr_int(nlen, np_array) else: carr = _convert_np_carr_double(nlen, np_array) diff --git a/src/xtgeo/well/_blockedwell_roxapi.py b/src/xtgeo/well/_blockedwell_roxapi.py index 2336a9ca5..be4072b5f 100644 --- a/src/xtgeo/well/_blockedwell_roxapi.py +++ b/src/xtgeo/well/_blockedwell_roxapi.py @@ -5,11 +5,10 @@ import pandas as pd from xtgeo.common import XTGeoDialog +from xtgeo.common._xyz_enum import _AttrName, _AttrType from xtgeo.common.exceptions import WellNotFoundError from xtgeo.roxutils import RoxUtils -from ..xyz_common._xyz_enum import _AttrName - try: import roxar # type: ignore except ImportError: @@ -27,7 +26,7 @@ def import_bwell_roxapi( ): """Private function for loading project and ROXAPI blockwell import""" - logger.info("Opening RMS project ...") + logger.debug("Opening RMS project ...") rox = RoxUtils(project, readonly=True) _roxapi_import_bwell(self, rox, gname, bwname, wname, lognames, ijk, realisation) @@ -40,7 +39,7 @@ def export_bwell_roxapi( ): """Private function for blockwell export (store in RMS) from XTGeo to RoxarAPI""" - logger.info("Opening RMS project ...") + logger.debug("Opening RMS project ...") rox = RoxUtils(project, readonly=False) _roxapi_export_bwell(self, rox, gname, bwname, wname, lognames, ijk, realisation) @@ -58,13 +57,13 @@ def _roxapi_import_bwell( if gname in rox.project.grid_models: gmodel = rox.project.grid_models[gname] - logger.info("RMS grid model <%s> OK", gname) + logger.debug("RMS grid model <%s> OK", gname) else: raise ValueError(f"No such grid name present: {gname}") if bwname in gmodel.blocked_wells_set: bwset = gmodel.blocked_wells_set[bwname] - logger.info("Blocked well set <%s> OK", bwname) + logger.debug("Blocked well set <%s> OK", bwname) else: raise ValueError(f"No such blocked well set: {bwname}") @@ -111,10 +110,10 @@ def _roxapi_import_bwell( tmplog = npma.filled(tmplog, fill_value=np.nan) tmplog[tmplog == -999] = np.nan if "discrete" in str(bwprop.type): - self.set_logtype(lname, "DISC") + self.set_logtype(lname, _AttrType.DISC.value) self.set_logrecord(lname, bwprop.code_names) else: - self.set_logtype(lname, "CONT") + self.set_logtype(lname, _AttrType.CONT.value) self.set_logrecord(lname, None) logs[lname] = tmplog @@ -132,7 +131,10 @@ def _roxapi_import_bwell( self._xpos, self._ypos = rox.project.wells[wname].wellhead else: self._rkb = None - self._xpos, self._ypos = self._df["X_UTME"][0], self._df["Y_UTMN"][0] + self._xpos, self._ypos = ( + self._df[_AttrName.XNAME][0], + self._df[_AttrName.YNAME][0], + ) def _roxapi_export_bwell( @@ -142,13 +144,13 @@ def _roxapi_export_bwell( if gname in rox.project.grid_models: gmodel = rox.project.grid_models[gname] - logger.info("RMS grid model <%s> OK", gname) + logger.debug("RMS grid model <%s> OK", gname) else: raise ValueError(f"No such grid name present: {gname}") if bwname in gmodel.blocked_wells_set: bwset = gmodel.blocked_wells_set[bwname] - logger.info("Blocked well set <%s> OK", bwname) + logger.debug("Blocked well set <%s> OK", bwname) bwprops = bwset.properties else: raise ValueError(f"No such blocked well set: {bwname}") @@ -179,7 +181,7 @@ def _roxapi_export_bwell( continue if lname not in bwnames: - if self._wlogtypes[lname] == "CONT": + if self._wlogtypes[lname] == _AttrType.CONT.value: print("Create CONT", lname, "for", wname) bwlog = bwset.properties.create( lname, roxar.GridPropertyType.continuous, np.float32 diff --git a/src/xtgeo/well/_blockedwells_roxapi.py b/src/xtgeo/well/_blockedwells_roxapi.py index b50863c06..85b46ce3b 100644 --- a/src/xtgeo/well/_blockedwells_roxapi.py +++ b/src/xtgeo/well/_blockedwells_roxapi.py @@ -18,7 +18,7 @@ def import_bwells_roxapi( ): # pragma: no cover """Private function for loading project and ROXAPI blockwell import""" - logger.info("Opening RMS project ...") + logger.debug("Opening RMS project ...") rox = RoxUtils(project, readonly=True) _roxapi_import_bwells(self, rox, gname, bwname, lognames, ijk, realisation) @@ -33,24 +33,24 @@ def _roxapi_import_bwells( if gname in rox.project.grid_models: gmodel = rox.project.grid_models[gname] - logger.info("RMS grid model <%s> OK", gname) + logger.debug("RMS grid model <%s> OK", gname) else: raise ValueError(f"No such grid name present: {gname}") if bwname in gmodel.blocked_wells_set: bwset = gmodel.blocked_wells_set[bwname] - logger.info("Blocked well set <%s> OK", bwname) + logger.debug("Blocked well set <%s> OK", bwname) else: raise ValueError(f"No such blocked well set: {bwname}") wnames = bwset.get_well_names() - logger.info("Lognames are %s", lnames) + logger.debug("Lognames are %s", lnames) bwlist = [] - logger.info("Loading wells ...") + logger.debug("Loading wells ...") for wname in wnames: - logger.info("Loading well %s", wname) + logger.debug("Loading well %s", wname) bwtmp = BlockedWell() bwtmp.from_roxar( rox.project, diff --git a/src/xtgeo/well/_well_aux.py b/src/xtgeo/well/_well_aux.py index 6ffd36fd6..d1ce8c7a8 100644 --- a/src/xtgeo/well/_well_aux.py +++ b/src/xtgeo/well/_well_aux.py @@ -15,8 +15,8 @@ import xtgeo from xtgeo.common import XTGeoDialog +from xtgeo.common._xyz_enum import _AttrName -from ..xyz_common._xyz_enum import _AttrName from . import _well_io xtg = XTGeoDialog() diff --git a/src/xtgeo/well/_well_io.py b/src/xtgeo/well/_well_io.py index ea9ca35c6..2057cfaa3 100644 --- a/src/xtgeo/well/_well_io.py +++ b/src/xtgeo/well/_well_io.py @@ -9,8 +9,7 @@ import xtgeo from xtgeo.common import XTGeoDialog - -from ..xyz_common._xyz_enum import _AttrName +from xtgeo.common._xyz_enum import _AttrName, _AttrType xtg = XTGeoDialog() @@ -97,7 +96,7 @@ def import_rms_ascii( logger.debug("Reading log name %s of type %s", lname, ltype) - if ltype == "DISC": + if ltype == _AttrType.DISC.value: xdict = {int(rxv[i]): rxv[i + 1] for i in range(0, len(rxv), 2)} wlogrecords[lname] = xdict else: @@ -232,7 +231,7 @@ def export_rms_ascii(self, wfile, precision=4): # make the disc as is np.int for lname in self.wlogtypes: - if self.wlogtypes[lname] == "DISC": + if self.wlogtypes[lname] == _AttrType.DISC.value: tmpdf[[lname]] = tmpdf[[lname]].astype(int) cformat = "%-." + str(precision) + "f" @@ -249,7 +248,7 @@ def export_rms_ascii(self, wfile, precision=4): def export_hdf5_well(self, wfile, compression="lzf"): """Save to HDF5 format.""" - logger.info("Export to hdf5 format...") + logger.debug("Export to hdf5 format...") self._ensure_consistency() @@ -266,13 +265,13 @@ def export_hdf5_well(self, wfile, compression="lzf"): complevel = 0 with pd.HDFStore(wfile.file, "w", complevel=complevel, complib=complib) as store: - logger.info("export to HDF5 %s", wfile.name) + logger.debug("export to HDF5 %s", wfile.name) store.put("Well", self._wdata.data) store.get_storer("Well").attrs["metadata"] = jmeta store.get_storer("Well").attrs["provider"] = "xtgeo" store.get_storer("Well").attrs["format_idcode"] = 1401 - logger.info("Export to hdf5 format... done!") + logger.debug("Export to hdf5 format... done!") def import_wlogs(wlogs: OrderedDict): @@ -294,7 +293,7 @@ def import_wlogs(wlogs: OrderedDict): for key in wlogs.keys(): typ, rec = wlogs[key] - if typ in {"DISC", "CONT"}: + if typ in {_AttrType.DISC.value, _AttrType.CONT.value}: wlogtypes[key] = deepcopy(typ) else: raise ValueError(f"Invalid log type found in input: {typ}") @@ -308,7 +307,7 @@ def import_wlogs(wlogs: OrderedDict): def import_hdf5_well(wfile, **kwargs): """Load from HDF5 format.""" - logger.info("The kwargs may be unused: %s", kwargs) + logger.debug("The kwargs may be unused: %s", kwargs) reqattrs = xtgeo.MetaDataWell.REQUIRED with pd.HDFStore(wfile.file, "r") as store: diff --git a/src/xtgeo/well/_well_oper.py b/src/xtgeo/well/_well_oper.py index e38d04a91..1506ef372 100644 --- a/src/xtgeo/well/_well_oper.py +++ b/src/xtgeo/well/_well_oper.py @@ -7,6 +7,7 @@ import xtgeo.cxtgeo._cxtgeo as _cxtgeo # type: ignore from xtgeo.common import XTGeoDialog from xtgeo.common import constants as const +from xtgeo.common._xyz_enum import _AttrType from xtgeo.common.sys import _get_carray xtg = XTGeoDialog() @@ -71,7 +72,7 @@ def rescale(self, delta=0.15, tvdrange=None): for lname in dfr.columns: if lname in self.wlogtypes: ltype = self.wlogtypes[lname] - if ltype == "DISC": + if ltype == _AttrType.DISC.value: dfr = dfr.round({lname: 0}) logger.debug("Updated dataframe:\n%s", dfr) @@ -135,12 +136,12 @@ def make_zone_qual_log(self, zqname): dcode = dict(zip(idlist, code)) # now create the new log - self.create_log(zqname, logtype="DISC", logrecord=codes) + self.create_log(zqname, logtype=_AttrType.DISC.value, logrecord=codes) for key, val in dcode.items(): self.dataframe.loc[dff["ztmp"] == key, zqname] = val # set the metadata - self.set_logtype(zqname, "DISC") + self.set_logtype(zqname, _AttrType.DISC.value) self.set_logrecord(zqname, codes) self._ensure_consistency() @@ -149,14 +150,14 @@ def make_zone_qual_log(self, zqname): def make_ijk_from_grid(self, grid, grid_id="", algorithm=1, activeonly=True): """Make an IJK log from grid indices.""" - logger.info("Using algorithm %s in %s", algorithm, __name__) + logger.debug("Using algorithm %s in %s", algorithm, __name__) if algorithm == 1: _make_ijk_from_grid_v1(self, grid, grid_id=grid_id) else: _make_ijk_from_grid_v2(self, grid, grid_id=grid_id, activeonly=activeonly) - logger.info("Using algorithm %s in %s done", algorithm, __name__) + logger.debug("Using algorithm %s in %s done", algorithm, __name__) def _make_ijk_from_grid_v1(self, grid, grid_id=""): @@ -164,7 +165,7 @@ def _make_ijk_from_grid_v1(self, grid, grid_id=""): This is the first version, using _cxtgeo.grd3d_well_ijk from C """ - logger.info("Using algorithm 1 in %s", __name__) + logger.debug("Using algorithm 1 in %s", __name__) wxarr = _get_carray(self.dataframe, self.wlogtypes, self.xname) wyarr = _get_carray(self.dataframe, self.wlogtypes, self.yname) @@ -217,7 +218,7 @@ def _make_ijk_from_grid_v1(self, grid, grid_id=""): self._wdata.data[kcellname] = kndarray for cellname in [icellname, jcellname, kcellname]: - self.set_logtype(cellname, "DISC") + self.set_logtype(cellname, _AttrType.DISC.value) self.set_logrecord(icellname, {ncel: str(ncel) for ncel in range(1, grid.ncol + 1)}) self.set_logrecord(jcellname, {ncel: str(ncel) for ncel in range(1, grid.nrow + 1)}) @@ -324,16 +325,14 @@ def get_gridproperties(self, gridprops, grid=("ICELL", "JCELL", "KCELL"), prop_i for pname, isdiscrete_codes in pnames.items(): isdiscrete, codes = isdiscrete_codes if isdiscrete: - wcopy.set_logtype(pname, "DISC") + wcopy.set_logtype(pname, _AttrType.DISC.value) wcopy.set_logrecord(pname, codes) else: - wcopy.set_logtype(pname, "CONT") + wcopy.set_logtype(pname, _AttrType.CONT.value) wcopy.set_logrecord(pname, ("", "")) wcopy.delete_logs(["ICELL_tmp", "JCELL_tmp", "KCELL_tmp"]) self.set_dataframe(wcopy.dataframe) - del wcopy - del dfr def report_zonation_holes(self, threshold=5): @@ -373,7 +372,7 @@ def report_zonation_holes(self, threshold=5): hole = True if zone > const.UNDEF_INT_LIMIT and ncv > threshold: - logger.info("Restart first (bigger hole)") + logger.debug("Restart first (bigger hole)") hole = False first = True ncv = 0 @@ -420,14 +419,14 @@ def mask_shoulderbeds(self, inputlogs, targetlogs, nsamples, strict): Returns True if inputlog(s) and targetlog(s) are present; otherwise False. """ - logger.info("Mask shoulderbeds for some logs...") + logger.debug("Mask shoulderbeds for some logs...") useinputs, usetargets, use_numeric = _mask_shoulderbeds_checks( self, inputlogs, targetlogs, nsamples, strict ) if not useinputs or not usetargets: - logger.info("Mask shoulderbeds for some logs... nothing done") + logger.debug("Mask shoulderbeds for some logs... nothing done") return False for inlog in useinputs: @@ -448,7 +447,7 @@ def mask_shoulderbeds(self, inputlogs, targetlogs, nsamples, strict): for target in usetargets: self._wdata.data.loc[bseries, target] = np.nan - logger.info("Mask shoulderbeds for some logs... done") + logger.debug("Mask shoulderbeds for some logs... done") return True @@ -459,7 +458,10 @@ def _mask_shoulderbeds_checks(self, inputlogs, targetlogs, nsamples, strict): for inlog in inputlogs: if inlog not in self.wlogtypes.keys() and strict is True: raise ValueError(f"Input log {inlog} is missing and strict=True") - if inlog in self.wlogtypes.keys() and self.wlogtypes[inlog] != "DISC": + if ( + inlog in self.wlogtypes.keys() + and self.wlogtypes[inlog] != _AttrType.DISC.value + ): raise ValueError(f"Input log {inlog} is not of type DISC") if inlog in self.wlogtypes.keys(): useinputs.append(inlog) @@ -548,7 +550,7 @@ def _get_bseries_by_distance(depth, inseries, distance): def create_surf_distance_log(self, surf, name): """Create a log which is vertical distance from a RegularSurface.""" - logger.info("Create a log which is distance to surface") + logger.debug("Create a log which is distance to surface") if not isinstance(surf, xtgeo.RegularSurface): raise ValueError("Input surface is not a RegularSurface instance.") diff --git a/src/xtgeo/well/_well_roxapi.py b/src/xtgeo/well/_well_roxapi.py index 37095c8b0..622c98697 100644 --- a/src/xtgeo/well/_well_roxapi.py +++ b/src/xtgeo/well/_well_roxapi.py @@ -5,12 +5,11 @@ import numpy.ma as npma import pandas as pd -import xtgeo from xtgeo.common import XTGeoDialog +from xtgeo.common._xyz_enum import _AttrName, _AttrType +from xtgeo.common.constants import UNDEF_INT_LIMIT, UNDEF_LIMIT from xtgeo.roxutils import RoxUtils -from ..xyz_common._xyz_enum import _AttrName - xtg = XTGeoDialog() logger = xtg.functionlogger(__name__) @@ -140,10 +139,10 @@ def _get_roxlog(wlogtypes, wlogrecords, roxlrun, lname): # pragma: no cover tmplog = npma.filled(tmplog, fill_value=np.nan) tmplog[tmplog == -999] = np.nan if roxcurve.is_discrete: - wlogtypes[lname] = "DISC" + wlogtypes[lname] = _AttrType.DISC.value wlogrecords[lname] = roxcurve.get_code_names() else: - wlogtypes[lname] = "CONT" + wlogtypes[lname] = _AttrType.CONT.value wlogrecords[lname] = None return tmplog @@ -159,7 +158,7 @@ def export_well_roxapi( realisation=0, ): """Private function for well export (store in RMS) from XTGeo to RoxarAPI.""" - logger.info("Opening RMS project ...") + logger.debug("Opening RMS project ...") rox = RoxUtils(project, readonly=False) @@ -184,7 +183,7 @@ def _roxapi_update_well(self, rox, wname, lognames, logrun, trajectory, realisat Also, the length of arrays should not change, at least not for now. """ - logger.info("Key realisation not in use: %s", realisation) + logger.debug("Key realisation not in use: %s", realisation) well = rox.project.wells[wname] traj = well.wellbore.trajectories[trajectory] @@ -199,10 +198,10 @@ def _roxapi_update_well(self, rox, wname, lognames, logrun, trajectory, realisat for lname in uselognames: isdiscrete = False - xtglimit = xtgeo.UNDEF_LIMIT - if self.wlogtypes[lname] == "DISC": + xtglimit = UNDEF_LIMIT + if self.wlogtypes[lname] == _AttrType.DISC.value: isdiscrete = True - xtglimit = xtgeo.UNDEF_INT_LIMIT + xtglimit = UNDEF_INT_LIMIT if isdiscrete: thelog = lrun.log_curves.create_discrete(name=lname) @@ -272,7 +271,7 @@ def _roxapi_create_well(self, rox, wname, lognames, logrun, trajectory, realisat cname = "MD_imported" xtg.warn(f"Logname MD is renamed to {cname}") - if curveprop[0] == "DISC": + if curveprop[0] == _AttrType.DISC.value: lcurve = lrun.log_curves.create_discrete(cname) cc = np.ma.masked_invalid(self.dataframe[curvename].values) lcurve.set_values(cc.astype(np.int32)) @@ -282,4 +281,4 @@ def _roxapi_create_well(self, rox, wname, lognames, logrun, trajectory, realisat lcurve = lrun.log_curves.create(cname) lcurve.set_values(self.dataframe[curvename].values) - logger.info("Log curve created: %s", cname) + logger.debug("Log curve created: %s", cname) diff --git a/src/xtgeo/well/_wellmarkers.py b/src/xtgeo/well/_wellmarkers.py index 9aab29bbf..76cb4f1d9 100644 --- a/src/xtgeo/well/_wellmarkers.py +++ b/src/xtgeo/well/_wellmarkers.py @@ -49,7 +49,7 @@ def get_zonation_points(self, tops, incl_limit, top_prefix, zonelist, use_undef) # need to declare as list; otherwise Py3 will get dict.keys zonelist = list(self.get_logrecord(self.zonelogname).keys()) - logger.info("Find values for %s", zonelist) + logger.debug("Find values for %s", zonelist) ztops, ztopnames, zisos, zisonames = _extract_ztops( self, @@ -330,9 +330,9 @@ def get_fraction_per_zone( A dataframe with relevant data... """ - logger.info("The zonelist is %s", zonelist) - logger.info("The dlogname is %s", dlogname) - logger.info("The dvalues are %s", dvalues) + logger.debug("The zonelist is %s", zonelist) + logger.debug("The dlogname is %s", dlogname) + logger.debug("The dvalues are %s", dvalues) if zonelogname is not None: usezonelogname = zonelogname @@ -368,8 +368,8 @@ def get_fraction_per_zone( xtralogs = [dlogname, useinclname, "_QFLAG"] for izon in zonelist: - logger.info("The zone number is %s", izon) - logger.info("The extralogs are %s", xtralogs) + logger.debug("The zone number is %s", izon) + logger.debug("The extralogs are %s", xtralogs) dfr = self.get_zone_interval(izon, extralogs=xtralogs) diff --git a/src/xtgeo/well/_wells_utils.py b/src/xtgeo/well/_wells_utils.py index 3c1c68260..28115ce73 100644 --- a/src/xtgeo/well/_wells_utils.py +++ b/src/xtgeo/well/_wells_utils.py @@ -41,11 +41,11 @@ def wellintersections( for iwell, well in enumerate(self.wells): progress.flush(iwell) - logger.info("Work with %s", well.name) + logger.debug("Work with %s", well.name) try: well.geometrics() except ValueError: - logger.info("Skip %s (cannot compute geometrics)", well.name) + logger.debug("Skip %s (cannot compute geometrics)", well.name) continue welldfr = well.dataframe.copy() @@ -53,7 +53,7 @@ def wellintersections( xcor = welldfr[well.xname].values ycor = welldfr[well.yname].values mcor = welldfr[well.mdlogname].values - logger.info("The mdlogname property is: %s", well.mdlogname) + logger.debug("The mdlogname property is: %s", well.mdlogname) if xcor.size < 2: continue @@ -71,7 +71,7 @@ def wellintersections( nox[well.name].append(other.name) continue # a quick check; no chance for overlap - logger.info("Consider crossing with %s ...", other.name) + logger.debug("Consider crossing with %s ...", other.name) # try to be smart to skip entries that earlier have beenn tested # for crossing. If other does not cross well, then well does not @@ -152,5 +152,5 @@ def wellintersections( progress.finished() - logger.info("All intersections found!") + logger.debug("All intersections found!") return dfr diff --git a/src/xtgeo/well/blocked_well.py b/src/xtgeo/well/blocked_well.py index 58380685a..8552761af 100644 --- a/src/xtgeo/well/blocked_well.py +++ b/src/xtgeo/well/blocked_well.py @@ -66,7 +66,9 @@ def blockedwell_from_roxar( # TODO: replace this with proper class method obj = BlockedWell( - *([0.0] * 3), "", pd.DataFrame({"X_UTME": [], "Y_UTMN": [], "Z_TVDSS": []}) + *([0.0] * 3), + "", + pd.DataFrame({_AttrName.XNAME: [], _AttrName.YNAME: [], _AttrName.ZNAME: []}), ) _blockedwell_roxapi.import_bwell_roxapi( diff --git a/src/xtgeo/well/blocked_wells.py b/src/xtgeo/well/blocked_wells.py index 7d6e5a02c..8f67f248a 100644 --- a/src/xtgeo/well/blocked_wells.py +++ b/src/xtgeo/well/blocked_wells.py @@ -95,7 +95,7 @@ def copy(self): def get_blocked_well(self, name): """Get a BlockedWell() instance by name, or None""" - logger.info("Calling super...") + logger.debug("Calling super...") return super().get_well(name) @deprecation.deprecated( diff --git a/src/xtgeo/well/well1.py b/src/xtgeo/well/well1.py index 5a3a546de..9c7fee120 100644 --- a/src/xtgeo/well/well1.py +++ b/src/xtgeo/well/well1.py @@ -14,8 +14,8 @@ import xtgeo import xtgeo.common.constants as const import xtgeo.cxtgeo._cxtgeo as _cxtgeo # type: ignore +from xtgeo.common import _AttrType, _xyz_data # type: ignore[attr-defined] -from ..xyz_common import _xyz_data # type: ignore[attr-defined] from . import _well_aux, _well_io, _well_oper, _well_roxapi, _wellmarkers xtg = xtgeo.XTGeoDialog() @@ -192,8 +192,6 @@ def __init__( self._zonelogname = zonelogname self._wdata = _xyz_data._XYZData(df, wlogtypes, wlogrecords) - # self._wlogtypes = self._wdata.attr_types - # self._wlogrecords = self._wdata.attr_records self._ensure_consistency() @@ -735,7 +733,7 @@ def get_wlogs(self) -> dict: res = dict() for key in self.get_lognames(): - wtype = "CONT" + wtype = _AttrType.CONT.value wrecord = None if key in self._wdata.attr_types: wtype = self._wdata.attr_types[key].name @@ -779,7 +777,10 @@ def isdiscrete(self, logname): .. versionadded:: 2.2.0 """ - if logname in self.get_lognames() and self.get_logtype(logname) == "DISC": + if ( + logname in self.get_lognames() + and self.get_logtype(logname) == _AttrType.DISC.value + ): return True return False @@ -811,7 +812,7 @@ def rename_log(self, lname, newname): def create_log( self, lname: str, - logtype: str = "CONT", + logtype: str = _AttrType.CONT.value, logrecord: Optional[dict] = None, value: float = 0.0, force: bool = True, @@ -848,7 +849,7 @@ def copy_log( newname: str, force: bool = True, ) -> bool: - """Copy a log from an exisitng to a name + """Copy a log from an existing to a name If the new log already exists, it will be silently overwritten, unless the option force=False. @@ -858,13 +859,13 @@ def copy_log( newname: name of new log Returns: - True ff a new log is made (either new or force overwrite an + True if a new log is made (either new or force overwrite an existing) or False if the new log already exists, and ``force=False``. Note:: - A copy can alos be done directly in the dataframe, but with less + A copy can also be done directly in the dataframe, but with less consistency checks; hence this method is recommended """ diff --git a/src/xtgeo/well/wells.py b/src/xtgeo/well/wells.py index 1b5f2d465..4156769dd 100644 --- a/src/xtgeo/well/wells.py +++ b/src/xtgeo/well/wells.py @@ -133,7 +133,7 @@ def copy(self): def get_well(self, name): """Get a Well() instance by name, or None""" - logger.info("Asking for a well with name %s", name) + logger.debug("Asking for a well with name %s", name) for well in self._wells: if well.name == name: return well @@ -216,13 +216,13 @@ def get_dataframe(self, filled=False, fill_value1=-999, fill_value2=-9999): fill_value2 (int): Only applied if filled=True, when logs are missing completely for that well. """ - logger.info("Ask for big dataframe for all wells") + logger.debug("Ask for big dataframe for all wells") bigdflist = [] for well in self._wells: dfr = well.dataframe.copy() dfr["WELLNAME"] = well.name - logger.info(well.name) + logger.debug(well.name) if filled: dfr = dfr.fillna(fill_value1) bigdflist.append(dfr) diff --git a/src/xtgeo/xyz_common/__init__.py b/src/xtgeo/xyz_common/__init__.py deleted file mode 100644 index d0d9058e2..000000000 --- a/src/xtgeo/xyz_common/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -# common low level and private modules for XYZ and Well; in an own folder so far to -# avoid circular import - -from xtgeo.xyz_common._xyz_data import _XYZData -from xtgeo.xyz_common._xyz_enum import _AttrName, _AttrType, _XYZType - -__all__ = ["_XYZData", "_AttrName", "_AttrType", "_XYZType"] diff --git a/tests/test_well/test_well_vs_grid.py b/tests/test_well/test_well_vs_grid.py index f9b2c83bc..6496d6c2e 100644 --- a/tests/test_well/test_well_vs_grid.py +++ b/tests/test_well/test_well_vs_grid.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- - +from __future__ import annotations from os.path import join diff --git a/tests/test_well/test_well_xyzdata_class.py b/tests/test_well/test_well_xyzdata_class.py index ad5fe5f84..57a0d9512 100644 --- a/tests/test_well/test_well_xyzdata_class.py +++ b/tests/test_well/test_well_xyzdata_class.py @@ -2,7 +2,7 @@ import pandas as pd import pytest -from xtgeo.xyz_common import _AttrType, _XYZData +from xtgeo.common import _AttrType, _XYZData @pytest.fixture(name="generate_data") @@ -163,8 +163,8 @@ def test_well_xyzdata_consistency_add_column(generate_data: pd.DataFrame): def test_attrtype_class(): """Test the ENUM type _LogClass""" - assert _AttrType.DISC.value == 2 - assert _AttrType.CONT.value == 1 + assert _AttrType.DISC.value == "DISC" + assert _AttrType.CONT.value == "CONT" assert "CONT" in _AttrType.__members__ assert "DISC" in _AttrType.__members__