MCPcopy Create free account
hub / github.com/danieljfarrell/pvtrace / Light

Class Light

pvtrace/light/light.py:61–161  ·  view source on GitHub ↗

Generic light source object which calls delegate functions to help generate rays that sample statistical distributions. Examples -------- Light of 555nm from the origin or the light's node along direction (0, 0, 1):: Light() Light with isotropic direc

Source from the content-addressed store, hash-verified

59
60
61class Light(object):
62 """ Generic light source object which calls delegate functions to help generate rays that
63 sample statistical distributions.
64
65 Examples
66 --------
67
68 Light of 555nm from the origin or the light's node along direction (0, 0, 1)::
69
70 Light()
71
72 Light with isotropic direction::
73
74 from pvtrace.material.utils import isotropic
75 Light(direction=isotropic)
76
77 Light emitted within solid-angle of half-angle pi/8 rads::
78
79 import functools
80 from pvtrace.material.utils import cone
81 Light(direction=functools.partial(cone, np.pi/8))
82
83 To generate a Lambertian source::
84
85 import functools
86 from pvtrace.material.utils import lambertian
87 Light(direction=lambertian)
88
89 To generate a square spatial distribution in the xy-plane with length and width
90 of one unit::
91
92 import functools
93 Light(position=functools.partial(rectangular_mask, 1, 1)
94
95 To generate a circular spatial distribution in the xy-plane with radius one::
96
97 import functools
98 Light(position=functools.partial(circular_mask, 1)
99
100 Any combination of spatial and divergence delegates can be used to generate the
101 required distribution of rays.
102 """
103
104 def __init__(self, wavelength=None, position=None, direction=None, name="Light"):
105 """
106 Returns a light source emitting along the positive z direction of the coordinate system
107 the light is attached to. Delegate functions can be used modify the wavelength, position
108 and direction of the emitted ray.
109
110 Parameters
111 ----------
112 wavelength: callable or None
113 A callable which returns the ray's wavelength. The callable should
114 have the following signature `func() -> float` which returns the
115 wavelength in nanometers.
116 position: callable or None
117 A callable which returns the ray's position. The callable should
118 have the following signature `func() -> (float, float, float)` which

Callers 5

_make_sceneMethod · 0.90
hello_world.pyFile · 0.85
hello_box.pyFile · 0.85
cylinder.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected