@@ -100,6 +100,93 @@ def deflections_yx_scalar(self, y, x, pixel_scales):
100100 def __eq__ (self , other ):
101101 return self .__dict__ == other .__dict__ and self .__class__ is other .__class__
102102
103+ def time_delay_geometry_term_from (self , grid ) -> aa .Array2D :
104+ """
105+ Returns the geometric time delay term of the Fermat potential for a given grid of image-plane positions.
106+
107+ This term is given by:
108+
109+ .. math::
110+ \[\t au_{\t ext{geom}}(\b oldsymbol{\t heta}) = \f rac{1}{2} |\b oldsymbol{\t heta} - \b oldsymbol{\b eta}|^2\]
111+
112+ where:
113+ - \( \b oldsymbol{\t heta} \) is the image-plane coordinate,
114+ - \( \b oldsymbol{\b eta} = \b oldsymbol{\t heta} - \b oldsymbol{\a lpha}(\b oldsymbol{\t heta}) \) is the source-plane coordinate,
115+ - \( \b oldsymbol{\a lpha} \) is the deflection angle at each image-plane coordinate.
116+
117+ Parameters
118+ ----------
119+ grid
120+ The 2D grid of (y,x) arc-second coordinates the deflection angles and time delay geometric term are computed
121+ on.
122+
123+ Returns
124+ -------
125+ The geometric time delay term at each grid position.
126+ """
127+ deflections = self .deflections_yx_2d_from (grid = grid )
128+
129+ src_y = grid [:, 0 ] - deflections [:, 0 ]
130+ src_x = grid [:, 1 ] - deflections [:, 1 ]
131+
132+ delay = 0.5 * ((grid [:, 0 ] - src_y ) ** 2 + (grid [:, 1 ] - src_x ) ** 2 )
133+
134+ if isinstance (grid , aa .Grid2DIrregular ):
135+ return aa .ArrayIrregular (values = delay )
136+ return aa .Array2D (values = delay , mask = grid .mask )
137+
138+ def fermat_potential_from (self , grid ) -> aa .Array2D :
139+ """
140+ Returns the Fermat potential for a given grid of image-plane positions.
141+
142+ This is the sum of the geometric time delay term and the gravitational (Shapiro) delay term (i.e. the lensing
143+ potential), and is given by:
144+
145+ .. math::
146+ \[\phi(\b oldsymbol{\t heta}) = \f rac{1}{2} |\b oldsymbol{\t heta} - \b oldsymbol{\b eta}|^2 - \psi(\b oldsymbol{\t heta})\]
147+
148+ where:
149+ - \( \b oldsymbol{\t heta} \) is the image-plane coordinate,
150+ - \( \b oldsymbol{\b eta} = \b oldsymbol{\t heta} - \b oldsymbol{\a lpha}(\b oldsymbol{\t heta}) \) is the source-plane coordinate,
151+ - \( \psi(\b oldsymbol{\t heta}) \) is the lensing potential,
152+ - \( \phi(\b oldsymbol{\t heta}) \) is the Fermat potential.
153+
154+ Parameters
155+ ----------
156+ grid
157+ The 2D grid of (y,x) arc-second coordinates the Fermat potential is computed on.
158+
159+ Returns
160+ -------
161+ The Fermat potential at each grid position.
162+ """
163+ time_delay_geometry_term = self .time_delay_geometry_term_from (grid = grid )
164+ potential = self .potential_2d_from (grid = grid )
165+
166+ fermat_potential = time_delay_geometry_term - potential
167+
168+ if isinstance (grid , aa .Grid2DIrregular ):
169+ return aa .ArrayIrregular (values = fermat_potential )
170+ return aa .Array2D (values = fermat_potential , mask = grid .mask )
171+
172+ def time_delays_from (self , grid ) -> aa .Array2D :
173+ """
174+ Returns the 2D time delay map of lensing object, which is computed as the deflection angles in the y and x
175+ directions multiplied by the y and x coordinates of the grid.
176+
177+ Parameters
178+ ----------
179+ grid
180+ The 2D grid of (y,x) arc-second coordinates the deflection angles and time delay are computed on.
181+ """
182+ deflections_yx = self .deflections_yx_2d_from (grid = grid )
183+
184+ return aa .Array2D (
185+ values = deflections_yx [:, 0 ] * grid [:, 0 ]
186+ + deflections_yx [:, 1 ] * grid [:, 1 ],
187+ mask = grid .mask ,
188+ )
189+
103190 def __hash__ (self ):
104191 return hash (repr (self ))
105192
0 commit comments