Open jrleeman opened 6 years ago
Well, we don't have Cressman smoothing for grids necessarily, but:
https://unidata.github.io/MetPy/latest/search.html?q=cressman&check_keywords=yes&area=default
Although it would probably work already since grids for input are just a specialization of point data...
I didn't know if that would do the same job and if it does we'll need that documented somewhere other than gridding, so I went ahead and filed.
Not sure if it is worth a separate function, but here is a toy example of how I think you could do it with existing functionality ('cressman' is default interpolation type for inverse_distance):
from metpy.gridding.interpolation import inverse_distance
from metpy.gridding.points import generate_grid_coords
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
vals = np.random.randint(0, 20, size=(2500))
gx, gy = np.meshgrid(list(range(50)), list(range(50)))
pts = generate_grid_coords(gx, gy)
x, y = pts[:, 0], pts[:, 1]
smoothed_vals = inverse_distance(x, y, vals, gx, gy, r=4)
fig, ax = plt.subplots(2, 1)
ax[0].imshow(vals.reshape(50, 50))
ax[1].imshow(smoothed_vals)
Add a Cressman smoother.