Python + RADIANCE = pyradiance

We are happy to release pyradiance to testing within the Radiance community!

Pyradiance is a python wrapper of RADIANCE tools. It mimics closely the RADIANCE CLI and presents an alternative approach of using Radiance is Python. Here is a complete list of supported RADIANCE tools.


Pyradiance comes with all the necessary RADIANCE binary and library files, meaning you don’t have to install RADIANCE separately. We hope this would alleviate the new user pain of installing RADIANCE. Pyradiance can be installed with pip through PyPI. All major platforms are supported, including macOS arm64.

pip install pyradiance


Here is a demo use of building a Scene and calling the render() function, and how the workflow can be integrated with other Python libraries such as numpy and matplotlib. Here is a more complete quickstart tutorial.

import pyradiance as pr
import numpy as np
import matplotlib.pyplot as plt

scene = pr.Scene("office1")
image = pr.render(scene)
nparray = np.frombuffer(pr.pvalue(image, outform='f', header=False, resstr=False), dtype=np.single).reshape(512, 512, 3)

Calling oconv and rtrace is still rather straightforward:

octree = pr.oconv("materials.mat", "floor.rad", "ceiling.rad")
with open("office.oct", "wb") as wtr:
pr.rtrace(b"1 1 1 0 0 1", "office.oct", header=False, params=["-I", "-ab", "1"])

Calling RADIANCE C-functions

The majority of tasks can be completed by calling RADIANCE command line tools (e.g., oconv and rpict) directly, but we can also expose Radiance C-functions to Python. Currently, you can access two Radiance C-functions through pyradiance one is called read_rad, which calls readobj() function in object.h. It parses Radiance scene files and returns a list of Primitive.

primitives = pr.read_rad("materials.mat", "floor.rad", "walls.rad")

The other is called get_view_resolu, which calls Radiance viewfile() function. This function returns the parsed view and image resolution from a .hdr or a .vf file.

view, res = pr.get_view_resolu("test.hdr")

We can expose more functions based on requests.

We very much appreciate any feedbacks regarding how to improve pyradiance to make it useful for your situations.


That’s awsome, thanks Taoning!
Looking forward to testing it…


Agreed, this looks awesome, Taoning!