Ejemplo n.º 1
0
def export_grid_roxapi(self,
                       projectname,
                       gname,
                       realisation,
                       info=False,
                       method="cpg"):
    """Export (i.e. store in RMS) via ROXAR API spec.

    Using method 'cpg' means that the CPG method is applied (from ROXAPI 1.3).
    This is possible from version ROXAPI ver 1.3, where the CornerPointGeometry
    class is defined.

    An alternative is to use simple roff import (via some /tmp area),
    can be used from version 1.2

    """
    rox = RoxUtils(projectname, readonly=False)

    if method != "cpg" and not rox.version_required("1.2"):
        minimumrms = rox.rmsversion("1.2")
        raise NotImplementedError(
            "Not supported in this ROXAPI version. Grid load/import requires "
            "RMS version {}".format(minimumrms))

    if method == "cpg" and not rox.version_required("1.3"):
        xtg.warn("Export method=cpg is not implemented for ROXAPI "
                 "version {}. Change to workaround...".format(rox.roxversion))
        method = "other"

    if method == "cpg":
        _export_grid_cornerpoint_roxapi(self, rox, gname, realisation, info)
    else:
        _export_grid_viaroff_roxapi(self, rox, gname, realisation)

    rox.safe_close()
Ejemplo n.º 2
0
def _import_grid_roxapi_v2(
    self, projectname, gname, realisation, info
):  # pragma: no cover
    """Import a Grid via ROXAR API spec."""

    rox = RoxUtils(projectname, readonly=True)

    proj = rox.project

    if not rox.version_required("1.3"):
        raise NotImplementedError("Functionality to implemented for Roxar API < 1.3")

    logger.info("Loading grid with realisation %s...", realisation)
    try:
        if gname not in proj.grid_models:
            raise KeyError("No such gridmodel: {}".format(gname))

        logger.info("Get roxgrid...")
        roxgrid = proj.grid_models[gname].get_grid()

        if info:
            _display_roxapi_grid_info(rox, roxgrid)

        _convert_to_xtgeo_grid_v2(self, roxgrid, gname)

    except KeyError as keyerror:
        raise RuntimeError(keyerror)

    if rox._roxexternal:
        rox.safe_close()
Ejemplo n.º 3
0
def _import_grid_roxapi_v2(
    self, projectname, gname, realisation, info
):  # pragma: no cover
    """Import a Grid via ROXAR API spec."""
    rox = RoxUtils(projectname, readonly=True)

    proj = rox.project

    if not rox.version_required("1.3"):
        raise NotImplementedError("Functionality to implemented for Roxar API < 1.3")

    logger.info("Loading grid with realisation %s...", realisation)
    try:
        if gname not in proj.grid_models:
            raise KeyError("No such gridmodel: {}".format(gname))

        logger.info("Get roxgrid...")
        roxgrid = proj.grid_models[gname].get_grid(realisation=realisation)

        if roxgrid.has_dual_index_system:
            xtg.warnuser(
                f"The roxar grid {gname} has dual index system.\n"
                "XTGeo does not implement extraction of simbox grid\n"
                "and only considers physical index."
            )

        if info:
            _display_roxapi_grid_info(rox, roxgrid)

        _convert_to_xtgeo_grid_v2(self, roxgrid, gname)

    except KeyError as keyerror:
        raise RuntimeError(keyerror)

    if rox._roxexternal:
        rox.safe_close()