Regridding high resolution gridded data to low resolution coarser resolution data?
<p>I have a netcdf file with high resolution grided data (.1 x .1 deg) and plotting on the basemap using matplotlib. The plot I am trying to do is contour lines. For a specific reason I would like to plot the data at the interval of 1 x 1 deg resolution. For which I have used the following code sample example  from here <a href="https://stackoverflow.com/questions/25544110/regridding-regular-netcdf-data">Regridding regular netcdf data</a>.</p>

<p>See the update 1 for link to actual data.</p>

<p>For the sake of clearity following is the code I am trying to execute for regridding to lower resolution:-</p>

<pre><code>from mpl_toolkits import basemap
from netCDF4 import Dataset

filename = 'path/to/netcdf/file.nc'
with Dataset(filename, mode='r') as fh:
   lons = fh.variables['LON'][:]
   lats = fh.variables['LAT'][:]
   data = fh.variables['Data'][:].squeeze()

lons_sub, lats_sub = np.meshgrid(lons[::4], lats[::4], sparse=True)

data_coarse = basemap.interp(data, lons, lats, lons_sub, lats_sub, order=1)
</code></pre>

<p>The code seems to be correct. But when I execute the code I get the following error in the line <code>data_coarse = basemap.interp(data, lons, lats, lons_sub, lats_sub, order=3)</code>:-</p>

<pre><code>/__init__.py", line 4897, in interp
    if xin[-1]-xin[0] &lt; 0 or yin[-1]-yin[0] &lt; 0:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
</code></pre>

<p>I have not understood where the problem lies and how to solve this?</p>

<p>Any help is appreciated. </p>

<p><strong>Update 1</strong></p>

<p>link to the actual data <a href="https://www.dropbox.com/s/ddlpbw5vvj5kz5w/mslp.txt?dl=0" rel="nofollow noreferrer">https://www.dropbox.com/s/ddlpbw5vvj5kz5w/mslp.txt?dl=0</a></p>

<p>link to lats <a href="https://www.dropbox.com/s/lpwjavxtwtt3r13/xlat.txt?dl=0" rel="nofollow noreferrer">https://www.dropbox.com/s/lpwjavxtwtt3r13/xlat.txt?dl=0</a></p>

<p>and the link to lons <a href="https://www.dropbox.com/s/1a0q49drfcd2o9h/xlon.txt?dl=0" rel="nofollow noreferrer">https://www.dropbox.com/s/1a0q49drfcd2o9h/xlon.txt?dl=0</a></p>