Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def swapaxes(self):
"""Swap the axes columns vs rows, keep origin. Will change yflip."""
ncol = _cxtgeo.new_intpointer()
nrow = _cxtgeo.new_intpointer()
yflip = _cxtgeo.new_intpointer()
xinc = _cxtgeo.new_doublepointer()
yinc = _cxtgeo.new_doublepointer()
rota = _cxtgeo.new_doublepointer()
_cxtgeo.intpointer_assign(ncol, self._ncol)
_cxtgeo.intpointer_assign(nrow, self._nrow)
_cxtgeo.intpointer_assign(yflip, self._yflip)
_cxtgeo.doublepointer_assign(xinc, self._xinc)
_cxtgeo.doublepointer_assign(yinc, self._yinc)
_cxtgeo.doublepointer_assign(rota, self._rotation)
val = self.get_values1d(fill_value=xtgeo.UNDEF)
ier = _cxtgeo.surf_swapaxes(
ncol, nrow, yflip, self.xori, xinc, self.yori, yinc, rota, val, 0
def swapaxes(self):
"""Swap the axes columns vs rows, keep origin. Will change yflip."""
ncol = _cxtgeo.new_intpointer()
nrow = _cxtgeo.new_intpointer()
yflip = _cxtgeo.new_intpointer()
xinc = _cxtgeo.new_doublepointer()
yinc = _cxtgeo.new_doublepointer()
rota = _cxtgeo.new_doublepointer()
_cxtgeo.intpointer_assign(ncol, self._ncol)
_cxtgeo.intpointer_assign(nrow, self._nrow)
_cxtgeo.intpointer_assign(yflip, self._yflip)
_cxtgeo.doublepointer_assign(xinc, self._xinc)
_cxtgeo.doublepointer_assign(yinc, self._yinc)
_cxtgeo.doublepointer_assign(rota, self._rotation)
val = self.get_values1d(fill_value=xtgeo.UNDEF)
ier = _cxtgeo.surf_swapaxes(
def _rkwquery(gfile, kws, name, swap):
"""Local function for _import_roff_v2, single data"""
kwtypedict = {"int": 1, "float": 2}
iresult = _cxtgeo.new_intpointer()
presult = _cxtgeo.new_floatpointer()
dtype = 0
reclen = 0
bytepos = 1
for items in kws:
if name in items[0]:
dtype = kwtypedict.get(items[1])
reclen = items[2]
bytepos = items[3]
break
logger.debug("DTYPE is %s", dtype)
if dtype == 0:
raise ValueError("Cannot find property <{}> in file".format(name))
"""Import ROFF format, version 1"""
# pylint: disable=too-many-locals
# there is a todo here to get it more robust for various cases,
# e.g. that a ROFF file may contain both a grid an numerous
# props
logger.info("Looking for %s in file %s", name, pfile.name)
ptr_ncol = _cxtgeo.new_intpointer()
ptr_nrow = _cxtgeo.new_intpointer()
ptr_nlay = _cxtgeo.new_intpointer()
ptr_ncodes = _cxtgeo.new_intpointer()
ptr_type = _cxtgeo.new_intpointer()
ptr_idum = _cxtgeo.new_intpointer()
ptr_ddum = _cxtgeo.new_doublepointer()
# read with mode 0, to scan for ncol, nrow, nlay and ndcodes, and if
# property is found...
ier, _codenames = _cxtgeo.grd3d_imp_prop_roffbin(
pfile.name,
0,
ptr_type,
ptr_ncol,
ptr_nrow,
ptr_nlay,
ptr_ncodes,
name,
ptr_idum,
ptr_ddum,
ptr_idum,
def _rkwquery(gfile, kws, name, swap):
"""Local function for _import_roff_v2, single data"""
kwtypedict = {"int": 1, "float": 2}
iresult = _cxtgeo.new_intpointer()
presult = _cxtgeo.new_floatpointer()
dtype = 0
reclen = 0
bytepos = 1
for items in kws:
if name in items[0]:
dtype = kwtypedict.get(items[1])
reclen = items[2]
bytepos = items[3]
break
logger.debug("DTYPE is %s", dtype)
if dtype == 0:
raise ValueError("Cannot find property <{}> in file".format(name))
ptr_ncol = _cxtgeo.new_intpointer()
ptr_nrow = _cxtgeo.new_intpointer()
ptr_nlay = _cxtgeo.new_intpointer()
ptr_xori = _cxtgeo.new_doublepointer()
ptr_yori = _cxtgeo.new_doublepointer()
ptr_zori = _cxtgeo.new_doublepointer()
ptr_xinc = _cxtgeo.new_doublepointer()
ptr_yinc = _cxtgeo.new_doublepointer()
ptr_zinc = _cxtgeo.new_doublepointer()
ptr_rotation = _cxtgeo.new_doublepointer()
ptr_minval = _cxtgeo.new_doublepointer()
ptr_maxval = _cxtgeo.new_doublepointer()
ptr_dummy = _cxtgeo.new_floatpointer()
ptr_yflip = _cxtgeo.new_intpointer()
ptr_zflip = _cxtgeo.new_intpointer()
optscan = 1
if scantracemode:
option = 1
logger.debug("Scan via C wrapper...")
_cxtgeo.cube_import_segy(
sfile,
# input
gn_bitsheader,
gn_formatcode,
gf_segyformat,
gn_samplespertrace,
# result (as pointers)
ptr_ncol,
def _import_roff_v1(self, pfile, name):
"""Import ROFF format, version 1"""
# pylint: disable=too-many-locals
# there is a todo here to get it more robust for various cases,
# e.g. that a ROFF file may contain both a grid an numerous
# props
logger.info("Looking for %s in file %s", name, pfile.name)
ptr_ncol = _cxtgeo.new_intpointer()
ptr_nrow = _cxtgeo.new_intpointer()
ptr_nlay = _cxtgeo.new_intpointer()
ptr_ncodes = _cxtgeo.new_intpointer()
ptr_type = _cxtgeo.new_intpointer()
ptr_idum = _cxtgeo.new_intpointer()
ptr_ddum = _cxtgeo.new_doublepointer()
# read with mode 0, to scan for ncol, nrow, nlay and ndcodes, and if
# property is found...
ier, _codenames = _cxtgeo.grd3d_imp_prop_roffbin(
pfile.name,
0,
ptr_type,
ptr_ncol,
ptr_nrow,
ptr_nlay,
ptr_ncodes,
name,
Example::
>>> from xtgeo.grid3d import Grid
>>> gf = Grid('gullfaks2.roff')
>>> gf.nlay
47
>>> gf.reduce_to_one_layer()
>>> gf.nlay
1
"""
# need new pointers in C (not for coord)
# Note this could probably be done with pure numpy operations
ptr_new_num_act = _cxtgeo.new_intpointer()
nnum = (1 + 1) * 4
new_zcorn = np.zeros(self.ncol * self.nrow * nnum, dtype=np.float64)
new_actnum = np.zeros(self.ncol * self.nrow * 1, dtype=np.int32)
_cxtgeo.grd3d_reduce_onelayer(
self.ncol,
self.nrow,
self.nlay,
self._zcornsv,
new_zcorn,
self._actnumsv,
new_actnum,
ptr_new_num_act,
0,
def _export_roff_discrete(self, pfile, name, append=False, last=True, binary=True):
carray = _gridprop_lowlevel.update_carray(self, undef=-999)
ptr_idum = _cxtgeo.new_intpointer()
ptr_ddum = _cxtgeo.new_doublepointer()
# codes:
ptr_codes = _cxtgeo.new_intarray(256)
ncodes = self.ncodes
codenames = ""
logger.info("Keys: %s", self.codes.keys())
for inum, ckey in enumerate(sorted(self.codes.keys())):
if ckey is not None:
codenames += str(self.codes[ckey])
codenames += "|"
_cxtgeo.intarray_setitem(ptr_codes, inum, int(ckey))
else:
logger.warning("For some odd reason, None is a key. Check!")
mode = 0