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
scene (raytraverse.scene.BaseScene) –
vecs (np.array str) – the vectors used to organizing the child data as array or file shape (N,3) or (N,4) if 3, indexed from 0
src (str) – name of source group.
- 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
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
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
SunSensorPlaneKD¶
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¶
- 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:
sky
point
view
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
- print(col, header=True, rowlabel=True, file=None, skyfill=None, **kwargs)[source]¶
first calls pull and then prints 2d result to file
- print_serial(col, basename, header=True, rowlabel=True, skyfill=None, **kwargs)[source]¶
print 3d result to series of 2d files
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¶