Skip to content

Reference

pyradiance

pyradiance is a Python interface for Radiance. It is a collection of Python modules that provide a high level interface to Radiance. It is designed to make Radiance easier to use and accessible to Python user.

BSDF

A BSDF object

components property

Report diffuse and specular components.

info property

Report general information about the BSDF

__init__(path)

Initialize the BSDF object from a file

direct_hemi(theta, phi, sflag)

Get hemispherical integral of BSDF.

Parameters:

Name Type Description Default
theta float

zenith angle (degrees)

required
phi float

azimuth angle (degrees)

required
sflag str

sampling flag (t, ts, td, r, rs, rd, s)

required

Returns:

Type Description
float

hemispherical value

Examples:

>>> import pyradiance as pr
>>> pr.BSDF("bsdf.xml").direct_hemi(0, 0, "t")
0.01

eval(itheta, iphi, otheta, ophi)

Query BSDF for given path.

Parameters:

Name Type Description Default
itheta float

incident zenith angle (degrees)

required
iphi float

incident azimuth angle (degrees)

required
otheta float

outgoing zenith angle (degrees)

required
ophi float

outgoing azimuth angle (degrees)

required

Returns:

Type Description
Tuple[float, float, float]

BSDF color in XYZ

Examples:

>>> import pyradiance as pr
>>> pr.BSDF("bsdf.xml").eval(0, 0, 180, 0)
2.3, 2.3, 2.3

sample(theta, phi, randx, sflag)

Sample BSDF for given direction.

Parameters:

Name Type Description Default
theta float

zenith angle (degrees)

required
phi float

azimuth angle (degrees)

required
randx float

random variable [0-1)

required
sflag str

sampling flag (t, ts, td, r, rs, rd, s)

required

Returns:

Type Description
Tuple[List[float], Tuple[float, float, float]]

Outgoing sample direction and color in XYZ.

Examples:

>>> import pyradiance as pr
>>> pr.BSDF("bsdf.xml").sample(0, 0, 0.5, "r")
[0.0, 0.0, 1.0], (0.1, 0.1, 0.1)

samples(theta, phi, nsamp, sflag)

Generate samples for a given incident direction.

Parameters:

Name Type Description Default
theta float

incident theta angle (degrees)

required
phi float

incident phi angle (degrees)

required
nsamp int

number of samples

required
sflag str

sampling flag {t | ts | td | r | rs | rd | s}

required

Returns:

Type Description
Tuple[List[List[float]], List[Tuple[float, float, float]]]

Outgoing sample directions and colors in XYZ.

Examples:

>>> import pyradiance as pr
>>> pr.BSDF("bsdf.xml").samples(0, 0, 10, "r")
[[0.0, 0.0, 1.0], [0.0, 0.0, 1.0], ...], [(0.1, 0.1, 0.1), (0.1, 0.1, 0.1), ...]

size(theta, phi, qflags='min_max', t2=None, p2=None)

Get resolution (in proj. steradians) for given direction(s)

Parameters:

Name Type Description Default
theta float

zenith angle (degrees)

required
phi float

azimuth angle (degrees)

required
qflags str

query flags (min_max, min, max, avg)

'min_max'
t2 Optional[float]

second zenith angle (degrees)

None
p2 Optional[float]

second azimuth angle (degrees)

None

Returns:

Type Description
Tuple[float, float]

resolution(s) (in proj. steradians)

Examples:

>>> import pyradiance as pr
>>> pr.BSDF("bsdf.xml").size(0, 0)
0.0001, 0.0001

Primitive dataclass

Radiance Primitive.

Attributes one-to-one mapped from Radiance.

Attributes:

Name Type Description
modifier str

modifier, which primitive modifies this one

ptype str

primitive type

identifier str

identifier, name of this primitive

sargs Sequence[str]

string arguments

fargs Sequence[float]

real arguments

RcModifier dataclass

Modifier for rcontrib command.

Attributes:

Name Type Description
modifier Optional[str]

Modifier name, mutually exclusive with modifier_path.

modifier_path Optional[str]

File with modifier names, mutually exclusive with modifier.

calfile Optional[str]

Calc file path.

expression Optional[str]

Variable and function expressions.

nbins Optional[str]

Number of bins, can be expression.

binv Optional[str]

Bin value.

param Optional[str]

Parameter.

xres Optional[int]

X resolution.

yres Optional[int]

Y resolution.

output Optional[str]

Output file.

args()

Return modifier as a list of arguments.

Scene

Radiance Scene.

materials property

Scene materials.

sid: str property

Scene id.

sources property

Scene sources.

surfaces property

Scene surfaces.

__init__(sid)

Parameters:

Name Type Description Default
sid str

scene id

required

add_material(material)

Add material to the scene.

Parameters:

Name Type Description Default
material Union[str, Path, Primitive]

material to be added

required

add_sensor(sensor)

Add sensor to the scene.

Parameters:

Name Type Description Default
sensor Sequence[float]

sensor to be added

required

add_source(source)

Add source to the scene.

Parameters:

Name Type Description Default
source Union[str, Path, Primitive]

source to be added

required

add_surface(surface)

Add surface to the scene.

Parameters:

Name Type Description Default
surface Union[str, Path, Primitive]

surface to be added

required

add_view(view)

Add view to the scene.

Parameters:

Name Type Description Default
view View

view to be added

required

build()

Build an octree, as {sid}.oct in the current directory. Will not build if scene has not changed since last build.

