Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
else:
klayer, what = where.split("_")
klayer = int(klayer)
if grid.nlay < klayer < 0:
raise ValueError("Klayer out of range in where={}".format(where))
option = 0
if what == "base":
option = 1
if rfactor < 0.5:
raise KeyError("Refinefactor rfactor is too small, should be >= 0.5")
_update_regsurf(self, template, grid, rfactor=float(rfactor))
# call C function to make a map
svalues = self.get_values1d() * 0.0 + xtgeo.UNDEF
ivalues = svalues.copy()
jvalues = svalues.copy()
_cxtgeo.surf_sample_grd3d_lay(
grid.ncol,
grid.nrow,
grid.nlay,
grid._coordsv,
grid._zcornsv,
grid._actnumsv,
klayer,
self.ncol,
self.nrow,
self.xori,
self.xinc,
self.yori,
names.append(cname)
self._attrs[cname] = dtyx
self._df = pd.read_csv(
pfile,
delim_whitespace=True,
skiprows=skiprows,
header=None,
names=names,
dtype=dtype,
)
for col in self._df.columns[3:]:
if col in self._attrs:
if self._attrs[col] == "float":
self._df[col].replace("UNDEF", xtgeo.UNDEF, inplace=True)
elif self._attrs[col] == "int":
self._df[col].replace("UNDEF", xtgeo.UNDEF_INT, inplace=True)
"elements; may get unexpected results, try to "
"achieve zero values as result!"
)
with np.errstate(divide="ignore", invalid="ignore"):
this = ma.filled(self.values, fill_value=1.0)
that = ma.filled(value, fill_value=1.0)
mask = ma.getmaskarray(self.values)
tmp = np.true_divide(this, that)
tmp = np.where(np.isinf(tmp), 0, tmp)
tmp = np.nan_to_num(tmp)
tmp = ma.array(tmp, mask=mask)
elif opname == "set":
tmp = value
elif opname == "eli":
tmp = value * 0 + xtgeo.UNDEF
tmp = ma.masked_greater(tmp, xtgeo.UNDEF_LIMIT)
self.values[proxyv == proxytarget] = tmp[proxyv == proxytarget]
del tmp
def update_carray(self, undef=None, discrete=None, dtype=None, order="F"):
"""Copy (update) values from numpy to SWIG, 1D array, returns a pointer
to SWIG C array. If discrete is defined as True or False, force
the SWIG array to be of that kind.
Note that dtype will "override" current datatype if set. The resulting
carray will be in Fortran order, unless order is specified as 'C'
"""
dstatus = self._isdiscrete
if discrete is not None:
dstatus = bool(discrete)
if undef is None:
undef = xtgeo.UNDEF
if dstatus:
undef = xtgeo.UNDEF_INT
logger.debug("Entering conversion from numpy to C array ...")
values = self._values.copy()
if not dtype:
if dstatus:
values = values.astype(np.int32)
else:
values = values.astype(np.float64)
else:
values = values.astype(dtype)
values = ma.filled(values, undef)
self._xori = 0.0
self._yori = 0.0
self._zori = 0.0
self._ncol = 5
self._nrow = 3
self._nlay = 4
self._xinc = 25.0
self._yinc = 25.0
self._zinc = 2.0
self._yflip = 1
self._values = np.zeros((5, 3, 4), dtype=np.float32)
self._ilines = np.array(range(1, 5 + 1), dtype=np.int32)
self._xlines = np.array(range(1, 3 + 1), dtype=np.int32)
self._rotation = 0.0
self._traceidcodes = np.ones((5, 3), dtype=np.int32)
self._undef = xtgeo.UNDEF
self._undef_limit = xtgeo.UNDEF_LIMIT
if len(args) >= 1:
fformat = kwargs.get("fformat", "guess")
self.from_file(args[0], fformat=fformat)
else:
self._filesrc = None
self._xori = kwargs.get("xori", 0.0)
self._yori = kwargs.get("yori", 0.0)
self._zori = kwargs.get("zori", 0.0)
self._ncol = kwargs.get("ncol", 5)
self._nrow = kwargs.get("nrow", 3)
self._nlay = kwargs.get("nlay", 2)
self._xinc = kwargs.get("xinc", 25.0)
self._yinc = kwargs.get("yinc", 25.0)
self._zinc = kwargs.get("zinc", 2.0)
def get_surface_picks(self, surf):
"""get Surface picks"""
xcor = self._df["X_UTME"].values
ycor = self._df["Y_UTMN"].values
zcor = self._df["Z_TVDSS"].values
if self.mdlogname:
mcor = self._df[self.mdlogname].values
else:
mcor = np.zeros(xcor.size, dtype=np.float64) + xtgeo.UNDEF
nval, xres, yres, zres, mres, dres = _cxtgeo.well_surf_picks(
xcor,
ycor,
zcor,
mcor,
surf.ncol,
surf.nrow,
surf.xori,
surf.yori,
surf.xinc,
surf.yinc,
surf.yflip,
surf.rotation,
surf.npvalues1d,
xcor.size,
mpr2 = ma.average(mpr2, weights=normed_dz, axis=2) # avg zone
newx.append(xpr2)
newy.append(ypr2)
newz.append(zpr2)
newd.append(dpr2)
newm.append(mpr2)
xpr = ma.dstack(newx)
ypr = ma.dstack(newy)
zpr = ma.dstack(newz)
dpr = ma.dstack(newd)
mpr = ma.dstack(newm)
zpr.astype(np.int32)
xpr = ma.filled(xpr, fill_value=xtgeo.UNDEF)
ypr = ma.filled(ypr, fill_value=xtgeo.UNDEF)
zpr = ma.filled(zpr, fill_value=0)
dpr = ma.filled(dpr, fill_value=0.0)
mpr = ma.filled(mpr, fill_value=0.0)
return xpr, ypr, zpr, mpr, dpr
newx.append(xpr2)
newy.append(ypr2)
newz.append(zpr2)
newd.append(dpr2)
newm.append(mpr2)
xpr = ma.dstack(newx)
ypr = ma.dstack(newy)
zpr = ma.dstack(newz)
dpr = ma.dstack(newd)
mpr = ma.dstack(newm)
zpr.astype(np.int32)
xpr = ma.filled(xpr, fill_value=xtgeo.UNDEF)
ypr = ma.filled(ypr, fill_value=xtgeo.UNDEF)
zpr = ma.filled(zpr, fill_value=0)
dpr = ma.filled(dpr, fill_value=0.0)
mpr = ma.filled(mpr, fill_value=0.0)
return xpr, ypr, zpr, mpr, dpr
def export_ijxyz_ascii(self, mfile):
"""Export to DSG IJXYZ ascii format."""
vals = self.get_values1d(fill_value=xtgeo.UNDEF)
ier = _cxtgeo.surf_export_ijxyz(
mfile.get_cfhandle(),
self._ncol,
self._nrow,
self._xori,
self._yori,
self._xinc,
self._yinc,
self._rotation,
self._yflip,
self._ilines,
self._xlines,
vals,
0,
)
def get_values1d(
self, order="C", asmasked=False, fill_value=xtgeo.UNDEF, activeonly=False
):
"""Get an an 1D, numpy or masked array of the map values.
Args:
order (str): Flatteting is in C (default) or F order
asmasked (bool): If true, return as MaskedArray, other as standard
numpy ndarray with undef as np.nan or fill_value
fill_value (str): Relevent only if asmasked is False, this
will be the value of undef entries
activeonly (bool): If True, only active cells. Keys 'asmasked' and
'fill_value' are not revelant.
Returns:
A numpy 1D array or MaskedArray
"""