raytraverse.sampler¶
Sampler¶
-
class
raytraverse.sampler.
Sampler
(scene, fdres=9, srcn=1, accuracy=1.0, idres=4, stype='generic', srcdef=None, plotp=False, bands=1, engine_args='', nproc=None, **kwargs)[source]¶ Bases:
object
base sampling class
To implement a proper-subclass an engine attribute must be set to a renderer instance prior to calling Sampler.__init__. Also, the method sample must be overriden to properly set up arguments for the renderer.call
- Parameters
scene (raytraverse.scene.Scene) – scene class containing geometry, location and analysis plane
fdres (int, optional) – final directional resolution given as log2(res)
srcn (int, optional) – number of sources return per vector by run
accuracy (float, optional) – parameter to set threshold at sampling level relative to final level threshold (smaller number will increase sampling, default is 1.0)
idres (int, optional) – initial direction resolution (as log2(res))
stype (str, optional) – sampler type (prefixes output files)
srcdef (str, optional) – path or string with source definition to add to scene
plotp (bool, optional) – show probability distribution plots at each level (first point only)
bands (int, optional) – number of spectral bands returned by the engine
engine_args (str, optional) – command line arguments used to initialize engine
nproc (int, optional) – number of processors to give to the engine, if None, uses os.cpu_count()
-
engine
= None¶
-
bands
= None¶ number of spectral bands / channels returned by renderer based on given renderopts (user ensures these agree).
- Type
int
-
samplemap
= None¶ mapper to use for sampling
- Type
func
-
srcn
= None¶ number of sources return per vector by run
- Type
int
-
idres
= None¶ initial direction resolution (as log2(res))
- Type
int
-
weights
= None¶ holds weights for self.draw
- Type
np.array
-
stype
= None¶ sampler type
- Type
str
-
property
compiledscene
¶
-
property
idx
¶ index of next level to sample
- Type
int
-
property
levels
¶ sampling scheme
- Getter
Returns the sampling scheme
- Setter
Set the sampling scheme from (ptres, fdres, skres)
- Type
np.array
-
property
scene
¶ scene information
- Getter
Returns this sampler’s scene
- Setter
Set this sampler’s scene and create octree with source desc
- Type
-
sample_idx
(pdraws)[source]¶ generate samples vectors from flat draw indices
- Parameters
pdraws (np.array) – flat index positions of samples to generate
- Returns
si (np.array) – index array of draws matching samps.shape
vecs (np.array) – sample vectors
-
dump_vecs
(vecs, si=None)[source]¶ save vectors to file
- Parameters
vecs (np.array) – ray directions to write
si (np.array, optional) – sample indices
-
draw
()[source]¶ draw samples based on detail calculated from weights detail is calculated across direction only as it is the most precise dimension
- Returns
pdraws – index array of flattened samples chosen to sample at next level
- Return type
np.array
SCBinSampler¶
-
class
raytraverse.sampler.
SCBinSampler
(scene, accuracy=1, rcopts='-ab 7 -ad 60000 -as 30000 -lw 1e-7', **kwargs)[source]¶ Bases:
raytraverse.sampler.sampler.Sampler
sample contributions from the sky hemisphere according to a square grid transformed by shirley-chiu mapping using rcontrib.
- Parameters
scene (raytraverse.scene.Scene) – scene class containing geometry, location and analysis plane
srcn (int, optional) – side of square sky resolution
SunSampler¶
-
class
raytraverse.sampler.
SunSampler
(scene, suns, plotp=False, **kwargs)[source]¶ Bases:
object
factory class for SingleSunSamplers.
- Parameters
scene (raytraverse.scene.Scene) – scene class containing geometry, location and analysis plane
suns (raytraverse.sunsetter.SunSetter) – sun class containing sun locations.
-
viewsampler
= None¶ raytraverse.sampler.SunViewSampler
-
sampleargs
= None¶ sampling arguments for SingleSunSampler
- Type
dict
-
reflsampler
= None¶ raytraverse.sampler.SingleSunSampler
SingleSunSampler¶
-
class
raytraverse.sampler.
SingleSunSampler
(scene, suns, sidx, speclevel=9, fdres=10, accuracy=1, rcopts='-ab 6 -ad 3000 -as 1500 -st 0 -ss 16 -aa .1', keepamb=False, ambcache=True, **kwargs)[source]¶ Bases:
raytraverse.sampler.sampler.Sampler
sample contributions from direct suns.
- Parameters
scene (raytraverse.scene.Scene) – scene class containing geometry, location and analysis plane
suns (raytraverse.sunsetter.SunSetter) – sun class containing sun locations.
sidx (int) – sun index to sample
speclevel (int, optional) – at this sampling level, pdf is made from brightness of sky sampling rather than progressive variance to look for fine scale specular highlights, this should be atleast 1 level from the end and the resolution of this level should be smaller than the size of the source
keepamb (bool, optional) – whether to keep ambient files after run, if kept, a successive call will load these ambient files, so care must be taken to not change any parameters
ambcache (bool, optional) – whether the rcopts indicate that the calculation will use ambient caching (and thus should write an -af file argument to the engine)
-
slimit
= None¶ controls sampling limit in case of limited contribution
- Type
float
-
specidx
= None¶ index of level at which brightness sampling occurs
- Type
int
-
sunpos
= None¶ sun position x,y,z
- Type
np.array
SunViewSampler¶
-
class
raytraverse.sampler.
SunViewSampler
(scene, suns, **kwargs)[source]¶ Bases:
raytraverse.sampler.sampler.Sampler
sample view rays to direct suns.
here idres and fdres are sampled on a per sun basis for a view centered on each sun direction with a view angle of .533 degrees (hardcoded in sunmapper class).
- Parameters
scene (raytraverse.scene.Scene) – scene class containing geometry, location and analysis plane
suns (raytraverse.sunsetter.SunSetter) – sun class containing sun locations.
loadsrc (bool) – include suns.rad in base scene initialization. if False, self.engine.load_source must be invoked before call.
-
property
levels
¶ sampling scheme
- Getter
Returns the sampling scheme
- Setter
Set the sampling scheme from (ptres, fdres, skres)
- Type
np.array