@@ -265,10 +265,10 @@ def uv_weights(self, u, v, spatial_function="triangle"):
265265 # weights = 1. - (np.abs(uv - grid)/np.diff(grid)[0])**2
266266 # weights = np.exp( - (uv - grid)**2/(2*np.diff(grid)[0]**2))
267267 # weights = np.exp( - abs(uv - grid)/(np.diff(grid)[0]))
268- _range = np .arange (self .uv_size ) - (self .uv_size - 1 ) / 2.0
269- _range *= self .uv_delta
270268 match spatial_function .casefold ():
271269 case "triangle" :
270+ _range = np .arange (self .uv_size ) - (self .uv_size - 1 ) / 2.0
271+ _range *= self .uv_delta
272272 x , y = np .meshgrid (_range , _range )
273273 x .shape += (1 ,)
274274 y .shape += (1 ,)
@@ -280,11 +280,22 @@ def uv_weights(self, u, v, spatial_function="triangle"):
280280 weights /= np .sum (weights , axis = (0 , 1 ))
281281 weights = np .transpose (weights , [2 , 0 , 1 ])
282282 case "nearest" :
283- u_index = np .argmin (np .abs (u - _range ))
284- v_index = np .argmin (np .abs (v - _range ))
283+ _range = np .arange (self .uv_size ) - (self .uv_size - 1 ) / 2.0
284+ _range *= self .uv_delta
285+ x , y = _range , _range
286+ x .shape += (1 ,)
287+ y .shape += (1 ,)
288+ x = u - x
289+ y = v - y
290+ u_index = np .argmin (np .abs (x ), axis = 0 )
291+ v_index = np .argmin (np .abs (y ), axis = 0 )
292+
293+ print (f"{ u_index .shape = :} , { v_index .shape = :} " )
285294 print (f"{ u_index = :} , { v_index = :} " )
286- weights = np .zeros ((1 , self .uv_size , self .uv_size ), dtype = complex )
287- weights [0 , u_index , v_index ] = 1.0
295+ weights = np .zeros (
296+ (x .shape [- 1 ], self .uv_size , self .uv_size ), dtype = complex
297+ )
298+ weights [:, u_index , v_index ] = 1.0
288299 case _:
289300 raise ValueError (
290301 f"Unknown value for 'spatial_function': { spatial_function } "
0 commit comments