raytraverse.integrator

Integrator

class raytraverse.integrator.Integrator(skyfield, sunfield=None, wea=None, loc=None, skyro=0.0, **kwargs)[source]

Bases: object

class to generate outputs from skyfield sunfield and sky conditions

This class provides an interface to:

  1. generate sky data using the perez

  2. combine lightfield data for sky and sun (handling sparsely populated sun data)

  3. apply sky data to the lightfield queries

  4. output luminance maps and photometric quantities and visual comfort metrics

Parameters
  • skyfield (raytraverse.lightfield.SCBinField) – class containing sky data

  • sunfield (raytraverse.lightfield.SunField) – class containing sun data (should share its scene parameter with the given skyfield

  • wea (str, np.array, optional) – path to epw, wea, or .npy file or np.array, if loc not set attempts to extract location data (if needed). The Integrator does not need to be initialized with weather data but for convinience can be. If skydata is not set then the optional parameter of get_sky_matrix() is required or an Exception will be raised.

  • loc ((float, float, int), optional) – location data given as lat, lon, mer with + west of prime meridian overrides location data in wea (but not in sunfield)

  • skyro (float, optional) – angle in degrees counter-clockwise to rotate sky (to correct model north, equivalent to clockwise rotation of scene) does not override rotation in SunField)

scene = None

raytraverse.scene.Scene

suns = None

raytraverse.sunsetter.SunSetter

sky = None

raytraverse.scene.SkyInfo

sunfield = None

raytraverse.lightfield.SunField

skyfield = None

raytraverse.lightfield.SCBinField

property skydata

sky data formatted as dx, dy, dz, dirnorm, diffhoriz

Getter

Returns this scene’s skydata

Setter

Sets this scene’s skydata from file path or

Type

np.array

format_skydata(dat)[source]

process dat argument as skydata

Parameters

dat (str, np.array) – This method takes either a file path or np.array. File path can point to a wea, epw, or .npy file. Loaded array must be one of the following: - 4 col: alt, az, dir, diff - 5 col: dx, dy, dz, dir, diff - 5 col: m, d, h, dir, diff’

Returns

dx, dy, dz, dir, diff

Return type

np.array

get_sky_mtx(skydata=None)[source]

generate sky, grnd and sun coefficients from sky data using perez

Parameters

skydata (str, np.array. optional) – if None, uses object skydata (will raise error if unassigned) see format_skydata() for argument specifics.

Returns

  • smtx (np.array) – shape (len(skydata), skyres**2) coefficients for each sky patch each row is a timestep, timesteps where a sun exists exclude the sun coefficient, otherwise the patch enclosing the sun position contains the energy of the sun

  • grnd (np.array) – shape (len(skydata),) coefficients for ground at each timestep

  • sun (np.array) – shape (len(skydata), 5) sun position (index 0,1,2) and coefficients for sun at each timestep assuming the true solid angle of the sun (index 3) and the weighted value for the sky patch (index 4).

  • si (np.array) – shape (len(skydata), 2) index for self.suns.suns pointing to correct proxy source (col 0) and sunbin for patch mapping (col 1)

  • daysteps (np.array) – shape (len(skydata),) boolean array masking timesteps when sun is below horizon

header()[source]

generate image header string

_hdr(res, vm, keymap, pi, suni, sun, pdirs, si, vstr, outf, interp, mask, skyv)[source]
hdr(pts, smtx, grnd=None, suns=None, suni=None, daysteps=None, vname='view', viewangle=180.0, res=400, interp=1)[source]
Parameters
  • pts (np.array) – points and view dirs shape (N, 6)

  • smtx (np.array) – shape (len(skydata), skyres**2) coefficients for each sky patch each row is a timestep, timesteps where a sun exists exclude the sun coefficient, otherwise the patch enclosing the sun position contains the energy of the sun

  • grnd (np.array) – shape (len(skydata),) coefficients for ground at each timestep

  • suns (np.array) – shape (len(skydata), 5) sun position (index 0,1,2) and coefficients for sun at each timestep assuming the true solid angle of the sun (index 3) and the weighted value for the sky patch (index 4).

  • suni (np.array) – shape (len(skydata), 2) index for self.suns.suns pointing to correct proxy source (col 0) and sunbin for patch mapping (col 1)

  • daysteps (np.array) – shape (len(skydata),) boolean array masking timesteps when sun is below horizon

  • vname (str) – view name for output file

  • viewangle (float, optional) – degree opening of view cone

  • res (int, optional) – image resolution

  • interp (int, optional) – number of nearest points to interpolate between. 1 will resemble voronoi patches

metric(pts, smtx, grnd=None, suns=None, suni=None, daysteps=None, metricfuncs=(<function illum>, ), **kwargs)[source]

calculate luminance based metrics for given sensors and skyvecs

Parameters
  • pts (np.array) – points and view dirs shape (N, 6)

  • smtx (np.array) – shape (len(skydata), skyres^2) coefficients for each sky patch each row is a timestep, timesteps where a sun exists exclude the sun coefficient, otherwise the patch enclosing the sun position contains the energy of the sun

  • grnd (np.array) – shape (len(skydata),) coefficients for ground at each timestep

  • suns (np.array) – shape (len(skydata), 5) sun position (index 0,1,2) and coefficients for sun at each timestep assuming the true solid angle of the sun (index 3) and the weighted value for the sky patch (index 4).

  • suni (np.array) – shape (len(skydata), 2) index for self.suns.suns pointing to correct proxy source (col 0) and sunbin for patch mapping (col 1)

  • daysteps (np.array) – shape (len(skydata),) boolean array masking timesteps when sun is below horizon

  • metricfuncs (tuple) – list of metric functions to apply, with the call signature: f(view, rays, omegas, lum, kwargs)

Returns

metrics – metrics at each point/direction and sky weighting axes ordered as: (view, points, skys, metrics) an additional column on the final axis is 0 when only the skyfield is used, 1 when sun reflections exists and 2 when a view to the sun also exists.

Return type

np.array