def get_xy_value_from_ij(self, iloc, jloc, zvalues=None): """Find X Y value from I J index""" if zvalues is None: zvalues = self.get_values1d() try: ier, xval, yval, value = _cxtgeo.surf_xyz_from_ij( iloc, jloc, self.xori, self.xinc, self.yori, self.yinc, self.ncol, self.nrow, self._yflip, self.rotation, zvalues, 0, ) except XTGeoCLibError: raise ValueError(f"Index i {iloc} and/or j {jloc} out of bounds") if value > xtgeo.UNDEF_LIMIT: value = None return xval, yval, value
def get_xy_value_from_ij(self, iloc, jloc, zvalues=None): """Find X Y value from I J index""" if zvalues is None: zvalues = self.get_values1d() if 1 <= iloc <= self.ncol and 1 <= jloc <= self.nrow: ier, xval, yval, value = _cxtgeo.surf_xyz_from_ij( iloc, jloc, self.xori, self.xinc, self.yori, self.yinc, self.ncol, self.nrow, self._yflip, self.rotation, zvalues, 0, ) if ier != 0: logger.critical("Error code %s, contact the author", ier) raise SystemExit("Error code {}".format(ier)) else: raise ValueError("Index i and/or j out of bounds") if value > xtgeo.UNDEF_LIMIT: value = None return xval, yval, value
def get_xy_value_from_ij(self, iloc, jloc, zvalues=None): """Find X Y value from I J index""" if zvalues is None: zvalues = self.get_values1d() if 1 <= iloc <= self.ncol and 1 <= jloc <= self.nrow: ier, xval, yval, value = _cxtgeo.surf_xyz_from_ij( iloc, jloc, self.xori, self.xinc, self.yori, self.yinc, self.ncol, self.nrow, self._yflip, self.rotation, zvalues, 0, ) if ier != 0: raise XTGeoCLibError( f"Error in surf_xyz_from_ij, error code: {ier}") else: raise ValueError("Index i and/or j out of bounds") if value > xtgeo.UNDEF_LIMIT: value = None return xval, yval, value
def test_xyz_from_ij_far_outside(i, j): surface = Surface() with pytest.raises(xtgeo.XTGeoCLibError, match="Accessing value outside surface"): _cxtgeo.surf_xyz_from_ij( i, j, surface.xori, surface.xinc, surface.yori, surface.yinc, surface.ncol, surface.nrow, surface.yflip, surface.rotation, surface.values, 0, )
def test_xyz_from_ij_one_outside(i, j, expected_position): surface = Surface() ier, xval, yval, value = _cxtgeo.surf_xyz_from_ij( i, j, surface.xori, surface.xinc, surface.yori, surface.yinc, surface.ncol, surface.nrow, surface.yflip, surface.rotation, surface.values, 0, ) assert (xval, yval) == expected_position
def test_xyz_from_ij_inside(i, j, expected_result, flag): surface = Surface() ier, xval, yval, value = _cxtgeo.surf_xyz_from_ij( i, j, surface.xori, surface.xinc, surface.yori, surface.yinc, surface.ncol, surface.nrow, surface.yflip, surface.rotation, surface.values, flag, ) assert (xval, yval, value) == expected_result