Note
Go to the end to download the full example code
Read GSLib Table
Read any GSLib file as a table pyvist.Table
import os
import pooch
from PVGeo.grids import TableToTimeGrid
from PVGeo.gslib import GSLibReader
# points_url = 'http://www.trainingimages.org/uploads/3/4/7/0/34703305/sundarbans.zip'
url = "https://raw.githubusercontent.com/pyvista/vtk-data/master/Data/sundarbans.SGEMS.zip"
file_paths = pooch.retrieve(url=url, known_hash=None, processor=pooch.Unzip())
file_path = [f for f in file_paths if os.path.basename(f) == "sundarbans.SGEMS"][0]
file_path
'/home/runner/.cache/pooch/86487d9e94190c342742d91d20091f70-sundarbans.SGEMS.zip.unzip/sundarbans.SGEMS'
reader = GSLibReader()
table = reader.apply(file_path)
# Print the file header
print(reader.get_file_header())
1200 1750 1
table
From inspecting the header, we realize that this dataset is gridded, so let’s
use the PVGeo.grid.TableToTimeGrid
filter to create a
pyvista.ImageData
of that dataset.
# 1200 x, 1750 y, 1 z, 1 t
grid = TableToTimeGrid(extent=(1200, 1750, 1, 1), order="F").apply(table)
grid
grid.plot(cpos="xy")
Total running time of the script: (0 minutes 33.913 seconds)