CBDM calculation

57 views
Skip to first unread message

Francesco Anselmo

unread,
Feb 19, 2017, 6:40:11 AM2/19/17
to VI-Suite

Hi Ryan and all in the VI-Suite discussion group.

Since this is my first post, first I'd like to thank Ryan for the excellent work putting together this tool! 
And also for spending time doing the excellent video tutorials!
Thank you!

I've started using VI-Suite about a couple of months ago and found it easy to learn - I'm both a Radiance and Energyplus user, and have written Blender scripts for conversion from - to Radiance in the past.

I'm now in the process of testing the more advanced features and have stumbled in a problem that I haven't managed to solve.
When I try the CBDM calculation, it stops with the following error messages:

-----------
TypeError: object of type 'numpy.float32' has no len()

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Applications/visuite04-osx/blender.app/Contents/Resources/2.78/scripts/addons/vi-suite04/vi_operators.py", line 752, in invoke
    calcout = li_calc(self, simnode, livisimacc(simnode))
  File "/Applications/visuite04-osx/blender.app/Contents/Resources/2.78/scripts/addons/vi-suite04/livi_calc.py", line 125, in li_calc
    udiout = o.udidacalcapply(scene, frames, rccmds, simnode, curres, pfile)
  File "/Applications/visuite04-osx/blender.app/Contents/Resources/2.78/scripts/addons/vi-suite04/vi_func.py", line 1074, in udidacalcapply
    self['livires']['dhilluave{}'.format(frame)] = average(totfinalillu, axis = 0).flatten().reshape(dno, hno).transpose()
    if type(a) is not mu.ndarray:
SystemError: <class 'type'> returned a result with an error set

location: <unknown location>:-1

location: <unknown location>:-1
-----------

I've tried debugging this but cannot find the root of the problem. Hope someone can help.

On a different note, I'm still trying to understand what is the best way to do scripting development in Blender.
I develop on a macbook, so I usually start Blender from the terminal, have the code in an editor and refresh the script in the Blender 3D window (F8).
I'm wondering if there is a better way...

Thank you,
Francesco

Ryan Southall

unread,
Feb 19, 2017, 8:27:17 AM2/19/17
to VI-Suite
Hi Francesco.
Thank you for your comments and the bug report. 
I think I've found the problem which I will include in the next release but for now at around line 955 in the vi_func.py file you should see a code block like 
resarray = array([[float(v) for v in sl.split('\t') if v] for sl in sensrun[0].splitlines() if sl not in ('\n', '\r\n')]).reshape(len(chunk), 146, 3).astype(float32)
chareas
= array([c.calc_area() for c in chunk]) if self['cpoint'] == '0' else array([vertarea(bm, c) for c in chunk]).astype(float32)
sensarray
= nsum(resarray*illuarray, axis = 2).astype(float32)
wsensearray  
= nsum(resarray*fwattarray, axis = 2).astype(float32)
finalillu
= inner(sensarray, vecvals).astype(float32)

The .astype(float32) was my attempt to reduce memory consumption but it seems Blender cannot auto convert a numpy float32 to a python float and this causes a problem for the CBDM calculation.
If you remove the .astype(float32) in the above lines or put a # in front like 
finalillu = inner(sensarray, vecvals)#.astype(float32)
this should fix the problem.
Regards
Ryan

Ryan Southall

unread,
Feb 19, 2017, 8:37:27 AM2/19/17
to VI-Suite
P.S. I think it was brad that inspired me to begin work on LiVi so thanks in return.
P.P.S. There is a way I think for the Blender text editor to run an externally edited file directly using some Python magic. I think there are details on the interweb somewhere.


On Sunday, 19 February 2017 11:40:11 UTC, Francesco Anselmo wrote:

Francesco Anselmo

unread,
Feb 19, 2017, 9:17:06 AM2/19/17
to VI-Suite
Hi Ryan, thanks for the quick reply!

That almost did the trick. I also had to remove the other type casting functions in the arrays above. 
Thanks for suggesting this, I would have scratched my head for a lot longer! ;-)

It was nice though to have a look at the code. I can see you've added nice features like multiprocessing that are great for interactive use!

Thanks so much!
F.

Francesco Anselmo

unread,
Feb 19, 2017, 9:28:05 AM2/19/17
to VI-Suite
Wow, nice to hear brad had a little role at the beginning of your project. But you've gone so much further!

Now I remember seeing this a while back 
It uses Eclipse PyDev, maybe it works on macos and linux too, I'll give it a go when I have a bit more time.

Ciao!
F.
Reply all
Reply to author
Forward
0 new messages