@@ -87,7 +87,7 @@ def effective_einstein_radius(self, center=None, initial_guess=1, initial_delta_
87
87
else :
88
88
center_x , center_y = center
89
89
90
- def loop_until_overshoot (r_Ein , delta , direction , runningtotal , total_pix ):
90
+ def _loop_until_overshoot (r_Ein , delta , direction , runningtotal , total_pix ):
91
91
"""
92
92
this subfunction iteratively adjusts the mask radius by delta either inward or outward until the sign flips on mean_kappa-area
93
93
"""
@@ -145,7 +145,7 @@ def only_between_r1r2(r1, r2, r_grid):
145
145
146
146
for n in range (n_iter ):
147
147
#overshoots, turn around and backtrack at higher precision
148
- r_Ein , delta , direction , runningtotal , total_pix = loop_until_overshoot (r_Ein , delta , direction , runningtotal , total_pix )
148
+ r_Ein , delta , direction , runningtotal , total_pix = _loop_until_overshoot (r_Ein , delta , direction , runningtotal , total_pix )
149
149
direction = direction * - 1
150
150
delta = delta / 2
151
151
accuracy = grid_res / 2 #after testing, accuracy is about grid_res/2
@@ -216,10 +216,9 @@ def effective_radial_slope(self, r_eval=None, center=None, r_vec=np.linspace(0,
216
216
if r_eval == None :
217
217
return slope
218
218
else :
219
- closest_r = self .find_nearest (r_vec ,r_eval ) #just takes closest r. Could rebuild it to interpolate.
219
+ closest_r = self ._find_nearest (r_vec ,r_eval ) #just takes closest r. Could rebuild it to interpolate.
220
220
return slope [r_vec == closest_r ]
221
221
222
-
223
222
def effective_radius_light (self , outer_radius = 10 , center = None , coordinates = None ,
224
223
initial_guess = 1 , initial_delta_pix = 10 ,
225
224
n_iter = 10 , return_model = False , return_accuracy = False ,
@@ -307,14 +306,6 @@ def effective_radius_light(self, outer_radius=10, center=None, coordinates=None,
307
306
return r_eff , accuracy
308
307
return r_eff
309
308
310
-
311
- def find_nearest (self , array , value ):
312
- """subfunction to find nearest closest element in array to value"""
313
- array = np .asarray (array )
314
- idx = (np .abs (array - value )).argmin ()
315
- return array [idx ]
316
-
317
-
318
309
def two_point_correlation (self , Nbins = 100 , rmax = None , normalize = False ,
319
310
use_profile_coordinates = True , coordinates = None ,
320
311
min_flux = None , min_flux_frac = None ,
@@ -508,7 +499,6 @@ def total_magnitude(self, outer_radius=10, center=None, coordinates=None,
508
499
mag_tot = - 2.5 * np .log10 (flux_tot ) + mag_zero_point
509
500
510
501
return mag_tot
511
-
512
502
513
503
def ellipticity_from_moments (self , center = None , coordinates = None , ** kwargs_selection ):
514
504
"""Estimates the axis ratio and position angle of the model map
@@ -571,6 +561,27 @@ def ellipticity_from_moments(self, center=None, coordinates=None, **kwargs_selec
571
561
572
562
return q , phi
573
563
564
+ def lensing_information (self , a = 16 , b = 0 ,
565
+ noise_map = None , arc_mask = None , theta_E = None ,
566
+ entity_idx_theta_E = 0 , profile_idx_theta_E = 0 ):
567
+ """
568
+ Computes the 'lensing information' defined in Yi Tan et al. 2023, Equations (8) and (9).
569
+ https://ui.adsabs.harvard.edu/abs/2023arXiv231109307T/abstract
570
+ """
571
+ data = self .coolest .observation .pixels .get_pixels ()
572
+ # TODO: subtract the lens light
573
+ print ("WARNING: no lens light subtracted; assuming the data contains only the arcs." )
574
+ if noise_map is None :
575
+ raise NotImplementedError ("Getting the noise map from the COOLEST instance is yet implemented." )
576
+ if theta_E is None :
577
+ mass_profile = self .coolest .lensing_entities [entity_idx_theta_E ].mass_model [profile_idx_theta_E ]
578
+ theta_E = mass_profile .parameters ['theta_E' ].point_estimate .value
579
+ x , y = self .coordinates .pixel_coordinates
580
+ I , theta_E , phi_ref , mask = util .lensing_information (
581
+ data , x , y , theta_E , noise_map , a = a , b = b , arc_mask = arc_mask
582
+ )
583
+ return I , theta_E , phi_ref , mask
584
+
574
585
575
586
@staticmethod
576
587
def effective_radius (light_map , x , y , outer_radius = 10 , initial_guess = 1 , initial_delta_pix = 10 , n_iter = 10 ):
@@ -633,3 +644,10 @@ def effective_radius(light_map, x, y, outer_radius=10, initial_guess=1, initial_
633
644
634
645
return r_eff , grid_res
635
646
647
+ @staticmethod
648
+ def _find_nearest (array , value ):
649
+ """subfunction to find nearest closest element in array to value"""
650
+ array = np .asarray (array )
651
+ idx = (np .abs (array - value )).argmin ()
652
+ return array [idx ]
653
+
0 commit comments