remove_material(material)

Remove material from the scene.

Parameters:

Name Type Description Default
material Union[str, Path, Primitive]

material to be removed

required

remove_source(source)

Remove source from the scene.

Parameters:

Name Type Description Default
source Union[str, Path, Primitive]

source to be removed

required

remove_surface(surface)

Remove surface from the scene.

Parameters:

Name Type Description Default
surface Union[str, Path, Primitive]

surface to be removed

required

View dataclass

Radiance View.

Attributes:

Name Type Description
vtype str

view type

position Tuple[float, float, float]

view position

direction Tuple[float, float, float]

view direction

vup Tuple[float, float, float]

view up

horiz float

horizontal field of view

vert float

vertical field of view

vfore float

view fore

vaft float

view aft

hoff float

horizontal offset

voff float

vertical offset

bsdf2klems(*inp, spp=None, half=False, quater=False, progress_bar=False, progress_bar_length=None, maxlobes=None, forward=False, backward=True, expr=None, file=None)

Generate XML Klems matrix description of a BSDF.

Parameters:

Name Type Description Default
inp

Path to XML file

()
spp Optional[int]

number of samples for each input-output patch pair, default=1024.

None
half bool

Generate instead a half Klems basis XML.

False
quater bool

Generate instead a quater Klems basis XML.

False
progress_bar bool

toggle to show progress bar.

False
progress_bar_length Optional[int]

length of the progress bar, default=79 characters.

None
maxlobes Optional[int]

maximum number of lobes in any interpolated radial basis function (default=15000). Setting the value to 0 turns off this limit.

None
forward bool

generate forward matrix (default=off).

False
backward bool

generate backward matrixi (default=on).

True
expr Optional[str]

expression to evaluate.

None
file Optional[str]

file to write the output to

None

Returns:

Type Description

The output of the command

bsdf2ttree(*inp, isotropic=False, reciprocity_averaging=True, resolution=6, percent_cull=[90], super_samples=256, difference_threshold=0.35, progress_bar=False, progress_bar_length=None, maxlobes=15000, forward=False, backward=True, expr=None, file=None)

Generate XML tensor tree description of a BSDF.

Parameters:

Name Type Description Default
inp

Path to XML file

()
isotropic bool

Generate an isotropic ttree.

False
reciprocity_averaging bool

Use reciprocity averaging.

True
resolution int

resolution of the ttree.

6
percent_cull Sequence[float]

percent of the ttree to cull.

[90]
super_samples int

number of samples for each input-output patch pair, default=1024.

256
difference_threshold float

difference threshold for culling.

0.35
progress_bar bool

toggle to show progress bar.

False
progress_bar_length Optional[int]

length of the progress bar, default=79 characters.

None
maxlobes int

maximum number of lobes in any interpolated radial basis function (default=15000). Setting the value to 0 turns off this limit.

15000
forward bool

generate forward matrix (default=off).

False
backward bool

generate backward matrixi (default=on).

True
expr Optional[str]

expression to evaluate.

None
file Optional[str]

file to write the output to

None

Returns:

Type Description

Tensor tree BSDF XML in bytes

cnt(*dims, shuffled=False)

Index counter.

Parameters:

Name Type Description Default
dims int

list of dimensions

()
shuffled bool

if True, the output will be shuffled

False

Returns:

Name Type Description
bytes bytes

output of cnt

Examples:

>>> cnt(2, 3)
b'0 0\n0 1\n0 2\n1 0\n1 1\n1 2\n'
>>> cnt(2, 3, shuffled=True)
b'1 2\n0 1\n1 0\n0 2\n1 1\n0 0\n'

dctimestep(*mtx, nstep=None, header=True, xres=None, yres=None, inform=None, outform=None, ospec=None)

Call dctimestep to perform matrix multiplication.

Parameters:

Name Type Description Default
mtx

input matrices

()
nstep Optional[int]

number of steps

None
header bool

include header

True
xres Optional[int]

x resolution

None
yres Optional[int]

y resolution

None
inform Optional[str]

input format

None
outform Optional[str]

output format

None
ospec Optional[str]

output specification

None

Returns:

Name Type Description
bytes Optional[bytes]

output of dctimestep

genblinds(mat, name, depth, width, height, nslats, angle, rcurv=None)

Generate a RADIANCE description of venetian blinds.

Parameters:

Name Type Description Default
mat str

Material name

required
name str

Name of the blinds

required
depth float

Depth of the blinds

required
width float

Width of the blinds

required
height float

Height of the blinds

required
nslats int

Number of slats

required
angle float

Angle of the slats

required
rcurv Optional[float]

Radius of curvature of the slats, + for upward curvature, - for downward

None

Returns:

Name Type Description
bytes bytes

RADIANCE description of the blinds

Examples:

>>> genblinds('mat', 'blinds', 0.1, 0.5, 1.0, 4, 45, 0.1)

genbsdf(*inp, nsamp=1, nproc=1, params=None, enforce_window=False, ttree_rank=None, ttree_res=None, color=False, reciprocity=True, recover_dir=None, forward=False, backward=True, mgf=None, geom=False, geom_unit=None, dim=None, **kwargs)

Generate BSDF description from Radiance or MGF input

Examples:

>>> genbsdf('material.mat', 'blinds.rad', nsamp=50, nproc=4)

Parameters:

Name Type Description Default
inp Union[str, Path]

