POVsnap: strange error

Asked by Michele Griffa

Hello everybody

I've been using the POVsnaps runnable many times successfully.
However, in my last 2D shear cell simulations it does not work.

This is the error message I get:

mpirun -np 2 -machinefile hosts.txt mpipython gouge2dbench_MGriffa.py 1 1

Traceback (most recent call last):
  File "gouge2dbench_MGriffa.py", line 237, in <module>
    runSimulation()
  File "gouge2dbench_MGriffa.py", line 220, in runSimulation
    mySim.run()
  File "/home/grm118/granular_media/ESyS_Particle_my_runnables/POVsnaps.py", line 29, in run
    self.snapshot()
  File "/home/grm118/granular_media/ESyS_Particle_my_runnables/POVsnaps.py", line 40, in snapshot
    camera.setLookAt(self.lookAt)
AttributeError: 'POVsnaps' object has no attribute 'lookAt'

The part of code where the POVsnaps runnable is defined and created is the following

# Add a Runnable of type POVsnaps for creating snapshots
        # povcam = POVsnaps(sim = mySim, interval = 100)
        # mySim.addPostTimeStepRunnable(povcam)

which should be the standard way as indicated in the Users Guide.

The text of POVsnaps.py is the following:

from esys.lsm import *
from esys.lsm.util import Vec3, BoundingBox
from esys.lsm.vis import povray

class POVsnaps (Runnable):
        def __init__(self, sim, interval):
                Runnable.__init__(self)
                self.sim = sim
                self.interval = interval
                self.count = 0
        def configure(self, lookAt=Vec3(35.0,60.0,0),camPosn=Vec3(35.0,60.0,0.0),zoomFactor=0.07,imageSize=[800,600]):
                self.lookAt = lookAt
                self.camPosn = camPosn
                self.zoomFactor = zoomFactor
                self.imageSize = imageSize
        def run(self):
                if ((self.sim.getTimeStep() % self.interval) == 0):
                        self.snapshot()
                        self.count += 1
        def snapshot(self):
                pkg = povray
                Scene = pkg.Scene()
                plist = self.sim.getParticleList()
                for pp in plist:
                        povsphere = pkg.Sphere(pp.getPosn(), pp.getRadius())
                        povsphere.apply(pkg.Colors.Red)
                        Scene.add(povsphere)
                camera = Scene.getCamera()
                camera.setLookAt(self.lookAt)
                camera.setPosn(self.camPosn)
                camera.setZoom(self.zoomFactor)
                fname = "2Dfgtest2finalsnap_%.4d.png" % (self.count)
                Scene.render(offScreen=True, interactive=False,fileName=fname,size=self.imageSize)

Is there any problem in my ESyS-Particle Python files ?

Thanks a lot for your help

Best regards

Michele

Question information

Language:
English Edit question
Status:
Solved
For:
ESyS-Particle Edit question
Assignee:
No assignee Edit question
Solved by:
Dion Weatherley
Solved:
Last query:
Last reply:
Revision history for this message
Best Dion Weatherley (d-weatherley) said :
#1

Hi Michele,

It would appear in your script that the POVsnaps.configure(..) subroutine is never called. This subroutine needs to be called at least once before POVsnaps.snapshot() or POVsnaps.run() is called. This because variables like self.lookAt and self.camPosn are declared within POVsnaps.configure(..). Usually I add a call to configure() to the POVsnaps __init__() subroutine on the line following self.count = 0. You can also call configure from your simulation script, in which case you could initialise your povcam with the following code:

# Add a Runnable of type POVsnaps for creating snapshots
        povcam = POVsnaps(sim = mySim, interval = 100)
        povcam.configure()
        mySim.addPostTimeStepRunnable(povcam)

I hope this helps.

Cheers,

Dion.

Revision history for this message
Michele Griffa (michele-griffa) said :
#2

Hi Dion

Thanks a lot. I did not look at the bingle_Runnable.py code of the Users Guide. It's already there.
In case it could be useful for the next revision of the Users Guide: I've noticed that the povcam.configure() subroutine is not included in the code lines cited within its text, Section 2.4.2, page 20.

Thanks again for your support

Michele
------------------------------------------------------------------------------------------------------------------------------
Michele Griffa, Ph.D.
EMPA, Swiss Federal Laboratories for Materials Testing and Research (ETH Domain)

Überlandstrasse 129
8600, Dübendorf, Switzerland

Ph.: +41 (0) 44 823 4789
Fax: +41 (0) 44 823 4009
email: <email address hidden>
Web site: http://www.empa.ch

Personal web site: http://www.calcolodistr.altervista.org
-----------------------------------------------------------------------------------------------------------------------------

>-----Original Message-----
>From: <email address hidden> [mailto:<email address hidden>] On Behalf Of
>Dion Weatherley
>Sent: Mittwoch, 15. Juli 2009 23:25
>To: Griffa, Michele
>Subject: Re: [Question #77083]: POVsnap: strange error
>
>Your question #77083 on ESyS-Particle changed:
>https://answers.launchpad.net/esys-particle/+question/77083
>
> Status: Open => Answered
>
>Dion Weatherley proposed the following answer:
>Hi Michele,
>
>It would appear in your script that the POVsnaps.configure(..)
>subroutine is never called. This subroutine needs to be called at least
>once before POVsnaps.snapshot() or POVsnaps.run() is called. This
>because variables like self.lookAt and self.camPosn are declared within
>POVsnaps.configure(..). Usually I add a call to configure() to the
>POVsnaps __init__() subroutine on the line following self.count = 0. You
>can also call configure from your simulation script, in which case you
>could initialise your povcam with the following code:
>
># Add a Runnable of type POVsnaps for creating snapshots
> povcam = POVsnaps(sim = mySim, interval = 100)
> povcam.configure()
> mySim.addPostTimeStepRunnable(povcam)
>
>I hope this helps.
>
>Cheers,
>
>Dion.
>
>--
>If this answers your question, please go to the following page to let us
>know that it is solved:
>https://answers.launchpad.net/esys-
>particle/+question/77083/+confirm?answer_id=0
>
>If you still need help, you can reply to this email or go to the
>following page to enter your feedback:
>https://answers.launchpad.net/esys-particle/+question/77083
>
>You received this question notification because you are a direct
>subscriber of the question.

Revision history for this message
Michele Griffa (michele-griffa) said :
#3

Thanks Dion Weatherley, that solved my question.