Skip to content

Commit 5da8ba5

Browse files
committed
Add method to compute Fermat potential
1 parent 36bf22a commit 5da8ba5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

coolest/api/composable_models.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,16 @@ def _eval_pot_posterior(self, x, y, param_list):
342342
mapped = map(partial(self._eval_pot_point, x, y), param_list)
343343
return np.array(list(mapped))
344344

345+
def fermat_potential(self, x, y, x_src, y_src, mode='point'):
346+
"""Computes the Fermat potential for image (x, y) and source position (x_src, y_src)
347+
"""
348+
# gravitational term
349+
psi = self.evaluate_potential(x, y, mode=mode)
350+
# geometric term
351+
geo = ((x - x_src)**2 + (y - y_src)**2) / 2.
352+
geo = np.broadcast_to(geo, psi.shape) # makes sure geo has same shape as psi
353+
return geo - psi
354+
345355
def evaluate_deflection(self, x, y):
346356
"""Evaluates the lensing deflection field at given coordinates"""
347357
alpha_x, alpha_y = np.zeros_like(x), np.zeros_like(x)

0 commit comments

Comments
 (0)