-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Jupyter Notebooks as tutorials:
- new pictures in doc - plantGL visualization feature - adds s2v and s5 (there were lost ?) - new examples (mainly for debugging notebooks) - debugging src
- Loading branch information
Showing
44 changed files
with
7,493 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from lightvegemanager.tool import LightVegeManager | ||
import openalea.plantgl.all as pgl | ||
|
||
print("--- START") | ||
|
||
# one triangle as a geometric element | ||
triangle_vertices_1 = [[(0.,0.,0.), (1.,0.,0.), (1.,1.,1.)]] | ||
triangle_vertices_2 = [[(0.,2.,0.), (1.,2.,0.), (1.,3.,1.)]] | ||
stems = [(0,1)] | ||
geometry = { | ||
"scenes" : [triangle_vertices_1, triangle_vertices_2], | ||
"stems id" : stems | ||
} | ||
|
||
# surfacic lighting with CARIBU | ||
lighting = LightVegeManager(lightmodel="caribu") | ||
|
||
# build the scene | ||
lighting.build(geometry=geometry) | ||
|
||
# compute lighting | ||
energy = 500 | ||
hour = 15 | ||
day = 264 # 21st september | ||
lighting.run(energy, hour, day) | ||
|
||
# output | ||
print(lighting.elements_outputs) | ||
|
||
# visualisation | ||
pglscene = lighting.plantGL_light() | ||
pgl.Viewer.display(pglscene) | ||
|
||
print("--- END") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# import the class tool | ||
from lightvegemanager.tool import LightVegeManager | ||
from lightvegemanager.trianglesmesh import random_triangle_generator | ||
import openalea.plantgl.all as pgl | ||
import random | ||
|
||
spheres = [] | ||
|
||
for i in range(255): | ||
x, y, z = [random.choice([-1, 1]) * random.randrange(0, int(255/2)) for i in range(3)] | ||
m = pgl.Material(ambient=(x+int(255/2), y+int(255/2), z+int(255/2)), shininess=0.1, diffuse=1) | ||
spheres.append(pgl.Shape(pgl.Translated(x, y, z, pgl.Sphere(random.randrange(1, 20), 20, 20)), m)) | ||
|
||
nb_triangles = 500 | ||
spheresize = (10., 2.) | ||
triangles = [] | ||
for i in range(nb_triangles): | ||
triangles.append(random_triangle_generator(spheresize=spheresize)) | ||
|
||
# initialize the instance | ||
lighting = LightVegeManager(lightmodel="caribu") | ||
|
||
# build the scene | ||
lighting.build(geometry=triangles) | ||
|
||
# compute the lighting | ||
energy = 500. | ||
hour = 15 | ||
day = 264 | ||
lighting.run(energy=energy, hour=hour, day=day) | ||
|
||
pglscene = lighting.plantGL_light() | ||
pgl.Viewer.display(pglscene) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import os | ||
from lightvegemanager.tool import LightVegeManager | ||
from openalea.plantgl.all import Scene, Viewer | ||
|
||
fet_fgeom = os.path.join(os.path.abspath(""), "data", "Fet-LD-F2.bgeom") | ||
luz_fgeom = os.path.join(os.path.abspath(""), "data", "LD-F1.bgeom") | ||
bgeom_files = [fet_fgeom, luz_fgeom] | ||
|
||
# setup environment | ||
environment = {} | ||
environment["coordinates"] = [48.8 ,2.3 ,1] # latitude, longitude, timezone | ||
|
||
# we compute only sun light in a finite scene | ||
environment["diffus"] = False | ||
environment["direct"] = True | ||
environment["reflected"] = False | ||
environment["infinite"] = False | ||
|
||
# CARIBU parameters | ||
caribu_parameters = {} | ||
caribu_parameters["sun algo"] = "caribu" | ||
caribu_parameters["caribu opt"] = {} | ||
caribu_parameters["caribu opt"]["par"] = (0.10, 0.05) | ||
|
||
# inputs values for lighting | ||
energy=500 | ||
day=264 | ||
hour=15 | ||
|
||
# scene generation parameters | ||
nplants = 10 | ||
plant_density=130 | ||
var_plant_position=110 | ||
|
||
from lightvegemanager.trianglesmesh import create_heterogeneous_canopy | ||
|
||
# Initializing the tool | ||
lighting = LightVegeManager(lightmodel="caribu", | ||
environment=environment, | ||
lightmodel_parameters=caribu_parameters) | ||
|
||
# generate random canopy from plant examples | ||
if not isinstance(bgeom_files, list): bgeom_files = [bgeom_files] | ||
scenes = [] | ||
for f in bgeom_files : | ||
plant_scene = Scene() | ||
plant_scene.read(f, 'BGEOM') | ||
|
||
# multiply a plant with variations | ||
canopy, domain = create_heterogeneous_canopy(plant_scene, | ||
nplants=nplants, | ||
plant_density=plant_density, | ||
var_plant_position=var_plant_position) | ||
|
||
scenes.append(canopy) | ||
|
||
# build the scene | ||
geometry = {"scenes" : scenes } | ||
|
||
lighting.build(geometry) | ||
|
||
# compute lighting | ||
lighting.run(energy=energy, hour=hour, day=day) | ||
|
||
s = lighting.plantGL_light(printtriangles=True, printvoxels=False) | ||
|
||
Viewer.display(s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from lightvegemanager.tool import LightVegeManager | ||
from lightvegemanager.trianglesmesh import random_triangle_generator | ||
from openalea.plantgl.all import Viewer | ||
|
||
# grid dimensions | ||
dxyz = [1.] * 3 | ||
nxyz = [5, 5, 7] | ||
orig = [0.] * 3 | ||
|
||
# random triangles | ||
nb_triangles = 50 | ||
spheresize = (1., 0.3) # vertices of triangles are the sphere surface | ||
triangles = [] | ||
for i in range(nb_triangles) : | ||
triangles.append(random_triangle_generator(worldsize=(0., 5.), spheresize=spheresize)) | ||
|
||
caribu_args = { "sensors" : ["grid", dxyz, nxyz, orig] } | ||
|
||
lighting = LightVegeManager(lightmodel="caribu", lightmodel_parameters=caribu_args, environment={"infinite":True}) | ||
lighting.build(geometry={"scenes" : [triangles]}) | ||
|
||
energy = 500. | ||
hour = 15 | ||
day = 264 | ||
lighting.run(energy=energy, hour=hour, day=day) | ||
|
||
s = lighting.plantGL_sensors(light=True) | ||
Viewer.display(s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from lightvegemanager.tool import LightVegeManager | ||
from lightvegemanager.trianglesmesh import random_triangle_generator | ||
import numpy | ||
|
||
# grid dimensions | ||
dxyz = [1.] * 3 | ||
nxyz = [7, 7, 7] | ||
orig = [-1., -1., 0.] | ||
|
||
spheresize = (1., 0.3) # vertices of triangles are the sphere surface | ||
worldsize = (0., 5.) | ||
|
||
nb_triangles = 10 | ||
triangles1 = [random_triangle_generator(worldsize=worldsize, spheresize=spheresize) for i in range(nb_triangles)] | ||
|
||
nb_triangles = 9 | ||
triangles2 = [random_triangle_generator(worldsize=worldsize, spheresize=spheresize) for i in range(nb_triangles)] | ||
|
||
nb_triangles = 8 | ||
triangles3 = [random_triangle_generator(worldsize=worldsize, spheresize=spheresize) for i in range(nb_triangles)] | ||
|
||
scene = {0: triangles1, 1: triangles2, 2: triangles3} | ||
|
||
|
||
ratp_parameters = { "voxel size" : dxyz, | ||
"origin" : orig, | ||
"number voxels" : nxyz, | ||
"full grid" : True} | ||
|
||
lighting = LightVegeManager(lightmodel="ratp", lightmodel_parameters=ratp_parameters) | ||
lighting.build(geometry={"scenes" : [scene] }) | ||
|
||
energy = 500. | ||
hour = 15 | ||
day = 264 | ||
lighting.run(energy=energy, hour=hour, day=day) | ||
|
||
m_lais = numpy.zeros([1] + nxyz) | ||
for row in lighting.voxels_outputs.itertuples(): | ||
m_lais[int(row.VegetationType)-1][row.Nz-1][row.Nx-1][row.Ny-1] = row.Area | ||
res_abs_i, res_trans = lighting.to_l_egume(m_lais=m_lais) | ||
|
||
print(res_abs_i[0]) | ||
print(res_trans) |
Oops, something went wrong.