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.6.1.tar.gz
(198.8 kB
view hashes)
Built Distributions
Close
Hashes for gsd-1.6.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4560ee732ee83ad4b0e3cd0f7ae298e4bc1428cb8a1e2d5f8418cc9e69e2e554 |
|
MD5 | 794a800e21d5b2c58f0d27c63f9dc8f7 |
|
BLAKE2b-256 | a48d5f13b2d202b5e195328be4fd7beba83876a8d297a5f93ff88a245f24d1f9 |
Close
Hashes for gsd-1.6.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef51872c13ccf457d69c0913b5379ffc3ff662f4fcac85577aa694dba90ffb2e |
|
MD5 | f90e2bf0482f7aa4558d974e5896fc22 |
|
BLAKE2b-256 | 88e00934a35cda56fabeb7d14cede6ab62c09d4f1ed60044dcada73a3f2cfafb |
Close
Hashes for gsd-1.6.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4dc4eb953652b9e35fbdc8c438bfd4ebc85e13d6d0721a62388d7bb46eae3cda |
|
MD5 | 3fe331f5972415340a5a7f89f0dac634 |
|
BLAKE2b-256 | 98c28314ae95165a3c7159d948233deeb6206340bd0eb2a4031be907ceb95e4d |
Close
Hashes for gsd-1.6.1-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5efd363d45f351d209c1cd2fcab1209e0af5434005a9f8a530649472ec267ea |
|
MD5 | 8b1448c298cba1c9a59c5dbc97fe6072 |
|
BLAKE2b-256 | 629291e72818e2db5f092e8e8c04b04c5c16cac2cee9414aec50862c64ca2d9c |
Close
Hashes for gsd-1.6.1-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 323e3b2cbc2a30e7e6e1b769af753f9f54e67d169f43cd4d654d4bf25f5bff15 |
|
MD5 | d1297bd513b8059b08b12f49aa368001 |
|
BLAKE2b-256 | d489a03109af191b7ad4a8d3c1adc98aff8297665e5fb1325ee341db8bc37616 |
Close
Hashes for gsd-1.6.1-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 355503482a85fb9d986dc2c162b60bfcdb180213507711f27c885948ff2890d6 |
|
MD5 | b1a620b4cae6719e692986a87715f893 |
|
BLAKE2b-256 | 54dab8362c21fc16bcb01f60cba0f028d522ada639be72cbdb641380ab4990dc |