Input files. This can be a list of files or a single string with

()
nsamp int

Number of samples to generate. Default is 1.

1
nproc int

Number of processors to use. Default is 1.

1
params Optional[Sequence[str]]

A list of parameters to pass to genBSDF.

None
enforce_window

Set to True to enforce the window. Default is False.

False
ttree_rank Optional[int]

Tensor tree rank, 3 for isotropic and 4 for anisotropic BSDF.

None
ttree_res Optional[int]

Tensor tree BSDF resolution, e.g., 5 6 7.

None
color bool

Set to True to generate color BSDF. Default is False.

False
reciprocity bool

Set to False to disable reciprocity. Default is True.

True
recover_dir Optional[Union[str, Path]]

Set to a path to recover from a previous run.

None
forward bool

Set to True to generate forward BSDF. Default is False.

False
backward bool

Set to True to generate backward BSDF. Default is True.

True
mgf Optional[Union[str, Path]]

Set to a path to a MGF file to use.

None
geom bool

Set to True to generate geometry BSDF. Default is False.

False
geom_unit Optional[str]

Set to a unit to use for geometry BSDF.

None
dim Optional[Sequence[float]]

Set to a list of 6 numbers to use for geometry BSDF.

None
kwargs

Additional parameters to pass to genBSDF.

{}

Returns:

Name Type Description
str bytes

Output of genBSDF.

gendaylit(dt, latitude, longitude, timezone, year=None, dirnorm=None, diffhor=None, dirhor=None, dirnorm_illum=None, diffhor_illum=None, solar=False, sky_only=False, silent=False, grefl=None, interval=None)

Generates a RADIANCE description of the daylight sources using Perez models for direct and diffuse components.

Parameters:

Name Type Description Default
dt datetime

python datetime object

required
latitude float

latitude in degrees

required
longitude float

longitude in degrees

required
timezone int

standard meridian timezone, e.g., 120 for PST

required
year Optional[int]

Need to set it explicitly, won't use year in datetime object

None
dirnorm Optional[float]

direct normal irradiance

None
diffhor Optional[float]

diffuse horizontal irradiance

None
dirhor Optional[float]

direct horizontal irradiance, either this or dirnorm

None
dirnormp

direct normal illuminance

required
diffhorp

diffuse horizontal illuminance

required
solar bool

if True, include solar position

False

Returns:

Name Type Description
str bytes

output of gendaylit

gendaymtx(weather_data, verbose=False, header=True, average=False, sun_only=False, sky_only=False, sun_file=None, sun_mods=None, daylight_hours_only=False, dryrun=False, sky_color=None, ground_color=None, rotate=None, outform=None, onesun=False, solar_radiance=False, mfactor=1)

Generate an annual Perez sky matrix from a weather tape.

Parameters:

Name Type Description Default
weather_data Union[str, Path, bytes]

weather data

required
mfactor int

multiplication factor

1
verbose bool

verbose

False
header bool

header

True
average bool

average

False
sun_only bool

sun only

False
sky_only bool

sky only

False
sun_file Optional[str]

sun file

None
sun_mods Optional[str]

sun mods

None
daylight_hours_only bool

daylight hours only

False
dryrun bool

dryrun

False
sky_color Optional[List[float]]

sky color

None
ground_color Optional[List[float]]

ground color

None
rotate Optional[float]

rotate

None
outform Optional[str]

outform

None
onesun bool

onesun

False
solar_radiance bool

solar radiance

False

Returns:

Name Type Description
bytes

output of gendaymtx

gensky(dt=None, latitude=None, longitude=None, timezone=None, altitude=None, azimuth=None, year=None, sunny_with_sun=False, sunny_without_sun=False, cloudy=False, intermediate_with_sun=False, intermediate_without_sun=False, uniform=False, ground_reflectance=None, zenith_brightness=None, horizontal_brightness=None, solar_radiance=None, horizontal_direct_irradiance=None, turbidity=None)

Generate a RADIANCE description of the sky.

Parameters:

Name Type Description Default
dt Optional[datetime]

datetime object, mutally exclusive with altitude and azimuth

None
latitude Optional[float]

latitude, only apply if dt is not None

None
longitude Optional[float]

longitude, only apply if dt is not None

None
timezone Optional[int]

timezone, only apply if dt is not None

None
altitude Optional[float]

solar altitude, mutally exclusive with dt

None
azimuth Optional[float]

solar azimuth, mutally exclusive with dt

None
year Optional[int]

year, only apply if dt is not None

None
sunny_with_sun bool

sunny with sun

False
sunny_without_sun bool

sunny without sun

False
cloudy bool

CIE overcast sky

False
intermediate_with_sun bool

intermediate with sun

False
intermediate_without_sun bool

intermediate without sun

False
uniform bool

uniform sky

False
ground_reflectance Optional[float]

ground reflectance

None
zenith_brightness Optional[float]

zenith brightness in watts/steradian/meter^2

None
horizontal_brightness Optional[float]

horizontal brightness in watts/metere^2

None
solar_radiance Optional[float]

solar radiance in watts/steradian/meter^2

None
horizontal_direct_irradiance Optional[float]

horizontal direct irradiance in watts/meter^2

None
turbidity Optional[float]

turbidity factor

None

Returns:

Name Type Description
str bytes

output of gensky

get_header(inp, dimension=False)

Get header information from a Radiance file.

Parameters:

Name Type Description Default
inp

input file or bytes

