From 5bd5e34a564e6f4c64de2595a2e0772c3264b54e Mon Sep 17 00:00:00 2001 From: mferrera Date: Fri, 9 Feb 2024 10:54:05 +0100 Subject: [PATCH] CLN: Import constants directly --- src/xtgeo/__init__.py | 1 - src/xtgeo/cube/_cube_import.py | 33 +++++++++++++------------- src/xtgeo/cube/_cube_utils.py | 6 ++--- src/xtgeo/cube/cube1.py | 7 +++--- src/xtgeo/io/_file.py | 5 ++-- src/xtgeo/metadata/metadata.py | 10 ++++---- src/xtgeo/roxutils/_roxutils_etc.py | 3 ++- src/xtgeo/well/_blockedwell_roxapi.py | 2 +- src/xtgeo/well/_blockedwells_roxapi.py | 3 ++- src/xtgeo/well/_well_aux.py | 2 +- src/xtgeo/well/_well_io.py | 2 +- src/xtgeo/well/_well_oper.py | 23 +++++++++--------- src/xtgeo/well/_wellmarkers.py | 22 ++++++++++------- src/xtgeo/well/well1.py | 8 +++---- src/xtgeo/xyz/_polygons_oper.py | 3 ++- src/xtgeo/xyz/_xyz.py | 3 ++- src/xtgeo/xyz/_xyz_data.py | 19 ++++++++------- src/xtgeo/xyz/_xyz_io.py | 13 +++++----- src/xtgeo/xyz/_xyz_lowlevel.py | 3 +-- src/xtgeo/xyz/_xyz_oper.py | 6 +++-- src/xtgeo/xyz/_xyz_roxapi.py | 2 +- src/xtgeo/xyz/points.py | 3 ++- src/xtgeo/xyz/polygons.py | 3 ++- 23 files changed, 96 insertions(+), 86 deletions(-) diff --git a/src/xtgeo/__init__.py b/src/xtgeo/__init__.py index 25b0a4f54..5ad898852 100644 --- a/src/xtgeo/__init__.py +++ b/src/xtgeo/__init__.py @@ -90,7 +90,6 @@ def _xprint(msg): _xprint("Import various XTGeo modules... metadata...") - from xtgeo.roxutils import roxutils from xtgeo.roxutils.roxutils import RoxUtils diff --git a/src/xtgeo/cube/_cube_import.py b/src/xtgeo/cube/_cube_import.py index a8404abf4..07155273d 100644 --- a/src/xtgeo/cube/_cube_import.py +++ b/src/xtgeo/cube/_cube_import.py @@ -40,11 +40,12 @@ import segyio from segyio import TraceField as TF -import xtgeo.common.calc as xcalc -import xtgeo.common.constants as const import xtgeo.common.sys as xsys from xtgeo import _cxtgeo -from xtgeo.common import XTGeoDialog, null_logger +from xtgeo.common import calc +from xtgeo.common.constants import UNDEF +from xtgeo.common.log import null_logger +from xtgeo.common.xtgeo_dialog import XTGeoDialog from xtgeo.metadata.metadata import MetaDataRegularCube if TYPE_CHECKING: @@ -141,22 +142,22 @@ def _segy_all_traces_attributes( traceidcodes = segyfile.attributes(trcode)[:].reshape(ncol, nrow) # need positions in corners for making vectors to compute geometries - c1v = xcalc.ijk_to_ib(1, 1, 1, ncol, nrow, 1, forder=False) - c2v = xcalc.ijk_to_ib(ncol, 1, 1, ncol, nrow, 1, forder=False) - c3v = xcalc.ijk_to_ib(1, nrow, 1, ncol, nrow, 1, forder=False) + c1v = calc.ijk_to_ib(1, 1, 1, ncol, nrow, 1, forder=False) + c2v = calc.ijk_to_ib(ncol, 1, 1, ncol, nrow, 1, forder=False) + c3v = calc.ijk_to_ib(1, nrow, 1, ncol, nrow, 1, forder=False) xori, yori, zori, zinc = _get_coordinate(segyfile, c1v) point_x1, point_y1, _, _ = _get_coordinate(segyfile, c2v) point_x2, point_y2, _, _ = _get_coordinate(segyfile, c3v) - slen1, _, rotation = xcalc.vectorinfo2(xori, point_x1, yori, point_y1) + slen1, _, rotation = calc.vectorinfo2(xori, point_x1, yori, point_y1) xinc = slen1 / (ncol - 1) - slen2, _, _ = xcalc.vectorinfo2(xori, point_x2, yori, point_y2) + slen2, _, _ = calc.vectorinfo2(xori, point_x2, yori, point_y2) yinc = slen2 / (nrow - 1) # find YFLIP by cross products - yflip = xcalc.find_flip( + yflip = calc.find_flip( (point_x1 - xori, point_y1 - yori, 0), (point_x2 - xori, point_y2 - yori, 0) ) @@ -207,7 +208,7 @@ def _import_segy_incomplete_traces(segyfile: segyio.segy.SegyFile) -> dict: nrow = int(abs(xlines_case.min() - xlines_case.max()) / xspacing) + 1 nlay = data.shape[1] - values = np.full((ncol, nrow, nlay), const.UNDEF, dtype=np.float32) + values = np.full((ncol, nrow, nlay), UNDEF, dtype=np.float32) traceidcodes = np.full((ncol, nrow), 2, dtype=np.int64) ilines_shifted = (ilines_case / ispacing).astype(np.int64) @@ -327,19 +328,17 @@ def _geometry_incomplete_traces( jl1x, jl1y, _, _ = _get_coordinate(segyfile, jnd1) jl2x, jl2y, _, _ = _get_coordinate(segyfile, jnd2) - xslen, _, rot1 = xcalc.vectorinfo2(il1x, il2x, il1y, il2y) + xslen, _, rot1 = calc.vectorinfo2(il1x, il2x, il1y, il2y) xinc = ispacing * xslen / (abs(ilines_case[ind1] - ilines_case[ind2])) - yslen, _, _ = xcalc.vectorinfo2(jl1x, jl2x, jl1y, jl2y) + yslen, _, _ = calc.vectorinfo2(jl1x, jl2x, jl1y, jl2y) yinc = xspacing * yslen / (abs(xlines_case[jnd1] - xlines_case[jnd2])) - yflip = xcalc.find_flip( - (il2x - il1x, il2y - il1y, 0), (jl2x - jl1x, jl2y - jl1y, 0) - ) + yflip = calc.find_flip((il2x - il1x, il2y - il1y, 0), (jl2x - jl1x, jl2y - jl1y, 0)) # need to compute xori and yori from 'case' I J indices with known x y and # (iline, xline); use ind1 with assosiated coordinates il1x il1y i_use, j_use = reverseindex_full[index_case[ind1]] - xori, yori = xcalc.xyori_from_ij( + xori, yori = calc.xyori_from_ij( i_use, j_use, il1x, il1y, xinc, yinc, ncol, nrow, yflip, rot1 ) @@ -613,7 +612,7 @@ def import_xtgregcube(mfile, values=True): # although we do not support initializing with any other value. # As xtgeo-format is only written/read by xtgeo as far as we know, this should # be unproblematic for now. - if results.pop("undef", None) != const.UNDEF: + if results.pop("undef", None) != UNDEF: raise ValueError( f"File {mfile.file} has non-standard undef, not supported by xtgeo" ) diff --git a/src/xtgeo/cube/_cube_utils.py b/src/xtgeo/cube/_cube_utils.py index 727a73628..c9f003a4f 100644 --- a/src/xtgeo/cube/_cube_utils.py +++ b/src/xtgeo/cube/_cube_utils.py @@ -4,11 +4,11 @@ import numpy as np -import xtgeo.common.constants as const from xtgeo import _cxtgeo from xtgeo._cxtgeo import XTGeoCLibError -from xtgeo.common import null_logger from xtgeo.common.calc import _swap_axes +from xtgeo.common.constants import UNDEF_LIMIT +from xtgeo.common.log import null_logger from xtgeo.xyz.polygons import Polygons logger = null_logger(__name__) @@ -264,7 +264,7 @@ def get_randomline( option, ) - values[values > const.UNDEF_LIMIT] = np.nan + values[values > UNDEF_LIMIT] = np.nan arr = values.reshape((xcoords.shape[0], nzsam)).T return (hcoords[0], hcoords[-1], zmin, zmax, arr) diff --git a/src/xtgeo/cube/cube1.py b/src/xtgeo/cube/cube1.py index 8f3a87cc3..2c4e5f49e 100644 --- a/src/xtgeo/cube/cube1.py +++ b/src/xtgeo/cube/cube1.py @@ -13,11 +13,12 @@ import deprecation import numpy as np -import xtgeo.common.constants as const -from xtgeo.common import XTGDescription, null_logger +from xtgeo.common.constants import UNDEF +from xtgeo.common.log import null_logger from xtgeo.common.sys import generic_hash from xtgeo.common.types import Dimensions from xtgeo.common.version import __version__ +from xtgeo.common.xtgeo_dialog import XTGDescription from xtgeo.grid3d.grid import grid_from_cube from xtgeo.io._file import FileFormat, FileWrapper from xtgeo.metadata.metadata import MetaDataRegularCube @@ -278,7 +279,7 @@ def _reset( else: self._traceidcodes = traceidcodes self._segyfile = segyfile - self.undef = const.UNDEF + self.undef = UNDEF self._metadata = MetaDataRegularCube() self._metadata.required = self diff --git a/src/xtgeo/io/_file.py b/src/xtgeo/io/_file.py index 687466b7a..665afcaee 100644 --- a/src/xtgeo/io/_file.py +++ b/src/xtgeo/io/_file.py @@ -15,9 +15,7 @@ from typing import TYPE_CHECKING, Literal, Union import xtgeo._cxtgeo -from xtgeo.common import null_logger - -logger = null_logger(__name__) +from xtgeo.common.log import null_logger if TYPE_CHECKING: from xtgeo.common.types import FileLike @@ -42,6 +40,7 @@ Wells, ] +logger = null_logger(__name__) VALID_FILE_ALIASES = ["$fmu-v1", "$md5sum", "$random"] diff --git a/src/xtgeo/metadata/metadata.py b/src/xtgeo/metadata/metadata.py index c1146c6e8..dae98e436 100644 --- a/src/xtgeo/metadata/metadata.py +++ b/src/xtgeo/metadata/metadata.py @@ -11,8 +11,8 @@ """ import xtgeo -import xtgeo.common.constants as const -from xtgeo.common import null_logger +from xtgeo.common.constants import UNDEF +from xtgeo.common.log import null_logger logger = null_logger(__name__) @@ -110,7 +110,7 @@ def description(self, newstr): raise ValueError("The description length must less or equal 64 letters.") invalids = r"/$<>[]:\&%" if set(invalids).intersection(newstr): - raise ValueError("The description constains invalid characters such as /.") + raise ValueError("The description contains invalid characters such as /.") self._description = newstr @@ -235,7 +235,7 @@ class MetaDataRegularSurface(MetaData): "yinc": 1.0, "yflip": 1, "rotation": 0.0, - "undef": const.UNDEF, + "undef": UNDEF, } def __init__(self): @@ -282,7 +282,7 @@ class MetaDataRegularCube(MetaData): "yflip": 1, "zflip": 1, "rotation": 0.0, - "undef": const.UNDEF, + "undef": UNDEF, } def __init__(self): diff --git a/src/xtgeo/roxutils/_roxutils_etc.py b/src/xtgeo/roxutils/_roxutils_etc.py index 31ea18489..b36e4eed2 100644 --- a/src/xtgeo/roxutils/_roxutils_etc.py +++ b/src/xtgeo/roxutils/_roxutils_etc.py @@ -1,10 +1,11 @@ """Private module for etc functions""" + import contextlib with contextlib.suppress(ImportError): import roxar -from xtgeo.common import null_logger +from xtgeo.common.log import null_logger logger = null_logger(__name__) diff --git a/src/xtgeo/well/_blockedwell_roxapi.py b/src/xtgeo/well/_blockedwell_roxapi.py index 895eda5b1..f1cb1641d 100644 --- a/src/xtgeo/well/_blockedwell_roxapi.py +++ b/src/xtgeo/well/_blockedwell_roxapi.py @@ -4,10 +4,10 @@ import numpy.ma as npma import pandas as pd -from xtgeo.common import null_logger from xtgeo.common._xyz_enum import _AttrName, _AttrType from xtgeo.common.constants import INT_MIN from xtgeo.common.exceptions import WellNotFoundError +from xtgeo.common.log import null_logger from xtgeo.roxutils import RoxUtils try: diff --git a/src/xtgeo/well/_blockedwells_roxapi.py b/src/xtgeo/well/_blockedwells_roxapi.py index e1e028857..3ea377c77 100644 --- a/src/xtgeo/well/_blockedwells_roxapi.py +++ b/src/xtgeo/well/_blockedwells_roxapi.py @@ -1,6 +1,7 @@ """Well input and output, private module for ROXAPI""" -from xtgeo.common import XTGeoDialog, null_logger +from xtgeo.common.log import null_logger +from xtgeo.common.xtgeo_dialog import XTGeoDialog from xtgeo.roxutils import RoxUtils from .blocked_well import blockedwell_from_roxar diff --git a/src/xtgeo/well/_well_aux.py b/src/xtgeo/well/_well_aux.py index 2514e6e3e..f6e976175 100644 --- a/src/xtgeo/well/_well_aux.py +++ b/src/xtgeo/well/_well_aux.py @@ -13,8 +13,8 @@ import pandas as pd -from xtgeo.common import null_logger from xtgeo.common._xyz_enum import _AttrName +from xtgeo.common.log import null_logger from xtgeo.io._file import FileFormat, FileWrapper from . import _well_io diff --git a/src/xtgeo/well/_well_io.py b/src/xtgeo/well/_well_io.py index 0e012e3b2..b4b03c162 100644 --- a/src/xtgeo/well/_well_io.py +++ b/src/xtgeo/well/_well_io.py @@ -6,8 +6,8 @@ import numpy as np import pandas as pd -from xtgeo.common import null_logger from xtgeo.common._xyz_enum import _AttrName, _AttrType +from xtgeo.common.log import null_logger from xtgeo.metadata.metadata import MetaDataWell logger = null_logger(__name__) diff --git a/src/xtgeo/well/_well_oper.py b/src/xtgeo/well/_well_oper.py index d952aebaf..59e66849e 100644 --- a/src/xtgeo/well/_well_oper.py +++ b/src/xtgeo/well/_well_oper.py @@ -6,8 +6,9 @@ import pandas as pd from xtgeo import _cxtgeo -from xtgeo.common import constants as const, null_logger from xtgeo.common._xyz_enum import _AttrType +from xtgeo.common.constants import UNDEF_INT, UNDEF_INT_LIMIT +from xtgeo.common.log import null_logger from xtgeo.common.sys import _get_carray from xtgeo.xyz.points import Points @@ -122,7 +123,7 @@ def make_zone_qual_log(self, zqname): else: prev_ = seq[ind - 1] next_ = seq[ind + 1] - if prev_ > const.UNDEF_INT_LIMIT or next_ > const.UNDEF_INT_LIMIT: + if prev_ > UNDEF_INT_LIMIT or next_ > UNDEF_INT_LIMIT: code.append(9) elif next_ > iseq > prev_: code.append(1) @@ -357,32 +358,32 @@ def report_zonation_holes(self, threshold=5): xvv = self._wdata.data[self.xname].values yvv = self._wdata.data[self.yname].values zvv = self._wdata.data[self.zname].values - zlog[np.isnan(zlog)] = const.UNDEF_INT + zlog[np.isnan(zlog)] = UNDEF_INT ncv = 0 first = True hole = False for ind, zone in np.ndenumerate(zlog): ino = ind[0] - if zone > const.UNDEF_INT_LIMIT and first: + if zone > UNDEF_INT_LIMIT and first: continue - if zone < const.UNDEF_INT_LIMIT and first: + if zone < UNDEF_INT_LIMIT and first: first = False continue - if zone > const.UNDEF_INT_LIMIT: + if zone > UNDEF_INT_LIMIT: ncv += 1 hole = True - if zone > const.UNDEF_INT_LIMIT and ncv > threshold: + if zone > UNDEF_INT_LIMIT and ncv > threshold: logger.debug("Restart first (bigger hole)") hole = False first = True ncv = 0 continue - if hole and zone < const.UNDEF_INT_LIMIT and ncv <= threshold: + if hole and zone < UNDEF_INT_LIMIT and ncv <= threshold: # here we have a hole that fits criteria if mdlog is not None: entry = ( @@ -403,7 +404,7 @@ def report_zonation_holes(self, threshold=5): hole = False ncv = 0 - if hole and zone < const.UNDEF_INT_LIMIT and ncv > threshold: + if hole and zone < UNDEF_INT_LIMIT and ncv > threshold: hole = False ncv = 0 @@ -531,11 +532,11 @@ def _get_bseries_by_distance(depth, inseries, distance): bseries = pd.Series(np.zeros(inseries.values.size), dtype="int32").values try: - inseries = np.nan_to_num(inseries.values, nan=const.UNDEF_INT).astype("int32") + inseries = np.nan_to_num(inseries.values, nan=UNDEF_INT).astype("int32") except TypeError: # for older numpy version inseries = inseries.values - inseries[np.isnan(inseries)] = const.UNDEF_INT + inseries[np.isnan(inseries)] = UNDEF_INT inseries = inseries.astype("int32") res = _cxtgeo.well_mask_shoulder( diff --git a/src/xtgeo/well/_wellmarkers.py b/src/xtgeo/well/_wellmarkers.py index 863cf17eb..ee1bdf3c8 100644 --- a/src/xtgeo/well/_wellmarkers.py +++ b/src/xtgeo/well/_wellmarkers.py @@ -3,9 +3,15 @@ import numpy as np import pandas as pd -import xtgeo.common.constants as const from xtgeo import _cxtgeo -from xtgeo.common import null_logger +from xtgeo.common.constants import ( + UNDEF, + UNDEF_DISC, + UNDEF_INT, + UNDEF_INT_LIMIT, + UNDEF_LIMIT, +) +from xtgeo.common.log import null_logger from xtgeo.xyz.points import Points logger = null_logger(__name__) @@ -27,7 +33,7 @@ def get_zonation_points(self, tops, incl_limit, top_prefix, zonelist, use_undef) if use_undef: dataframe.dropna(subset=[scopy.zonelogname], inplace=True) zlog = dataframe[scopy.zonelogname].values - zlog[np.isnan(zlog)] = const.UNDEF_DISC + zlog[np.isnan(zlog)] = UNDEF_DISC zlog = np.rint(zlog).astype(int) else: return None @@ -139,8 +145,8 @@ def _extract_ztops( f" was {usezonerange}" ) - iundef = const.UNDEF_INT - iundeflimit = const.UNDEF_INT_LIMIT + iundef = UNDEF_INT + iundeflimit = UNDEF_INT_LIMIT pzone = iundef if use_undef: @@ -382,7 +388,7 @@ def get_fraction_per_zone( if dseries.size < count_limit: # interval too short for fraction logger.debug("Skipped due to too few values %s", dseries.size) continue - if dseries.max() > const.UNDEF_INT_LIMIT: + if dseries.max() > UNDEF_INT_LIMIT: logger.debug("Skipped due to too missing/undef value(s)") continue @@ -422,7 +428,7 @@ def get_surface_picks(self, surf): if self.mdlogname: mcor = dataframe[self.mdlogname].values else: - mcor = np.zeros(xcor.size, dtype=np.float64) + const.UNDEF + mcor = np.zeros(xcor.size, dtype=np.float64) + UNDEF nval, xres, yres, zres, mres, dres = _cxtgeo.well_surf_picks( xcor, @@ -448,7 +454,7 @@ def get_surface_picks(self, surf): if nval > 0: poi = Points() - mres[mres > const.UNDEF_LIMIT] = np.nan + mres[mres > UNDEF_LIMIT] = np.nan res = {} res[poi.xname] = xres[:nval] diff --git a/src/xtgeo/well/well1.py b/src/xtgeo/well/well1.py index 528e1b129..3b65121ae 100644 --- a/src/xtgeo/well/well1.py +++ b/src/xtgeo/well/well1.py @@ -10,9 +10,9 @@ import numpy as np import pandas as pd -import xtgeo.common.constants as const from xtgeo import _cxtgeo from xtgeo.common._xyz_enum import _AttrType +from xtgeo.common.constants import UNDEF, UNDEF_INT, UNDEF_LIMIT from xtgeo.common.log import null_logger from xtgeo.common.version import __version__ from xtgeo.common.xtgeo_dialog import XTGDescription @@ -990,9 +990,7 @@ def get_dataframe(self, copy: bool = True): """ return self._wdata.get_dataframe(copy=copy) - def get_filled_dataframe( - self, fill_value=const.UNDEF, fill_value_int=const.UNDEF_INT - ): + def get_filled_dataframe(self, fill_value=UNDEF, fill_value_int=UNDEF_INT): """Fill the Nan's in the dataframe with real UNDEF values. This module returns a copy of the dataframe in the object; it @@ -1095,7 +1093,7 @@ def truncate_parallel_path( raise RuntimeError("Unexpected error") dfr = self.get_dataframe() - dfr = dfr[dfr[self.xname] < const.UNDEF_LIMIT] + dfr = dfr[dfr[self.xname] < UNDEF_LIMIT] self.set_dataframe(dfr) def may_overlap(self, other): diff --git a/src/xtgeo/xyz/_polygons_oper.py b/src/xtgeo/xyz/_polygons_oper.py index 4497bb4ed..e7fafc7e0 100644 --- a/src/xtgeo/xyz/_polygons_oper.py +++ b/src/xtgeo/xyz/_polygons_oper.py @@ -8,6 +8,7 @@ Functions starting with '_' are local helper functions """ + from math import ceil import numpy as np @@ -17,7 +18,7 @@ from shapely.ops import polygonize import xtgeo -from xtgeo.common import null_logger +from xtgeo.common.log import null_logger logger = null_logger(__name__) MINIMUM_NUMBER_POINTS = 4 diff --git a/src/xtgeo/xyz/_xyz.py b/src/xtgeo/xyz/_xyz.py index c6826aeab..a8bc2cf3f 100644 --- a/src/xtgeo/xyz/_xyz.py +++ b/src/xtgeo/xyz/_xyz.py @@ -8,7 +8,8 @@ import numpy as np -from xtgeo.common import XTGDescription, XTGeoDialog, null_logger +from xtgeo.common.log import null_logger +from xtgeo.common.xtgeo_dialog import XTGDescription, XTGeoDialog from . import _xyz_oper diff --git a/src/xtgeo/xyz/_xyz_data.py b/src/xtgeo/xyz/_xyz_data.py index 7fb2cd452..992850b20 100644 --- a/src/xtgeo/xyz/_xyz_data.py +++ b/src/xtgeo/xyz/_xyz_data.py @@ -41,10 +41,11 @@ import pandas as pd from joblib import hash as jhash -import xtgeo.common.constants as const -from xtgeo import XTGeoCLibError, _cxtgeo -from xtgeo.common import null_logger +from xtgeo import _cxtgeo +from xtgeo._cxtgeo import XTGeoCLibError from xtgeo.common._xyz_enum import _AttrName, _AttrType, _XYZType +from xtgeo.common.constants import UNDEF_CONT, UNDEF_DISC +from xtgeo.common.log import null_logger from xtgeo.common.sys import _convert_carr_double_np, _get_carray if TYPE_CHECKING: @@ -247,8 +248,8 @@ def _infer_automatic_record(self, attr_name: str): codes = {value: str(value) for value in unique} if self._undef_disc in codes: del codes[self._undef_disc] - if const.UNDEF_DISC in codes: - del codes[const.UNDEF_DISC] + if UNDEF_DISC in codes: + del codes[UNDEF_DISC] else: codes = None @@ -301,13 +302,13 @@ def _ensure_consistency_df_dtypes(self): logger.debug("Replacing CONT undef...") self._df[name].replace( self._undef_cont, - np.float64(const.UNDEF_CONT).astype(self._floatbits), + np.float64(UNDEF_CONT).astype(self._floatbits), inplace=True, ) else: logger.debug("Replacing INT undef...") self._df[name].replace( - self._undef_disc, np.int32(const.UNDEF_DISC), inplace=True + self._undef_disc, np.int32(UNDEF_DISC), inplace=True ) logger.info("Processed dataframe: %s", list(self._df.dtypes)) @@ -438,8 +439,8 @@ def get_dataframe_copy( self, infer_dtype: bool = False, filled=False, - fill_value=const.UNDEF_CONT, - fill_value_int=const.UNDEF_DISC, + fill_value=UNDEF_CONT, + fill_value_int=UNDEF_DISC, ): """Get a deep copy of the dataframe, with options. diff --git a/src/xtgeo/xyz/_xyz_io.py b/src/xtgeo/xyz/_xyz_io.py index 465866853..851142d3c 100644 --- a/src/xtgeo/xyz/_xyz_io.py +++ b/src/xtgeo/xyz/_xyz_io.py @@ -1,11 +1,10 @@ """Private import and export routines for XYZ stuff.""" - import numpy as np import pandas as pd -import xtgeo -from xtgeo.common import null_logger +from xtgeo.common.constants import UNDEF, UNDEF_INT +from xtgeo.common.log import null_logger from xtgeo.io._file import FileWrapper logger = null_logger(__name__) @@ -159,9 +158,9 @@ def import_rms_attr(pfile, zname="Z_TVDSS"): for col in dfr.columns[3:]: if col in _attrs: if _attrs[col] == "float": - dfr[col].replace("UNDEF", xtgeo.UNDEF, inplace=True) + dfr[col].replace("UNDEF", UNDEF, inplace=True) elif _attrs[col] == "int": - dfr[col].replace("UNDEF", xtgeo.UNDEF_INT, inplace=True) + dfr[col].replace("UNDEF", UNDEF_INT, inplace=True) # cast to numerical if possible dfr[col] = pd.to_numeric(dfr[col], errors="ignore") @@ -308,9 +307,9 @@ def export_rms_attr(self, pfile, attributes=True, pfilter=None, ispolygons=False if col in df.columns: fout.write(transl[self._attrs[col]] + " " + col + "\n") if self._attrs[col] == "int": - df[col].replace(xtgeo.UNDEF_INT, "UNDEF", inplace=True) + df[col].replace(UNDEF_INT, "UNDEF", inplace=True) elif self._attrs[col] == "float": - df[col].replace(xtgeo.UNDEF, "UNDEF", inplace=True) + df[col].replace(UNDEF, "UNDEF", inplace=True) with open(pfile, mode) as fc: df.to_csv(fc, sep=" ", header=None, columns=columns, index=False) diff --git a/src/xtgeo/xyz/_xyz_lowlevel.py b/src/xtgeo/xyz/_xyz_lowlevel.py index 56e79751a..ef1161519 100644 --- a/src/xtgeo/xyz/_xyz_lowlevel.py +++ b/src/xtgeo/xyz/_xyz_lowlevel.py @@ -1,10 +1,9 @@ """Private low level routines (SWIG vs C)""" - import numpy as np from xtgeo import _cxtgeo -from xtgeo.common import null_logger +from xtgeo.common.log import null_logger logger = null_logger(__name__) diff --git a/src/xtgeo/xyz/_xyz_oper.py b/src/xtgeo/xyz/_xyz_oper.py index b3cafeebe..745bf8bda 100644 --- a/src/xtgeo/xyz/_xyz_oper.py +++ b/src/xtgeo/xyz/_xyz_oper.py @@ -9,7 +9,9 @@ import xtgeo from xtgeo import _cxtgeo -from xtgeo.common import XTGeoDialog, null_logger +from xtgeo.common.constants import UNDEF_LIMIT +from xtgeo.common.log import null_logger +from xtgeo.common.xtgeo_dialog import XTGeoDialog xtg = XTGeoDialog() logger = null_logger(__name__) @@ -105,7 +107,7 @@ def operation_polygons_v1(self, poly, value, opname="add", inside=True, where=Tr if ies != 0: raise RuntimeError(f"Something went wrong, code {ies}") - zcor[zcor > xtgeo.UNDEF_LIMIT] = np.nan + zcor[zcor > UNDEF_LIMIT] = np.nan dataframe = self.get_dataframe() dataframe[self.zname] = zcor # removing rows where Z column is undefined diff --git a/src/xtgeo/xyz/_xyz_roxapi.py b/src/xtgeo/xyz/_xyz_roxapi.py index f6588b8e7..b5cd8b3a7 100644 --- a/src/xtgeo/xyz/_xyz_roxapi.py +++ b/src/xtgeo/xyz/_xyz_roxapi.py @@ -11,9 +11,9 @@ import pandas as pd from xtgeo import ROXAR # type: ignore -from xtgeo.common import null_logger from xtgeo.common._xyz_enum import _AttrName from xtgeo.common.constants import UNDEF, UNDEF_INT, UNDEF_INT_LIMIT, UNDEF_LIMIT +from xtgeo.common.log import null_logger from xtgeo.io._file import FileWrapper from xtgeo.roxutils import RoxUtils from xtgeo.xyz import _xyz_io, points, polygons diff --git a/src/xtgeo/xyz/points.py b/src/xtgeo/xyz/points.py index 9c6285d80..8d519438b 100644 --- a/src/xtgeo/xyz/points.py +++ b/src/xtgeo/xyz/points.py @@ -13,7 +13,8 @@ import pandas as pd import xtgeo -from xtgeo.common import inherit_docstring, null_logger +from xtgeo.common.log import null_logger +from xtgeo.common.sys import inherit_docstring from xtgeo.common.version import __version__ from xtgeo.io._file import FileFormat, FileWrapper from xtgeo.xyz import XYZ, _xyz_io, _xyz_oper, _xyz_roxapi diff --git a/src/xtgeo/xyz/polygons.py b/src/xtgeo/xyz/polygons.py index d7b08fc88..25ebf8b53 100644 --- a/src/xtgeo/xyz/polygons.py +++ b/src/xtgeo/xyz/polygons.py @@ -16,7 +16,8 @@ import pandas as pd import shapely.geometry as sg -from xtgeo.common import inherit_docstring, null_logger +from xtgeo.common.log import null_logger +from xtgeo.common.sys import inherit_docstring from xtgeo.common.version import __version__ from xtgeo.io._file import FileFormat, FileWrapper from xtgeo.xyz import _xyz_io, _xyz_roxapi