gl-website-deployer/generic/splotch.rst
2024-11-19 08:02:04 +01:00

2.0 KiB

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> </head>

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

System Message: WARNING/2 (<stdin>, line 20)

Cannot analyze code. No Pygments lexer found for "language-python".

.. 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])

```

System Message: WARNING/2 (<stdin>, line 78); backlink

Inline literal start-string without end-string.

System Message: WARNING/2 (<stdin>, line 78); backlink

Inline interpreted text or phrase reference start-string without end-string.
</html>