required

Returns:

Name Type Description
bytes bytes

header

get_image_dimensions(image)

Get the dimensions of an image.

Parameters:

Name Type Description Default
image Union[str, Path, bytes]

image file or bytes

required

Returns:

Type Description
Tuple[int, int]

Tuple[int, int]: width and height

get_view_resolu(path)

Get view and resolu from a view or hdr file

Parameters:

Name Type Description Default
path

Path to view or hdr file

required

Returns:

Type Description
Tuple[View, Resolu]

A tuple of View and Resolu

Examples:

>>> import pyradiance as pr
>>> pr.get_view_resolu("view.vf")

getinfo(*inputs, dimension_only=False, dimension=False, strip_header=False, replace='', append='', command='')

Get header information from a Radiance file.

Parameters:

Name Type Description Default
inputs Union[str, Path, bytes]

input file or bytes

()
dimension_only bool

return only the dimension

False
dimension bool

return the dimension

False
strip_header bool

strip header from the output

False
replace str

replace the header with this string

''
append str

append this string to the header

''
command str

command to use to get the header

''

Returns:

Type Description
bytes

getinfo output

ies2rad(*inp, libdir=None, prefdir=None, outname=None, stdout=False, units=None, radius=None, instancing_geometry=False, lampdat=None, lamp_type=None, lamp_color=None, set_default_lamp_color=None, multiply_factor=None)

Convert IES luminaire data to RADIANCE description.

Parameters:

Name Type Description Default
inp Union[str, Path]

Path to IES file

()
libdir Optional[str]

Path to directory where the library files are located.

None
outname Optional[str]

Output file name root.

None
stdout bool

Print the output to stdout.

False
units Optional[str]

Set the units of the output file.

None
rad

ignore the crude geometry given by the IES input file and use instead an illum sphere with radius rad.

required
instancing_geometry bool

compile MGF detail geometry into a separate octree and create a single instance referencing it.

False
lampdat Optional[str]

map lamp name to xy chromaticity and lumen depreciation data.

None
lamp_type Optional[str]

lamp type.

None
lamp_color Optional[str]

set lamp color to red green blue if lamp type is unknown.

None
set_default_lamp_color Optional[str]

set default lamp color according to the entry for lamp in the lookup table.

None
multiply_factor Optional[float]

multiply all output quantities by this factor. This is the best way to scale fixture brightness for different lamps.

None

Returns:

Type Description

The output of the command

load_views(file)

Load views from a file. One view per line.

Parameters:

Name Type Description Default
file Union[str, Path]

A file path to a view file.

required

Returns:

Type Description
List[View]

A view object.

mgf2rad(*inp, matfile=None, mult=None, dist=None)

Convert Materials and Geometry Format file to RADIANCE description.

Parameters:

Name Type Description Default
inp

Path to MGF file

()
matfile

Path to material file where the translated materials will be written.

None
mult

multiplier for all the emission values

None
dist

glow distance (in meters) for all emitting surfaces.

None

Returns:

Type Description

The output of the command

mkillum(inp, octree, nproc=1, params=None)

Compute illum sources for a RADIANCE scene

Parameters:

Name Type Description Default
inp bytes

input file content as bytes

required
octree Union[str, Path]

octree file

required
nproc int

number of processes

1
params Optional[Sequence[str]]

additional parameters

None

Returns:

Type Description
bytes

Output of mkillum in bytes

mkpmap(octree, global_map=None, caustic_map=None, volume_map=None, direct_map=None, contrib_map=None, pre_global_map=None, predistrib=None, rect_region=None, sphere_region=None, maxbounce=None, maxprepass=None, port_mod=None, port_modfile=None, precomp=None, seed=None, virtual_mod=None, virtual_modfile=None, amb_excl_mod=None, amb_excl_modfile=None, amb_incl_mod=None, amb_incl_modfile=None, backface_vis=False, sample_res=None, partition_size=None, progress_file=None, overwrite=False, maxdist=None, scattering_albedo=None, extinction_coefficient=None, scattering_eccentricity=None, nproc=1, progress_interval=None)

Mkpmap takes a RADIANCE scene description as an octree and performs Monte Carlo forward path tracing from the light sources, depositing indirect ray hitpoints along with their energy (flux) as "photons". The resulting localised energy distribution represents a global illumination solution which is written to a file for subsequent evaluation by rpict(1), rtrace(1) and rvu(1) in a backward raytracing pass. The photon map(s) can be reused for multiple viewpoints and sensor locations as long as the geometry remains unchanged.

Parameters:

Name Type Description Default
octree Union[Path, str]

Octree file path.

required
global_map Optional[Tuple[Union[Path, str], int]]

Global map file path and number of photons.

None
caustic_map Optional[Tuple[Union[Path, str], int]]

Caustic map file path and number of photons.

None
volume_map Optional[Tuple[Union[Path, str], int]]

Volume map file path and number of photons.

None
direct_map Optional[Tuple[Union[Path, str], int]]

Direct map file path and number of photons.

None
contrib_map Optional[Tuple[Union[Path, str], int]]

Contribution map file path and number of photons.

None
pre_global_map Optional[Tuple[Union[Path, str], int, float]]

Precomputed global map file path, number of photons and bandwidth.

None
predistrib Optional[float]

Photon predistribution factor.

None
rect_region Tuple[float, float, float, float, float, float]

Rectangular region

None
sphere_region Tuple[float, float, float, float]

