Skip to main content

garnett

CircleCI RTD Contributors License

About

This is a collection of samples, parsers and writers for formats used in the Glotzer Group at the University of Michigan, Ann Arbor.

Maintainers

Setup

To install this package with pip, execute:

pip install garnett --user

Documentation

The package's documentation is available at: https://garnett.readthedocs.io/

To build the documentation yourself using sphinx, execute within the repository:

cd doc
make html
open _build/html/index.html

Quickstart

Reading and writing

import garnett

# Autodetects file format for a uniform trajectory API
with garnett.read('gsdfile.gsd') as traj:
    for frame in traj:
        pos = frame.position

# Simple conversion of trajectory formats
with garnett.read('posfile.pos') as traj:
    garnett.write(traj, 'gsdfile.gsd')

Data access

Access individual frames by indexing or create subsets of trajectories with slicing:

first_frame = traj[0]
last_frame = traj[-1]
nth_frame = traj[n]
# and so on

sub_trajectory = traj[i:j]

Access properties of trajectories:

traj.load_arrays()
traj.box             # M
traj.N               # M
traj.types           # MxT
traj.type_shapes     # MxT
traj.typeid          # MxN
traj.position        # MxNx3
traj.orientation     # MxNx4
traj.velocity        # MxNx3
traj.mass            # MxN
traj.charge          # MxN
traj.diameter        # MxN
traj.moment_inertia  # MxNx3
traj.angmom          # MxNx4
traj.image           # MxNx3

# M is the number of frames
# T is the number of particle types in a frame
# N is the number of particles in a frame

Access properties of individual frames:

frame = traj[i]
frame.box              # garnett.trajectory.Box object
frame.N                # scalar, number of particles
frame.types            # T, string names for each type
frame.type_shapes      # T, list of shapes for each type
frame.typeid           # N, type indices of each particle
frame.position         # Nx3
frame.orientation      # Nx4
frame.velocity         # Nx3
frame.mass             # N
frame.charge           # N
frame.diameter         # N
frame.moment_inertia   # Nx3
frame.angmom           # Nx4
frame.image            # Nx3
frame.data             # Dictionary of lists for each attribute
frame.data_key         # List of strings

All matrices are NumPy arrays.

Example use with HOOMD-blue

See the examples directory for additional examples.

pos_reader = PosFileReader()
with open('cube.pos') as posfile:
    traj = pos_reader.read(posfile)

# Initialize from last frame
snapshot = traj[-1].to_hoomd_snapshot()
system = init.read_snapshot(snapshot)

# Restore last frame
snapshot = system.take_snapshot()
traj[-1].to_hoomd_snapshot(snapshot)

Testing

To run all garnett tests, ddt, HOOMD-blue (hoomd), and pycifrw must be installed in the testing environments.

Execute the tests with:

python -m unittest discover tests

Metadata

Release files for garnett 0.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for garnett 0.7.1
File Size Uploaded Provenance
garnett-0.7.1.tar.gz 126.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for garnett 0.7.1
File Interpreter ABI Platform
garnett-0.7.1-py3-none-any.whl Python 3 none any Details

Total release size: 202.5 kB

Release files / garnett-0.7.1.tar.gz

Download URL garnett-0.7.1.tar.gz
Size 126.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1734a1ef477a2bae0422a6dbe9d76bd3c208d851825fe067d6a80f1339dea698
BLAKE2b-256 checksum
How to use checksums
e4d902e249c34f4575954a3a37ca13897c7b9fb076bbee618b73a50cfc93b37a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.8.0 tqdm/4.43.0 CPython/3.8.2

Release files / garnett-0.7.1-py3-none-any.whl

Download URL garnett-0.7.1-py3-none-any.whl
Size 76.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
25444120fe6aa9effde9fb3133b0269494f0f79789175fa9f67e0ea5d3f5ce95
BLAKE2b-256 checksum
How to use checksums
b1dbdbe598c79ca7f52b0698a17e871ca01c3aa873553f77ee867b734b03b1c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.8.0 tqdm/4.43.0 CPython/3.8.2

Security for garnett 0.7.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page