General simulation data file format.
Project description
GSD
GSD (General Simulation Data) is a file format specification and a library to read and write it. The package also contains a python module that reads and writes hoomd schema gsd files with an easy to use syntax.
See the full GSD documentation at readthedocs.io.
Overview
GSD files:
- Efficiently store many frames of data from simulation runs.
- High performance file read and write.
- Support arbitrary chunks of data in each frame (position, orientation, type, etc...).
- Append frames to an existing file with a monotonically increasing frame number.
- Resilient to job kills.
- Variable number of named chunks in each frame.
- Variable size of chunks in each frame.
- Each chunk identifies data type.
- Common use cases: NxM arrays in double, float, int, char types.
- Generic use case: binary blob of N bytes.
- Easy to integrate into other tools with python, or a C API (< 1k lines).
- Fast random access to frames.
HOOMD examples
Create a hoomd gsd file.
>>> s = gsd.hoomd.Snapshot()
>>> s.particles.N = 4
>>> s.particles.types = ['A', 'B']
>>> s.particles.typeid = [0,0,1,1]
>>> s.particles.position = [[0,0,0],[1,1,1], [-1,-1,-1], [1,-1,-1]]
>>> s.configuration.box = [3, 3, 3, 0, 0, 0]
>>> traj = gsd.hoomd.open(name='test.gsd', mode='wb')
>>> traj.append(s)
Append frames to a gsd file:
>>> def create_frame(i):
... s = gsd.hoomd.Snapshot();
... s.configuration.step = i;
... s.particles.N = 4+i;
... s.particles.position = numpy.random.random(size=(4+i,3))
... return s;
>>> with gsd.hoomd.open('test.gsd', 'ab') as t:
... t.extend( (create_frame(i) for i in range(10)) )
... print(len(t))
11
Randomly index frames:
>>> with gsd.hoomd.open('test.gsd', 'rb') as t:
... snap = t[5]
... print(snap.configuration.step)
4
... print(snap.particles.N)
8
... print(snap.particles.position)
[[ 0.56993282 0.42243481 0.5502916 ]
[ 0.36892486 0.38167036 0.27310368]
[ 0.04739023 0.13603486 0.196539 ]
[ 0.120232 0.91591144 0.99463677]
[ 0.79806316 0.16991436 0.15228257]
[ 0.13724308 0.14253527 0.02505 ]
[ 0.39287439 0.82519054 0.01613089]
[ 0.23150323 0.95167434 0.7715748 ]]
Slice frames:
>>> with gsd.hoomd.open('test.gsd', 'rb') as t:
... for s in t[5:-2]:
... print(s.configuration.step, end=' ')
4 5 6 7
File layer examples
with gsd.fl.open(name='file.gsd', mode='wb') as f:
f.write_chunk(name='position', data=numpy.array([[1,2,3],[4,5,6]], dtype=numpy.float32));
f.write_chunk(name='angle', data=numpy.array([0, 1], dtype=numpy.float32));
f.write_chunk(name='box', data=numpy.array([10, 10, 10], dtype=numpy.float32));
f.end_frame()
with gsd.fl.open(name='file.gsd', mode='rb') as f:
for i in range(1,f.nframes):
position = f.read_chunk(frame=i, name='position');
do_something(position);
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
gsd-1.7.0.tar.gz
(198.8 kB
view hashes)
Built Distributions
Close
Hashes for gsd-1.7.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e4b2ba51cde02b62500e6081b9f08e3e1df361b9f0e0636a87aa0216694cc0c |
|
MD5 | beb461ff354b03054a562e1a0f7a86d6 |
|
BLAKE2b-256 | 16b3cdb604e677c248786f34346335c3b1968ae5c2db0daa5a23949b0613f1db |
Close
Hashes for gsd-1.7.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6c8028210c1f231a765a030cdc4d55b9fd8883e0c01915b1bfa84138b1abea9 |
|
MD5 | c9a30a6d453e9649a1a2a862e5f00679 |
|
BLAKE2b-256 | 54e4d34048ca21c8ac5824c8ff1baa63ef50614b0376a3217714b9576c63414d |
Close
Hashes for gsd-1.7.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31effbcdbcb7ad579bbe01a9e298e34be22a8eb904ec583042e6016ed1a0db82 |
|
MD5 | 3f65f4e008eca1640dd684a4dd5cce06 |
|
BLAKE2b-256 | 9223387f02b31227cadbb7565f46052677c57ac2a183d40c6cf93145629cf319 |
Close
Hashes for gsd-1.7.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb45f2e43b5a8071dcde791dd507fdcb463094ac788a816a15fabf2f987a7e5b |
|
MD5 | 0df1b84a4ad31a82f9bb88fa4c7d6b31 |
|
BLAKE2b-256 | 711bef61de678030ee766c1d8026feeba5db32209b1afd9bd2fc2dacb4885284 |
Close
Hashes for gsd-1.7.0-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 194dc8eb284b18e3ddc10d0b8391d5f98d0910ef51b65796a9bd7dfe41d90f63 |
|
MD5 | 4b79e5b906c60e572b39ff250e435615 |
|
BLAKE2b-256 | 1e79ff8e7d5df4acd7dfd49980df605f03f03f78691cced156414c4b05db45dc |