vispy.io package#

Subpackages#

Submodules#

Module contents#

Utilities related to data reading, writing, fetching, and generation.

vispy.io.imread(filename, format=None)#

Read image data from disk

Requires imageio or PIL.

Parameters:
filenamestr

Filename to read.

formatstr | None

Format of the file. If None, it will be inferred from the filename.

Returns:
dataarray

Image data.

vispy.io.imsave(filename, im, format=None)#

Save image data to disk

Requires imageio or PIL.

Parameters:
filenamestr

Filename to write.

imarray

Image data.

formatstr | None

Format of the file. If None, it will be inferred from the filename.

vispy.io.load_crate()#

Load an image of a crate

Returns:
cratearray

256x256x3 crate image.

vispy.io.load_data_file(fname, directory=None, force_download=False)#

Get a standard vispy demo data file

Parameters:
fnamestr

The filename on the remote demo-data repository to download, e.g. 'molecular_viewer/micelle.npy'. These correspond to paths on https://github.com/vispy/demo-data/.

directorystr | None

Directory to use to save the file. By default, the vispy configuration directory is used.

force_downloadbool | str

If True, the file will be downloaded even if a local copy exists (and this copy will be overwritten). Can also be a YYYY-MM-DD date to ensure a file is up-to-date (modified date of a file on disk, if present, is checked).

Returns:
fnamestr

The path to the file on the local system.

vispy.io.load_iris()#

Load the iris dataset

Returns:
irisNpzFile

data[‘data’] : a (150, 4) NumPy array with the iris’ features data[‘group’] : a (150,) NumPy array with the iris’ group

vispy.io.load_spatial_filters(packed=True)#

Load spatial-filters kernel

Parameters:
packedbool

Whether or not the data should be in “packed” representation for use in GLSL code.

Returns:
kernelarray

16x1024x4 (packed float in rgba) or 16x1024 (unpacked float) 16 interpolation kernel with length 1024 each.

namestuple of strings

Respective interpolation names, plus “Nearest” which does not require a filter but can still be used

vispy.io.read_mesh(fname)#

Read mesh data from file.

Parameters:
fnamestr

File name to read. Format will be inferred from the filename. Currently only ‘.obj’ and ‘.obj.gz’ are supported.

Returns:
verticesarray

Vertices.

facesarray | None

Triangle face definitions.

normalsarray

Normals for the mesh.

texcoordsarray | None

Texture coordinates.

vispy.io.read_png(filename)#

Read a PNG file to RGB8 or RGBA8 Requires Pillow.

Parameters:
filenamestr

File to read.

Returns:
dataarray

Image data.

See also

write_png, imread, imsave
vispy.io.write_mesh(fname, vertices, faces, normals, texcoords, name='', format=None, overwrite=False, reshape_faces=True)#

Write mesh data to file.

Parameters:
fnamestr

Filename to write. Must end with “.obj” or “.gz”.

verticesarray

Vertices.

facesarray | None

Triangle face definitions.

normalsarray

Normals for the mesh.

texcoordsarray | None

Texture coordinates.

namestr

Name of the object.

formatstr

Currently only “obj” is supported.

overwritebool

If the file exists, overwrite it.

reshape_facesbool

Reshape the faces array to (Nf, 3). Set to False if you need to write a mesh with non triangular faces.

vispy.io.write_png(filename, data)#

Write a PNG file

Unlike imsave, this requires no external dependencies.

Parameters:
filenamestr

File to save to.

dataarray

Image data.

See also

read_png, imread, imsave