diff options
author | Anthony LaTorre <tlatorre9@gmail.com> | 2011-08-26 23:01:27 -0400 |
---|---|---|
committer | Anthony LaTorre <tlatorre9@gmail.com> | 2011-08-26 23:01:27 -0400 |
commit | 1943931e95711f9676b5585f901c5fff25b7d759 (patch) | |
tree | 9e0d66517b4b30fbbeb32a54f8cafc8bf5bea31d /event.py | |
parent | dd4085d7ca49bbde2826192716c1aa7c69b4bcc6 (diff) | |
download | chroma-1943931e95711f9676b5585f901c5fff25b7d759.tar.gz chroma-1943931e95711f9676b5585f901c5fff25b7d759.tar.bz2 chroma-1943931e95711f9676b5585f901c5fff25b7d759.zip |
photon object initializes any arguments not passed when initialized. camera.EventViewer uses new fileio.root.RootReader class.
Diffstat (limited to 'event.py')
-rw-r--r-- | event.py | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -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''' |