def test_grd3d_reduce_onelayer(): with pytest.raises( xtgeo.XTGeoCLibError, match="IFLAG other than 0 not implemented", ): _cxtgeo.grd3d_reduce_onelayer( 0, 0, 0, np.array([0.0]), np.array([1.0]), np.array([1], dtype=np.int32), np.array([1], dtype=np.int32), _cxtgeo.new_intarray(1), 1, )
def reduce_to_one_layer(self): """Reduce the grid to one single layer. This can be useful for algorithms that need to test if a point is within the full grid. 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 self._xtgformat1() 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, ) self._nlay = 1 self._zcornsv = new_zcorn self._actnumsv = new_actnum self._props = None self._subgrids = None
def reduce_to_one_layer(self): """Reduce the grid to one single layer. This can be useful for algorithms that need to test if a point is within the full grid. 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) ptr_new_num_act = _cxtgeo.new_intpointer() nnum = (1 + 1) * 4 ptr_new_zcorn_v = _cxtgeo.new_doublearray(self.ncol * self.nrow * nnum) ptr_new_actnum_v = _cxtgeo.new_intarray(self.ncol * self.nrow * 1) _cxtgeo.grd3d_reduce_onelayer( self.ncol, self.nrow, self.nlay, self._p_zcorn_v, ptr_new_zcorn_v, self._p_actnum_v, ptr_new_actnum_v, ptr_new_num_act, 0, XTGDEBUG, ) self._nlay = 1 self._p_zcorn_v = ptr_new_zcorn_v self._p_actnum_v = ptr_new_actnum_v self._props = None self._subgrids = None