Spherical region

None
maxbounce Optional[int]

Maximum number of bounces.

None
maxprepass Optional[int]

Maximum number of iteratiosn of distributoin prepass before terminating.

None
port_mod Optional[Sequence[str]]

Specifies a modifier to act as a photon port.

None
port_modfile Optional[str]

File with modifiers to act as photon ports.

None
precomp Optional[float]

Fraction of global photons to precompute.

None
seed Optional[int]

Random seed.

None
virtual_mod Optional[Sequence[str]]

Specifies a modifier to act as a virtual source.

None
virtual_modfile Optional[str]

File with modifiers to act as virtual sources.

None
amb_excl_mod Optional[str]

Specifies a modifier to exclude from ambient calculation.

None
amb_excl_modfile Optional[str]

File with modifiers to exclude from ambient calculation.

None
amb_incl_mod Optional[str]

Specifies a modifier to include in ambient calculation.

None
amb_incl_modfile Optional[str]

File with modifiers to include in ambient calculation.

None
backface_vis bool

Backface visibility.

False
sample_res Optional[int]

Sample resolution.

None

obj2rad(inp, quallist=False, flatten=False, mapfile=None, objname=None)

Convert Wavefront .OBJ file to RADIANCE description.

Parameters:

Name Type Description Default
inp Union[bytes, str, Path]

Path to OBJ file

required
quallist bool

Produce a list of qualifiers from which to construct a mapping for the given .OBJ file.

False
flatten bool

Flatten all faces, effectively ignoring vertex normal information.

False
mapfile Optional[str]

Mapping rules files for assigning material names for the surfaces.

None
objname Optional[str]

Specify the name of this object, though it will be overriden by any "o" statements in the input file. If this option is absent, and there are no "o" statements, obj2rad will attempt to name surfaces based on their group associations.

None

Returns:

Type Description
bytes

The converted RADIANCE scene description in bytes

oconv(*paths, warning=True, stdin=None, frozen=False, octree=None)

Run Radiance oconv tool to build an octree.

Parameters:

Name Type Description Default
paths

list of Radiance files

()
warning

if False, warnings will be suppressed

True
stdin

if not None, stdin will be used

None
frozen bool

if True, the octree will be frozen

False
octree

if provided, the resulting octree incorporate existing one

None

Returns:

Name Type Description
bytes bytes

output of oconv

pabopto2bsdf(*inp, nproc=1, symmetry=None, angle=None, reverse=False)

Convert BSDF measurements to a scattering interpolant representation.

Parameters:

Name Type Description Default
inp

pab-opto Mountain files, need two or more.

()
nproc int

number of processors to use.

1
symmetry Optional[str]

BSDF symmetry, which is one of "isotropic", "quadrilateral", "bilateral", "up", or "anisotropic". Any of these may be abbreviated with as little as a single letter, and case is ignored.

None
angle Optional[Union[float, str]]

cull scattered measurements that are nearer to grazing than the given angle in degrees. If the word "auto" (which can be abbreviated as 'a' or 'A') is given instead of an angle, then the near-grazing angle will be determined by the lowest incident angle measurement present in the input data. This is sometimes necessary to eliminate noise and edge effects that some measurements exhibit near grazing.

None
reverse

reverses the assumed sample orientation front-to-back, and is discussed below under the "#intheta" header entry.

False

Returns:

Type Description
bytes

SIR data in bytes

parse_primitive(pstr)

Parse Radiance primitives inside a file path into a list of dictionary.

Parameters:

Name Type Description Default
pstr str

A string of Radiance primitives.

required

Returns:

Type Description
List[Primitive]

list of primitives

pcond(hdr, human=False, acuity=False, veiling=False, sense=False, closs=False, center_weighted=False, linear=False, fixfrac=0.0, fixpoints=None, histo='', expval='', ldmax=100.0, lddyn=100.0, primaries=None, macbeth='', mapfile='')

Condition a Radiance picture.

Parameters:

Name Type Description Default
hdr Path

input hdr

required
human bool

Mimic human visual response. This is the same as turning on all acuity, veiling, sensitivity, and color loss.

False
acuity bool

Defocus darker region.

False
veiling bool

Add veiling glare.

False
sense bool

Use human contrast sensitivity, simulating eye internal scattering.

False
center_weighted bool

Use center-weighted average for acuity and veiling.

False
linear bool

Use a linear reponse function instead of the standard dynamic range compression. This preseves the extremas.

False
fixfrac float

Fixation fraction for acuity and veiling.

0.0
histo str

Histogram file for acuity and veiling.

''
expval str

Exposure value for acuity and veiling.

''
ldmax float

Maximum luminance for acuity and veiling.

100.0
lddyn float

Luminance dynamic range for acuity and veiling.

100.0
primaries Optional[List[float]]

Color primaries for color loss.

None
macbeth str

Macbeth chart file for color loss.

''
mapfile str

Color map file for color loss.

''

Returns:

Name Type Description
bytes bytes

output of pcond

pfilt(image, xres=None, yres=None, pixel_aspect=0, pa_correct=False, exposure=0, lamp=None, lampdat=None, one_pass=False, gaussian_filter_radius=None, limitfrac=None, hot_threshold=100, star_points=0, star_spread=0.0001, average_hot=False)

filter a Radiance picture. By default, it uses two passes on the input, using a box filter.

Parameters:

Name Type Description Default
image Union[str, Path, bytes]

