gl-website-deployer/generic/splotch.rst

79 lines
2.0 KiB
ReStructuredText
Raw Permalink Normal View History

2024-11-19 08:02:04 +01:00
PySplotch
=========
Rationale
---------
Splotch is a software for visualizing simulation originally written by Klaus Dolag and Martin Reinecke. The original website is
https://wwwmpa.mpa-garching.mpg.de/~kdolag/Splotch/.
PySplotch is a trimmed down version, alongside a python binding. I removed the CUDA acceleration and allowed for more generic data exchange between the rendering core and the user.
Notably there is now a Python binding and a number of helper object to control the camera, the transition between datasets and the generation of a large number of images for video making.
The source code may be found here: https://bitbucket.org/glavaux/pysplotch/.
Example
-------
.. code-block:: language-python
import _splotch
import numpy as np
Np=20000
w,h=800,800
x = _splotch.particleArray(Np)
x[:] = np.random.rand(Np,3)
#x[0] = [0.5,.5,.5]
x.setIntensity(0.01)
x.setRadius(0.005)
x.setValues(np.random.rand(Np))
cmap = _splotch.SplotchColormap(num_types=1)
cmap.addValue(0, 0, (0, 0, 0))
cmap.addValue(0, .5, (.5, 0.5, 0))
cmap.addValue(0, .5, (0, 0.5, 0.5))
cmap.addValue(0, 1, (1, 0., 0))
theta=np.pi/4
r = 2
for i,phi in enumerate(np.arange(0,2*np.pi, 0.05)):
campos = _splotch.SplotchCamera([r*np.cos(phi)*np.cos(theta)+0.5,r*np.sin(phi)*np.cos(theta)+0.5,r*np.sin(theta)+0.5], [0.5,0.5,0.5], [0,0,1])
import _splotch
import numpy as np
Np=20000
w,h=800,800
x = _splotch.particleArray(Np)
x[:] = np.random.rand(Np,3)
#x[0] = [0.5,.5,.5]
x.setIntensity(0.01)
x.setRadius(0.005)
x.setValues(np.random.rand(Np))
cmap = _splotch.SplotchColormap(num_types=1)
cmap.addValue(0, 0, (0, 0, 0))
cmap.addValue(0, .5, (.5, 0.5, 0))
cmap.addValue(0, .5, (0, 0.5, 0.5))
cmap.addValue(0, 1, (1, 0., 0))
theta=np.pi/4
r = 2
for i,phi in enumerate(np.arange(0,2*np.pi, 0.05)):
campos = _splotch.SplotchCamera([r*np.cos(phi)*np.cos(theta)+0.5,r*np.sin(phi)*np.cos(theta)+0.5,r*np.sin(theta)+0.5], [0.5,0.5,0.5], [0,0,1])
```