def get_xyz(self, names=("X_UTME", "Y_UTMN", "Z_TVDSS"), asmasked=True): """Get X Y Z as properties.""" # TODO: May be issues with asmasked vs activeonly here? self._xtgformat1() xv = np.zeros(self.ntotal, dtype=np.float64) yv = np.zeros(self.ntotal, dtype=np.float64) zv = np.zeros(self.ntotal, dtype=np.float64) option = 0 if asmasked: option = 1 _cxtgeo.grd3d_calc_xyz( self._ncol, self._nrow, self._nlay, self._coordsv, self._zcornsv, self._actnumsv, xv, yv, zv, option, ) xv = np.ma.masked_greater(xv, xtgeo.UNDEF_LIMIT) yv = np.ma.masked_greater(yv, xtgeo.UNDEF_LIMIT) zv = np.ma.masked_greater(zv, xtgeo.UNDEF_LIMIT) xo = GridProperty( ncol=self._ncol, nrow=self._nrow, nlay=self._nlay, values=xv, name=names[0], discrete=False, ) yo = GridProperty( ncol=self._ncol, nrow=self._nrow, nlay=self._nlay, values=yv, name=names[1], discrete=False, ) zo = GridProperty( ncol=self._ncol, nrow=self._nrow, nlay=self._nlay, values=zv, name=names[2], discrete=False, ) return xo, yo, zo
def test_grd3d_get_xyz(): with pytest.raises( xtgeo.XTGeoCLibError, match="Errors in array lengths checks in grd3d_calc_xyz", ): _cxtgeo.grd3d_calc_xyz( 1, 1, 1, np.array([0.0]), np.array([1.0]), np.array([1], dtype=np.int32), np.array([0.0]), np.array([0.0]), np.array([0.0]), 0, )
def get_xyz(self, names=("X_UTME", "Y_UTMN", "Z_TVDSS"), asmasked=True): """Get X Y Z as properties... May be issues with asmasked vs activeonly here""" ntot = self.ntotal x = GridProperty( ncol=self._ncol, nrow=self._nrow, nlay=self._nlay, values=np.zeros(ntot, dtype=np.float64), name=names[0], discrete=False, ) y = GridProperty( ncol=self._ncol, nrow=self._nrow, nlay=self._nlay, values=np.zeros(ntot, dtype=np.float64), name=names[1], discrete=False, ) z = GridProperty( ncol=self._ncol, nrow=self._nrow, nlay=self._nlay, values=np.zeros(ntot, dtype=np.float64), name=names[2], discrete=False, ) ptr_x_v = _cxtgeo.new_doublearray(self.ntotal) ptr_y_v = _cxtgeo.new_doublearray(self.ntotal) ptr_z_v = _cxtgeo.new_doublearray(self.ntotal) option = 0 if asmasked: option = 1 _cxtgeo.grd3d_calc_xyz( self._ncol, self._nrow, self._nlay, self._p_coord_v, self._p_zcorn_v, self._p_actnum_v, ptr_x_v, ptr_y_v, ptr_z_v, option, XTGDEBUG, ) _gridprop_lowlevel.update_values_from_carray(x, ptr_x_v, np.float64, delete=True) _gridprop_lowlevel.update_values_from_carray(y, ptr_y_v, np.float64, delete=True) _gridprop_lowlevel.update_values_from_carray(z, ptr_z_v, np.float64, delete=True) # Note: C arrays are deleted in the update_values_from_carray() return x, y, z