input image

required
xres Optional[str]

horizontal resolution

None
yres Optional[str]

vertical resolution

None
pixel_aspect float

pixel aspect ratio

0
exposure Optional[float]

exposure value

0
lamp Optional[str]

lamp file

None
lampdat Optional[str]

lamp data file

None
one_pass bool

use one pass filter

False
gaussian_filter_radius Optional[float]

gaussian filter radius

None
limitfrac Optional[float]

limit fraction

None
hot_threshold float

Set intensity considered 'hot', default 100 watts/sr/m2

100
star_points int

Number of points on a start pattern.

0
star_spread float

star pattern spread

0.0001
average_hot bool

average hot spots

False

Returns:

Name Type Description
bytes bytes

output of pfilt

pkgbsdf(*xml, frozen=False, stdout=False)

Pacakge BSDFs provided as XML for Radiance.

Parameters:

Name Type Description Default
xml Union[str, Path]

Path to XML files

()
frozen bool

produce frozen octree instance for any detail geometry.

False
stdout bool

print the output to stdout, only works for a single XML input.

False

Returns:

Type Description
Optional[bytes]

The output of the command

pvalue(pic, unique=False, original=False, header=True, resstr=True, skip=0, exposure=0, gamma=1.0, dataonly=False, outform='', reverse_rgb=False, interleaving=True, brightness=False, outprimary=None)

convert RADIANCE picture to/from alternate formats Pvalue converts the pixels of a RADIANCE picture to or from another format. In the default mode, pixels are sent to the standard output, one per line, in the following ascii format: xpos ypos red green blue

Parameters:

Name Type Description Default
pic Union[Path, str, bytes]

hdr file path. Either path or stdin is used, path takes precedence.

required
unique bool

if True, only unique values will be returned

False
original bool

if True, print original values, before exposure compensation

False
header bool

if True, header will be returned

True
resstr bool

if True, resolution string will be returned

True
skip int

number of bytes to skip

0
exposure int

exposure value

0
gamma float

gamma value

1.0
dataonly bool

if True, only data will be returned

False
outform str

output data format

''
reverse_rgb bool

if True, RGB values will be reversed

False
interleaving bool

if True, interleaving will be used

True
brightness bool

if True, only brightness will be returned

False
outprimary Optional[str]

output color primaries

None

Returns:

Name Type Description
bytes bytes

output of pvalue

pvaluer(pic, xres=None, yres=None, inform='a', resstr=True, dataonly=False, header=False, primaries=None, pxyz=False)

Run Radiance pvalue tools reverse mode: constructing a image from pixel values.

Parameters:

Name Type Description Default
pic Union[Path, str, bytes]

Path or bytes of the input pixel data.

required
xres Optional[int]

X resolution.

None
yres Optional[int]

Y resolution.

None
inform str

input data format. Default is "a" for ascii.

'a'
header bool

Set to True if the picture file has a header. Default is False.

False
primaries Optional[List[float]]

List of primaries for XYZ calculation. Default is None.

None
pxyz bool

Set to True to calculate XYZ values. Default is False.

False

Returns:

Type Description
bytes

Bytes of the pvalue output

rcode_depth(inp, ref_depth='1.0', inheader=True, outheader=True, inresolution=True, outresolution=True, xres=None, yres=None, inform='a', outform='a', decode=False, compute_intersection=False, per_point=False, depth_file=None, flush=False)

Encode/decode 16-bit depth map.

Parameters:

Name Type Description Default
inp Union[str, Path, bytes]

input file or bytes

required
ref_depth str

reference distance, can be follow by /unit.

'1.0'
inheader bool

Set to False to not expect header on input

True
outheader bool

Set to False to not include header on output

True
inresolution bool

Set to False to not expect resolution on input

True
outresolution bool

Set to False to not include resolution on output

True
xres Optional[int]

x resolution

None
yres Optional[int]

y resolution

None
inform str

input format

'a'
outform str

output format when decoding

'a'
decode bool

Set to True to decode instead

False
compute_intersection bool

Set to True to compute intersection instead

False
per_point bool

Set to True to compute per point instead of per pixel

False
depth_file Optional[str]

depth file

None
flush bool

Set to True to flush output

False

Returns:

Name Type Description
bytes bytes

output of rcode_depth

rcode_ident(inp, index_size=16, sep='\n', decode=False, header=True, xres=None, yres=None, resstr=True, identifiers=False, indexes=False, per_point=False, flush=False)

Store identifiers in an indexed map and retrieve from same

Parameters:

Name Type Description Default
inp Union[str, Path, bytes]

input file or bytes

required
index_size int

index size

16
sep str

separator

'\n'
decode bool

Set to True to decode instead

False
header bool

Set to False to not to expect header on input; or not to include header on output when decoding

True
xres Optional[int]

x resolution

None
yres Optional[int]

y resolution

None
resstr bool

Set to False to not include resolution string on output

True
identifiers bool

Set to True to include identifiers on output

False
indexes bool

Set to True to instead list identifiers indexes on output

False
per_point bool

Set to True to compute per point instead of per pixel

False
flush bool

Set to True to flush output after each identifier

False

Returns:

Name Type Description
bytes bytes

output of rcode_ident

rcode_norm(inp, inheader=True, outheader=True, inresolution=True, outresolution=True, xres=None, yres=None, inform='a', outform='a', decode=False, per_point=False, norm_file=None, flush=False)

