コード例 #1
0
def get_gridproperties(self,
                       gridprops,
                       grid=("ICELL", "JCELL", "KCELL"),
                       prop_id=""):
    """Getting gridproperties as logs"""

    if not isinstance(gridprops, (xtgeo.GridProperty, xtgeo.GridProperties)):
        raise ValueError(
            '"gridprops" not a GridProperties or GridProperty instance')

    if isinstance(gridprops, xtgeo.GridProperty):
        gprops = xtgeo.GridProperties()
        gprops.append_props([gridprops])
    else:
        gprops = gridprops

    if isinstance(grid, tuple):
        icl, jcl, kcl = grid
    elif isinstance(grid, xtgeo.Grid):
        self.make_ijk_from_grid(grid, grid_id="_tmp", algorithm=2)
        icl, jcl, kcl = ("ICELL_tmp", "JCELL_tmp", "KCELL_tmp")
    else:
        raise ValueError('The "grid" is of wrong type, must be a tuple or '
                         "a Grid")

    iind = self.dataframe[icl].values - 1
    jind = self.dataframe[jcl].values - 1
    kind = self.dataframe[kcl].values - 1

    xind = iind.copy()

    iind[np.isnan(iind)] = 0
    jind[np.isnan(jind)] = 0
    kind[np.isnan(kind)] = 0

    #    iind = np.ma.masked_where(iind[~np.isnan(iind)].astype('int')
    iind = iind.astype("int")
    jind = jind.astype("int")
    kind = kind.astype("int")

    for prop in gprops.props:
        arr = prop.values[iind, jind, kind].astype("float")
        arr[np.isnan(xind)] = np.nan
        pname = prop.name + prop_id
        self.dataframe[pname] = arr
        self._wlognames.append(pname)
        if prop.isdiscrete:
            self._wlogtype[pname] = "DISC"
            self._wlogrecord[pname] = copy.deepcopy(prop.codes)
    self._ensure_consistency()
    self.delete_logs(["ICELL_tmp", "JCELL_tmp", "KCELL_tmp"])
コード例 #2
0
def get_gridquality_properties(self):
    """Get the grid quality properties"""

    numqual = 10

    self._xtgformat2()

    fresults = np.ones((numqual, self.ncol * self.nrow * self.nlay),
                       dtype=np.float32)

    _cxtgeo.grdcp3d_quality_indicators(
        self.ncol,
        self.nrow,
        self.nlay,
        self._coordsv,
        self._zcornsv,
        self._actnumsv,
        fresults,
    )
    qcnames = {
        0: "minangle_topbase",
        1: "maxangle_topbase",
        2: "minangle_topbase_proj",
        3: "maxangle_topbase_proj",
        4: "minangle_sides",
        5: "maxangle_sides",
        6: "collapsed",
        7: "faulted",
        8: "negative_thickness",
        9: "concave_proj",
    }

    # some of the properties shall be discrete:
    qcdiscrete = [6, 7, 8, 9]

    grdprops = xtgeo.GridProperties()

    for num, name in qcnames.items():
        prop = xtgeo.GridProperty(self, name=name)
        dtype = np.float32
        if num in qcdiscrete:
            dtype = np.int32
            prop.isdiscrete = True
            prop.codes = {0: "None", 1: name}
        prop.values = fresults[num, :].astype(dtype)
        grdprops.append_props([prop])

    return grdprops
コード例 #3
0
    def read_gridprops(self, gridprops, gridname=None, reuse=None):
        """Read 3D grid props, from file or RMS."""

        gridname = gridname if self._project is not None else join(
            self._path, gridname)

        CMN.print_info("Reading grid properties...")
        gprops = []
        if "gridprops" in reuse:
            reused_gprops, gridprops = self._reuse_gridprops(
                gridprops, gridname)
            gprops = reused_gprops

        if self._project is None:
            for gprop in gridprops:
                if isinstance(gprop, list):
                    pname, pfile = gprop
                else:
                    pfile = gprop
                    pname = "unknown"

                gridproppath = join(self._path, pfile)

                xtg_gprop = xtgeo.gridproperty_from_file(gridproppath,
                                                         name=pname,
                                                         grid=self.grid)
                xtg_gprop.name = pname if pname != "unknown" else pfile
                gprops.append(xtg_gprop)
                if isinstance(gprop, list):
                    self._xtgdata["gridprops"][gridname][tuple(
                        gprop)] = xtg_gprop
                else:
                    self._xtgdata["gridprops"][gridname][gprop] = xtg_gprop
        else:
            # read from RMS/ROXAPI
            for pname in gridprops:
                xtg_gprop = xtgeo.gridproperty_from_roxar(
                    self._project, gridname, pname)
                gprops.append(xtg_gprop)
                self._xtgdata["gridprops"][gridname][pname] = xtg_gprop

        self._gridprops = xtgeo.GridProperties()
        self._gridprops.append_props(gprops)