Пример #1
0
def delete_carray(self, carray):
    """Delete carray SWIG C pointer, return carray as None"""

    logger.debug("Enter delete carray values method for %d", id(self))
    if carray is None:
        return None

    if "int" in str(carray):
        _cxtgeo.delete_intarray(carray)
        carray = None
    elif "float" in str(carray):
        _cxtgeo.delete_floatarray(carray)
        carray = None
    elif "double" in str(carray):
        _cxtgeo.delete_doublearray(carray)
        carray = None
    else:
        raise RuntimeError("BUG?")

    return carray
Пример #2
0
def update_values(cube):

    if cube._cvalues is None and cube._values is None:
        raise ValueError("Cube values and cvalues are both None")

    elif cube._cvalues is None:
        return cube._values, None

    logger.debug("Updating numpy values...")
    ncrl = cube._ncol * cube._nrow * cube._nlay
    xvv = _cxtgeo.swig_carr_to_numpy_f1d(ncrl, cube._cvalues)

    xvv = np.reshape(xvv, (cube._ncol, cube._nrow, cube._nlay), order="F")

    logger.debug("Updating numpy values... done")

    xtype = xvv.dtype
    logger.info("VALUES of type %s", xtype)

    # free the C values (to save memory)
    _cxtgeo.delete_floatarray(cube._cvalues)

    return xvv, None
Пример #3
0
def update_values(cube):

    if cube._cvalues is None and cube._values is None:
        logger.critical("Something is wrong. STOP!")
        sys.exit(9)

    elif cube._cvalues is None:
        return cube._values, None

    logger.debug("Updating numpy values...")
    ncrl = cube._ncol * cube._nrow * cube._nlay
    xvv = _cxtgeo.swig_carr_to_numpy_f1d(ncrl, cube._cvalues)

    xvv = np.reshape(xvv, (cube._ncol, cube._nrow, cube._nlay), order="F")

    logger.debug("Updating numpy values... done")

    xtype = xvv.dtype
    logger.info("VALUES of type %s", xtype)

    # free the C values (to save memory)
    _cxtgeo.delete_floatarray(cube._cvalues)

    return xvv, None