-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update code and tests to same as xtgeo.plot #29
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have a weak-feeling that this should maybe be a weakref. My thinking being, if you have a few figures open and close one of them. The closing figures memory should be cleared then and not hang around until all a closed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not so sure about this either. Hopefully we can come back to this code at some point. But for now, it's just copying the current state of xtgeo.plot to here.
I made an issue for it: #30