How to use the xtgeo.cxtgeo._cxtgeo.intpointer_value function in xtgeo

To help you get started, we’ve selected a few xtgeo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github equinor / xtgeo / src / xtgeo / grid3d / _gridprop_import_roff.py View on Github external
ptr_ddum,
        ptr_idum,
        0,
    )

    if ier == -1:
        msg = "Cannot find property name {}".format(name)
        logger.warning(msg)
        raise SystemExit("Error from ROFF import")

    self._ncol = _cxtgeo.intpointer_value(ptr_ncol)
    self._nrow = _cxtgeo.intpointer_value(ptr_nrow)
    self._nlay = _cxtgeo.intpointer_value(ptr_nlay)
    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"
github equinor / xtgeo / src / xtgeo / grid3d / _gridprop_import_roff.py View on Github external
ptr_ncodes,
        name,
        ptr_idum,
        ptr_ddum,
        ptr_idum,
        0,
    )

    if ier == -1:
        msg = "Cannot find property name {}".format(name)
        logger.warning(msg)
        raise SystemExit("Error from ROFF import")

    self._ncol = _cxtgeo.intpointer_value(ptr_ncol)
    self._nrow = _cxtgeo.intpointer_value(ptr_nrow)
    self._nlay = _cxtgeo.intpointer_value(ptr_nlay)
    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)
github equinor / xtgeo / src / xtgeo / grid3d / _gridprop_import_roff.py View on Github external
ptr_nrow,
        ptr_nlay,
        ptr_ncodes,
        name,
        ptr_idum,
        ptr_ddum,
        ptr_idum,
        0,
    )

    if ier == -1:
        msg = "Cannot find property name {}".format(name)
        logger.warning(msg)
        raise SystemExit("Error from ROFF import")

    self._ncol = _cxtgeo.intpointer_value(ptr_ncol)
    self._nrow = _cxtgeo.intpointer_value(ptr_nrow)
    self._nlay = _cxtgeo.intpointer_value(ptr_nlay)
    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
github equinor / xtgeo / src / xtgeo / cube / _cube_utils.py View on Github external
_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,
    )
    if ier != 0:
        raise Exception

    self._ncol = _cxtgeo.intpointer_value(ncol)
    self._nrow = _cxtgeo.intpointer_value(nrow)
    self._yflip = _cxtgeo.intpointer_value(yflip)

    self._xinc = _cxtgeo.doublepointer_value(xinc)
    self._yinc = _cxtgeo.doublepointer_value(yinc)
    self._rotation = _cxtgeo.doublepointer_value(rota)

    ilines = self._xlines.copy()
    xlines = self._ilines.copy()
    self._xlines = xlines
    self._ilines = ilines

    self._traceidcodes = traceid1d.reshape((self._ncol, self._nrow))
    self._values = values1d.reshape((self._ncol, self._nrow, self.nlay))
github equinor / xtgeo / src / xtgeo / cube / _cube_import.py View on Github external
option = 1

    _cxtgeo.cube_scan_segy_hdr(
        sfile,
        ptr_gn_bitsheader,
        ptr_gn_formatcode,
        ptr_gf_segyformat,
        ptr_gn_samplespertrace,
        ptr_gn_measuresystem,
        option,
        outfile,
    )

    # get values
    gn_bitsheader = _cxtgeo.intpointer_value(ptr_gn_bitsheader)
    gn_formatcode = _cxtgeo.intpointer_value(ptr_gn_formatcode)
    gf_segyformat = _cxtgeo.floatpointer_value(ptr_gf_segyformat)
    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()
github equinor / xtgeo / src / xtgeo / cube / _cube_utils.py View on Github external
_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,
    )
    if ier != 0:
        raise Exception

    self._ncol = _cxtgeo.intpointer_value(ncol)
    self._nrow = _cxtgeo.intpointer_value(nrow)
    self._yflip = _cxtgeo.intpointer_value(yflip)

    self._xinc = _cxtgeo.doublepointer_value(xinc)
    self._yinc = _cxtgeo.doublepointer_value(yinc)
    self._rotation = _cxtgeo.doublepointer_value(rota)

    ilines = self._xlines.copy()
    xlines = self._ilines.copy()
    self._xlines = xlines
    self._ilines = ilines

    self._traceidcodes = traceid1d.reshape((self._ncol, self._nrow))
    self._values = values1d.reshape((self._ncol, self._nrow, self.nlay))
github equinor / xtgeo / src / xtgeo / cube / _cube_import.py View on Github external
ptr_rotation,
        ptr_yflip,
        ptr_zflip,
        ptr_minval,
        ptr_maxval,
        # options
        optscan,
        option,
        outfile,
    )

    logger.debug("Scan via C wrapper... done")

    ncol = _cxtgeo.intpointer_value(ptr_ncol)
    nrow = _cxtgeo.intpointer_value(ptr_nrow)
    nlay = _cxtgeo.intpointer_value(ptr_nlay)

    if scantracemode:
        return None

    nrcl = ncol * nrow * nlay

    ptr_cval_v = _cxtgeo.new_floatarray(nrcl)

    # next is to do the actual import of the cube
    optscan = 0

    logger.debug("Import via C wrapper...")
    _cxtgeo.cube_import_segy(
        sfile,
        # input
        gn_bitsheader,
github equinor / xtgeo / src / xtgeo / surface / _regsurf_utils.py View on Github external
_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
    )
    if ier != 0:
        raise RuntimeError(
            "Unspecied runtime error from {}: Code: {}".format(__name__, ier)
        )

    self._ncol = _cxtgeo.intpointer_value(ncol)
    self._nrow = _cxtgeo.intpointer_value(nrow)
    self._yflip = _cxtgeo.intpointer_value(yflip)

    self._xinc = _cxtgeo.doublepointer_value(xinc)
    self._yinc = _cxtgeo.doublepointer_value(yinc)
    self._rotation = _cxtgeo.doublepointer_value(rota)

    ilines = self._xlines.copy()
    xlines = self._ilines.copy()

    self._ilines = ilines
    self._xlines = xlines

    self.values = val  # reshaping and masking is done in self.values