I would like to use a "footprint filter with weights" in Python. I tried to use the generic_filter
from scipy.ndimages.filters
. But it does not take weights. A little bit more details: I do have meteorological data and I would like to create weighted means in 4 main directions (North, South, East, West). Therefore I create a user-defined footprint matrix as shown in this post.
The problem: the generic_filter
just takes bool
footprints and converts my nice filter matrix into True
when > 0
and False
when == 0
. The effect: I don't get a weighted mean, the function just returns the mean over the lower "pyramid".
I was searching for a few hours in different packages but haven't found anything useful. Probably I am searching at the wrong end of the spectrum? Does anyone have a hint for me? Thanks a lot!