-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update code and tests to same as xtgeo.plot
- Loading branch information
Showing
8 changed files
with
413 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import pathlib | ||
|
||
import xtgeoviz.plot._colortables as ct | ||
|
||
TPATH = pathlib.Path("../xtgeo-testdata") | ||
|
||
|
||
def test_readfromfile(): | ||
"""Read color table from RMS file.""" | ||
cfile = TPATH / "etc/colortables/colfacies.txt" | ||
ctable = ct.colorsfromfile(cfile) | ||
assert ctable[5] == (0.49019608, 0.38431373, 0.05882353) | ||
|
||
|
||
def test_xtgeo_colors(): | ||
"""Read the XTGeo color table.""" | ||
ctable = ct.xtgeocolors() | ||
assert ctable[5] == (0.000, 1.000, 1.000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import os | ||
import pathlib | ||
|
||
import pytest | ||
import xtgeo | ||
|
||
from xtgeoviz.plot import Grid3DSlice | ||
|
||
TPATH = pathlib.Path("../xtgeo-testdata") | ||
|
||
USEFILE1 = TPATH / "3dgrids/reek/reek_sim_grid.roff" | ||
USEFILE2 = TPATH / "3dgrids/reek/reek_sim_poro.roff" | ||
USEFILE3 = TPATH / "etc/colortables/rainbow_reverse.rmscolor" | ||
|
||
|
||
def test_slice_simple_layer(tmpdir, show_plot, generate_plot): | ||
"""Trigger XSection class, and do some simple things basically.""" | ||
layslice = Grid3DSlice() | ||
|
||
mygrid = xtgeo.grid_from_file(USEFILE1) | ||
myprop = xtgeo.gridproperty_from_file(USEFILE2, grid=mygrid, name="PORO") | ||
|
||
assert myprop.values.mean() == pytest.approx(0.1677, abs=0.001) | ||
|
||
wd = None # [457000, 464000, 1650, 1800] | ||
for lay in range(1, mygrid.nlay + 1): | ||
layslice.canvas(title=f"My Grid Layer plot for layer {lay}") | ||
layslice.plot_gridslice( | ||
mygrid, | ||
prop=myprop, | ||
mode="layer", | ||
index=lay, | ||
window=wd, | ||
linecolor="black", | ||
) | ||
|
||
if show_plot: | ||
layslice.show() | ||
if generate_plot: | ||
layslice.savefig(os.path.join(tmpdir, "layerslice_" + str(lay) + ".png")) | ||
layslice.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import pathlib | ||
from os.path import join | ||
|
||
import xtgeo | ||
|
||
from xtgeoviz.plot import Map | ||
|
||
TPATH = pathlib.Path("../xtgeo-testdata") | ||
|
||
SFILE1 = TPATH / "surfaces/reek/1/topreek_rota.gri" | ||
PFILE1 = TPATH / "polygons/reek/1/top_upper_reek_faultpoly.pol" | ||
SFILE2 = TPATH / "surfaces/reek/1/reek_perm_lay1.gri" | ||
|
||
|
||
def test_simple_plot(tmpdir, generate_plot): | ||
"""Test as simple map plot only making an instance++ and plot.""" | ||
|
||
mysurf = xtgeo.surface_from_file(SFILE1) | ||
|
||
# just make the instance, with a lot of defaults behind the scene | ||
myplot = Map() | ||
myplot.canvas(title="My o my") | ||
myplot.colormap = "gist_ncar" | ||
myplot.plot_surface(mysurf) | ||
|
||
if generate_plot: | ||
myplot.savefig(join(tmpdir, "map_simple.png"), last=True) | ||
else: | ||
myplot.close() | ||
|
||
|
||
def test_map_plot_with_points(tmpdir, generate_plot): | ||
"""Test as simple map plot with underlying points.""" | ||
|
||
mysurf = xtgeo.surface_from_file(SFILE1) | ||
|
||
mypoints = xtgeo.points_from_surface(mysurf) | ||
|
||
df = mypoints.dataframe.copy() | ||
df = df[::20] | ||
mypoints.dataframe = df | ||
|
||
# just make the instance, with a lot of defaults behind the scene | ||
myplot = Map() | ||
myplot.canvas(title="My o my") | ||
myplot.colormap = "gist_ncar" | ||
myplot.plot_surface(mysurf) | ||
myplot.plot_points(mypoints) | ||
|
||
if generate_plot: | ||
myplot.savefig(join(tmpdir, "map_with_points.png"), last=True) | ||
else: | ||
myplot.close() | ||
|
||
|
||
def test_more_features_plot(tmpdir, generate_plot): | ||
"""Map with some more features added, such as label rotation.""" | ||
|
||
mysurf = xtgeo.surface_from_file(SFILE1) | ||
|
||
myfaults = xtgeo.polygons_from_file(PFILE1) | ||
|
||
# just make the instance, with a lot of defaults behind the scene | ||
myplot = Map() | ||
myplot.canvas(title="Label rotation") | ||
myplot.colormap = "rainbow" | ||
myplot.plot_surface(mysurf, minvalue=1250, maxvalue=2200, xlabelrotation=45) | ||
|
||
myplot.plot_faults(myfaults) | ||
|
||
if generate_plot: | ||
myplot.savefig(join(tmpdir, "map_more1.png"), last=True) | ||
else: | ||
myplot.close() | ||
|
||
|
||
def test_perm_logarithmic_map(tmpdir, generate_plot): | ||
"""Map with PERM, log scale.""" | ||
|
||
mysurf = xtgeo.surface_from_file(SFILE2) | ||
|
||
myplot = Map() | ||
myplot.canvas(title="PERMX normal scale") | ||
myplot.colormap = "rainbow" | ||
myplot.plot_surface( | ||
mysurf, minvalue=0, maxvalue=6000, xlabelrotation=45, logarithmic=True | ||
) | ||
|
||
if generate_plot: | ||
myplot.savefig(join(tmpdir, "permx_normal.png"), last=True) | ||
else: | ||
myplot.close() |
Oops, something went wrong.