Encode/decode 32-bit surface normal map.

Parameters:

Name Type Description Default
inp

input file or bytes

required
inheader bool

Set to False to not expect header on input

True
outheader bool

Set to False to not include header on output

True
inresolution bool

Set to False to not expect resolution on input

True
outresolution bool

Set to False to not include resolution on output

True
xres Optional[int]

x resolution

None
yres Optional[int]

y resolution

None
inform str

input format

'a'
outform str

output format when decoding

'a'
decode bool

Set to True to decode instead

False
per_point bool

Set to True to compute per point instead of per pixel

False
flush bool

Set to True to flush output

False

Returns:

Name Type Description
bytes bytes

output of rcode_norm

rcontrib(inp, octree, modifiers, nproc=1, yres=None, inform=None, outform=None, report=0, params=None)

Run rcontrib command.

Parameters:

Name Type Description Default
inp bytes

A bytes object.

required
octree Union[Path, str]

A path to octree file.

required
modifiers Sequence[RcModifier]

A list of RcModifier objects.

required
nproc int

Number of processes.

1
yres Optional[int]

Y resolution.

None
inform Optional[str]

Input format.

None
outform Optional[str]

Output format.

None
params Optional[Sequence[str]]

A list of additional parameters.

None

Returns:

Type Description
bytes

A bytes object.

read_rad(*paths)

Read Radiance files and return a list of Primitives. Files order matters.

Parameters:

Name Type Description Default
paths str

A list of paths to Radiance files.

()

Returns:

Type Description

A list of Primitives.

Examples:

>>> import pyradiance as pr
>>> pr.read_rad("scene.rad")

render(scene, view=None, quality='Medium', variability='Medium', detail='Medium', nproc=1, resolution=None, ambbounce=None, ambcache=True, params=None)

Render a scene.

Parameters:

Name Type Description Default
scene

Scene object.

required
quality str

Quality level.

'Medium'
variability str

Variability level.

'Medium'
detail str

Detail level.

'Medium'
nproc int

Number of processes to use.

1
ambbounce Optional[int]

Number of ambient bounces.

None
ambcache bool

Use ambient cache.

True
params Optional[SamplingParameters]

Sampling parameters.

None

Returns:

Type Description
bytes

tuple[bytes, int, int]: output of render, width, height

rfluxmtx(receiver, surface=None, rays=None, params=None, octree=None, scene=None)

Run rfluxmtx command.

Parameters:

Name Type Description Default
scene Optional[Sequence[Union[Path, str]]]

A Scene object.

None
sender

A Sender.

required
receiver Union[str, Path]

A Radiance SensorGrid.

required
option

Radiance parameters for rfluxmtx command as a list of strings.

required

Sender: stdin, polygon Receiver: surface with -o

rlam(*inputs)

Laminate records from multiple files.

Parameters:

Name Type Description Default
inputs

list of input files or bytes. There can

()

Returns:

Name Type Description
bytes bytes

output of rlam

rmtxop(inp, outform='a', transpose=False, scale=None, transform=None, reflectance=None)

Run rmtxop command.

robjutil(inp, radout=False, verbose=False, remove_texture_coordinates=False, remove_surface_normal=False, remove_surface_by_modifier=None, keep_surface_by_modifier=None, remove_surface_by_group=None, keep_surface_by_group=None, epsilon=None, triangulate=False, transform=None)

Operate on Wavefront .OBJ file

Parameters:

Name Type Description Default
inp Union[str, Path]

Input .OBJ file path

required
radout bool

Output RADIANCE scene description

False
verbose bool

Set to True to turn on verbosity

False
remove_texture_coordinates bool

Remove texture coordinates from the output

False
remove_surface_normal bool

Remove surface normal from the output

False
remove_surface_by_modifier Optional[Sequence[str]]

Remove surfaces by modifier, mutually exclusive with keep_surface_by_modifier

None
keep_surface_by_modifier Optional[Sequence[str]]

Keep surfaces by modifier, mutually exclusive with remove_surface_by_modifier

None
remove_surface_by_group Optional[Sequence[str]]

Remove surfaces by group/object, mutually exclusive with keep_surface_by_group

None
keep_surface_by_group Optional[Sequence[str]]

Keep surfaces by group/object, mutually exclusive with remove_surface_by_group

None
epsilon Optional[float]

Coalesce vertices that are within the given epsilon

None
triangulate bool

Turns all faces with 4 or more sides into triangles

False
transform Optional[str]

Transform the input, using xform CLI syntax.

None

Returns:

Type Description
bytes

The output of the command

rpict(view, octree, xres=None, yres=None, report=0, report_file=None, params=None)

Get rpict command.

Parameters:

Name Type Description Default
view Sequence[str]

A list of view parameters in strings.

required
octree Union[Path, str]

A path to octree file.

required
xres Optional[int]

X resolution.

None
yres Optional[int]

Y resolution.

None
report float

Report.

0
report_file Optional[Path]

Report file.

None
params Optional[Sequence[str]]

A list of additional parameters.

None

Returns:

Type Description
bytes

A bytes object.

rsensor(sensor, sensor_view=None, direct_ray=None, ray_count=None, octree=None, nproc=1, params=None)

Compute sensor signal from a RADIANCE scene

Parameters:

Name Type Description Default
sensor Sequence[Union[str, Path]]

Sensor file

required
sensor_view Optional[Sequence[Union[str, Path]]]

Sensor view file

