photonmap.Simulator
Classes
A class which contains the result of simulation. |
|
A class which include all the tools of simulation. |
Module Contents
- class photonmap.Simulator.SimulationResult(simulator)[source]
A class which contains the result of simulation.
Attributes
- N_sim_virtual_captor: dict
Number of received photons on each captor
- N_sim_face_captor: dict
Number of received photons on each organ of plant
- N_mes_virtual_captor: dict
The energies after the calibration on each captor
- N_mes_face_captor: dict
The energies after the calibration on each organ of plant
- nb_photons: int
The number of photons in simulation
- divided_spectral_range: array
The list of spectral ranges divided from the base spectral range.
- list_virtual_captor: array
The list of virtual captor in simulation
- class photonmap.Simulator.Simulator[source]
A class which include all the tools of simulation.
Attributes
- nb_photons: int
The number of photons in simulation
- maximum_depth: int
The maximum number of times that the light bounces in the scene
- scale_factor: float
The size of geometries. The vertices of geometries is recalculated by dividing their coordinates by this value
- t_min: float
The minimum distance between the point of intersection and the origin of the light ray
- nb_thread: int
The number of threads on the CPU used to calculate in parallel. This value is between 0 and the number of cores of your CPU.
- is_backface_culling: bool
Define which mode of intersection is chosen: intersect only with the front face or intersect with both faces.
- base_spectral_range: dict
The base spectral range which includes all the other spectral ranges
- divided_spectral_range: array
The list of spectral ranges divided from the base spectral range.
- rendering: bool
Set to True to render the output images
- N_sim_virtual_captor: dict
Number of received photons on each captor
- N_sim_face_captor: dict
Number of received photons on each organ of plant
- spectrum_file: str
The link to the file which contains the informations of the heterogeneity of the spectrum
- points_calibration_file: str
The link to the file which contains the informations of the captors used to calibrate the final result
- list_virtual_captor: array
The list of virtual captor in simulation
- pgl_scene: openalea.plantgl.scenegraph.Scene
The plantgl scene object used to save the meshs of environment
- plantPos: Vec3
The position of the plant
- po_dir: str
The link to the folder which contains the optical properties of the room
- addEnvToScene(sh)[source]
Add a environment’s object to scene
Parameters
- shplantgl.Shape
The mesh of object
Returns
The object is added to the scene
- addFaceCaptorToScene(shape, position, scale_factor)[source]
Add a face captor object to scene
Parameters
- shape: Shape
The geometry and material of captor
- positiontuple(int,int,int)
The position of captor
- scale_factor: int
The size of geometries. The vertices of geometries is recalculated by dividing their coordinates by this value
Returns
The face captor is added to the scene
- addVirtualCaptorToScene(shape, position, scale_factor)[source]
Add a virtual captor object to scene
Parameters
- shape: Shape
The geometry and material of captor
- positiontuple(int,int,int)
The position of captor
- scale_factor: int
The size of geometries. The vertices of geometries is recalculated by dividing their coordinates by this value
Returns
The virtual captor is added to the scene
- addVirtualDiskCaptorToScene(pos, normal, r, captor_id)[source]
Add a virtual disk shaped captor object to scene
Parameters
- postuple(float,float,float)
The position of captor
- normal: tuple(float,float,float)
The vector normal of captor
- r: float
The radius of captor
- captor_id: int
The id of captor
Returns
The disk shaped captor is added to the scene
- run()[source]
Run the simulation with the configurations which is determined
Returns
The number of received photons on each captor and organs of plant is saved into the files located in folde ./results
- calculateCalibrationCoefficient(spectrum_file='', points_calibration_file='')[source]
Calculate the coefficients which is used to calibrate the final result of simulation with the captors
Parameters
- spectrum_file: str
The link to the file which contains the informations of the heterogeneity of the spectrum
- points_calibration_file: str
The link to the file which contains the informations of the captors used to calibrate the final result
- calibrateResults(spectrum_file='', points_calibration_file='')[source]
Calibrate the final result of simulation
Parameters
- spectrum_file: str
The link to the file which contains the informations of the heterogeneity of the spectrum
- points_calibration_file: str
The link to the file which contains the informations of the captors used to calibrate the final result
- visualiserSimulationScene(mode='ipython')[source]
Visualize the scene of simulation with the tools of OpenAlea To run this function, it has to run these command first: – ipython – %gui qt5
Parameters
- mode: str
This variable define the mode used to visualize the scene. There are the supported modes: ipython, pgljupyter
Returns
A rendered scene in 3D
- test_t_min(nb_photons, start_t, loop, is_only_lamp=False)[source]
Test the simulation with multiple values of Tmin to avoid the problem of auto-intersection
Parameters
- nb_photons: int
The total number of photons is shooting from the light in the simulation
- start_t: float
The first (smallest) value of Tmin used to run the test
- loop: int
The number of iteration. At each iteration, the current value Tmin is multiply with 10, then run the simulation
- is_only_lamp: bool
If True, run the test with only the lamps and captors, If False, run the test with all the objects in scene
Returns
A graph is generated to show the connection between the Tmin and the results of simulation
- initSimulationScene(scene, current_band, moyenne_wavelength, is_only_lamp=False)[source]
Setup all the necessary objects (environment, captor, plant) in the simulation
Parameters
- scene: libphotonmap_core.Scene
The object which contains all the object in the scene of simulation
- current_band: dict
Current divided spectral range where the simulation is running
- moyenne_wavelength: Vec3
The average wavelength of spectral range used to determine the color of the light
- is_only_lamp: bool
if True, only the lamps and captors is added to the scene, if False, all the objects is added.
Returns
- scene: libphotonmap_core.Scene
The object which contains all the object in the scene of simulation
- has_virtual_captor: bool
Return true if the scene has the captors
- captor_triangle_dict: dict
Dictionary of the triangles of the captors. Using to counting the number of photons received in each captor
- has_plant: bool
Return true if the scene has the model of plant
- tr2shmap: dict
Dictionary of the triangles of the plant. Using to counting the number of photons received in each organ of plant
- render(integrator, scene, w, sampler)[source]
Visualize the photon map of the simulation in the scene
Parameters
- integrator: libphotonmap_core.PhotonMapping
The object which handles all the simulation of photon mapping
- scene: libphotonmap_core.Scene
The object which contains all the object in the scene of simulation
- w: Vec3
The average wavelength of spectral range used to determine the color of the light
- sampler: libphotonmap_core.Sampler
The generator of the random number
Returns
Rendered images is saved into the folder ./result
- addEnvFromFile(room_file: str, po_dir: str, flip_normal=False)[source]
Setup the room/environment of the simulation from file.
Parameters
- room_file: str
The link to the file which contains the geometries of the room
- po_dir: str
The link to the folder which contains the optical properties of the room
- flip_normal: bool
Determine the direction of the vector normal of triangle.
- setupRender(lookfrom=Vec3(0, 0, 0), lookat=Vec3(0, 0, 0))[source]
Enable the capacity to render/visulize the photon map in the scene
Parameters
- lookfrom: Vec3
The position of the camera.
- lookat: Vec3
The point where the camera is looking at
- addVirtualDiskCaptorsFromFile(captor_file: str)[source]
Setup the captors in the simulation. Enable the capacity to run the simulation with the circle captors
Parameters
- captor_file: str
The link to the file which contains the informations of the captors in the simulation
- addFaceCaptorsFromLpyFile(plant_file: str, plant_pos=Vec3(0, 0, 0), derivationLength=None)[source]
Setup a plant in the simulation. Enable the capacity to run the simulation with a model of plant
Parameters
- plant_file: str
The link to the file of the model of plant. (currently only support .lpy file)
- plantPos: Vec3
The position of the plant
- derivationLength: int
The number of iteration to interpret the plant
- initCameraRender(lookfrom=Vec3(0, 0, 0), lookat=Vec3(0, 0, 0))[source]
Init the camera to render image. Calling by the function setupRender
Parameters
- lookfrom: Vec3
The position of the camera.
- lookat: Vec3
The point where the camera is looking at
Returns
- camera: libphotonmap_core.Camera
An object with all the informations of camera