Exemplo n.º 1
0
def test_xsect_larger_geogrid(show_plot):
    """Test a larger xsection"""

    mygrid = xtgeo.Grid(BIGRGRID1)
    poro = xtgeo.GridProperty(BIGPROP1)
    mywell1 = xtgeo.Well(BIGWELL1)
    mywell2 = xtgeo.Well(BIGWELL2)

    fence1 = mywell1.get_fence_polyline(sampling=5, tvdmin=1750, asnumpy=True)

    (hmin1, hmax1, vmin1, vmax1, arr1) = mygrid.get_randomline(fence1,
                                                               poro,
                                                               zmin=1750,
                                                               zmax=2100,
                                                               zincrement=0.2)

    fence2 = mywell2.get_fence_polyline(sampling=5, tvdmin=1500, asnumpy=True)

    (hmin2, hmax2, vmin2, vmax2, arr2) = mygrid.get_randomline(fence2,
                                                               poro,
                                                               zmin=1500,
                                                               zmax=1850,
                                                               zincrement=0.2)

    if show_plot:
        plt.figure()
        plt.imshow(arr1, cmap="rainbow", extent=(hmin1, hmax1, vmax1, vmin1))
        plt.axis("tight")
        plt.figure()
        plt.imshow(arr2, cmap="rainbow", extent=(hmin2, hmax2, vmax2, vmin2))
        plt.axis("tight")
        plt.show()
Exemplo n.º 2
0
def test_randomline_fence_from_well():
    """Import ROFF grid with props and make fences"""

    grd = xtgeo.Grid(REEKROOT, fformat="eclipserun", initprops=["PORO"])
    wll = xtgeo.Well(WELL1, zonelogname="Zonelog")

    print(grd.describe(details=True))

    # get the polygon for the well, limit it to 1200
    fspec = wll.get_fence_polyline(sampling=10, nextend=2, asnumpy=False, tvdmin=1200)
    print(fspec.dataframe)

    tsetup.assert_almostequal(fspec.dataframe[fspec.dhname][4], 12.6335, 0.001)
    logger.info(fspec.dataframe)

    fspec = wll.get_fence_polyline(sampling=10, nextend=2, asnumpy=True, tvdmin=1200)

    # get the "image", which is a 2D numpy that can be plotted with e.g. imgshow
    hmin, hmax, vmin, vmax, por = grd.get_randomline(
        fspec, "PORO", zmin=1600, zmax=1700, zincrement=1.0
    )

    if XTGSHOW:
        import matplotlib.pyplot as plt

        plt.figure()
        plt.imshow(
            por, cmap="rainbow", extent=(hmin, hmax, vmax, vmin)
        )
        plt.axis("tight")
        plt.colorbar()
        plt.show()
Exemplo n.º 3
0
def test_get_well_x_surf():
    """Getting XYZ, MD for well where crossing a surface"""

    wll = xtgeo.Well(WFILE, mdlogname="Q_MDEPTH")
    surf = xtgeo.RegularSurface(SFILE)
    top = wll.get_surface_picks(surf)

    assert top.dataframe.Q_MDEPTH[5] == pytest.approx(5209.636860, abs=0.001)
Exemplo n.º 4
0
def test_well_to_polygons():
    """Import well from file and amke a Polygons object"""

    mywell = xtgeo.Well(WFILE)

    poly = mywell.get_polygons()

    assert isinstance(poly, xtgeo.xyz.Polygons)
    print(poly.dataframe)

    assert mywell.dataframe["X_UTME"].mean() == poly.dataframe["X_UTME"].mean()
def load_well(
    wfile: Union[str, Path],
    zonelogname: Optional[str] = None,
    mdlogname: Optional[str] = None,
    lognames: Optional[List[str]] = None,
) -> xtgeo.Well:
    lognames = [] if not lognames else lognames
    well = xtgeo.Well(wfile=wfile,
                      zonelogname=zonelogname,
                      mdlogname=mdlogname)

    return well
