ZnVis


NameZnVis JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/zincware/ZnVis
SummaryVisualization of particle trajectories.
upload_time2023-03-22 16:36:02
maintainer
docs_urlNone
authorzincwarecode
requires_python>=3.8
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![PyTest](https://github.com/zincware/ZnVis/actions/workflows/pytest.yaml/badge.svg)
[![code-style](https://img.shields.io/badge/code%20style-black-black)](https://github.com/psf/black/)
[![zincware](https://img.shields.io/badge/Powered%20by-zincware-darkcyan)](https://github.com/zincware)


# ZnVis

ZnVis is a visualisation engine for particle simulation data.
Simply define the particles in the simulation with details including their positions,
colour, direction, and shape, and the visualization engine will display the system
using the Open3D engine.
ZnVis works both from a Python script and in Jupyter!

ZnVis can currently perform the following tasks:

* Visualize simulations and trajectories
* Create spherical and cylindrical mesh's for visualization
* Handle custom mesh objects
* Export png stills from the visualizer
* Export scences as `.obj` files.

## Installation

ZnVis is a purely Python package hosted on PyPi.
It can therefore be installed using pip with:

```sh
pip install znvis
```

If you prefer to access the source code, run the following from a terminal:

```sh
   git clone https://github.com/zincware/ZnVis.git
   cd ZnVis
   pip install .
```

Once complete, you will be able to start using the visualizer by importing it as:

```python
import znvis
```

## How does it work?

ZnVis is essentially a convenience wrapper of the 
[Open3D](https://github.com/isl-org/Open3D) project with a focus on mesh visualization.
The idea came out of wanting a simple way of visualizing particle trajectories from 
numpy arrays directly from a simulation script.

Below we show an example script from a reinforcement learning experiment built using
*Shameless plug alert* [SwarmRL](https://github.com/SwarmRL/SwarmRL)

```python
import numpy as np
import h5py as hf

import znvis as vis

# Load data from the database
with hf.File("training/trajectory.hdf5", 'r') as db:
    positions = db["colloids"]["Unwrapped_Positions"][:]

# Split data for convenience
colloid_positions = positions[:, 0:10, :]
rod_positions = positions[:, 10:, :]

# Create free colloid mesh
colloid_mesh = vis.Sphere(radius=2.14, colour=np.array([30, 144, 255]) / 255, resolution=10)
colloid_particle = vis.Particle(name="Colloid", mesh=mesh, position=colloid_positions)

# Create rod colloid mesh
rod_mesh = vis.Sphere(radius=2.14, colour=np.array([255, 140, 0]) / 255, resolution=10)
rod_particle = vis.Particle(name="Rod", mesh=mesh, position=rod_positions)

# Run the visualizer
visualizer = vis.Visualizer(particles=[colloid_particle, rod_particle], frame_rate=80)
visualizer.run_visualization()
```

Just like that, a visualization window (shown below) will pop up from which you can play 
the trajectory and watch your RL agents rotate a rod.

![Visualizer Example](./readme_image.png)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/zincware/ZnVis",
    "name": "ZnVis",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "",
    "author": "zincwarecode",
    "author_email": "tovey.samuel@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/69/47/9938feecf7d7e8c501ea2cfd36c953415a9c0d86919c47f8f8aeb1c16038/ZnVis-0.1.0.tar.gz",
    "platform": null,
    "description": "![PyTest](https://github.com/zincware/ZnVis/actions/workflows/pytest.yaml/badge.svg)\n[![code-style](https://img.shields.io/badge/code%20style-black-black)](https://github.com/psf/black/)\n[![zincware](https://img.shields.io/badge/Powered%20by-zincware-darkcyan)](https://github.com/zincware)\n\n\n# ZnVis\n\nZnVis is a visualisation engine for particle simulation data.\nSimply define the particles in the simulation with details including their positions,\ncolour, direction, and shape, and the visualization engine will display the system\nusing the Open3D engine.\nZnVis works both from a Python script and in Jupyter!\n\nZnVis can currently perform the following tasks:\n\n* Visualize simulations and trajectories\n* Create spherical and cylindrical mesh's for visualization\n* Handle custom mesh objects\n* Export png stills from the visualizer\n* Export scences as `.obj` files.\n\n## Installation\n\nZnVis is a purely Python package hosted on PyPi.\nIt can therefore be installed using pip with:\n\n```sh\npip install znvis\n```\n\nIf you prefer to access the source code, run the following from a terminal:\n\n```sh\n   git clone https://github.com/zincware/ZnVis.git\n   cd ZnVis\n   pip install .\n```\n\nOnce complete, you will be able to start using the visualizer by importing it as:\n\n```python\nimport znvis\n```\n\n## How does it work?\n\nZnVis is essentially a convenience wrapper of the \n[Open3D](https://github.com/isl-org/Open3D) project with a focus on mesh visualization.\nThe idea came out of wanting a simple way of visualizing particle trajectories from \nnumpy arrays directly from a simulation script.\n\nBelow we show an example script from a reinforcement learning experiment built using\n*Shameless plug alert* [SwarmRL](https://github.com/SwarmRL/SwarmRL)\n\n```python\nimport numpy as np\nimport h5py as hf\n\nimport znvis as vis\n\n# Load data from the database\nwith hf.File(\"training/trajectory.hdf5\", 'r') as db:\n    positions = db[\"colloids\"][\"Unwrapped_Positions\"][:]\n\n# Split data for convenience\ncolloid_positions = positions[:, 0:10, :]\nrod_positions = positions[:, 10:, :]\n\n# Create free colloid mesh\ncolloid_mesh = vis.Sphere(radius=2.14, colour=np.array([30, 144, 255]) / 255, resolution=10)\ncolloid_particle = vis.Particle(name=\"Colloid\", mesh=mesh, position=colloid_positions)\n\n# Create rod colloid mesh\nrod_mesh = vis.Sphere(radius=2.14, colour=np.array([255, 140, 0]) / 255, resolution=10)\nrod_particle = vis.Particle(name=\"Rod\", mesh=mesh, position=rod_positions)\n\n# Run the visualizer\nvisualizer = vis.Visualizer(particles=[colloid_particle, rod_particle], frame_rate=80)\nvisualizer.run_visualization()\n```\n\nJust like that, a visualization window (shown below) will pop up from which you can play \nthe trajectory and watch your RL agents rotate a rod.\n\n![Visualizer Example](./readme_image.png)\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Visualization of particle trajectories.",
    "version": "0.1.0",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2fecaa3cb8311fed730f93d1d7fceed8887cde98057a1ab93bef464576328575",
                "md5": "8ef456071764d65c74ad0437936d631b",
                "sha256": "041daf6cae4628133cdf512f2b701dca0c79272259f5b0ecb3dd3eed1465161d"
            },
            "downloads": -1,
            "filename": "ZnVis-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8ef456071764d65c74ad0437936d631b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 20514,
            "upload_time": "2023-03-22T16:36:01",
            "upload_time_iso_8601": "2023-03-22T16:36:01.369100Z",
            "url": "https://files.pythonhosted.org/packages/2f/ec/aa3cb8311fed730f93d1d7fceed8887cde98057a1ab93bef464576328575/ZnVis-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "69479938feecf7d7e8c501ea2cfd36c953415a9c0d86919c47f8f8aeb1c16038",
                "md5": "8c310da0250131f43354f4ba1552bc3b",
                "sha256": "305b4d8acbe5def5784e239cb9f1987c2d1de9d058d6aab604795a481e40b179"
            },
            "downloads": -1,
            "filename": "ZnVis-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "8c310da0250131f43354f4ba1552bc3b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 12914,
            "upload_time": "2023-03-22T16:36:02",
            "upload_time_iso_8601": "2023-03-22T16:36:02.502921Z",
            "url": "https://files.pythonhosted.org/packages/69/47/9938feecf7d7e8c501ea2cfd36c953415a9c0d86919c47f8f8aeb1c16038/ZnVis-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-22 16:36:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "zincware",
    "github_project": "ZnVis",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "znvis"
}
        
Elapsed time: 0.05037s