[yt-dev] Issue #1132: [Experimental] camera.width is currently assumed to be a yt array, contrary to what it currently says in the docs (yt_analysis/yt)

Andrew Myers issues-reply at bitbucket.org
Mon Oct 19 22:33:45 PDT 2015


New issue 1132: [Experimental] camera.width is currently assumed to be a yt array, contrary to what it currently says in the docs
https://bitbucket.org/yt_analysis/yt/issues/1132/experimental-camerawidth-is-currently

Andrew Myers:

You can see this by trying to render something with a default-constructed Camera:


```
#!python

import yt
import numpy as np
from yt.visualization.volume_rendering.api import Scene, PointSource, Camera
sc = Scene()

npoints = 1000
vertices = np.random.random([npoints, 3])
colors = np.random.random([npoints, 4])
colors[:,3] = 1.0

source = PointSource(vertices, colors=colors)
sc.add_source(source)
cam = Camera()
cam.focus = np.array([0.5, 0.5, 0.5])
sc.camera = cam
im = sc.render()
```


```
#!python

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-9e1f41c9da61> in <module>()
     15 cam.focus = np.array([0.5, 0.5, 0.5])
     16 sc.camera = cam
---> 17 im = sc.render()

/Users/atmyers/yt-x86_64/src/yt-hg/yt/visualization/volume_rendering/scene.pyc in render(self, sigma_clip, camera)
    159         assert(camera is not None)
    160         self._validate()
--> 161         bmp = self.composite(camera=camera)
    162         self.last_render = bmp
    163         return bmp

/Users/atmyers/yt-x86_64/src/yt-hg/yt/visualization/volume_rendering/scene.pyc in composite(self, camera)
    259 
    260         for k, source in self._iter_opaque_sources():
--> 261             opaque = source.render(camera, zbuffer=opaque)
    262             im = opaque.rgba
    263 

/Users/atmyers/yt-x86_64/src/yt-hg/yt/visualization/volume_rendering/render_source.pyc in render(self, camera, zbuffer)
    501         # DRAW SOME POINTS
    502         camera.lens.setup_box_properties(camera)
--> 503         px, py, dz = camera.lens.project_to_plane(camera, vertices)
    504         zpoints(empty, z, px.d, py.d, dz.d, self.colors, self.color_stride)
    505 

/Users/atmyers/yt-x86_64/src/yt-hg/yt/visualization/volume_rendering/lens.py in project_to_plane(self, camera, pos, res)
    123         dz = np.dot(pos - self.front_center.d, -camera.unit_vectors[2])
    124         # Transpose into image coords.
--> 125         py = (res[0]*(dx/camera.width[0].d)).astype('int')
    126         px = (res[1]*(dy/camera.width[1].d)).astype('int')
    127         return px, py, dz

AttributeError: 'numpy.float64' object has no attribute 'd'
```

Responsible: atmyers



More information about the yt-dev mailing list