None
direct_ray Optional[Sequence[int]]

The number of rays sent to each light source per sensor

None
ray_count Optional[Sequence[int]]

The number of ray samples sent at random

None
octree Optional[Union[str, Path]]

Octree file

None
nproc int

Number of processors to use

1
params Optional[Sequence[str]]

Additional parameters for rsensor command

None

Returns:

Type Description
bytes

Output of rsensor command

rtpict(view, octree, nproc=1, outform=None, outdir=None, ref_depth=None, xres=None, yres=None, params=None)

Run rtpict command.

Parameters:

Name Type Description Default
view View

A View object.

required
octree Union[str, Path]

Path to octree file.

required
nproc int

Number of processors to use.

1
outform Optional[str]

Output format. Default is "i".

None
outdir Optional[str]

Output directory. Default is current directory.

None
ref_depth Optional[str]

Maximum number of reflections. Default is 5.

None
xres Optional[int]

Horizontal resolution. Default is 512.

None
yres Optional[int]

Vertical resolution. Default is 512.

None
params Optional[Sequence[str]]

Radiance parameters for rtpict command as a list of strings.

None

Returns:

Type Description
Optional[bytes]

Rendered image as output or None if output to directory

rtrace(rays, octree, header=True, inform='a', outform='a', irradiance=False, irradiance_lambertian=False, outspec=None, trace_exclude='', trace_include='', trace_exclude_file=None, trace_include_file=None, uncorrelated=False, xres=None, yres=None, nproc=None, params=None, report=False, version=False)

Run rtrace.

Parameters:

Name Type Description Default
rays bytes

A string of bytes representing the input rays.

required
octree Union[Path, str]

Path to octree file.

required
header bool

A boolean to indicate if the header should be included in the output.

True
inform str

Input format. Default is 'a'.

'a'
outform str

Output format. Default is 'a'.

'a'
irradiance bool

A boolean to indicate if irradiance should be calculated.

False
irradiance_lambertian bool

A boolean to indicate if irradiance should be calculated using Lambertian assumption.

False
outspec Optional[str]

Output specification. Default is None.

None
trace_exclude str

A string of space separated material names to exclude from the trace.

''
trace_include str

A string of space separated material names to include in the trace.

''
trace_exclude_file Optional[Union[str, Path]]

Path to a file containing material names to exclude from the trace.

None
trace_include_file Optional[Union[str, Path]]

Path to a file containing material names to include in the trace.

None
uncorrelated bool

A boolean to indicate if uncorrelated sampling should be used.

False
xres Optional[int]

X resolution of the output image.

None
yres Optional[int]

Y resolution of the output image.

None
nproc Optional[int]

Number of processors to use.

None
options

A SamplingParameters object.

required

Returns:

Type Description
bytes

A string of bytes representing the output of rtrace.

vwrays(pixpos=None, unbuf=False, outform='a', ray_count=1, pixel_jitter=0, pixel_diameter=0, pixel_aspect=1, xres=512, yres=512, dimensions=False, view=None, pic=None, zbuf=None)

vwrays.

wrapbsdf(inp=None, enforce_window=False, comment=None, correct_solid_angle=False, basis=None, tf=None, tb=None, rf=None, rb=None, spectr=None, unlink=False, unit=None, geometry=None, **kwargs)

Wrap BSDF.

Parameters:

Name Type Description Default
inp

Input file. Default is stdin.

None
enforce_window

Enforce window convention. Default is False.

False
comment Optional[str]

Comment. Default is None.

None
correct_solid_angle

Correct solid angle. Default is False.

False
basis Optional[str]

Basis. Default is None.

None
tf Optional[Union[str, Path]]

Front transmittance. Default is None.

None
tb Optional[Union[str, Path]]

Back transmittance. Default is None.

None
rf Optional[Union[str, Path]]

Front reflectance. Default is None.

None
rb Optional[Union[str, Path]]

Back reflectance. Default is None.

None
spectr Optional[str]

Spectral data. Default is None.

None
unlink bool

Unlink. Default is False.

False
unit

Unit. Default is None.

None
geometry

Geometry. Default is None.

None
**kwargs

Additional arguments for Window tags such as n, m, t...

{}

Returns:

Type Description
bytes

Wrapped BSDF.

xform(inp, translate=None, expand_cmd=True, iprefix=None, modifier=None, invert=False, rotatex=None, rotatey=None, rotatez=None, scale=None, mirrorx=False, mirrory=False, mirrorz=False)

Transform a RADIANCE scene description

Notes

Iterate and arrays are not supported.

Parameters:

Name Type Description Default
inp

Input file or string

required
translate Optional[Tuple[float, float, float]]

Translation vector

None
expand_cmd bool

Set to True to expand command

True
iprefix Optional[str]

Prefix identifier

None
mprefix

Set surface modifier to this name

required
invert bool

Invert surface normal

False
rotatex Optional[float]

Rotate the scene degrees about the x axis. A positive rotation corresponds to

None
rotatey Optional[float]

Rotate the scene degrees about the y axis.

None
rotatez Optional[float]

Rotate the scene degrees about the z axis.

None
scale Optional[float]

Scale the scene by this factor

None
mirrorx bool

Mirror the scene about the yz plane.

False
mirrory bool

Mirror the scene about the xz plane.

False
mirrorz bool

Mirror the scene about the xy plane.

False

Returns:

Type Description
bytes

The transformed scene description in bytes