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')
../_images/Notebooks_ex_training_images_6_0.png

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
../_images/Notebooks_ex_training_images_8_1.png
Loading and plotting checkerboard2
../_images/Notebooks_ex_training_images_8_3.png
Loading and plotting strebelle
../_images/Notebooks_ex_training_images_8_5.png
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
../_images/Notebooks_ex_training_images_8_7.png
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
../_images/Notebooks_ex_training_images_8_9.png
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
../_images/Notebooks_ex_training_images_8_11.png
Loading and plotting maze
Beginning download of https://raw.githubusercontent.com/cultpenguin/mGstat/master/ti/maze.gslib to ti_maze.dat
../_images/Notebooks_ex_training_images_8_13.png
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(
Loading and plotting horizons
Beginning download of https://github.com/GAIA-UNIL/trainingimages/raw/master/MPS_book_data/Part2/TI_horizons_continuous.SGEMS to ti_horizons.dat
Loading and plotting fluvsim
Beginning download of https://github.com/GAIA-UNIL/trainingimages/raw/master/MPS_book_data/Part2/ti_fluvsim_big_channels3D.zip to ti_fluvsim.dat.zip
Unziping ti_fluvsim.dat.zip to ti_fluvsim.dat

Coarsen a 2D training to a 3D

[5]:
# load the full Strebelle TI
TI, TI_name = mps.trainingimages.strebelle(di=1)
mps.plot.plot(np.squeeze(TI))

# load every 4th pixel from Strebelle
TI, TI_name = mps.trainingimages.strebelle(di=4)
mps.plot.plot(np.squeeze(TI))

../_images/Notebooks_ex_training_images_10_0.png
../_images/Notebooks_ex_training_images_10_1.png
[6]:
# load every set of possible variation of Strebelle usong a subrgid of 4x4
TI, TI_name = mps.trainingimages.strebelle(di=4,coarse3d=1)
mps.plot.plot(np.squeeze(TI))
[ ]: