Exemple #1
0
 def test_angle_between(self):
     v1 = (1, 0, 0)
     v2 = (0, 1, 0)
     v3 = (-1, 0, 0)
     self.assertAlmostEqual(0, angle_between(v1, v1))
     self.assertAlmostEqual(np.pi/2, angle_between(v1, v2))
     self.assertAlmostEqual(np.pi, angle_between(v1, v3))
Exemple #2
0
    def add_mc_tracks(self, blob):
        """Find MC particles and add them to the objects to render."""
        try:
            track_ins = blob['TrackIns']
        except KeyError:
            return

        highest_energetic_track = max(track_ins, key=lambda t: t.E)
        highest_energy = highest_energetic_track.E
        for track in track_ins:
            if track.particle_type in (0, 22):
                # skip unknowns, photons
                continue
            if angle_between(highest_energetic_track.dir, track.dir) > 0.035:
                # TODO: make this realistic!
                # skip if angle too large
                continue
            if track.particle_type not in (-11, 11, -13, 13, -15, 15):
                # TODO: make this realistic!
                track.length = 200 * track.E / highest_energy
            particle = Particle(track.pos.x, track.pos.y, track.pos.z,
                                track.dir.x, track.dir.y, track.dir.z,
                                track.time, constants.c, self.colourist,
                                track.E, track.length)
            particle.hidden = not self.show_secondaries
            if track.id == highest_energetic_track.id:
                particle.color = (0.0, 1.0, 0.2)
                particle.line_width = 3
                particle.cherenkov_cone_enabled = True
                particle.hidden = False
            self.objects.setdefault("mc_tracks", []).append(particle)
Exemple #3
0
 def zenith(self):
     return angle_between(self, (0, 0, -1))
Exemple #4
0
 def test_angle_between_returns_nan_for_zero_length_vectors(self):
     v1 = (0, 0, 0)
     v2 = (1, 0, 0)
     self.assertTrue(np.isnan(angle_between(v1, v2)))