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 inline vs xline, keep origin."""
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)
values1d = self.values.reshape(-1)
traceid1d = self._traceidcodes.reshape(-1)
ier = _cxtgeo.cube_swapaxes(
ncol, nrow, self.nlay, yflip, xinc, yinc, rota, values1d, traceid1d,
gn_samplespertrace = _cxtgeo.intpointer_value(ptr_gn_samplespertrace)
if scanheadermode:
logger.info("Scan SEGY header ... %s bytes ... DONE", gn_bitsheader)
return None
# next is to scan first and last trace, in order to allocate
# cube size
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(
# 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,
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
if not binary:
def export_grdecl(self, pfile, name, append=False, binary=False, dtype=None):
logger.info("Exporting %s to file %s, GRDECL format", name, pfile)
if dtype is None:
if self._isdiscrete:
dtype = "int32"
else:
dtype = "float32"
carray = _gridprop_lowlevel.update_carray(self, dtype=dtype)
iarr = _cxtgeo.new_intpointer()
farr = _cxtgeo.new_floatpointer()
darr = _cxtgeo.new_doublepointer()
if "double" in str(carray):
ptype = 3
darr = carray
elif "float" in str(carray):
ptype = 2
farr = carray
else:
ptype = 1
iarr = carray
mode = 0
if not binary:
mode = 1
def swapaxes(self):
"""Swap the axes inline vs xline, keep origin."""
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)
values1d = self.values.reshape(-1)
traceid1d = self._traceidcodes.reshape(-1)
ier = _cxtgeo.cube_swapaxes(
ncol, nrow, self.nlay, yflip, xinc, yinc, rota, values1d, traceid1d,
)