Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
exclude_lines =
pragma: no cover
omit =
*__init__*
*tests*
show_missing = True

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[![Building Package](https://github.com/openalea-incubator/spice/actions/workflows/conda-package-build.yml/badge.svg)](https://github.com/openalea-incubator/spice/actions/workflows/conda-package-build.yml)
[![Python Version](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![License: CeCILL-C](https://img.shields.io/badge/License--CeCILL-C-blue)](https://cecill.info/licences/Licence_CeCILL_V2-en.html)
[![Anaconda-Server Badge](https://anaconda.org/openalea3/openalea.spice/badges/version.svg)](https://anaconda.org/openalea3/openalea.spice)
Expand Down
1 change: 1 addition & 0 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ test:
- openalea.spice.simulator
requires:
- openalea.plantgl
- openalea.lpy
- pytest
source_files:
- tests/**
Expand Down
8 changes: 4 additions & 4 deletions examples/python/obj-scene/main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from datetime import datetime
import random
import sys
from datetime import datetime
from pathlib import Path

from openalea.spice.libspice_core import *
from openalea.spice import *

if __name__ == "__main__":
n_samples = 12
Expand Down Expand Up @@ -36,7 +35,8 @@
print("Creating Scene..")
scene = Scene()
scene.loadModel(str(Path.home() / "models/Sponza/sponza.obj"))
scene.addPointLight(Vec3(0, -50, 0), 500, Vec3(1, 1, 1))
#scene.addPointLight(Vec3(0, -50, 0), 500, Vec3(1, 1, 1))
scene.addLight()
scene.build()

print("Done!")
Expand Down
2 changes: 1 addition & 1 deletion src/openalea/spice/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def read_file(self, filepath: Path):

Parameters
----------
filepath: str
filepath: Path
Name of the configuration file.

"""
Expand Down
2 changes: 1 addition & 1 deletion src/openalea/spice/energy/calculate_energy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

# Objective of this module is counting the number of photon on plant/sensor
# Resultat is located in this directory: ./results
# Result is located in this directory: ./results


def write_sensor_energy(n_sim, n_calibration, sensor_list, bands_spectre, filename):
Expand Down
10 changes: 5 additions & 5 deletions src/openalea/spice/energy/correct_energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ def get_correct_energy_coeff(
divided_spectral_range: range
The section of the base spectral range used to run the simulation
spec_file: str
The link to the file which contains the informations of the
The link to the file which contains the information of the
heterogeneity of the spectrum

Returns
-------
integrals: array
The list of the coefficents of energy's correction
The list of the coefficients of energy's correction

"""

Expand Down Expand Up @@ -161,7 +161,7 @@ def get_points_calibration(
return points_calibration


def get_calibaration_coefficient(energies, correction_ratios, points_calibration):
def get_calibration_coefficient(energies, correction_ratios, points_calibration):
"""
Calculate the coefficients used to calibrate the result of simulation

Expand Down Expand Up @@ -206,11 +206,11 @@ def get_calibaration_coefficient(energies, correction_ratios, points_calibration
return coeff_calibration


def calibrate_captor_energy(
def calibrate_sensor_energy(
energies, correction_ratios, points_calibration, coeffs_calibration
):
"""
Calibrate the captor energy from photons to Mmol / m2 / s
Calibrate the sensor energy from photons to Mmol / m2 / s

Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion src/openalea/spice/loader/load_plant.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# Data is located in this directory: ./assets


def add_lpy_file_to_scene(scene, filename, t, tr2shmap, anchor, scale_factor):
def add_lpy_file_to_scene(scene, filename, t, tr2shmap, anchor, scale_factor=1):
"""
Adds the lpy mesh to the photonmapping scene.

Expand Down
141 changes: 71 additions & 70 deletions src/openalea/spice/loader/load_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,83 +120,85 @@ def initVirtualDiskSensor(self, nor=(0, 0, 0), r=0, sensor_id=0):
The id of sensor

"""
def createVirtualDisk(self):
"""
Create geometry of circular sensor

Returns
-------
vertices: array
The vertices of sensor's geometry
normals: array
The normal vectors of each vertices in sensor's geometry
triangles: array
The triangles of sensor's geometry

"""
vertices = []
normals = []
triangles = []

val = 3.14285 / 180
deltaAngle = 10
triangleCount = 0

vertices.append((self.xSite, self.ySite, self.zSite))
normals.append((self.xNormal, self.yNormal, self.zNormal))

if self.zNormal == 1:
x1 = self.radius * cos(0)
y1 = self.radius * sin(0)
z1 = 0
else:
x1 = self.radius * cos(0)
y1 = 0
z1 = self.radius * sin(0)

vertices.append((x1 + self.xSite, y1 + self.ySite, z1 + self.zSite))
normals.append((self.xNormal, self.yNormal, self.zNormal))

i = 0
while i < 360:
if self.zNormal == 1:
x2 = self.radius * cos((i + deltaAngle) * val)
y2 = self.radius * sin((i + deltaAngle) * val)
z2 = 0
else:
x2 = self.radius * cos((i + deltaAngle) * val)
y2 = 0
z2 = self.radius * sin((i + deltaAngle) * val)

vertices.append((x2 + self.xSite, y2 + self.ySite, z2 + self.zSite))
normals.append((self.xNormal, self.yNormal, self.zNormal))
triangles.append((triangleCount + 1, triangleCount + 2, 0))

triangleCount += 1
i += deltaAngle

sensor_shape = Shape(
TriangleSet(vertices, triangles, normals),
Material(
name="Sensor",
ambient=Color3(0),
specular=Color3(0),
shininess=1,
transparency=0,
),
)

self.shape = sensor_shape

self.xNormal = nor[0]
self.yNormal = nor[1]
self.zNormal = nor[2]
self.radius = r
self.sensor_id = sensor_id

self.createVirtualDisk()
createVirtualDisk()

return self

def createVirtualDisk(self):
"""
Create geometry of circular sensor

Returns
-------
vertices: array
The vertices of sensor's geometry
normals: array
The normal vectors of each vertices in sensor's geometry
triangles: array
The triangles of sensor's geometry

"""
vertices = []
normals = []
triangles = []

val = 3.14285 / 180
deltaAngle = 10
triangleCount = 0

vertices.append((self.xSite, self.ySite, self.zSite))
normals.append((self.xNormal, self.yNormal, self.zNormal))

if self.zNormal == 1:
x1 = self.radius * cos(0)
y1 = self.radius * sin(0)
z1 = 0
else:
x1 = self.radius * cos(0)
y1 = 0
z1 = self.radius * sin(0)

vertices.append((x1 + self.xSite, y1 + self.ySite, z1 + self.zSite))
normals.append((self.xNormal, self.yNormal, self.zNormal))

i = 0
while i < 360:
if self.zNormal == 1:
x2 = self.radius * cos((i + deltaAngle) * val)
y2 = self.radius * sin((i + deltaAngle) * val)
z2 = 0
else:
x2 = self.radius * cos((i + deltaAngle) * val)
y2 = 0
z2 = self.radius * sin((i + deltaAngle) * val)

vertices.append((x2 + self.xSite, y2 + self.ySite, z2 + self.zSite))
normals.append((self.xNormal, self.yNormal, self.zNormal))
triangles.append((triangleCount + 1, triangleCount + 2, 0))

triangleCount += 1
i += deltaAngle

sensor_shape = Shape(
TriangleSet(vertices, triangles, normals),
Material(
name="Sensor",
ambient=Color3(0),
specular=Color3(0),
shininess=1,
transparency=0,
),
)

self.shape = sensor_shape

def equal(self, xSite, ySite, zSite):
"""
Expand All @@ -213,8 +215,7 @@ def equal(self, xSite, ySite, zSite):

Returns
-------
True if equal
False if not equal
True if equal else False

"""

Expand Down Expand Up @@ -252,7 +253,7 @@ def getOpticalProperties(self):
specular: float
The specular
trans: float
The tranparency
The transparency
roughness: float
The roughness

Expand Down
10 changes: 8 additions & 2 deletions src/openalea/spice/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def calculateCalibrationCoefficient(
points_calibration_file,
self.configuration.DIVIDED_SPECTRAL_RANGE,
)
self.coeffs_calibration = correct_energy.get_calibaration_coefficient(
self.coeffs_calibration = correct_energy.get_calibration_coefficient(
self.N_sim_virtual_sensor, self.integrals, self.points_calibration
)
return True
Expand Down Expand Up @@ -626,6 +626,7 @@ def visualizeResults(self, mode="ipython", wavelength_index=0, colormap="jet"):

if mode == "ipython":
pgl.Viewer.display(self.scene_pgl)
return None
elif mode == "oawidgets":
from oawidgets.plantgl import PlantGL
import k3d
Expand All @@ -650,6 +651,7 @@ def visualizeResults(self, mode="ipython", wavelength_index=0, colormap="jet"):
return plot
else:
pgl.Viewer.display(self.scene_pgl)
return None

def get_photons_per_triangles(self):
"""
Expand Down Expand Up @@ -770,7 +772,7 @@ def r():
ph_sc.add(sh)
ph_sc.merge(self.scene_pgl)
pgl.Viewer.display(ph_sc)

return None
elif mode == "oawidgets":
from oawidgets.plantgl import PlantGL
import k3d
Expand Down Expand Up @@ -1143,6 +1145,8 @@ def setupRender(self, lookfrom=Vec3(0, 0, 0), lookat=Vec3(0, 0, 0), vfov=50.0):
The position of the camera.
lookat: Vec3
The point where the camera is looking at
vfov: float
The vertical field of view of the camera

"""
self.configuration.RENDERING = True
Expand Down Expand Up @@ -1226,6 +1230,8 @@ def initCameraRender(lookfrom=Vec3(0, 0, 0), lookat=Vec3(0, 0, 0), vfov=50.0):
The position of the camera.
lookat: Vec3
The point where the camera is looking at
vfov: float
The vertical field of view of the camera

Returns
-------
Expand Down
File renamed without changes.
Loading
Loading