Use Python to execute Radiance command

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

Can't you just add an ampersand ('&') to the end of your rad command to run it in the background?

-Greg

···

From: Ji Zhang <[email protected]>
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

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 <[email protected]> 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 <[email protected]>

*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
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

Hi Ji,

Yes, the ampersand can be used to send most any program to the background. This is a UNIX thing, not a Radiance thing. You may want to get familiar with the "top" program, so you can check on the status of your background jobs.

You can also have multiple terminal windows open, so you could have your processes running on the foreground and just start up another shell to do other stuff.

The "screen" program can also be useful for popping in and out of processes you have running (http://www.gnu.org/software/screen/).

Rob Guglielmetti IESNA, LEED AP
Commercial Buildings Research Group
National Renewable Energy Laboratory
1617 Cole Blvd MS:RSF202
Golden, CO 80401
T. 303.275.4319
F. 303.630.2055
E. [email protected]

···

On 6/20/11 10:16 AM, "Ji Zhang" <[email protected]<mailto:[email protected]>> 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 <[email protected]<mailto:[email protected]>> 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 <[email protected]<mailto:[email protected]>>

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
[email protected]<mailto:[email protected]>
http://www.radiance-online.org/mailman/listinfo/radiance-general

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 <[email protected]> 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 <[email protected]>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 <[email protected]>

*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
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

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:

- Cheers, Ji

···

On Tue, Jun 21, 2011 at 1:14 AM, Thomas Bleicher <[email protected]>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 <[email protected]> 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 <[email protected]>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 <[email protected]>

*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
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

Hi Ji!

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.

I would advice to spend a week-end on unix useage. It is the base of what can be done on any Linux/BSD/Solaris/Mac OS system these days, and has been for the last 30 years, which is due to its rather generic conceptual nature. Working with processes, inputs and outputs, redirection, filters, is all very useful here and works on all unix-based platforms.

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/

Cool, thank you for sharing the link. Are you also going to use simulation results as input for modeling, such as design optimization? Maybe there will be some work shared on a coming Radiance workshop? Say hello to SDE folks, Shinya is references on the blog, too :slight_smile:

Cheers, Lars.

Hi, Lars, Thanks a lot for your advice!

Yes, Dr Janssen is guiding us in a research project in which we try to
examine the environmental performance (view, daylight, insolation, energy
consumption, etc) of various high density building forms.

Houdini is used as a parametric modeling platform to create 3D models. But
it's strong customizability allows us to define our own toolset to perform
specific types of simulation tasks. Basically, these tools 1) retrieve the
3D model information and pass it to simulation software (e.g. Radiance,
EnergyPlus), 2) activate simulation software and feed in the parameters
required by the software, 3) retrieve the simulation results and bring the
date generated back to the 3D model for visualization and other analysis
purpose. So, Python is like a "glue" in this process that connects
parametric modeling software and simulation software, and Houdini is the
platform where we built tools and control panels to manipulate forms and
simulation processes. Radiance is used to simulate Sky View Factor, Daylight
Factor, and facade insolation. We're still working on key performance
indicators and benchmark values to be used to compare across cases, and
these indicators and benchmark values might be used to drive the design
optimization process.

Actually, Patrick will demo this workflow in a workshop in the upcoming CAAD
Future 2011 conference next month:
http://www.lucid.ulg.ac.be/conferences/caadfutures2011/Workshop3.html

Yes, Lars, I think you nurtured fans here in SDE, e.g. Daniel, who still
talks about your expertise in Radiance quite often. hehe.

- Cheers, Ji

···

On Tue, Jun 21, 2011 at 5:02 AM, Lars O. Grobe <[email protected]> wrote:

Hi Ji!

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.

I would advice to spend a week-end on unix useage. It is the base of what
can be done on any Linux/BSD/Solaris/Mac OS system these days, and has been
for the last 30 years, which is due to its rather generic conceptual nature.
Working with processes, inputs and outputs, redirection, filters, is all
very useful here and works on all unix-based platforms.

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/<http://patrickjanssenstudio.blogspot.com/>

Cool, thank you for sharing the link. Are you also going to use simulation
results as input for modeling, such as design optimization? Maybe there will
be some work shared on a coming Radiance workshop? Say hello to SDE folks,
Shinya is references on the blog, too :slight_smile:

Cheers, Lars.

______________________________**_________________
Radiance-general mailing list
Radiance-general@radiance-**online.org<[email protected]>
http://www.radiance-online.**org/mailman/listinfo/radiance-**general<http://www.radiance-online.org/mailman/listinfo/radiance-general>

Interesting discussion! Would love to see the Houdini2Radiance
pipeline in the workshop, but i don't think i'll be in Liege.
Some time ago i had a strong wish of having a Python wrapper for
Radiance, but i could not find any, and i found the project to
overwhelming to just start myself. Besides that i use Python
merely for everyday scripting with 3d, so skillfully designing
modules is a different cup of tea. Is there any fragment of a
project like that around that i might have missed?

Aksel