gsd.fl module¶
GSD file layer API.
Low level access to gsd files. gsd.fl
allows direct access to create,
read, and write gsd
files. The module is implemented in C and is optimized.
See File layer examples for detailed example code.
GSDFile
- Class interface to read and write gsd files.create()
- Create a gsd file (deprecated).open()
- Open a gsd file.
-
class
gsd.fl.
GSDFile
(name, mode, application, schema, schema_version)¶ GSD file access interface.
GSDFile implements an object oriented class interface to the GSD file layer. Use
open()
to open a GSD file and obtain a GSDFile instance.GSDFile
can be used as a context manager.Changed in version 1.2: For new code, use
open()
instead of constructing GSDFile directly. GSDFile.__init__ is backwards compatible with the old open syntax used in GSD versions 1.0.x and 1.1.x.-
name
¶ str – Name of the open file (read only).
-
mode
¶ str – Mode of the open file (read only).
-
gsd_version
¶ tuple[int] – GSD file layer version number [major, minor] (read only).
-
application
¶ str – Name of the generating application (read only).
-
schema
¶ str – Name of the data schema (read only).
-
schema_version
¶ tuple[int] – Schema version number [major, minor] (read only).
-
nframes
¶ int – Number of frames (read only).
-
chunk_exists
(frame, name)¶ Test if a chunk exists.
Parameters: Returns: True if the chunk exists in the file. False if it does not.
Return type: Example
In [1]: with gsd.fl.open(name='file.gsd', mode='wb', application="My application", schema="My Schema", schema_version=[1,0]) as f: ...: f.write_chunk(name='chunk1', data=numpy.array([1,2,3,4], dtype=numpy.float32)); ...: f.write_chunk(name='chunk2', data=numpy.array([[5,6],[7,8]], dtype=numpy.float32)); ...: f.end_frame(); ...: f.write_chunk(name='chunk1', data=numpy.array([9,10,11,12], dtype=numpy.float32)); ...: f.write_chunk(name='chunk2', data=numpy.array([[13,14],[15,16]], dtype=numpy.float32)); ...: f.end_frame(); ...: In [2]: f = gsd.fl.open(name='file.gsd', mode='rb', application="My application", schema="My Schema", schema_version=[1,0]) In [3]: f.chunk_exists(frame=0, name='chunk1') Out[3]: True In [4]: f.chunk_exists(frame=0, name='chunk2')
-