[Radiance-general] Use Python to execute Radiance command

Ji Zhang hope.zh at gmail.com
Mon Jun 20 10:47:01 PDT 2011


Dear Thomas and Robert,

Thank you very much for your prompt advice! Seems I need to bear in mind
that Radiance is developed in UNIX environment initially and a lot of UNIX
conventions can be utilized.

As to Thomas comments on Python wrapper library for Radiance, I think my
colleague Dr Patrick Janssen is exploring on that direction by testing it on
a procedure modeling software platform called Houdini (www.sidefx.com).

Actually, most of the questions I post here were derived in the learning
process of connecting Houdini and Radiance (as well as other building
performance simulation software) via the Python interface built into
Houdini.

Some of the work-in-progress can be found in Dr Janssen's teaching website:
http://patrickjanssenstudio.blogspot.com/

- Cheers, Ji



On Tue, Jun 21, 2011 at 1:14 AM, Thomas Bleicher
<tbleicher at googlemail.com>wrote:

> Ji
>
> The "&" is a standard Unix shell control character and as such can be
> applied to any process, not only those related to Radiance.
>
> Sometimes it is tricky to find the right place for it, though, especially
> if you have multiple redirections in your command line. You should always
> test your commands manually before you use them in a Python "os.system()"
> call.
>
> Note 1: If you use the return value of the os.system() call to check if the
> command was successful you will get a "0" (=success) if the command with "&"
> was started successfully, not if it actually run without errors.
>
> Note 2: "os.system()" was replaced by "Popen()" in the "subprocess" module.
>
> Note 3: If you use your Python script only to automate a simple sequence of
> tasks you should be fine with using rad directly in the script. For more
> control over the processes and their success/failure you should use the
> underlying programs "oconv", "rpict", "pfilt" etc. directly. Unfortunately
> the project to write a nice little Python wrapper library for Radiance
> didn't really get of the ground ...
>
> Regards,
> Thomas
>
>
> On Mon, Jun 20, 2011 at 11:16 AM, Ji Zhang <hope.zh at gmail.com> wrote:
>
>> Thank you very much for your advice, Greg! It works.
>>
>> May I ask whether specifying the '&' option for rad command to make it run
>> in background can be applied in similar way to other Radiance command such
>> as rpict, rtrace, etc to make them run in background as well?
>>
>> Thanks again!
>>
>> - Cheers, Ji
>>
>>
>> On Mon, Jun 20, 2011 at 12:58 AM, Greg Ward <gregoryjward at gmail.com>wrote:
>>
>>> Can't you just add an ampersand ('&') to the end of your rad command to
>>> run it in the background?
>>>
>>> -Greg
>>>
>>> *From: *Ji Zhang <hope.zh at gmail.com>
>>>
>>> *Date: *June 19, 2011 5:48:30 AM PDT
>>>
>>> *
>>> *
>>>
>>> Dear Radiance experts,
>>>
>>> Suppose you want to use Python to call rad command and render an image
>>> using the following script:
>>>
>>> ################################
>>> import os
>>> rad_command = "rad -e -v vw1 /test.rif"
>>> os.system(rad_command)
>>> ################################
>>>
>>> Python will hang there until the rad command running in background is
>>> finished. During this period, you can do nothing in the Python Shell...
>>>
>>> So, is there a way to use Python to call the Terminal and "paste" the rad
>>> command string into the Terminal and then run rad? In this way, Python is
>>> freed from the rad rendering process once it's be activated in the Terminal.
>>>
>>>
>>> Appreciate your advices!
>>>
>>> (using Mac OS 10.6.7, Radiance 4, and Python 2.6.5)
>>>
>>> Ji
>>>
>>>
>>> _______________________________________________
>>> Radiance-general mailing list
>>> Radiance-general at radiance-online.org
>>> http://www.radiance-online.org/mailman/listinfo/radiance-general
>>>
>>>
>>
>> _______________________________________________
>> Radiance-general mailing list
>> Radiance-general at radiance-online.org
>> http://www.radiance-online.org/mailman/listinfo/radiance-general
>>
>>
>
> _______________________________________________
> Radiance-general mailing list
> Radiance-general at radiance-online.org
> http://www.radiance-online.org/mailman/listinfo/radiance-general
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.radiance-online.org/pipermail/radiance-general/attachments/20110621/577a611f/attachment.html>


More information about the Radiance-general mailing list