@@ -977,7 +977,13 @@ def kernel_bessel(self, lat, wave_length, order=1):
977
977
kernel_ = empty ((half_x_pt * 2 * order + 1 , half_y_pt * 2 * order + 1 ))
978
978
kernel_ [half_x_pt * order :] = kernel
979
979
kernel_ [:half_x_pt * order ] = kernel [:0 :- 1 ]
980
- return kernel_
980
+ # remove unused row/column
981
+ k_valid = kernel_ != 0
982
+ x_valid = where (k_valid .sum (axis = 1 ))[0 ]
983
+ x_slice = slice (x_valid [0 ], x_valid [- 1 ] + 1 )
984
+ y_valid = where (k_valid .sum (axis = 0 ))[0 ]
985
+ y_slice = slice (y_valid [0 ], y_valid [- 1 ] + 1 )
986
+ return kernel_ [x_slice , y_slice ]
981
987
982
988
def _low_filter (self , grid_name , x_cut , y_cut ):
983
989
"""low filtering
@@ -995,7 +1001,8 @@ def _low_filter(self, grid_name, x_cut, y_cut):
995
1001
mode = 'wrap' if self .is_circular () else 'reflect' )
996
1002
997
1003
def convolve_filter_with_dynamic_kernel (self , grid , kernel_func , lat_max = 85 , extend = False , ** kwargs_func ):
998
- logging .warning ('No filtering above %f degrees of latitude' , lat_max )
1004
+ if (abs (self .y_c ) > lat_max ).any ():
1005
+ logging .warning ('No filtering above %f degrees of latitude' , lat_max )
999
1006
if isinstance (grid , str ):
1000
1007
data = self .grid (grid ).copy ()
1001
1008
else :
0 commit comments