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.5.5.tar.gz
(199.2 kB
view hashes)
Built Distributions
Close
Hashes for gsd-1.5.5-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbab5359aeb07cc830e4889dffd695e65c484b6823114f36e1f6d7d2e00b1f9e |
|
MD5 | c10c23e94f1a7434e9d2d20859e0927f |
|
BLAKE2b-256 | fd306ce73d4bd0ed6290353e0f2063b5567e961435b50d2a2d705d7ebb8a858a |
Close
Hashes for gsd-1.5.5-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c0796fb7b14dd319182f9497ede9d1635f58714dbff2967016cb0be96097756 |
|
MD5 | 47b3778731be4745a9189e984e692f9c |
|
BLAKE2b-256 | e87639907861e62418adf5cd2482ed1a80385083755e68eb24c58b036cfff62b |
Close
Hashes for gsd-1.5.5-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 112292cd6552b0d5ee252ce9272956e62f9eff86a71b76fe5e4bf4950aaf9c79 |
|
MD5 | ab82ad313b07a4c07e0f702715706e43 |
|
BLAKE2b-256 | a7ef1da0fc8a8376849607c25f22e2a981284639fa21bd591c930cbe1c3e1f11 |
Close
Hashes for gsd-1.5.5-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21de70fdf75118b09ff86f80a4bd211bafe9203a3e007dcc259005dbeaa70c87 |
|
MD5 | 559009dea00d1696e40fbca1658d3c7e |
|
BLAKE2b-256 | 279a08e7d1a711a5c1d0d50dfcae3a947b506b90ce2be3b3ed9f0b686570e15f |
Close
Hashes for gsd-1.5.5-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5d1312fc716fe71db6eb48219ef773601e3ce22fd52fe95f2fa1757508bfc3b |
|
MD5 | f570472b030661e1c268c24a8004d06a |
|
BLAKE2b-256 | 0c51ba1bfa4c6520e9797eeaaafdf53339074522e03a04158b5a79987504dfa3 |
Close
Hashes for gsd-1.5.5-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88793484f57c5709a40132a2a518cf2143f7feff488885399fe5ad165da993cb |
|
MD5 | aeb0c2f15242016a2726d86cb2bf9270 |
|
BLAKE2b-256 | 654dea79e71cedf41e8b0ec8c5c8d91a71e6f1d6c577a61d1e084328fe48a256 |