raytraverse.lightfield

LightField

class raytraverse.lightfield.LightField(scene, vecs, pm, src)[source]

Bases: object

collection of light data with KDtree structure for spatial query

Parameters
property samplelevel

the level at which the vec was sampled (all zero if not provided upon initialization

property vecs

indexing vectors (such as position, sun positions, etc.)

property data

light data

property kd

kdtree for spatial queries built on demand

property omega

solid angle or area

query(vecs)[source]

return the index and distance of the nearest point to each of points

Parameters

vecs (np.array) – shape (N, 3) vectors to query.

Returns

  • i (np.array) – integer indices of closest ray to each query

  • d (np.array) – distance from query to point in spacemapper.

evaluate(*args, **kwargs)[source]

LightPlaneKD

class raytraverse.lightfield.LightPlaneKD(scene, vecs, pm, src)[source]

Bases: LightField

collection of lightpoints with KDtree structure for positional query

property data

LightPointSet

property omega

representative area of each point

Getter

Returns array of areas

Setter

sets areas

Type

np.array

evaluate(skyvec, points=None, vm=None, metricclass=<class 'raytraverse.evaluate.metricset.MetricSet'>, metrics=None, mask=True, **kwargs)[source]
make_image(outf, vals, res=1024, interp=False, showsample=False)[source]

make an image from precomputed values for every point in LightPlane

Parameters
  • outf (str) – the file to write

  • vals (np.array) – shape (len(self.points),) the values computed for each point

  • res (int, optional) – image resolution (the largest dimension

  • interp (bool, optional) – apply linear interpolation, points outside convex hull of results fall back to nearest

  • showsample (bool, optionaal) – color pixel at sample location red

direct_view(res=512, showsample=True, vm=None, area=False, metricclass=<class 'raytraverse.evaluate.metricset.MetricSet'>, metrics=('avglum', ), interp=False)[source]

create a summary image of lightplane showing samples and areas

SunsPlaneKD

class raytraverse.lightfield.SunsPlaneKD(scene, vecs, pm, src)[source]

Bases: LightField

collection of lightplanes with KDtree structure for sun position query

property vecs

indexing vectors (sx, sy, sz, px, py, pz)

property suns
property data

LightPlaneSet

property kd

kdtree for spatial queries built on demand

property sunkd

kdtree for sun position queries built on demand

query(vecs)[source]

return the index and distance of the nearest vec to each of vecs

Parameters

vecs (np.array) – shape (N, 6) vectors to query.

Returns

  • i (np.array) – integer indices of closest ray to each query

  • d (np.array) – distance from query to point, positional distance is normalized by the average chord-length between level 0 sun samples divided by the average distance between level 0 pt samples.

query_by_sun(sunvec, fixed_points=None, stol=10, minsun=1)[source]

for finding vectors across zone, sun vector based query

Parameters
  • sunvec (Sequence) – sun direction vector (normalized, xyz)

  • fixed_points (Sequence, optional) – 2d array like, shape (N, 3) of additional fixed points to return use for example with a matching sky query. Note that if point filter is to large not all of these points are necessarily returned.

  • stol (Union[float, int], optional) – maximum angle (in degrees) for matching sun vectors

  • minsun (int, optional) – if atleast these many suns are not returned based on stol, directly query for this number of results (regardless of sun error)

Returns

  • vecs (np.array) – shape (N, 6) final vectors, because of fixed_points, this may not match exactly with self.vecs[i] so this array mus be used in further processing

  • i (np.array) – integer indices of the closest rays to each query

  • d (np.array) – angle (in degrees) between queried sunvec and returned index

query_by_suns(sunvecs, fixed_points=None, stol=10, minsun=1)[source]

parallel processing call to query_by_sun for 2d array of sunvecs

Parameters
  • sunvecs (np.array) – shape (N, 3) sun direction vectors (normalized, xyz)

  • fixed_points (Sequence, optional) – 2d array like, shape (N, 3) of additional fixed points to return use for example with a matching sky query. Note that if point filter is to large not all of these points are necessarily returned.

  • stol (Union[float, int], optional) – maximum angle (in degrees) for matching sun vectors

  • minsun (int, optional) – if atleast these many suns are not returned based on stol, directly query for this number of results (regardless of sun error)

Returns

  • vecs (list) – list of np.array, one for each sunvec (see query_by_sun)

  • idx (list) – list of np.array, one for each sunvec (see query_by_sun)

  • d (list) – list of np.array, one for each sunvec (see query_by_sun)

SensorPlaneKD

class raytraverse.lightfield.SensorPlaneKD(scene, vecs, pm, src)[source]

Bases: LightPlaneKD

collection of sensor results with KDtree structure for positional query

data has shape (pts, sensors, sources, bands)

property sensors
property vecs

indexing vectors (such as position, sun positions, etc.)

property data

light data

static apply_coef(data, coefs)[source]

apply coefficient vector to data

Parameters
  • data (np.array) – ndims should match self.data (N, sensors, nsrcs, nfeatures)

  • coefs (np.array int float list) – shape (L, self.srcn) or broadcastable

Returns

alum – shape (L, N, sensors, nfeatures)

Return type

np.array

evaluate(skyvec, points=None, sensoridx=None, mask=True, **kwargs)[source]
direct_view(res=512, showsample=True, area=False, interp=False, sensoridx=None, **kwargs)[source]

create a summary image of lightplane showing samples and areas

SunSensorPlaneKD

class raytraverse.lightfield.SunSensorPlaneKD(scene, vecs, pm, src)[source]

Bases: SunsPlaneKD

collection of sensorplanes with KDtree structure for sun position query

data has shape (pts * suns, sensors, sources, bands)

property sensors
property suns
property data

LightPlaneSet

static apply_coef(data, coefs)[source]

apply coefficient vector to data

Parameters
  • data (np.array) – ndims should match self.data (N, M, nsrcs, nfeatures)

  • coefs (np.array int float list) – shape (L, self.srcn) or broadcastable

Returns

alum – shape (L, N, M, nfeatures)

Return type

np.array

LightResult

class raytraverse.lightfield.LightResult(data, *axes, boundary=None)[source]

Bases: object

a dense representation of lightfield data analyzed for a set of metrics

this class handles writing and loading results to disk as binary data and intuitive result extraction and reshaping for downstream visualisation and analysis using one of the “pull” methods. axes are indexed both numerically and names for increased transparency and ease of use.

Parameters
  • data (np.array str) – multidimensional array of result data or file path to saved LightResule

  • axes (Sequence[raytraverse.lightfield.ResultAxis]) – axis information

property boundary
property data
property axes
property names
property file
axis(name)[source]
load(file)[source]
write(file, compressed=True)[source]
merge(*lrs, axis='sky')[source]

create merged lightresult from lightresults, must match on all axes except axis. does not sort but culls duplicates

pull(*axes, preserve=1, **kwargs)[source]

arrange and extract data slices from result.

Integrators construct a light result with these axes:

  1. sky

  2. point

  3. view

  4. metric

Parameters
  • axes (Union[int, str]) – the axes (by name or integer index) to reorder output, list will fill with default object order.

  • preserve (int, optional) – number of dimensions to preserve (result will be N+1).

  • kwargs – keys with axis names will be used to filter output.

Returns

  • result (np.array) – the result array, will have 1+len(axes) dims, with the shaped determined by axis size and any indices argument.

  • labels (Sequence) – list of labels for each axis, for flattened axes will be a tuple of broadcast axis labels.

  • names (Sequence) – list of strings of returned axis names

static row_labels(labels)[source]
static fmt_names(name, labels)[source]
pull_header(names, labels, rowlabel=True)[source]
print(col, header=True, rowlabel=True, file=None, skyfill=None, **kwargs)[source]

first calls pull and then prints 2d result to file

sky_percentile(metric, per=(50,), **kwargs)[source]
print_serial(col, basename, header=True, rowlabel=True, skyfill=None, **kwargs)[source]

print 3d result to series of 2d files

rebase(points)[source]
pull2hdr(basename, col='metric', skyfill=None, spd=24, pm=None, res=480, showsample=False, **kwargs)[source]
info()[source]

ZonalLightResult

class raytraverse.lightfield.ZonalLightResult(data, *axes, boundary=None)[source]

Bases: LightResult

a semi-dense representation of lightfield data analyzed for a set of metrics

this class handles writing and loading results to disk as binary data and intuitive result extraction and reshaping for downstream visualisation and analysis using one of the “pull” methods. axes are indexed both numerically and names for increased transparency and ease of use.

property data
load(file)[source]
write(file, compressed=True)[source]
merge(*lrs, axis='sky')[source]

create merged lightresult from lightresults, must match on all axes except axis. does not sort but culls duplicates

pull2hdr(basename, showsample=False, pm=None, res=480, **kwargs)[source]
rebase(points)[source]

sets

LightSet

class raytraverse.lightfield.sets.LightSet(dataclass, scene, points, idx, **kwargs)[source]

Bases: object

LightPointSet

class raytraverse.lightfield.sets.LightPointSet(scene, points, idx, src, parent)[source]

Bases: LightSet

a collection of LightPoints, initialized by getitem

MultiLightPointSet

class raytraverse.lightfield.sets.MultiLightPointSet(scene, points, idx, src, parent)[source]

Bases: LightSet

SensorPointSet

class raytraverse.lightfield.sets.SensorPointSet(data, idx, **kwargs)[source]

Bases: LightSet

RaggedResult

class raytraverse.lightfield.RaggedResult(a)[source]

Bases: tuple

has a shape parameter and indexing similar to a np.array, but with varying shape along the second axis. composed of a list of np.arrays whose shape match after the first dimension.

ResultAxis

class raytraverse.lightfield.ResultAxis(values, name, cols=None)[source]

Bases: object

value_array()[source]
index(i)[source]
property cols