summaryrefslogtreecommitdiff
path: root/event.py
diff options
context:
space:
mode:
Diffstat (limited to 'event.py')
-rw-r--r--event.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/event.py b/event.py
index 657f414..633fe26 100644
--- a/event.py
+++ b/event.py
@@ -4,14 +4,10 @@ from chroma.sample import uniform_sphere
class Photons(object):
def __init__(self, positions, directions, wavelengths, polarizations=None, times=None, last_hit_triangles=None, histories=None):
- self.positions = positions
-
nphotons = len(positions)
- assert len(directions) == nphotons
+ self.positions = positions
self.directions = directions
-
- assert len(wavelengths) == nphotons
self.wavelengths = wavelengths
if polarizations is not None:
@@ -24,9 +20,21 @@ class Photons(object):
polarizations /= np.tile(np.apply_along_axis(np.linalg.norm,1,polarizations),[3,1]).transpose()
self.polarizations = np.asarray(polarizations, order='C')
- self.times = times
- self.last_hit_triangles = last_hit_triangles
- self.histories = histories
+ if times is None:
+ self.times = np.zeros(nphotons, dtype=np.float32)
+ else:
+ self.times = times
+
+ if last_hit_triangles is None:
+ self.last_hit_triangles = np.empty(nphotons, dtype=np.int32)
+ self.last_hit_triangles.fill(-1)
+ else:
+ self.last_hit_triangles = last_hit_triangles
+
+ if histories is None:
+ self.histories = np.zeros(nphotons, dtype=np.uint32)
+ else:
+ self.histories = histories
def concatenate_photons(photons):
'''Merge a list of Photons objects into one long list of photons'''