Skip to content

Geoplotting large HDF data with cartopy causes crash

(This is part of #23 (closed) Use cartopy instead of basemap._

Eva has some test data that causes glance to crash when trying to geoplot some data. I've been able to reproduce it.

TEST DATA: 40-crash.nc

I'm using these libraries at the moment, all from Anaconda:

# packages in environment at /home/adesmet/src/glance/anaconda:
#
# Name                    Version                   Build  Channel
hdf4                      4.2.13               h3ca952b_2  
hdf5                      1.10.4               hb1b8bf9_0  
libnetcdf                 4.6.1                h11d0813_2  
netcdf4                   1.4.2            py27h808af73_0  
numpy                     1.16.4           py27h7e9f1db_0  
numpy-base                1.16.4           py27hde5b4d6_0  
pyhdf                     0.10.1           py27h3a4e923_1  conda-forge
python                    2.7.16               h9bab390_0  

I'm working with UW-Glance ad359acf, which is the current head of tocartopy.

The failure:

$ glance inspectreport 40-crash.nc --outputpath=out --longitude pixel_longitude --latitude pixel_latitude ^baseline_cmask_seviri_cloud_mask$
ERROR:glance.plotcreatefns:Someone has instantiated PlottingFunctionFactory. This class is NOT meant to be instantiated.
ERROR:glance.plotcreatefns:Someone has instantiated PlottingFunctionFactory. This class is NOT meant to be instantiated.
lat type: <type 'numpy.ndarray'>
lon type: <type 'numpy.ndarray'>
ERROR:shapely.geos:TopologyException: side location conflict at -109 50
Traceback (most recent call last):
  File "/home/adesmet/src/glance/anaconda/bin/glance", line 11, in <module>
    load_entry_point('uwglance', 'console_scripts', 'glance')()
  File "/home/adesmet/src/glance/pyglance/glance/compare.py", line 1613, in main
    rc = lower_locals[args[0].lower()](*args[1:])
  File "/home/adesmet/src/glance/pyglance/glance/compare.py", line 1479, in inspectReport
    return inspect_library_call(clean_path(args[0]), args[1:], tempOptions)
  File "/home/adesmet/src/glance/pyglance/glance/compare.py", line 601, in inspect_library_call
    histRange=varRunInfo[HISTOGRAM_RANGE_KEY] if HISTOGRAM_RANGE_KEY in varRunInfo else None)
  File "/home/adesmet/src/glance/pyglance/glance/plot.py", line 333, in plot_and_save_comparison_figures
    makeSmall, doFork, shouldClearMemoryWithThreads, fullDPI=fullDPI, thumbDPI=thumbDPI)
  File "/home/adesmet/src/glance/pyglance/glance/plot.py", line 98, in _log_spawn_and_wait_if_needed
    fullDPI=fullDPI, thumbDPI=thumbDPI)
  File "/home/adesmet/src/glance/pyglance/glance/plot.py", line 55, in _handle_fig_creation_task
    figure_obj = child_figure_function()
  File "/home/adesmet/src/glance/pyglance/glance/plotcreatefns.py", line 1455, in <lambda>
    units=units_a)),
  File "/home/adesmet/src/glance/pyglance/glance/figures.py", line 613, in create_mapped_figure
    img_temp = maps.contourf_on_map(longitudeClean, latitudeClean, data, axes_obj, in_projection, **kwargs)
  File "/home/adesmet/src/glance/pyglance/glance/graphics.py", line 263, in contourf_on_map
    img_temp = axes_object.contourf(lon, lat, data, levelsToUse, transform=in_projection, **kwargs)
  File "/home/adesmet/src/glance/anaconda/lib/python2.7/site-packages/cartopy/mpl/geoaxes.py", line 1397, in contourf
    if col.get_paths()])
  File "/home/adesmet/src/glance/anaconda/lib/python2.7/site-packages/matplotlib/collections.py", line 196, in get_datalim
    paths = [transform.transform_path_non_affine(p) for p in paths]
  File "/home/adesmet/src/glance/anaconda/lib/python2.7/site-packages/matplotlib/transforms.py", line 2492, in transform_path_non_affine
    return self._a.transform_path_non_affine(path)
  File "/home/adesmet/src/glance/anaconda/lib/python2.7/site-packages/cartopy/mpl/geoaxes.py", line 189, in transform_path_non_affine
    getattr(self, 'force_path_ccw', False))
  File "/home/adesmet/src/glance/anaconda/lib/python2.7/site-packages/cartopy/mpl/patch.py", line 212, in path_to_geos
    collection[-1][0].contains(geom.exterior)):
  File "/home/adesmet/src/glance/anaconda/lib/python2.7/site-packages/shapely/geometry/base.py", line 691, in contains
    return bool(self.impl['contains'](self, other))
  File "/home/adesmet/src/glance/anaconda/lib/python2.7/site-packages/shapely/predicates.py", line 18, in __call__
    self._check_topology(err, this, other)
  File "/home/adesmet/src/glance/anaconda/lib/python2.7/site-packages/shapely/topology.py", line 38, in _check_topology
    self.fn.__name__, repr(geom)))
shapely.errors.TopologicalError: The operation 'GEOSContains_r' could not be performed. Likely cause is invalidity of the geometry <shapely.geometry.polygon.Polygon object at 0x7fbf8927a790>

Trying to plot interactively with glance gui generated similar output.

Edited by Alan De Smet