### Install Pyradiance via pip Source: https://lbnl-eta.github.io/pyradiance Installs Pyradiance and its bundled Radiance binaries and libraries, setting up the PATH environment. Does not interfere with an existing RADIANCE installation. ```bash pip install pyradiance ``` -------------------------------- ### Complete example: separating window contributions Source: https://lbnl-eta.github.io/pyradiance/howtos/guide3 Computes contributions of two window groups to a grid of floor sensors. Builds sensor rays, runs rcontrib for both modifiers, parses ASCII output into a numpy array, and computes luminance using standard RGB coefficients. ```python import pyradiance as pr import numpy as np # Build the sensor ray list: 5×5 grid on the floor at z=0.8 m, facing up xs = np.linspace(0.5, 4.5, 5) ys = np.linspace(0.5, 4.5, 5) rays = b"" for x in xs: for y in ys: rays += f"{x:.2f} {y:.2f} 0.8 0 0 1\n".encode() # Run rcontrib for both window modifiers simultaneously rc = ( pr.Rcontrib( inp=rays, octree="room.oct", params=["-ab", "2", "-ad", "4096", "-lw", "1e-5"], ) .add_modifier(modifier="win_east") .add_modifier(modifier="win_west") ) result = rc() # Parse ASCII output into a numpy array # With the default outform="a", values are space-separated floats. # rcontrib writes all modifier outputs concatenated: first all rays for # modifier 1, then all rays for modifier 2. nrays = len(rays.splitlines()) values = list(map(float, result.decode().split())) # Shape: (n_modifiers, n_rays, 3_channels) arr = np.array(values).reshape(2, nrays, 3) # Luminance via standard RGB coefficients east_luminance = arr[0] @ [47.4, 119.9, 11.6] # shape (nrays,) west_luminance = arr[1] @ [47.4, 119.9, 11.6] ``` -------------------------------- ### getinfo(*inputs, dimension_only=False, dimension=False, strip_header=False, replace='', append='', command='') Source: https://lbnl-eta.github.io/pyradiance/reference Get header information from a Radiance file. ```APIDOC ## getinfo(*inputs, dimension_only=False, dimension=False, strip_header=False, replace='', append='', command='') ### Description Get header information from a Radiance file. ### Method Function call ### Endpoint `getinfo(*inputs, dimension_only=False, dimension=False, strip_header=False, replace='', append='', command='')` ### Parameters #### Path Parameters - **inputs** (tuple[str | Path | bytes, ...]) - Required - input file or bytes #### Query Parameters - **dimension_only** (bool) - Optional - return only the dimension - Default: `False` - **dimension** (bool) - Optional - return the dimension - Default: `False` - **strip_header** (bool) - Optional - strip header from the output - Default: `False` - **replace** (str) - Optional - replace the header with this string - Default: `''` - **append** (str) - Optional - append this string to the header - Default: `''` - **command** (str) - Optional - command to use to get the header - Default: `''` ### Returns - **bytes** - getinfo output ``` -------------------------------- ### rpict(view, octree, xres=None, yres=None, report=0, report_file=None, params=None) Source: https://lbnl-eta.github.io/pyradiance/reference Get rpict command. Takes view parameters and an octree file path, with optional resolution and reporting parameters, returning the command output as bytes. ```APIDOC ## rpict(view, octree, xres=None, yres=None, report=0, report_file=None, params=None) ### Description Get rpict command. ### Method Function call ### Endpoint rpict(view, octree, xres=None, yres=None, report=0, report_file=None, params=None) ### Parameters #### Path Parameters - **view** (Sequence[str]) - Required - A list of view parameters in strings. - **octree** (Path | str) - Required - A path to octree file. #### Query Parameters - **xres** (None | int) - Optional - X resolution (default: None) - **yres** (None | int) - Optional - Y resolution (default: None) - **report** (float) - Optional - Report (default: 0) - **report_file** (None | Path) - Optional - Report file (default: None) - **params** (None | Sequence[str]) - Optional - A list of additional parameters (default: None) ### Response #### Success Response - **bytes** - A bytes object. ``` -------------------------------- ### getbbox(*inputs, header=False, warning=True) Source: https://lbnl-eta.github.io/pyradiance/reference Get axis-aligned bounding box of a Radiance scene. ```APIDOC ## getbbox(*inputs, header=False, warning=True) ### Description Get axis-aligned bounding box of a Radiance scene. ### Method Function call ### Endpoint `getbbox(*inputs, header=False, warning=True)` ### Parameters #### Path Parameters - **path** - Required - path to Radiance scene #### Query Parameters - **header** (bool) - Optional - include header - Default: `False` - **warning** (bool) - Optional - Default: `True` ### Returns - **list** (list[float]) - bounding box ``` -------------------------------- ### Pcomb.__init__() Source: https://lbnl-eta.github.io/pyradiance/reference Initializes a Pcomb instance to combine Radiance pictures and/or float matrices. ```APIDOC ## Pcomb.__init__(xres=None, yres=None, inform='a', fout=True, header=False, expression=None, source=None) ### Description Combine Radiance pictures and/or float matrices. ### Method N/A ### Endpoint N/A ### Parameters #### Constructor Parameters - **xres** (None | int) - Optional - horizontal resolution - **yres** (None | int) - Optional - vertical resolution - **inform** (str) - Optional - input data format. Default is "a" for ascii. - **fout** (bool) - Optional - if True, write output to file - **header** (bool) - Optional - if True, write header - **expression** (None | str) - Optional - expression - **source** (None | str) - Optional - source ### Request Example N/A ### Response #### Success Response - **Pcomb** - The Pcomb instance #### Response Example N/A ``` -------------------------------- ### oconv(*paths, warning=True, stdin=None, frozen=False, octree=None) Source: https://lbnl-eta.github.io/pyradiance/reference Runs the Radiance oconv tool to build an octree from a list of Radiance files. Supports warning suppression, stdin input, freezing the octree, and incorporating an existing octree. ```APIDOC ## oconv(*paths, warning=True, stdin=None, frozen=False, octree=None) ### Description Run Radiance oconv tool to build an octree. ### Parameters - **paths** (str) - Required - list of Radiance files - **warning** (bool) - Optional - if False, warnings will be suppressed. Default: True - **stdin** (None | bytes) - Optional - if not None, stdin will be used. Default: None - **frozen** (bool) - Optional - if True, the octree will be frozen. Default: False - **octree** (None | str | Path) - Optional - if provided, the resulting octree incorporate existing one. Default: None ### Returns - **bytes** - output of oconv ``` -------------------------------- ### Get qualifiers with obj2rad(quallist=True) Source: https://lbnl-eta.github.io/pyradiance/howtos/guide1 Use obj2rad() with quallist=True to get just the list of qualifiers (modifier names) without producing a full scene description. ```python qualifiers = pr.obj2rad("room.obj", quallist=True).decode().splitlines() print(qualifiers) ``` -------------------------------- ### get_image_dimensions(image) Source: https://lbnl-eta.github.io/pyradiance/reference Get the dimensions of an image. ```APIDOC ## get_image_dimensions(image) ### Description Get the dimensions of an image. ### Method Function call ### Endpoint `get_image_dimensions(image)` ### Parameters #### Path Parameters - **image** (str | Path | bytes) - Required - image file path or image bytes ### Returns - **tuple[int, int]** - Tuple[int, int]: width and height ``` -------------------------------- ### Xform.__init__ Source: https://lbnl-eta.github.io/pyradiance/reference Initializes an Xform object for transforming RADIANCE scene descriptions. ```APIDOC ## Xform.__init__ ### Description Initializes a transformation operation of a RADIANCE scene description. ### Method Constructor ### Parameters - **inp** (str | Path | bytes) - Required - Input file or bytes - **expand_cmd** (bool) - Optional - Set to True to expand command - **iprefix** (None | str) - Optional - Prefix identifier - **modifier** (None | str) - Optional - Set surface modifier to this name - **invert** (bool) - Optional - Invert surface normal ### Returns None ``` -------------------------------- ### get_header(inp, dimension=False) Source: https://lbnl-eta.github.io/pyradiance/reference Get header information from a Radiance file. ```APIDOC ## get_header(inp, dimension=False) ### Description Get header information from a Radiance file. ### Method Function call ### Endpoint `get_header(inp, dimension=False)` ### Parameters #### Path Parameters - **inp** (str | Path | bytes) - Required - input file or bytes #### Query Parameters - **dimension** (bool) - Optional - Default: `False` ``` -------------------------------- ### Create and configure a default view Source: https://lbnl-eta.github.io/pyradiance/tutorials Create a default view and set its position (vp) to (1, 1.5, 1) and direction (vdir) to (1, 0, 0). Other view parameters use default values. ```python aview = pr.create_default_view() aview.vp = (1, 1.5, 1) aview.vdir = (1, 0, 0) ``` -------------------------------- ### pkgbsdf(*xml, frozen=False, stdout=False) Source: https://lbnl-eta.github.io/pyradiance/reference Package BSDFs provided as XML for Radiance. ```APIDOC ## pkgbsdf(*xml, frozen=False, stdout=False) ### Description Package BSDFs provided as XML for Radiance. ### Parameters - **xml** (tuple[str | Path, ...]) - Required - Path to XML files - **frozen** (bool) - Optional - produce frozen octree instance for any detail geometry. Default: False - **stdout** (bool) - Optional - print the output to stdout, only works for a single XML input. Default: False ### Returns - **None | bytes** - The output of the command ``` -------------------------------- ### Import pyradiance.bsdf module Source: https://lbnl-eta.github.io/pyradiance/howtos/bsdf Import the pyradiance.bsdf module to access BSDF loading, querying, and sampling functions. ```python from pyradiance import bsdf ``` -------------------------------- ### Access specular distribution components (SDSpectralDF) Source: https://lbnl-eta.github.io/pyradiance/howtos/bsdf Access specular distribution components (SDSpectralDF) via sd.rf, sd.rb, sd.tf, and sd.tb to get peak hemispherical values and minimum projected solid angle. ```python print(sd.rf.maxHemi) # peak front hemispherical reflectance print(sd.tf.maxHemi) # peak front hemispherical transmittance print(sd.rf.minProjSA) # minimum projected solid angle ``` -------------------------------- ### rmtxop(inp, outform='a', transpose=False, scale=None, transform=None, reflectance=None) Source: https://lbnl-eta.github.io/pyradiance/reference Run rmtxop command. Takes input and optional parameters for output format, transpose, scale, and transform, returning results in bytes. ```APIDOC ## rmtxop(inp, outform='a', transpose=False, scale=None, transform=None, reflectance=None) ### Description Run rmtxop command. ### Parameters - **inp** (str | Path | bytes) - Required - input - **outform** (FileType) - Optional - output format: 'a', 'f', 'd', 'c' (default: 'a') - **transpose** (bool) - Optional - whether to transpose matrix (default: False) - **scale** (None | float) - Optional - scaling factor (default: None) - **transform** (None | str | Sequence[float]) - Optional - transform factors for each channel (default: None) ### Returns - **bytes** (bytes) - The results of rmtxop in bytes ``` -------------------------------- ### cnt usage examples with shuffled option Source: https://lbnl-eta.github.io/pyradiance/reference Illustrate the output of `cnt(2, 3)` and `cnt(2, 3, shuffled=True)`. The first returns a counter of all combinations in order, the shuffled variant randomizes the order. Use this to verify expected matrix indices in RADIANCE workflows. ```python >>> 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' ``` -------------------------------- ### rfluxmtx(receiver, surface=None, rays=None, params=None, octree=None, scene=None) Source: https://lbnl-eta.github.io/pyradiance/reference Run rfluxmtx command. Takes receiver file path and optional surface, rays, parameters, octree, and scene files, returning results in bytes. ```APIDOC ## rfluxmtx(receiver, surface=None, rays=None, params=None, octree=None, scene=None) ### Description Run rfluxmtx command. ### Parameters - **receiver** (str | Path) - Required - receiver file path - **surface** (None | str | Path) - Optional - input surface file path, mutually exclusive with rays (default: None) - **rays** (None | bytes) - Optional - input rays bytes, mutually exclusive with surface (default: None) - **params** (None | Sequence[str]) - Optional - ray tracing parameters (default: None) - **octree** (None | Path | str) - Optional - octree file path (default: None) - **scene** (None | Sequence[Path | str]) - Optional - list of scene files (default: None) ### Returns - **bytes** (bytes) - The results of rfluxmtx in bytes ``` -------------------------------- ### Rcomb.__init__() Source: https://lbnl-eta.github.io/pyradiance/reference Initializes an Rcomb instance to combine multiple rasters. ```APIDOC ## Rcomb.__init__(transform=None, transform_all=None, source=None, expression=None, concat=None, outform=None, header=True, silent=False) ### Description Combine multiple rasters. ### Method N/A ### Endpoint N/A ### Parameters #### Constructor Parameters - **transform** (None | str) - Optional - transform - **transform_all** (None | str) - Optional - transform all - **source** (None | str) - Optional - source - **expression** (None | str) - Optional - expression - **concat** (None | Sequence[str]) - Optional - concat - **outform** (None | FileType) - Optional - output format - **header** (bool) - Optional - include header - **silent** (bool) - Optional - suppress output ### Request Example N/A ### Response #### Success Response - **Rcomb** - The Rcomb instance #### Response Example N/A ``` -------------------------------- ### evalglare(inp, view=None, detailed=False, ev_only=False, ev=None, smooth=False, threshold=None, task_area=None, masking_file=None, band_lum_angle=None, check_file=None, correction_mode=None, peak_extraction=True, peak_extraction_value=50000, bg_lum_mode=0, search_radius=0.2, version=False, source_color=None, fast=None) Source: https://lbnl-eta.github.io/pyradiance/reference Runs evalglare on a Radiance image to compute glare metrics. Accepts an input image and various optional parameters for view, smoothing, threshold, and more. Returns the evalglare output as bytes. ```APIDOC ## evalglare(inp, view=None, detailed=False, ev_only=False, ev=None, smooth=False, threshold=None, task_area=None, masking_file=None, band_lum_angle=None, check_file=None, correction_mode=None, peak_extraction=True, peak_extraction_value=50000, bg_lum_mode=0, search_radius=0.2, version=False, source_color=None, fast=None) ### Description Run evalglare on a Radiance image. ### Parameters - **inp** (str | bytes | Path) - Required - input image - **view** (None | list[str]) - Optional - view parameters - **detailed** (bool) - Optional - detailed output - **ev_only** (bool) - Optional - return vertical illuminance value - **ev** (None | float | Sequence[float]) - Optional - vertical illuminance value to use instead of the one computer from the image. - **smooth** (bool) - Optional - enable smoothing function. - **threshold** (None | float) - Optional - Threshold factor. - **task_area** (None | tuple) - Optional - task area - **masking_file** (None | str | Path) - Optional - masking file - **band_lum_angle** (None | float) - Optional - band luminance angle - **check_file** (None | str | Path) - Optional - check file path. - **correction_mode** (None | str) - Optional - correction mode - **peak_extraction** (bool) - Optional - enable luminance peak extraction - **peak_extraction_value** (float) - Optional - luminance peak extraction value - **bg_lum_mode** (int) - Optional - background luminance calculation mode - **search_radius** (float) - Optional - search radius - **version** (bool) - Optional - print version - **source_color** (None | tuple[float, float, float]) - Optional - source color ### Returns - **bytes** - Evalglare output ``` -------------------------------- ### pvaluer(pic, xres=None, yres=None, inform='a', resstr=True, dataonly=False, header=True, primaries=None, pxyz=False) Source: https://lbnl-eta.github.io/pyradiance/reference Run Radiance pvalue tools reverse mode: constructing an image from pixel values. ```APIDOC ## pvaluer(pic, xres=None, yres=None, inform='a', resstr=True, dataonly=False, header=True, primaries=None, pxyz=False) ### Description Run Radiance pvalue tools reverse mode: constructing an image from pixel values. ### Method Function call ### Parameters #### Path Parameters - **pic** (Path | str | bytes) - Required - Path or bytes of the input pixel data. #### Query Parameters - **xres** (None | int) - Optional - X resolution. Default: None - **yres** (None | int) - Optional - Y resolution. Default: None - **inform** (str) - Optional - input data format. Default is "a" for ascii. Default: 'a' - **header** (bool) - Optional - Set to True if the picture file has a header. Default is False. Default: True - **primaries** (None | list[float]) - Optional - list of primaries for XYZ calculation. Default is None. - **pxyz** (bool) - Optional - Set to True to calculate XYZ values. Default is False. ### Returns - **bytes** (bytes) - Bytes of the pvalue output ``` -------------------------------- ### Import pyradiance as pr Source: https://lbnl-eta.github.io/pyradiance/tutorials Import the pyradiance library using the alias 'pr' for improved code readability. ```python import pyradiance as pr ``` -------------------------------- ### render(scene, view=None, quality='Medium', variability='Medium', detail='Medium', nproc=1, ncssamp=3, resolution=None, ambbounce=0, ambcache=True, params=None) Source: https://lbnl-eta.github.io/pyradiance/reference Render a scene. Takes a Scene object and returns rendered output as bytes along with width and height. ```APIDOC ## render(scene, view=None, quality='Medium', variability='Medium', detail='Medium', nproc=1, ncssamp=3, resolution=None, ambbounce=0, ambcache=True, params=None) ### Description Render a scene. ### Parameters - **scene** (Scene) - Required - Scene object. - **view** (None) - Optional - View (default: None) - **quality** (str) - Optional - Quality level (default: 'Medium') - **variability** (str) - Optional - Variability level (default: 'Medium') - **detail** (str) - Optional - Detail level (default: 'Medium') - **nproc** (int) - Optional - Number of processes to use (default: 1) - **ncssamp** (int) - Optional - Number of channels to sample (default: 3) - **resolution** (None) - Optional - Resolution (default: None) - **ambbounce** (int) - Optional - Number of ambient bounces (default: 0) - **ambcache** (bool) - Optional - Use ambient cache (default: True) - **params** (None | RayParams) - Optional - Sampling parameters (default: None) ### Returns - **bytes** (bytes) - tuple[bytes, int, int]: output of render, width, height ``` -------------------------------- ### 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) Source: https://lbnl-eta.github.io/pyradiance/reference Run rtrace with the given rays and octree, returning the output as bytes. ```APIDOC ## 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) ### Description Run rtrace. ### Parameters - **rays** (bytes) - Required - A string of bytes representing the input rays. - **octree** (Path | str) - Required - Path to octree file. - **header** (bool) - Optional - A boolean to indicate if the header should be included in the output. Default: True - **inform** (str) - Optional - Input format. Default is 'a'. Default: 'a' - **outform** (str) - Optional - Output format. Default is 'a'. Default: 'a' - **irradiance** (bool) - Optional - A boolean to indicate if irradiance should be calculated. Default: False - **irradiance_lambertian** (bool) - Optional - A boolean to indicate if irradiance should be calculated using Lambertian assumption. Default: False - **outspec** (None | str) - Optional - Output specification. Default is None. Default: None - **trace_exclude** (str) - Optional - A string of space separated material names to exclude from the trace. Default: '' - **trace_include** (str) - Optional - A string of space separated material names to include in the trace. Default: '' - **trace_exclude_file** (None | str | Path) - Optional - Path to a file containing material names to exclude from the trace. Default: None - **trace_include_file** (None | str | Path) - Optional - Path to a file containing material names to include in the trace. Default: None - **uncorrelated** (bool) - Optional - A boolean to indicate if uncorrelated sampling should be used. Default: False - **xres** (None | int) - Optional - X resolution of the output image. Default: None - **yres** (None | int) - Optional - Y resolution of the output image. Default: None - **nproc** (None | int) - Optional - Number of processors to use. Default: None ### Returns - **bytes** - A string of bytes representing the output of rtrace. ``` -------------------------------- ### load_material_smd(file, roughness=0.0, spectral=False, metal=False) Source: https://lbnl-eta.github.io/pyradiance/reference Generate Radiance primitives from csv file from spectral material database (spectraldb.com). ```APIDOC ## load_material_smd(file, roughness=0.0, spectral=False, metal=False) ### Description Generate Radiance primitives from csv file from spectral material database (spectraldb.com). ### Method Function call ### Endpoint `load_material_smd(file, roughness=0.0, spectral=False, metal=False)` ### Parameters #### Path Parameters - **file** (Path) - Required - Path to .csv file #### Query Parameters - **roughness** (float) - Optional - Roughtness of material - Default: `0.0` - **spectral** (bool) - Optional - Output spectral primitives - Default: `False` - **metal** (bool) - Optional - Whether material is metal - Default: `False` ### Returns - **list[Primitive]** - A list of primitives ``` -------------------------------- ### Add materials and surfaces to scene Source: https://lbnl-eta.github.io/pyradiance/tutorials Add materials and surfaces to the scene from local directories. ```python scene.add_material("Objects/materials.mat") scene.add_surface("Objects/walls.rad") scene.add_surface("Objects/ceiling.rad") scene.add_surface("Objects/floor.rad") ``` -------------------------------- ### 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) Source: https://lbnl-eta.github.io/pyradiance/reference Generates an annual Perez sky matrix from a weather tape, with options for sun-only, sky-only, and various output formats. ```APIDOC ## 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) ### Description Generate an annual Perez sky matrix from a weather tape. ### Parameters - **weather_data** (str | Path | bytes) - Required - weather data - **mfactor** (int) - Optional - multiplication factor (default: 1) - **verbose** (bool) - Optional - verbose (default: False) - **header** (bool) - Optional - header (default: True) - **average** (bool) - Optional - average (default: False) - **sun_only** (bool) - Optional - sun only (default: False) - **sky_only** (bool) - Optional - sky only (default: False) - **sun_file** (None | str) - Optional - sun file (default: None) - **sun_mods** (None | str) - Optional - sun mods (default: None) - **daylight_hours_only** (bool) - Optional - daylight hours only (default: False) - **dryrun** (bool) - Optional - dryrun (default: False) - **sky_color** (None | list[float]) - Optional - sky color (default: None) - **ground_color** (None | list[float]) - Optional - ground color (default: None) - **rotate** (None | float) - Optional - rotate (default: None) - **outform** (None | str) - Optional - outform (default: None) - **onesun** (bool) - Optional - onesun (default: False) - **solar_radiance** (bool) - Optional - solar radiance (default: False) ### Returns - **bytes** - output of gendaymtx ``` -------------------------------- ### get_view_args(*args, **kwargs) Source: https://lbnl-eta.github.io/pyradiance/reference Returns a list of string for the view. ```APIDOC ## get_view_args(*args, **kwargs) ### Description Returns a list of string for the view. ### Method Function call ### Endpoint `get_view_args(*args, **kwargs)` ### Parameters No parameters documented. ### Returns - **list** - A list of strings. ``` -------------------------------- ### pcompos(inputs, pos=None, xres=None, yres=None, spacing=0, background=None, anchors=None, header=True, lower_threashold=None, upper_threshold=None, label=None, label_height=None, ncols=None, anchor_point=None) Source: https://lbnl-eta.github.io/pyradiance/reference Composites Radiance pictures from a list of input files. Supports positioning, resolution, spacing, background color, anchors, header control, thresholds, labels, column count, and anchor point. ```APIDOC ## pcompos(inputs, pos=None, xres=None, yres=None, spacing=0, background=None, anchors=None, header=True, lower_threashold=None, upper_threshold=None, label=None, label_height=None, ncols=None, anchor_point=None) ### Description Composite Radiance pictures ### Parameters - **inputs** (Sequence[Path | str | bytes]) - Required - list of input files - **pos** (None | Sequence[Sequence[float]]) - Optional - list of positions. Default: None - **xres** (None | int) - Optional - horizontal resolution. Default: None - **yres** (None | int) - Optional - vertical resolution. Default: None - **spacing** (int) - Optional - spacing between images. Default: 0 - **background** (None | tuple[float, float, float]) - Optional - background color. Default: None - **anchors** (None | Sequence[str]) - Optional - list of anchors. Default: None - **header** (bool) - Optional - set to False if want to reduce header. Default: True - **lower_threashold** (None | float) - Optional - lower threshold. Default: None - **upper_threshold** (None | float) - Optional - upper threshold. Default: None - **label** (None | str) - Optional - label. Default: None - **label_height** (None | int) - Optional - label height. Default: None - **ncols** (None | int) - Optional - number of columns. Default: None - **anchor_point** (None | Sequence[str]) - Optional - anchor point. Default: None ### Returns - **bytes** - output of pcompos ``` -------------------------------- ### WrapBSDF.__init__ Source: https://lbnl-eta.github.io/pyradiance/reference Initializes a WrapBSDF object for wrapping BSDF data into XML format. ```APIDOC ## WrapBSDF.__init__ ### Description Initializes a wrapper operation for BSDF data into XML. ### Method Constructor ### Parameters - **inxml** (None | str | Path) - Optional - Input XML file - **enforce_window** (bool) - Optional - Enforcing LBNL Window XML schema - **comment** (None | str) - Optional - Additional comment to add to XML - **correct_solid_angle** (bool) - Optional - Correct the input BSDF by solid angles - **basis** (None | str) - Optional - BSDF basis to use: "kf", "kh", "kq" - **unlink** (bool) - Optional - Whether to remove input file after creating XML file - **unit** (None | str) - Optional - BSDF geometry unit - **geometry** (None | str) - Optional - Whether to include geometry in XML - **kwargs** (str | float) - Optional - Additional tags to be passed into XML ### Returns None ``` -------------------------------- ### Add light source to scene Source: https://lbnl-eta.github.io/pyradiance/tutorials Add a light source to the scene from a local directory. ```python scene.add_source("Sources/sky.rad") ``` -------------------------------- ### 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) Source: https://lbnl-eta.github.io/pyradiance/reference Convert IES luminaire data to RADIANCE description. ```APIDOC ## 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) ### Description Convert IES luminaire data to RADIANCE description. ### Method Function call ### Endpoint `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)` ### Parameters #### Path Parameters - **inp** (tuple[str | Path, ...]) - Required - Path to IES file #### Query Parameters - **libdir** (None | str) - Optional - Path to directory where the library files are located. - Default: `None` - **prefdir** (None | str) - Optional - Set the library subdirectory. - Default: `None` - **outname** (None | str) - Optional - Output file name root. - Default: `None` - **stdout** (bool) - Optional - Print the output to stdout. - Default: `False` - **units** (None | str) - Optional - Set the units of the output file. - Default: `None` - **radius** (None | float) - Optional - ignore the crude geometry given by the IES input file and use instead an illum sphere with radius rad. - Default: `None` - **instancing_geometry** (bool) - Optional - compile MGF detail geometry into a separate octree and create a single instance referencing it. - Default: `False` - **lampdat** (None | str) - Optional - map lamp name to xy chromaticity and lumen depreciation data. - Default: `None` - **lamp_type** (None | str) - Optional - lamp type. - Default: `None` - **lamp_color** (None | str) - Optional - set lamp color to red green blue if lamp type is unknown. - Default: `None` - **set_default_lamp_color** (None | str) - Optional - set default lamp color according to the entry for lamp in the lookup table. - Default: `None` - **multiply_factor** (None | float) - Optional - multiply all output quantities by this factor. This is the best way to scale fixture brightness for different lamps. - Default: `None` ### Returns - **bytes** - The output of the command ``` -------------------------------- ### obj2mesh(inp, matfiles=None, matlib=None, objlim=9, maxres=16384, silent=False, stats=False) Source: https://lbnl-eta.github.io/pyradiance/reference Converts a Wavefront OBJ file to a RADIANCE description, returning the converted scene as bytes. ```APIDOC ## obj2mesh(inp, matfiles=None, matlib=None, objlim=9, maxres=16384, silent=False, stats=False) ### Description Convert Wavefront .OBJ file to RADIANCE description. ### Method Function call ### Endpoint obj2mesh(inp, matfiles=None, matlib=None, objlim=9, maxres=16384, silent=False, stats=False) ### Parameters #### Path Parameters - **inp** (bytes | str | Path) - Required - Path to OBJ file, or bytes #### Query Parameters - **matfiles** (None | Sequence[str]) - Optional - Radiance material files to use - **matlib** (None | str) - Optional - Radiance material library file, RAYPATH are searched - **objlim** (int) - Optional - the maximum surface setsize for each voxel (default: 9) - **maxres** (int) - Optional - Maximum octree resolution (default: 16384) - **silent** (bool) - Optional - Suppress warnings (default: False) - **stats** (bool) - Optional - Print statistics (default: False) ### Response #### Success Response (200) - **bytes** - The converted RADIANCE scene description in bytes #### Response Example ``` (bytes) ``` ``` -------------------------------- ### Chain V × D with pr.Rmtxop Source: https://lbnl-eta.github.io/pyradiance/howtos/guide2 Alternative to dctimestep using pr.Rmtxop for the V × D product. Supports scaling, transposing, and combining matrices with + or * operators. Useful for adding a direct subtraction term (3PM/5PM) or converting units with a scaling factor. ```python result = ( pr.Rmtxop(outform="a") .add_input("vmtx.dmx") .add_input("smtx.dmx") () ) ``` -------------------------------- ### obj2rad(inp, quallist=False, flatten=False, mapfile=None, objname=None) Source: https://lbnl-eta.github.io/pyradiance/reference Converts a Wavefront .OBJ file to a RADIANCE scene description. Accepts a path to the OBJ file and optional parameters for qualifier list generation, face flattening, material mapping, and object naming. ```APIDOC ## obj2rad(inp, quallist=False, flatten=False, mapfile=None, objname=None) ### Description Convert Wavefront .OBJ file to RADIANCE description. ### Parameters - **inp** (bytes | str | Path) - Required - Path to OBJ file - **quallist** (bool) - Optional - Produce a list of qualifiers from which to construct a mapping for the given .OBJ file. Default: False - **flatten** (bool) - Optional - Flatten all faces, effectively ignoring vertex normal information. Default: False - **mapfile** (None | str) - Optional - Mapping rules files for assigning material names for the surfaces. Default: None - **objname** (None | str) - Optional - 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. Default: None ### Returns - **bytes** - The converted RADIANCE scene description in bytes ``` -------------------------------- ### Full 2PM simulation with pyradiance Source: https://lbnl-eta.github.io/pyradiance/howtos/guide2 Complete two-phase matrix daylighting simulation: computes the view matrix with rfluxmtx, the sky matrix with gendaymtx, and the annual results with dctimestep. Writes results to results.txt. Note that for large scenes or fine Reinhart subdivisions (MF:4+), rfluxmtx can take significant time; write view_mtx to disk for reuse. ```python import pyradiance as pr # 1. View matrix with open("sensors.txt", "rb") as f: rays = f.read() view_mtx = pr.rfluxmtx( receiver="sky.rad", rays=rays, params=["-ab", "5", "-ad", "10000", "-lw", "1e-4", "-c", "1000"], octree="scene.oct", scene=["materials.mat", "geometry.rad"], ) # 2. Sky matrix sky_mtx = pr.gendaymtx("weather.epw", mfactor=4, outform="f") # 3. Annual results (sensor × timestep rows) results = pr.dctimestep(view_mtx, sky_mtx, outform="a") with open("results.txt", "wb") as f: f.write(results) ``` -------------------------------- ### 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) Source: https://lbnl-eta.github.io/pyradiance/reference Operate on Wavefront .OBJ file. Takes an input OBJ file path and optional parameters to modify the output, returning the result as bytes. ```APIDOC ## 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) ### Description Operate on Wavefront .OBJ file. ### Method Function call ### Endpoint 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) ### Parameters #### Path Parameters - **inp** (str | Path) - Required - Input .OBJ file path #### Query Parameters - **radout** (bool) - Optional - Output RADIANCE scene description (default: False) - **verbose** (bool) - Optional - Set to True to turn on verbosity (default: False) - **remove_texture_coordinates** (bool) - Optional - Remove texture coordinates from the output (default: False) - **remove_surface_normal** (bool) - Optional - Remove surface normal from the output (default: False) - **remove_surface_by_modifier** (None | Sequence[str]) - Optional - Remove surfaces by modifier, mutually exclusive with keep_surface_by_modifier (default: None) - **keep_surface_by_modifier** (None | Sequence[str]) - Optional - Keep surfaces by modifier, mutually exclusive with remove_surface_by_modifier (default: None) - **remove_surface_by_group** (None | Sequence[str]) - Optional - Remove surfaces by group/object, mutually exclusive with keep_surface_by_group (default: None) - **keep_surface_by_group** (None | Sequence[str]) - Optional - Keep surfaces by group/object, mutually exclusive with remove_surface_by_group (default: None) - **epsilon** (None | float) - Optional - Coalesce vertices that are within the given epsilon (default: None) - **triangulate** (bool) - Optional - Turns all faces with 4 or more sides into triangles (default: False) - **transform** (None | str) - Optional - Transform the input, using xform CLI syntax (default: None) ### Response #### Success Response - **bytes** - The output of the command ``` -------------------------------- ### Convert .obj to Radiance with obj2rad() Source: https://lbnl-eta.github.io/pyradiance/howtos/guide1 Use obj2rad() to convert a .obj file to a Radiance scene description. The result is returned as bytes. ```python import pyradiance as pr room_rad = pr.obj2rad("room.obj") ``` -------------------------------- ### create_default_view(*args, **kwargs) Source: https://lbnl-eta.github.io/pyradiance/reference Creates a default view object. ```APIDOC ## create_default_view(*args, **kwargs) ### Description create_default_view() -> pyradiance.rad_params.View ``` -------------------------------- ### Render scene with ambbounce=1 Source: https://lbnl-eta.github.io/pyradiance/tutorials Render the scene using the render() function. The ambbounce argument overrides the default zero ambient bounce. The function returns the generated .hdr image as bytes. ```python image = pr.render(scene, ambbounce=1) ``` -------------------------------- ### 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) Source: https://lbnl-eta.github.io/pyradiance/reference Generate rays for a view. ```APIDOC ## 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) ### Description vwrays. ``` -------------------------------- ### dctimestep(*mtx, nstep=None, header=True, xres=None, yres=None, inform=None, outform=None, ospec=None) Source: https://lbnl-eta.github.io/pyradiance/reference Call dctimestep to perform matrix multiplication. Takes input matrices and various options. ```APIDOC ## dctimestep(*mtx, nstep=None, header=True, xres=None, yres=None, inform=None, outform=None, ospec=None) ### Description Call dctimestep to perform matrix multiplication. ### Parameters - **mtx** (str | bytes) - Required - input matrices - **nstep** (None | int) - Optional - number of steps - **header** (bool) - Optional - include header - **xres** (None | int) - Optional - x resolution - **yres** (None | int) - Optional - y resolution - **inform** (None | str) - Optional - input format - **outform** (None | str) - Optional - output format - **ospec** (None | str) - Optional - output specification ### Returns - **bytes** - output of dctimestep ``` -------------------------------- ### viewfile(*args, **kwargs) Source: https://lbnl-eta.github.io/pyradiance/reference Read a view file into a View object. ```APIDOC ## viewfile(*args, **kwargs) ### Description viewfile(arg: str, /) -> pyradiance.rad_params.View Read a view file into a View object ``` -------------------------------- ### Load BSDF file with bsdf.load_file() Source: https://lbnl-eta.github.io/pyradiance/howtos/bsdf Load a tabulated BSDF file using bsdf.load_file(), which returns an SDData object. ```python sd = bsdf.load_file("bsdf.xml") ``` -------------------------------- ### Tonemap HDR image with pcond() Source: https://lbnl-eta.github.io/pyradiance/tutorials Write the HDR image to a file and apply tonemapping with pcond() using human vision adaptation. pcond() requires a file path as input. ```python with open("raw.hdr", "wb") as wtr: wtr.write(image) timage = pr.pcond("raw.hdr", human=True) ``` -------------------------------- ### Multiply V × D with pr.dctimestep Source: https://lbnl-eta.github.io/pyradiance/howtos/guide2 Multiplies the view matrix and sky matrix with pr.dctimestep. Takes exactly 2 or 4 matrix arguments; here passes vmtx.dmx and smtx.dmx. Writes results to results.txt; each row is the RGB/luminance at one sensor for one timestep, ordered as sensors × timesteps. ```python # Both matrices on disk results = pr.dctimestep("vmtx.dmx", "smtx.dmx", outform="a") with open("results.txt", "wb") as f: f.write(results) ```