Skip to content

matrix

Frads Matrix class simply encapsulate the components necessary to generate a matrix, such as ray sender and receiver. The matrix data is by default store as numpy array in memory for later access.

frads.Matrix

Matrix(sender, receivers, octree=None, surfaces=None)

Base Matrix object.

Attributes:

Name Type Description
sender

Sender object

receivers

List of receiver objects

array

Matrix array, this is usually where the matrix data is stored

ncols

Number of columns

nrows int

Number of rows

dtype

Matrix data type

ncomp

Number of components

octree

Octree file used to generate the matrix

surfaces

List of environment surface primitives

Initialize a matrix.

Parameters:

Name Type Description Default
sender Union[SensorSender, ViewSender, SurfaceSender]

Sender object

required
receivers Union[List[SkyReceiver], List[SurfaceReceiver], List[SunReceiver]]

List of receiver objects

required
octree Optional[str]

Octree file used to generate the matrix

None
surfaces Optional[List[Primitive]]

List of environment surface file paths

None

generate

generate(
    params,
    nproc=1,
    sparse=False,
    to_file=False,
    memmap=False,
)

Call rfluxmtx to generate the matrix.

Parameters:

Name Type Description Default
params List[str]

List of rfluxmtx parameters

required
nproc int

Number of processes to use

1
sparse bool

Use sparse matrix format

False
to_file bool

Indicate the matrix will be written to file directly as specified by rfluxmtx markup. As a result, the matrix will not be stored in memory as numpy array.

False
memmap bool

Use memory mapping (out-of-core) to store the matrix, which is useful for large matrices.

False

frads.SensorSender

SensorSender(sensors, ray_count=1)

Sender object as a list of sensors.

Attributes:

Name Type Description
sensors

A list of sensors, each sensor is a list of 6 numbers

content

Sensor encoded for Radiance

yres

Number of sensors

Initialize a sender object with a list of sensors:

Parameters:

Name Type Description Default
sensors List[List[float]]

A list of sensors, each sensor is a list of 6 numbers

required
ray_count int

Number of rays per sensor

1

frads.ViewSender

ViewSender(view, ray_count=1, xres=800, yres=800)

Sender object as a view.

Attributes:

Name Type Description
view

A view object

content

View encoded for Radiance

xres

x resolution

yres

y resolution

frads.SurfaceSender

SurfaceSender(
    surfaces, basis, left_hand=False, offset=None
)

Sender object as a list of surface primitives.

Attributes:

Name Type Description
surfaces

A list of surface primitives

basis

Sender sampling basis

content

Surface encoded for Radiance

Instantiate a SurfaceSender object.

Parameters:

Name Type Description Default
surfaces List[Primitive]

A list of surface primitives

required
basis str

Sender sampling basis

required
left_hand bool

Whether to use left-hand coordinate system

False
offset bool

Offset of the sender surface

None

frads.SkyReceiver

SkyReceiver(basis, out=None)

Bases: Receiver

Sky as receiver object.

Attributes:

Name Type Description
basis

Receiver sampling basis

content

Sky encoded for Radiance

frads.SurfaceReceiver

SurfaceReceiver(
    surfaces,
    basis,
    left_hand=False,
    offset=None,
    source="glow",
    out=None,
)

Bases: Receiver

Receiver object as a list of surface primitives.

Attributes:

Name Type Description
surfaces

A list of surface primitives

basis

Receiver sampling basis

content

Surface encoded for Radiance

frads.SunMatrix

SunMatrix(sender, receiver, octree, surfaces=None)

Bases: Matrix

Sun Matrix object, specialized for sun-only matrices.

Attributes:

Name Type Description
sender

Sender object

receiver

Receiver object

octree

Octree file

surfaces

List of surface files

array

Matrix array

nrows

Number of rows

ncols

Number of columns

dtype

Data type

ncomp

Number of components

generate

generate(parameters, nproc=1, radmtx=False, sparse=False)

Call rcontrib to generate a matrix and store it in memory as a numpy array.

Parameters:

Name Type Description Default
parameters List[str]

List of rcontrib parameters

required
nproc int

Number of processes to use

1
radmtx bool

If true, return the matrix bytes from rcontrib directly

False
sparse bool

Use sparse matrix format, this is usually a good idea given the nature of sun-only matrices.

False

frads.SunReceiver

SunReceiver(
    basis,
    sun_matrix=None,
    window_normals=None,
    full_mod=False,
)

Bases: Receiver

Sun as receiver object. The number of suns is reduced depending on the input. If an annual sun_matrix is provided, only the non-zero solar position is used. If window_normals are provided, only the suns that are visible through the window are used.

Attributes:

Name Type Description
basis

Receiver sampling basis

content

Sun encoded for Radiance

modifiers

Sun modifier names

Initialize a sun receiver.

Parameters:

Name Type Description Default
basis str

Sampling basis

required
sun_matrix Optional[ndarray]

Annual sun matrix

None
window_normals Optional[List[ndarray]]

List of window normals

None
full_mod bool

Use full set of sun modifiers

False

frads.load_matrix

load_matrix(file, dtype='float')

Load a Radiance matrix file into numpy array.

Parameters:

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

a file path

required
dtype str

data type

'float'

Returns:

Type Description
ndarray

A numpy array

frads.load_binary_matrix

load_binary_matrix(
    buffer, nrows, ncols, ncomp, dtype, header=False
)

Load a matrix in binary format into a numpy array.

Parameters:

Name Type Description Default
buffer bytes

buffer to read from

required
nrows int

number of rows

required
ncols int

number of columns

required
ncomp int

number of components

required
dtype str

data type

required
header bool

if True, strip header

False

Returns:

Type Description
ndarray

The matrix as a numpy array

frads.surfaces_view_factor

surfaces_view_factor(surfaces, env, ray_count=10000)

Calculate surface to surface view factor using rfluxmtx.

Parameters:

Name Type Description Default
surfaces List[Primitive]

list of surface primitives that we want to calculate view factor for. Surface normal needs to be facing outward.

required
env List[Primitive]

list of environment primitives that our surfaces will be exposed to. Surface normal needs to be facing inward.

required
ray_count int

number of rays spawned for each surface.

10000

Returns:

Type Description
Dict[str, Dict[str, List[float]]]

A dictionary of view factors, where the key is the surface identifier.