Exemplo n.º 6
0
def test_simple_plot_with_seismics(tmpdir, show_plot, generate_plot):
    """Test as simple XSECT plot with seismic backdrop."""

    mywell = xtgeo.Well(USEFILE7)
    mycube = xtgeo.Cube(USEFILE6)

    mysurfaces = []
    mysurf = xtgeo.RegularSurface()
    mysurf.from_file(USEFILE2)

    for i in range(10):
        xsurf = mysurf.copy()
        xsurf.values = xsurf.values + i * 20
        xsurf.name = "Surface_{}".format(i)
        mysurfaces.append(xsurf)

    myplot = XSection(
        zmin=1000,
        zmax=1900,
        well=mywell,
        surfaces=mysurfaces,
        cube=mycube,
        sampling=10,
        nextend=2,
    )

    # set the color table, from file
    clist = [0, 1, 222, 3, 5, 7, 3, 12, 11, 10, 9, 8]
    cfil1 = "xtgeo"
    cfil2 = TPATH / "etc/colortables/colfacies.txt"

    assert 222 in clist
    assert "xtgeo" in cfil1
    assert "colfacies" in str(cfil2)

    myplot.set_colortable(cfil1, colorlist=None)

    myplot.canvas(title="Plot with seismics", subtitle="Some well")

    myplot.plot_cube()
    myplot.plot_surfaces(fill=False)

    myplot.plot_well()

    myplot.plot_map()

    if generate_plot:
        myplot.savefig(join(tmpdir, "xsect_wcube.png"), last=False)

    if show_plot:
        myplot.show()
Exemplo n.º 7
0
def _read_from_disk(self, data):

    _get_verbosity(self, data)

    if "path" in data.keys():

        self.print_debug("PATH: {}".format(data["path"]))
        self._path = data["path"]

    reuse_grid = False
    if "grid" in data.keys():

        gridpath = join(self._path, data["grid"])
        if gridpath == self._gridname:
            self.print_info("Grid is already loaded")
            reuse_grid = True
        else:
            self.print_debug("GRIDPATH: {}".format(gridpath))
            self._grid = xtgeo.Grid(gridpath)
            self._gridname = gridpath

    if "zone" in data.keys():
        zonedict = data["zone"]
        zonename, zonefile = _unpack_dict1(zonedict)

        zonefile = join(self._path, zonefile)

        # since grid can be different but zonefile may the same (rare for files...)
        if reuse_grid and zonefile == self._gridzonename:
            self.print_info("Grid zone is already loaded")
        else:
            self._gridzone = xtgeo.GridProperty(zonefile, name=zonename)
            self._gridzonename = zonefile

    if "wells" in data.keys():
        # fields may contain wildcards for "globbing"
        wdata = []
        if isinstance(data["wells"], list):
            for welldata in data["wells"]:
                abswelldata = join(self._path, welldata)
                for wellentry in glob(abswelldata):
                    wdata.append(xtgeo.Well(wellentry))
                    self.print_debug(wellentry)

        self._wells = xtgeo.Wells()
        self._wells.wells = wdata
Exemplo n.º 8
0
def test_simple_plot():
    """Test as simple XSECT plot."""

    mywell = xtgeo.Well(USEFILE4)

    mysurfaces = []
    mysurf = xtgeo.RegularSurface()
    mysurf.from_file(USEFILE2)

    for i in range(10):
        xsurf = mysurf.copy()
        xsurf.values = xsurf.values + i * 20
        xsurf.name = "Surface_{}".format(i)
        mysurfaces.append(xsurf)

    myplot = XSection(zmin=1500, zmax=1800, well=mywell, surfaces=mysurfaces)

    # set the color table, from file
    clist = [0, 1, 222, 3, 5, 7, 3, 12, 11, 10, 9, 8]
    cfil1 = "xtgeo"
    cfil2 = "../xtgeo-testdata/etc/colortables/colfacies.txt"

    assert 222 in clist
    assert "xtgeo" in cfil1
    assert "colfacies" in cfil2

    myplot.set_colortable(cfil1, colorlist=None)

    myplot.canvas(title="Manamana", subtitle="My Dear Well")

    myplot.plot_surfaces(fill=False)

    myplot.plot_well(zonelogname="Zonelog")

    # myplot.plot_map()

    myplot.savefig(join(TMPD, "xsect_gbf1.png"))

    if XTGSHOW:
        print("Show plot")
        myplot.show()
