[Radiance-general] Python Radiance Package

Greg Ward gregoryjward at gmail.com
Sat Nov 6 12:50:49 PDT 2010


Hi Dave,

This is an interesting idea.  I'm not very familiar with Python, so I'm going to ask some naive questions:

1) Can't you just invoke a system command line from Python?  Is this how you would implement these methods?

2) What are the advantages of encapsulating Radiance tools in this way?  Who do you expect will benefit?

It seems like you're just trading one syntax (the Unix command line) for another (Python objects and methods).  This can be worthwhile if the syntax is easier to use or leverages capabilities of the language in new ways.  Do you have an actual problem in mind that you think is best solved this way?  Your example gives a flavor of what you could do, but you're not really doing anything here you couldn't do by shelling out commands and stowing the results in files instead of variables.

Can you share a little more of your broader vision?  Are these just hooks for applications like Blender, or are they somehow better than the commands themselves?  Do you plan to store entire images in memory, or does Python manage variables with megabytes of data in them efficiently?

Cheers,
-Greg


> From: David Smith <dbs176 at gmail.com>
> Date: November 6, 2010 11:59:41 AM PDT
> 
> Dear Radiance community,
> 
> Does anybody have any interest in a generic Radiance wrapper package for Python? I think I'm going to make one (and make it open source), and was wondering if anybody had any interest, suggestions, advice, code they would be willing to contribute, etc. I'm aiming for a 1:1 functionality but I know there are going to be some things that will be tough/impossible to do.
> 
> I made what I think a simple program could be like below - it imports geometry, creates a series of images, manipulates and combines those images, then saves them.
> 
> The benefits of this are the flexibility of working within a higher level scripting language. You open up the possibility of scripting complex problems, parameteric geometry, iterative solutions, and ultimately, adaptive design. This comes at the slight disadvantage of speed and the flexibility of pipes, etc.
> 
> Why Python? I know it isn't as revered or speedy as C or Perl, but it has a very simple syntax and a lot of the 3rd party tools as of late seem to be written in Python. It's also available on all platforms and in some modeling packages such as Rhino 5, Max (Py3dsMax), Blender, etc.
> 
> Ultimately, it could be the engine behind an OpenDX / Grasshopper like GUI for Radiance. I'll leave that up to someone else though.
> 
> So, yeah. Any interest?
> 
> --Dave
> 
> P.S. - I posted here because it's not directly related to the Radiance code, it would be just calling the Radiance programs and scripts. It's possible to loop in C code, but I think keeping it separate and modularized is better practice.
> 
> 
> 
> # Python Radiance
> 
> # Package would be called Radiance
> from Radiance import rpict, obj2rad, HDRImage, RADGeometry, RadianceOptions, ImportOBJGeometry, ViewFile, CompiledGeometry
> 
> ltg_zone1 = RADGeometry("ltg_zone1.rad")
> ltg_zone2 = RADGeometry("ltg_zone2.rad")
> 
> #these would be equivalent
> scene = ImportOBJGeometry("base_geometry.obj")
> scene = RADGeometry(obj2rad("base_geometry.obj"))
> 
> view1 = ViewFile("view1.vf")
> 
> zone1 = CompiledGeometry(scene, ltg_zone1)
> zone2 = CompiledGeometry(scene, ltg_zone2)
> zone1and2 = CompiledGeometry(zone1, ltg_zone2) #add to an existing octree
> 
> opt_hq = RadianceOptions("hq.opt")
> 
> hdr_zone1 = rpict(zone1, ab=3, ad=256, ps=1, vf=view1)
> hdr_zone2 = rpict(zone2, ab=3, ad=256, ps=1, vf=view1)
> hdr_all = rpict(zone1and2, opt_hq, vf=view1)
> 
> from somewhere import specialrpictfunction
> #this could be a function that you write that analyzes over the course of a year or special post processing, etc.
> hdr_special = specialrpictfunction(zone1and2)
> 
> hdr_scene1 = (0.6 * hdr_zone1) + (0.4 * hdr_zone2)
> hdr_scene2 = (0.9 * hdr_zone1)
> hdr_scene3 = (0.2 * hdr_zone1) + (hdr_zone2)
> 
> hdr_scene1.save("img1.hdr")
> hdr_scene2.save("img2.hdr")
> hdr_scene3.save("img3.hdr")
> 
> hdr_all.save("img4.hdr")
> hdr_special.save("img5.hdr")



More information about the Radiance-general mailing list