zvtk.Reader

Contents

zvtk.Reader#

class zvtk.Reader(filename: Path | str)#

Class to control zvtk file decompression.

Use this class in lieu of zvtk.read() to fine-tune reading in compressed files. With this you can:

  • Inspect the dataset before reading it.

  • Control which arrays to read in.

  • For files containing a pyvista.MultiBlock, select which blocks to read in.

Parameters:
filenamepathlib.Path | str

Path to the file. Must end in .zvtk.

Attributes:
available_cell_arrays

Return a set of all cell array names available in the dataset.

available_field_arrays

Return a set of all field array names available in the dataset.

available_point_arrays

Return a set of all point array names available in the dataset.

decompressed_sizes

Return decompressed frame sizes.

nbytes

Return the size of the decompressed dataset.

selected_cell_arrays

Return the set of currently selected cell arrays to read.

selected_field_arrays

Return the set of currently selected field arrays to read.

selected_point_arrays

Return the set of currently selected point arrays to read.

Methods

read([n_threads])

Read in the dataset from the zvtk file.

show_frame_compression()

Return a table showing compression statistics for each frame in the dataset.

Examples

First write out an example dataset.

>>> import pyvista as pv
>>> import zvtk
>>> ds = pv.Sphere()
>>> zvtk.write(ds, "sphere.zvtk")

Create a reader.

>>> reader = zvtk.Reader("sphere.zvtk")
>>> reader
zvtk.Decompressor (0x7f1ed1496c00)
  File:               sphere.zvtk
  File Version:       0
  Compression:        zstandard
  Compression Level:  3
  Dataset Type:       PolyData
  N Points:           842 (<class 'numpy.float32'>)
  N Cells:            1680
  Point arrays:
      Normals                  float32    (842, 3)

Disable reading in point arrays and read the dataset.

>>> reader.selected_point_arrays = set()
>>> ds_in = reader.read()
>>> ds_in
PolyData (0x7f1ece066ce0)
  N Cells:    1680
  N Points:   842
  N Strips:   0
  X Bounds:   -4.993e-01, 4.993e-01
  Y Bounds:   -4.965e-01, 4.965e-01
  Z Bounds:   -5.000e-01, 5.000e-01
  N Arrays:   0

Methods

Reader.__init__(filename)

Initialize the decompressor.

Reader.read([n_threads])

Read in the dataset from the zvtk file.

Reader.show_frame_compression()

Return a table showing compression statistics for each frame in the dataset.

Attributes

Reader.available_cell_arrays

Return a set of all cell array names available in the dataset.

Reader.available_field_arrays

Return a set of all field array names available in the dataset.

Reader.available_point_arrays

Return a set of all point array names available in the dataset.

Reader.decompressed_sizes

Return decompressed frame sizes.

Reader.nbytes

Return the size of the decompressed dataset.

Reader.selected_cell_arrays

Return the set of currently selected cell arrays to read.

Reader.selected_field_arrays

Return the set of currently selected field arrays to read.

Reader.selected_point_arrays

Return the set of currently selected point arrays to read.