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
HeaderData Arrays
TableInformation
N Rows2100000
N Arrays1
NameTypeN CompMinMax
vfloat6412.667e+002.550e+02


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
HeaderData Arrays
ImageDataInformation
N Cells2100000
N Points4205902
X Bounds0.000e+00, 1.200e+03
Y Bounds0.000e+00, 1.750e+03
Z Bounds0.000e+00, 1.000e+00
Dimensions1201, 1751, 2
Spacing1.000e+00, 1.000e+00, 1.000e+00
N Arrays1
NameFieldTypeN CompMinMax
vCellsfloat6412.667e+002.550e+02


grid.plot(cpos="xy")
read table

Total running time of the script: (0 minutes 33.913 seconds)

Gallery generated by Sphinx-Gallery