Exemplo n.º 9
0
def test_reek1(tmpdir, generate_plot):
    """Test XSect for a Reek well."""

    myfield = xtgeo.Polygons()
    myfield.from_file(USEFILE3, fformat="xyz")

    mywells = []
    wnames = glob.glob(str(USEFILE4))
    wnames.sort()
    for wname in wnames:
        mywell = xtgeo.Well(wname)
        mywells.append(mywell)

    logger.info("Wells are read...")

    mysurfaces = []
    surfnames = glob.glob(str(USEFILE5))
    surfnames.sort()
    for fname in surfnames:
        mysurf = xtgeo.RegularSurface()
        mysurf.from_file(fname)
        mysurfaces.append(mysurf)

    # Troll lobes
    mylobes = []
    surfnames = glob.glob(str(USEFILE5))
    surfnames.sort()
    for fname in surfnames:
        mysurf = xtgeo.RegularSurface()
        mysurf.from_file(fname)
        mylobes.append(mysurf)

    for wo in mywells:
        myplot = XSection(
            zmin=1500,
            zmax=1700,
            well=wo,
            surfaces=mysurfaces,
            zonelogshift=-1,
            outline=myfield,
        )

        myplot.canvas(
            title=wo.truewellname,
            subtitle="Before my corrections",
            infotext="Heisan sveisan",
            figscaling=1.2,
        )

        # myplot.colortable('xtgeo')

        myplot.plot_surfaces(fill=True)

        myplot.plot_surfaces(
            surfaces=mylobes,
            fill=False,
            linewidth=4,
            legendtitle="Lobes",
            fancyline=True,
        )

        myplot.plot_well(zonelogname="Zonelog")

        myplot.plot_wellmap()

        myplot.plot_map()

        if generate_plot:
            myplot.savefig(join(tmpdir, "xsect2a.svg"),
                           fformat="svg",
                           last=False)
            myplot.savefig(join(tmpdir, "xsect2a.png"), fformat="png")
Exemplo n.º 10
0
def load_well(well_path: str) -> xtgeo.Well:
    return xtgeo.Well(well_path)
Exemplo n.º 11
0
def load_well(well_path):
    """Return a well object (xtgeo) for a given file (RMS ascii format)"""
    return xtgeo.Well(well_path, mdlogname="MD")
Exemplo n.º 12
0
def load_well(well_path):
    return xtgeo.Well(well_path)
    def __init__(
        self,
        app: dash.Dash,
        webviz_settings: WebvizSettings,
        basedir: Path,
        planned_wells_dir: Path = None,
    ):

        super().__init__()
        self.plotly_theme = webviz_settings.theme.plotly_theme
        self.uid = uuid4()
        WEBVIZ_ASSETS.add(
            Path(webviz_subsurface.__file__).parent / "_assets" / "css" /
            "modal.css")
        self.set_callbacks(app)

        self.basedir = basedir
        self.planned_wells_dir = planned_wells_dir
        self.modelfile_path = basedir / "model_file.xml"
        self.modelfile = get_path(self.modelfile_path)
        self.surfaces = load_surfaces(basedir, self.modelfile_path)
        self.planned_wellfiles = (json.load(
            find_files(planned_wells_dir, "*.txt"))
                                  if planned_wells_dir else None)
        self.wellfiles = json.load(
            find_files(basedir / "input" / "welldata", "*.txt"))
        self.wellfiles = [str(get_path(Path(w))) for w in self.wellfiles]
        self.allfiles = json.load(find_files(basedir))
        self.allfiles.append(self.modelfile_path)
        self.allfiles += self.planned_wellfiles
        self.planned_wellfiles = [
            str(get_path(Path(w))) for w in self.planned_wellfiles
        ]
        self.surface_attributes = {}
        for i, surface in enumerate(self.surfaces):
            self.surface_attributes[surface["name"]] = {
                "color": get_color(i),
                "order": i,
                "name": surface["name"],
                "topofzone": surface["topofzone"],
                "surface": surface["d_"],
                "surface_de": surface["de_"],
                "surface_dt": surface["dt_"],
                "surface_dr": surface["dr_"],
                "surface_dte": surface["dte_"],
            }

        self.surfacenames = [surface["name"] for surface in self.surfaces]
        # Log files
        zonation_status_file = get_zonation_status(basedir)
        well_points_file = get_well_points(basedir)
        zonelog_name = get_zonelog_name(self.modelfile)
        self.xsec = HuvXsection(
            self.surface_attributes,
            zonation_status_file,
            well_points_file,
            zonelog_name,
        )
        target_points_file = get_target_points(basedir)
        self.df_well_target_points = FilterTable(target_points_file,
                                                 well_points_file)

        # Wellfiles and planned wells
        self.planned_wells = {}
        if planned_wells_dir is not None:
            self.planned_wells = {
                wf: xtgeo.Well(wf)
                for wf in self.planned_wellfiles
            }

        self.wells = {wf: xtgeo.Well(wf) for wf in self.wellfiles}

        # Store current layers
        self.state = {"switch": False}
        self.layers_state = []