def cropping(self, icols, jrows, klays): """Cropping, where inputs are tuples""" icol1, icol2 = icols jrow1, jrow2 = jrows klay1, klay2 = klays val = self.values.copy() ncol = self.ncol nrow = self.nrow nlay = self.nlay val = val[ 0 + icol1 : ncol - icol2, 0 + jrow1 : nrow - jrow2, 0 + klay1 : nlay - klay2 ] self._ncol = val.shape[0] self._nrow = val.shape[1] self._nlay = val.shape[2] self._ilines = self._ilines[0 + icol1 : ncol - icol2] self._xlines = self._xlines[0 + jrow1 : nrow - jrow2] self.traceidcodes = self.traceidcodes[ 0 + icol1 : ncol - icol2, 0 + jrow1 : nrow - jrow2 ] # 1 + .., since the following routine as 1 as base for i j ier, xpp, ypp = _cxtgeo.cube_xy_from_ij( 1 + icol1, 1 + jrow1, self.xori, self.xinc, self.yori, self.yinc, ncol, nrow, self.yflip, self.rotation, 0, ) if ier != 0: raise RuntimeError("Unexpected error, code is {}".format(ier)) # get new X Y origins self._xori = xpp self._yori = ypp self._zori = self.zori + klay1 * self.zinc self.values = val
def get_xy_value_from_ij(self, iloc, jloc, ixline=False, zerobased=False): """Find X Y value from I J index, or corresponding inline/xline""" # assumes that inline follows I and xlines follows J iuse = iloc juse = jloc if zerobased: iuse = iuse + 1 juse = juse + 1 if ixline: ilst = self.ilines.tolist() jlst = self.xlines.tolist() iuse = ilst.index(iloc) + 1 juse = jlst.index(jloc) + 1 if 1 <= iuse <= self.ncol and 1 <= juse <= self.nrow: ier, xval, yval = _cxtgeo.cube_xy_from_ij( iuse, juse, self.xori, self.xinc, self.yori, self.yinc, self.ncol, self.nrow, self._yflip, self.rotation, 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") return xval, yval
def get_xy_value_from_ij(self, iloc, jloc, ixline=False, zerobased=False): """Find X Y value from I J index, or corresponding inline/xline""" # assumes that inline follows I and xlines follows J iuse = iloc juse = jloc if zerobased: iuse = iuse + 1 juse = juse + 1 if ixline: ilst = self.ilines.tolist() jlst = self.xlines.tolist() iuse = ilst.index(iloc) + 1 juse = jlst.index(jloc) + 1 if 1 <= iuse <= self.ncol and 1 <= juse <= self.nrow: ier, xval, yval = _cxtgeo.cube_xy_from_ij( iuse, juse, self.xori, self.xinc, self.yori, self.yinc, self.ncol, self.nrow, self._yflip, self.rotation, 0, ) if ier != 0: raise XTGeoCLibError( f"cube_xy_from_ij failed with error code: {ier}") else: raise ValueError("Index i and/or j out of bounds") return xval, yval