Closed tlvu closed 1 year ago
New Jupyter env in PR https://github.com/Ouranosinc/PAVICS-e2e-workflow-tests/pull/121 (see relevant changes there).
19:17:05 Notebook cell execution failed 19:17:05 Cell 7: Cell execution caused an exception 19:17:05 19:17:05 Input: 19:17:05 warnings.filterwarnings("ignore", category=cartopy.io.DownloadWarning) 19:17:05 fig = plt.figure(figsize=(8, 6)) 19:17:05 ax = fig.add_axes([0, 0, 1, 1], projection=cartopy.crs.Mollweide()) 19:17:05 ax.imshow( 19:17:05 data, 19:17:05 origin="upper", 19:17:05 extent=(-180, 180, -90, 90), 19:17:05 transform=cartopy.crs.PlateCarree(), 19:17:05 ) 19:17:05 ax.coastlines() 19:17:05 plt.show() 19:17:05 19:17:05 Traceback: 19:17:05 19:17:05 --------------------------------------------------------------------------- 19:17:05 ValueError Traceback (most recent call last) 19:17:05 Cell In[8], line 4 19:17:05 2 fig = plt.figure(figsize=(8, 6)) 19:17:05 3 ax = fig.add_axes([0, 0, 1, 1], projection=cartopy.crs.Mollweide()) 19:17:05 ----> 4 ax.imshow( 19:17:05 5 data, 19:17:05 6 origin="upper", 19:17:05 7 extent=(-180, 180, -90, 90), 19:17:05 8 transform=cartopy.crs.PlateCarree(), 19:17:05 9 ) 19:17:05 10 ax.coastlines() 19:17:05 11 plt.show() 19:17:05 19:17:05 File /opt/conda/envs/birdy/lib/python3.10/site-packages/cartopy/mpl/geoaxes.py:318, in _add_transform.<locals>.wrapper(self, *args, **kwargs) 19:17:05 313 raise ValueError(f'Invalid transform: Spherical {func.__name__} ' 19:17:05 314 'is not supported - consider using ' 19:17:05 315 'PlateCarree/RotatedPole.') 19:17:05 317 kwargs['transform'] = transform 19:17:05 --> 318 return func(self, *args, **kwargs) 19:17:05 19:17:05 File /opt/conda/envs/birdy/lib/python3.10/site-packages/cartopy/mpl/geoaxes.py:1331, in GeoAxes.imshow(self, img, *args, **kwargs) 19:17:05 1329 from cartopy.img_transform import warp_array 19:17:05 1330 original_extent = extent 19:17:05 -> 1331 img, extent = warp_array(img, 19:17:05 1332 source_proj=transform, 19:17:05 1333 source_extent=original_extent, 19:17:05 1334 target_proj=self.projection, 19:17:05 1335 target_res=regrid_shape, 19:17:05 1336 target_extent=target_extent, 19:17:05 1337 mask_extrapolated=True, 19:17:05 1338 ) 19:17:05 1339 alpha = kwargs.pop('alpha', None) 19:17:05 1340 if np.array(alpha).ndim == 2: 19:17:05 19:17:05 File /opt/conda/envs/birdy/lib/python3.10/site-packages/cartopy/img_transform.py:192, in warp_array(array, target_proj, source_proj, target_res, source_extent, target_extent, mask_extrapolated) 19:17:05 186 # XXX Take into account the extents of the original to determine 19:17:05 187 # target_extents? 19:17:05 188 target_native_x, target_native_y, extent = mesh_projection( 19:17:05 189 target_proj, target_res[0], target_res[1], 19:17:05 190 x_extents=target_x_extents, y_extents=target_y_extents) 19:17:05 --> 192 array = regrid(array, source_native_xy[0], source_native_xy[1], 19:17:05 193 source_proj, target_proj, 19:17:05 194 target_native_x, target_native_y, 19:17:05 195 mask_extrapolated) 19:17:05 196 return array, extent 19:17:05 19:17:05 File /opt/conda/envs/birdy/lib/python3.10/site-packages/cartopy/img_transform.py:278, in regrid(array, source_x_coords, source_y_coords, source_proj, target_proj, target_x_points, target_y_points, mask_extrapolated) 19:17:05 274 else: 19:17:05 275 # Versions of scipy >= v0.16 added the balanced_tree argument, 19:17:05 276 # which caused the KDTree to hang with this input. 19:17:05 277 kdtree = scipy.spatial.cKDTree(xyz, balanced_tree=False) 19:17:05 --> 278 _, indices = kdtree.query(target_xyz, k=1) 19:17:05 279 mask = indices >= len(xyz) 19:17:05 280 indices[mask] = 0 19:17:05 19:17:05 File _ckdtree.pyx:795, in scipy.spatial._ckdtree.cKDTree.query() 19:17:05 19:17:05 ValueError: 'x' must be finite, check for nan or inf values
See https://github.com/SciTools/cartopy/issues/2199
Possible solutions from the thread:
I confirm that installing pykdtree resolves the issue.
New Jupyter env in PR https://github.com/Ouranosinc/PAVICS-e2e-workflow-tests/pull/121 (see relevant changes there).