From 1943931e95711f9676b5585f901c5fff25b7d759 Mon Sep 17 00:00:00 2001 From: Anthony LaTorre Date: Fri, 26 Aug 2011 23:01:27 -0400 Subject: photon object initializes any arguments not passed when initialized. camera.EventViewer uses new fileio.root.RootReader class. --- event.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'event.py') 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''' -- cgit