def Detect(self, xp0, vg): A, B, C = self.GetQuadraticEqCoefficients(xp0, vg) t1, t2 = self.QuadraticTime(A, B, C) xp = np.copy(xp0) ray_kernel.TestStep(t1, xp, vg) t1_bad = self.ClipImpact(xp) t1[np.where(t1_bad)] = self.clip xp = np.copy(xp0) ray_kernel.TestStep(t2, xp, vg) t2_bad = self.ClipImpact(xp) t2[np.where(t2_bad)] = self.clip # Choose the earlier event provided it is in the future # Magnitude of negative times is incorrect, but we only need the fact that they are negative. t1[np.where(np.logical_and(t2 < t1, t2 > 0.0))] = 0.0 t2[np.where(np.logical_and(t1 < t2, t1 > 0.0))] = 0.0 t1[np.where(np.logical_and(t1 < 0.0, t2 > 0.0))] = 0.0 t2[np.where(np.logical_and(t2 < 0.0, t1 > 0.0))] = 0.0 time_to_surface = t1 + t2 # If a satellite misses but the primary hits, still deflect the satellite ray_kernel.RepairSatellites(time_to_surface) #time_to_surface[np.where(time_to_surface<0)] = time_to_surface[...,0:1] impact_filter = np.where(time_to_surface[..., 0] > 0)[0] return time_to_surface, impact_filter
def Detect(self, xp, vg): '''Determine which bundles should interact with the surface. :returns: time of ray impact, indices of impacting bundles :rtype: numpy.array, numpy.array, numpy.array''' # Encode no impact with a negative time time_to_surface = self.GetRawImpactTimes(xp, vg) time_to_surface[np.where(np.isinf(time_to_surface))] = self.clip time_to_surface[np.where(np.isnan(time_to_surface))] = self.clip # Include the effect of non-analytical clipping functions xp1 = np.copy(xp) ray_kernel.TestStep(time_to_surface, xp1, vg) cond_table = self.ClipImpact(xp1) time_to_surface[np.where(cond_table)] = self.clip # If a satellite misses, but the primary hits, deflect the satellite # based on extrapolation of surface data and approximate synchronism. ray_kernel.RepairSatellites(time_to_surface) impact_filter = np.where(time_to_surface[:, 0] > 0)[0] return time_to_surface, impact_filter
def GetStartingSimplices(self, dt, xp, vg): ray_kernel.TestStep(dt, xp, vg) tri_list = self.tri.find_simplex(xp[..., 0, 1:3]) ray_kernel.TestStep(-dt, xp, vg) return tri_list