MPSlib: Training images in scikit-mps
scikit-mps conrtains a module, mpslib.trainingimages, that allow loading and creating a number of training images
[1]:
import numpy as np
import matplotlib.pyplot as plt
import mpslib as mps
import pyvista
pyvista.set_plot_theme("document")
pyvista.global_theme.jupyter_backend = 'panel' # use this in jupyter lab
#pyvista.global_theme.jupyter_backend = 'pythreejs' # use this in notebook
List the available training images
[2]:
TI_type, TI_desc = mps.trainingimages.ti_list()
Available training images:
checkerboard - 2D checkerboard
checkerboard2 - 2D checkerboard - alternative
strebelle - 2D discrete channels from Strebelle
lines - 2D discrete lines
stones - 2D continious stones
bangladesh - 2D discrete Bangladesh
maze - 2D discrete maze
rot90 - 3D rotation 90
horizons - 3D continious horizons
fluvsim - 3D discrete fluvsim
Plot training images
Load and plot a single training image
[3]:
TI, TI_filename=mps.trainingimages.strebelle()
TI.shape
mps.plot.plot_2d(TI, header='Strebelle')
Plot all training images
[4]:
for i in range(len(TI_type)):
ti_type=TI_type[i]
print('Loading and plotting %s' % (ti_type) )
O_TI=getattr(mps.trainingimages,ti_type)
TI, TI_fname=O_TI()
mps.plot.plot(np.squeeze(TI), slice=0, header=TI_desc[i])
Loading and plotting checkerboard
Loading and plotting checkerboard2
Loading and plotting strebelle
Loading and plotting lines
Beginning download of https://github.com/GAIA-UNIL/trainingimages/raw/master/MPS_book_data/Part2/ti_lines_arrows.sgems to ti_lines.dat
Loading and plotting stones
Beginning download of https://github.com/GAIA-UNIL/trainingimages/raw/master/MPS_book_data/Part2/ti_stonewall.sgems to ti_stones.dat
Loading and plotting bangladesh
Beginning download of https://github.com/GAIA-UNIL/trainingimages/raw/master/MPS_book_data/Part2/bangladesh.sgems to ti_bangladesh.dat
Loading and plotting maze
Beginning download of https://raw.githubusercontent.com/cultpenguin/mGstat/master/ti/maze.gslib to ti_maze.dat
Loading and plotting rot90
Beginning download of https://github.com/GAIA-UNIL/trainingimages/raw/master/MPS_book_data/Part2/checker_rtoinvariant_90.zip to ti_tot90.dat.zip
Unziping ti_tot90.dat.zip to ti_tot90.dat
/home/tmeha/miniconda3/envs/mps/lib/python3.9/site-packages/pyvista/core/dataset.py:1555: PyvistaDeprecationWarning: Use of `cell_arrays` is deprecated. Use `cell_data` instead.
warnings.warn(