Search code examples
pythonpython-3.xinterpolationlatitude-longitude

Regridding latitudes and longitudes with interpolation


How would I go about regridding a weather map that uses two separate 2D arrays for latitudes and longitudes that makes a map as shown:

weather_map

Into a new, smaller grid consisting of two 1D arrays for latitude and longitudes?

(These are the new latitudes and longitudes for reference)

new_lats = np.linspace(-34, -48, 14*4+1), new_lons = np.linspace(166, 182, 16*4+1)

I have looked into scipy.interpolate.interp2d, but couldn't get it to work and the processing time was simply long.

(Update: I have looked into xESMF, however, when using its Regridder function I get this error ImportError: Regrid(filename) requires PIO and does not work if ESMF has not been built with MPI support)


Solution

  • After further tinkering with xESMF and reading various forums, I discovered that xESMF has some dependency issues in the latest release, so $ conda install -c conda-forge esmpy==7.1.0 managed to solve my problem, and then using the regridder function.