Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
logger.warning(
"Cannot compute geometrics for %s. Too few " "trajectory points",
self.name,
)
return False
# extract numpies from XYZ trajetory logs
ptr_xv = self.get_carray("X_UTME")
ptr_yv = self.get_carray("Y_UTMN")
ptr_zv = self.get_carray("Z_TVDSS")
# get number of rows in pandas
nlen = self.nrow
ptr_md = _cxtgeo.new_doublearray(nlen)
ptr_incl = _cxtgeo.new_doublearray(nlen)
ptr_az = _cxtgeo.new_doublearray(nlen)
ier = _cxtgeo.well_geometrics(
nlen, ptr_xv, ptr_yv, ptr_zv, ptr_md, ptr_incl, ptr_az, 0,
)
if ier != 0:
sys.exit(-9)
dnumpy = self._convert_carr_double_np(ptr_md)
self._df["Q_MDEPTH"] = pd.Series(dnumpy, index=self._df.index)
dnumpy = self._convert_carr_double_np(ptr_incl)
self._df["Q_INCL"] = pd.Series(dnumpy, index=self._df.index)
dnumpy = self._convert_carr_double_np(ptr_az)
if self._df.size < 3:
logger.warning(
"Cannot compute geometrics for %s. Too few " "trajectory points",
self.name,
)
return False
# extract numpies from XYZ trajetory logs
ptr_xv = self.get_carray("X_UTME")
ptr_yv = self.get_carray("Y_UTMN")
ptr_zv = self.get_carray("Z_TVDSS")
# get number of rows in pandas
nlen = self.nrow
ptr_md = _cxtgeo.new_doublearray(nlen)
ptr_incl = _cxtgeo.new_doublearray(nlen)
ptr_az = _cxtgeo.new_doublearray(nlen)
ier = _cxtgeo.well_geometrics(
nlen, ptr_xv, ptr_yv, ptr_zv, ptr_md, ptr_incl, ptr_az, 0,
)
if ier != 0:
sys.exit(-9)
dnumpy = self._convert_carr_double_np(ptr_md)
self._df["Q_MDEPTH"] = pd.Series(dnumpy, index=self._df.index)
dnumpy = self._convert_carr_double_np(ptr_incl)
self._df["Q_INCL"] = pd.Series(dnumpy, index=self._df.index)
"Cannot compute geometrics for %s. Too few " "trajectory points",
self.name,
)
return False
# extract numpies from XYZ trajetory logs
ptr_xv = self.get_carray("X_UTME")
ptr_yv = self.get_carray("Y_UTMN")
ptr_zv = self.get_carray("Z_TVDSS")
# get number of rows in pandas
nlen = self.nrow
ptr_md = _cxtgeo.new_doublearray(nlen)
ptr_incl = _cxtgeo.new_doublearray(nlen)
ptr_az = _cxtgeo.new_doublearray(nlen)
ier = _cxtgeo.well_geometrics(
nlen, ptr_xv, ptr_yv, ptr_zv, ptr_md, ptr_incl, ptr_az, 0,
)
if ier != 0:
sys.exit(-9)
dnumpy = self._convert_carr_double_np(ptr_md)
self._df["Q_MDEPTH"] = pd.Series(dnumpy, index=self._df.index)
dnumpy = self._convert_carr_double_np(ptr_incl)
self._df["Q_INCL"] = pd.Series(dnumpy, index=self._df.index)
dnumpy = self._convert_carr_double_np(ptr_az)
self._df["Q_AZI"] = pd.Series(dnumpy, index=self._df.index)
self._ncodes = _cxtgeo.intpointer_value(ptr_ncodes)
ptype = _cxtgeo.intpointer_value(ptr_type)
ntot = self._ncol * self._nrow * self._nlay
if self._ncodes <= 1:
self._ncodes = 1
self._codes = {0: "undef"}
logger.debug("Number of codes: %s", self._ncodes)
# allocate
if ptype == 1: # float, assign to double
ptr_pval_v = _cxtgeo.new_doublearray(ntot)
ptr_ival_v = _cxtgeo.new_intarray(1)
self._isdiscrete = False
self._dtype = "float64"
elif ptype > 1:
ptr_pval_v = _cxtgeo.new_doublearray(1)
ptr_ival_v = _cxtgeo.new_intarray(ntot)
self._isdiscrete = True
self._dtype = "int32"
# number of codes and names
ptr_ccodes_v = _cxtgeo.new_intarray(self._ncodes)
# NB! note the SWIG trick to return modified char values; use cstring.i
# inn the config and %cstring_bounded_output(char *p_codenames_v, NN);
# Then the argument for *p_codevalues_v in C is OMITTED here!
def _convert_np_carr_double(self, np_array):
"""Convert numpy 1D array to C array, assuming double type."""
carr = _cxtgeo.new_doublearray(self.nrow)
_cxtgeo.swig_numpy_to_carr_1d(np_array, carr)
return carr
if self._ncodes <= 1:
self._ncodes = 1
self._codes = {0: "undef"}
logger.debug("Number of codes: %s", self._ncodes)
# allocate
if ptype == 1: # float, assign to double
ptr_pval_v = _cxtgeo.new_doublearray(ntot)
ptr_ival_v = _cxtgeo.new_intarray(1)
self._isdiscrete = False
self._dtype = "float64"
elif ptype > 1:
ptr_pval_v = _cxtgeo.new_doublearray(1)
ptr_ival_v = _cxtgeo.new_intarray(ntot)
self._isdiscrete = True
self._dtype = "int32"
# number of codes and names
ptr_ccodes_v = _cxtgeo.new_intarray(self._ncodes)
# NB! note the SWIG trick to return modified char values; use cstring.i
# inn the config and %cstring_bounded_output(char *p_codenames_v, NN);
# Then the argument for *p_codevalues_v in C is OMITTED here!
ier, cnames = _cxtgeo.grd3d_imp_prop_roffbin(
pfile.name,
1,
ptr_type,
ptr_ncol,
else:
values = values.astype(dtype)
values = ma.filled(values, undef)
if order == "F":
values = np.asfortranarray(values)
values1d = np.ravel(values, order="K")
if values1d.dtype == "float64" and dstatus and not dtype:
values1d = values1d.astype("int32")
logger.debug("Casting has been done")
if values1d.dtype == "float64":
logger.debug("Convert to carray (double)")
carray = _cxtgeo.new_doublearray(self.ntotal)
_cxtgeo.swig_numpy_to_carr_1d(values1d, carray)
elif values1d.dtype == "float32":
logger.debug("Convert to carray (float)")
carray = _cxtgeo.new_floatarray(self.ntotal)
_cxtgeo.swig_numpy_to_carr_f1d(values1d, carray)
elif values1d.dtype == "int32":
logger.debug("Convert to carray (int32)")
carray = _cxtgeo.new_intarray(self.ntotal)
_cxtgeo.swig_numpy_to_carr_i1d(values1d, carray)
else:
raise RuntimeError("Unsupported dtype, probable bug in {}".format(__name__))
return carray
z = GridProperty(
ncol=self._ncol,
nrow=self._nrow,
nlay=self._nlay,
values=np.zeros(ntot, dtype=np.float64),
name=zname,
discrete=False,
)
grid_props.append(x)
grid_props.append(y)
grid_props.append(z)
ptr_coord = []
for i in range(24):
some = _cxtgeo.new_doublearray(self.ntotal)
ptr_coord.append(some)
for i, va in enumerate(ptr_coord):
logger.debug("SWIG object %s %s", i, va)
option = 0
# note, fool the argument list to unpack ptr_coord with * ...
_cxtgeo.grd3d_get_all_corners(
self._ncol,
self._nrow,
self._nlay,
self._coordsv,
self._zcornsv,
self._actnumsv,
*(ptr_coord + [option])
df[perflogname].fillna(-999, inplace=True)
df = df[df[perflogname] > 0]
df = df.copy()
df.reset_index(drop=True, inplace=True)
well.dataframe = df
# get the relevant well log C arrays...
ptr_xc = well.get_carray("X_UTME")
ptr_yc = well.get_carray("Y_UTMN")
ptr_zc = well.get_carray("Z_TVDSS")
ptr_zo = well.get_carray(zonelogname)
nval = well.nrow
ptr_results = _cxtgeo.new_doublearray(10)
ptr_zprop = _gridprop_lowlevel.update_carray(zoneprop)
cstatus = _cxtgeo.grd3d_rpt_zlog_vs_zon(
self._ncol,
self._nrow,
self._nlay,
self._coordsv,
self._zcornsv,
self._actnumsv,
ptr_zprop,
nval,
ptr_xc,
ptr_yc,
ptr_zc,
ptr_zo,
def convert_np_carr_double(xyz, np_array): # pragma: no cover
"""Convert numpy 1D array to C array, assuming double type."""
carr = _cxtgeo.new_doublearray(xyz.nrow)
_cxtgeo.swig_numpy_to_carr_1d(np_array, carr)
return carr