Skip to content

Commit beb7d34

Browse files
committed
move the phi_modulo into the if condition for optimisation
1 parent d791c0f commit beb7d34

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

src/ctapipe/image/muon/intensity_fitter.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ def chord_length(radius, rho, phi, phi0=0):
8080
def _chord_length(radius, rho, phi, phi0):
8181
phi = phi - phi0
8282

83-
phi_modulo = (phi + np.pi) % (2 * np.pi) - np.pi
84-
85-
discriminant_norm = 1 - (rho**2 * np.sin(phi_modulo) ** 2)
83+
discriminant_norm = 1 - (rho**2 * np.sin(phi) ** 2)
8684
if discriminant_norm < 0:
8785
return 0
8886

@@ -91,7 +89,7 @@ def _chord_length(radius, rho, phi, phi0):
9189
if rho <= 1.0:
9290
# muon has hit the mirror
9391
effective_chord_length = radius * (
94-
np.sqrt(discriminant_norm) + rho * np.cos(phi_modulo)
92+
np.sqrt(discriminant_norm) + rho * np.cos(phi)
9593
)
9694

9795
return effective_chord_length
@@ -100,6 +98,7 @@ def _chord_length(radius, rho, phi, phi0):
10098
# muon did not hit the mirror
10199
effective_chord_length = 2 * radius * np.sqrt(discriminant_norm)
102100
# Filtering out non-physical solutions for phi
101+
phi_modulo = (phi + np.pi) % (2 * np.pi) - np.pi
103102
if np.abs(phi_modulo) > np.arcsin(1.0 / rho):
104103
return 0
105104

0 commit comments

Comments
 (0)