holoviz / geoviews

Simple, concise geographical visualization in Python
http://geoviews.org
BSD 3-Clause "New" or "Revised" License
595 stars 77 forks source link

`rasterize` causes plot to disappear on pan/zoom in bokeh #483

Open tdhopper opened 3 years ago

tdhopper commented 3 years ago

Description of expected behavior and the observed behavior

I’m trying to use rasterize to speed up plotting of weather maps with Geoviews/Holoviews/Bokeh in a Panel dashboard. However, when I try to pan or zoom in Bokeh, the plot disappears.

Here’s a minimum example

I run this with panel serve rasterize.ipynb.

When I try to pan or zoom the plot in the browser, the plot disappears and I get this in the Panel log:

/opt/conda/lib/python3.7/site-packages/xarray/core/nputils.py:227: RuntimeWarning: All-NaN slice encountered result = getattr(npmodule, name)(values, axis=axis, **kwargs) /opt/conda/lib/python3.7/site-packages/xarray/core/nputils.py:227: RuntimeWarning: All-NaN slice encountered

Environment

OS is Debian 10.1. Browser is firefox.

Conda env:

# packages in environment at /opt/conda:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       1_gnu    conda-forge
aiobotocore               1.1.2                      py_0    conda-forge
aiohttp                   3.7.2            py37h8f50634_0    conda-forge
aioitertools              0.7.0                      py_0    conda-forge
appdirs                   1.4.4              pyh9f0ad1d_0    conda-forge
argon2-cffi               20.1.0           py37h8f50634_2    conda-forge
async-timeout             3.0.1                   py_1000    conda-forge
async_generator           1.10                       py_0    conda-forge
attrs                     20.2.0             pyh9f0ad1d_0    conda-forge
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
backports                 1.0                        py_2    conda-forge
backports.functools_lru_cache 1.6.1                      py_0    conda-forge
black                     20.8b1                   pypi_0    pypi
bleach                    3.2.1              pyh9f0ad1d_0    conda-forge
bokeh                     2.2.3            py37hc8dfbb8_0    conda-forge
bokeh-root-cmd            0.0.5                    pypi_0    pypi
boost-cpp                 1.74.0               h9359b55_0    conda-forge
botocore                  1.17.44            pyh9f0ad1d_0    conda-forge
brotlipy                  0.7.0           py37hb5d75c8_1001    conda-forge
bzip2                     1.0.8                h516909a_3    conda-forge
c-ares                    1.16.1               h516909a_3    conda-forge
ca-certificates           2020.6.20            hecda079_0    conda-forge
cairo                     1.16.0            h488836b_1006    conda-forge
cartopy                   0.18.0           py37hfca54e7_5    conda-forge
certifi                   2020.6.20        py37he5f6b98_2    conda-forge
cffi                      1.14.3           py37h00ebd2e_1    conda-forge
cfgrib                    0.9.8.4                    py_0    conda-forge
cfitsio                   3.470                hce51eda_7    conda-forge
cftime                    1.2.1            py37h161383b_1    conda-forge
chardet                   3.0.4           py37he5f6b98_1008    conda-forge
click                     7.1.2              pyh9f0ad1d_0    conda-forge
click-plugins             1.1.1                      py_0    conda-forge
cligj                     0.7.0                      py_0    conda-forge
cloudpickle               1.6.0                      py_0    conda-forge
colorcet                  2.0.1                      py_0    conda-forge
conda                     4.9.0            py37he5f6b98_1    conda-forge
conda-package-handling    1.7.2            py37hb5d75c8_0    conda-forge
convert                   0.1.2                    pypi_0    pypi
cryptography              3.2.1            py37hc72a4ac_0    conda-forge
curl                      7.71.1               he644dc0_8    conda-forge
cycler                    0.10.0                     py_2    conda-forge
cytoolz                   0.11.0           py37h8f50634_1    conda-forge
dask                      2.30.0                     py_0    conda-forge
dask-core                 2.30.0                     py_0    conda-forge
datashader                0.11.1             pyh9f0ad1d_0    conda-forge
datashape                 0.5.4                      py_1    conda-forge
dbus                      1.13.6               hfdff14a_1    conda-forge
decorator                 4.4.2                      py_0    conda-forge
defusedxml                0.6.0                      py_0    conda-forge
distributed               2.30.0           py37hc8dfbb8_1    conda-forge
docutils                  0.15.2                   py37_0    conda-forge
dtn-sia                   2020.11                  pypi_0    pypi
eccodes                   2.19.0               hf05d9b7_2    conda-forge
entrypoints               0.3             py37hc8dfbb8_1002    conda-forge
esmf                      8.0.1           nompi_hbeb3ca6_1    conda-forge
expat                     2.2.9                he1b5a44_2    conda-forge
fastparquet               0.4.1            py37h03ebfcd_0    conda-forge
fiona                     1.8.17           py37ha3d844c_1    conda-forge
flake8                    3.8.4                    pypi_0    pypi
fontconfig                2.13.1            h7e3eb15_1002    conda-forge
freetype                  2.10.4               h7ca028e_0    conda-forge
freexl                    1.0.5             h516909a_1002    conda-forge
fsspec                    0.8.4                      py_0    conda-forge
gdal                      3.1.4            py37h2b22b9e_0    conda-forge
geopandas                 0.8.1                      py_0    conda-forge
geos                      3.8.1                he1b5a44_0    conda-forge
geotiff                   1.6.0                h5d11630_3    conda-forge
geoviews                  1.8.2                      py_0    conda-forge
geoviews-core             1.8.2                      py_0    conda-forge
gettext                   0.19.8.1          hf34092f_1004    conda-forge
giflib                    5.2.1                h36c2ea0_2    conda-forge
glib                      2.66.2               h58526e2_0    conda-forge
gsl                       2.6                  hf94e986_0    conda-forge
gst-plugins-base          1.14.5               h0935bb2_2    conda-forge
gstreamer                 1.14.5               h36ae1b5_2    conda-forge
hdf4                      4.2.13            hf30be14_1003    conda-forge
hdf5                      1.10.6          nompi_h54c07f9_1110    conda-forge
hdfeos2                   2.20              h64bfcee_1000    conda-forge
hdfeos5                   5.1.16               hb4ce793_7    conda-forge
heapdict                  1.0.1                      py_0    conda-forge
holoviews                 1.13.5             pyh9f0ad1d_0    conda-forge
hvplot                    0.6.0                    pypi_0    pypi
icu                       67.1                 he1b5a44_0    conda-forge
idna                      2.10               pyh9f0ad1d_0    conda-forge
importlib-metadata        2.0.0                      py_1    conda-forge
importlib_metadata        2.0.0                         1    conda-forge
importlib_resources       3.3.0            py37h89c1867_0    conda-forge
iniconfig                 1.1.1                    pypi_0    pypi
ipykernel                 5.3.4            py37hc6149b9_1    conda-forge
ipython                   7.19.0           py37h888b3d9_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
isort                     5.6.4                    pypi_0    pypi
jasper                    1.900.1           h07fcdf6_1006    conda-forge
jedi                      0.17.2           py37hc8dfbb8_1    conda-forge
jinja2                    2.11.2             pyh9f0ad1d_0    conda-forge
jmespath                  0.10.0             pyh9f0ad1d_0    conda-forge
jpeg                      9d                   h36c2ea0_0    conda-forge
json-c                    0.13.1            hbfbb72e_1002    conda-forge
jsonschema                3.2.0                      py_2    conda-forge
jupyter_client            6.1.7                      py_0    conda-forge
jupyter_core              4.6.3            py37hc8dfbb8_2    conda-forge
jupyterlab_pygments       0.1.2              pyh9f0ad1d_0    conda-forge
kealib                    1.4.13               h33137a7_1    conda-forge
kiwisolver                1.3.1            py37hc928c03_0    conda-forge
krb5                      1.17.1               hfafb76e_3    conda-forge
lcms2                     2.11                 hbd6801e_0    conda-forge
ld_impl_linux-64          2.35                 h769bd43_9    conda-forge
libaec                    1.0.4                he1b5a44_1    conda-forge
libblas                   3.9.0                2_openblas    conda-forge
libcblas                  3.9.0                2_openblas    conda-forge
libclang                  10.0.1          default_hde54327_1    conda-forge
libcurl                   7.71.1               hcdd3856_8    conda-forge
libdap4                   3.20.6               h1d1bd15_1    conda-forge
libedit                   3.1.20191231         he28a2e2_2    conda-forge
libev                     4.33                 h516909a_1    conda-forge
libevent                  2.1.10               hcdb4288_3    conda-forge
libffi                    3.2.1             he1b5a44_1007    conda-forge
libgcc-ng                 9.3.0               h5dbcf3e_17    conda-forge
libgdal                   3.1.4                h670eac6_0    conda-forge
libgfortran-ng            7.5.0               hae1eefd_17    conda-forge
libgfortran4              7.5.0               hae1eefd_17    conda-forge
libglib                   2.66.2               hbe7bbb4_0    conda-forge
libgomp                   9.3.0               h5dbcf3e_17    conda-forge
libiconv                  1.16                 h516909a_0    conda-forge
libkml                    1.3.0             h74f7ee3_1012    conda-forge
liblapack                 3.9.0                2_openblas    conda-forge
libllvm10                 10.0.1               he513fc3_3    conda-forge
libnetcdf                 4.7.4           nompi_hefab0ff_106    conda-forge
libnghttp2                1.41.0               h8cfc5f6_2    conda-forge
libopenblas               0.3.12          pthreads_hb3c22a3_1    conda-forge
libpng                    1.6.37               h21135ba_2    conda-forge
libpq                     12.3                 h5513abc_2    conda-forge
libsodium                 1.0.18               h516909a_1    conda-forge
libspatialindex           1.9.3                he1b5a44_3    conda-forge
libspatialite             5.0.0                h4dde289_0    conda-forge
libssh2                   1.9.0                hab1572f_5    conda-forge
libstdcxx-ng              9.3.0               h2ae2ef3_17    conda-forge
libtiff                   4.1.0                h4f3a223_6    conda-forge
libuuid                   2.32.1            h14c3975_1000    conda-forge
libwebp-base              1.1.0                h36c2ea0_3    conda-forge
libxcb                    1.13              h14c3975_1002    conda-forge
libxkbcommon              0.10.0               he1b5a44_0    conda-forge
libxml2                   2.9.10               h68273f3_2    conda-forge
llvmlite                  0.34.0           py37h5202443_2    conda-forge
locket                    0.2.0                      py_2    conda-forge
lz4-c                     1.9.2                he1b5a44_3    conda-forge
markdown                  3.3.3              pyh9f0ad1d_0    conda-forge
markupsafe                1.1.1            py37hb5d75c8_2    conda-forge
matplotlib                3.3.2            py37hc8dfbb8_1    conda-forge
matplotlib-base           3.3.2            py37hc9afd2a_1    conda-forge
mccabe                    0.6.1                    pypi_0    pypi
metpy                     0.12.2                     py_0    conda-forge
mistune                   0.8.4           py37h8f50634_1002    conda-forge
msgpack-python            1.0.0            py37h99015e2_2    conda-forge
multidict                 4.7.5            py37h8f50634_2    conda-forge
multipledispatch          0.6.0                      py_0    conda-forge
munch                     2.5.0                      py_0    conda-forge
mypy-extensions           0.4.3                    pypi_0    pypi
mysql-common              8.0.21                        2    conda-forge
mysql-libs                8.0.21               hf3661c5_2    conda-forge
nbclient                  0.5.1                      py_0    conda-forge
nbconvert                 6.0.7            py37hc8dfbb8_2    conda-forge
nbformat                  5.0.8                      py_0    conda-forge
ncl                       6.6.2               h087f628_23    conda-forge
ncurses                   6.2                  he1b5a44_2    conda-forge
nest-asyncio              1.4.2              pyhd8ed1ab_0    conda-forge
netcdf-fortran            4.5.3           nompi_hfef6a68_101    conda-forge
netcdf4                   1.5.4           nompi_py37hcbfd489_103    conda-forge
notebook                  6.1.4            py37hc8dfbb8_1    conda-forge
nspr                      4.29                 he1b5a44_1    conda-forge
nss                       3.58                 h27285de_1    conda-forge
numba                     0.51.2           py37h9fdb41a_0    conda-forge
numpy                     1.19.2           py37h7008fea_1    conda-forge
olefile                   0.46               pyh9f0ad1d_1    conda-forge
openjpeg                  2.3.1                h981e76c_3    conda-forge
openssl                   1.1.1h               h516909a_0    conda-forge
packaging                 20.4               pyh9f0ad1d_0    conda-forge
pandas                    1.1.4            py37h10a2094_0    conda-forge
pandoc                    2.11.0.4             hd18ef5c_0    conda-forge
pandocfilters             1.4.2                      py_1    conda-forge
panel                     0.10.1             pyhd8ed1ab_0    conda-forge
param                     1.10.0                     py_0    conda-forge
parso                     0.7.1              pyh9f0ad1d_0    conda-forge
partd                     1.1.0                      py_0    conda-forge
pathspec                  0.8.0                    pypi_0    pypi
pcre                      8.44                 he1b5a44_0    conda-forge
pexpect                   4.8.0              pyh9f0ad1d_2    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pillow                    8.0.1            py37h718be6c_0    conda-forge
pint                      0.16.1                     py_0    conda-forge
pip                       20.2.4                     py_0    conda-forge
pixman                    0.38.0            h516909a_1003    conda-forge
pluggy                    0.13.1                   pypi_0    pypi
pooch                     1.2.0                      py_0    conda-forge
poppler                   0.89.0               h4190859_1    conda-forge
poppler-data              0.4.10                        0    conda-forge
postgresql                12.3                 h8573dbc_2    conda-forge
proj                      7.1.1                h966b41f_3    conda-forge
prometheus_client         0.8.0              pyh9f0ad1d_0    conda-forge
prompt-toolkit            3.0.8                      py_0    conda-forge
psutil                    5.7.3            py37hb5d75c8_0    conda-forge
pthread-stubs             0.4               h14c3975_1001    conda-forge
ptyprocess                0.6.0                   py_1001    conda-forge
py                        1.9.0                    pypi_0    pypi
pycodestyle               2.6.0                    pypi_0    pypi
pycosat                   0.6.3           py37hb5d75c8_1005    conda-forge
pycparser                 2.20               pyh9f0ad1d_2    conda-forge
pyct                      0.4.6                      py_0    conda-forge
pyct-core                 0.4.6                      py_0    conda-forge
pyflakes                  2.2.0                    pypi_0    pypi
pygments                  2.7.2                      py_0    conda-forge
pyopenssl                 19.1.0                     py_1    conda-forge
pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
pyproj                    2.6.1.post1      py37h6415a23_3    conda-forge
pyqt                      5.12.3           py37h8685d9f_4    conda-forge
pyqt5-sip                 4.19.18                  pypi_0    pypi
pyqtchart                 5.12                     pypi_0    pypi
pyqtwebengine             5.12.1                   pypi_0    pypi
pyrsistent                0.17.3           py37h8f50634_1    conda-forge
pyshp                     2.1.2              pyh9f0ad1d_0    conda-forge
pysocks                   1.7.1            py37he5f6b98_2    conda-forge
pytest                    6.1.2                    pypi_0    pypi
python                    3.7.8           h6f2ec95_1_cpython    conda-forge
python-dateutil           2.8.1                      py_0    conda-forge
python-snappy             0.5.4            py37h484ad9e_3    conda-forge
python_abi                3.7                     1_cp37m    conda-forge
pytz                      2020.4             pyhd8ed1ab_0    conda-forge
pyviz_comms               0.7.6              pyh9f0ad1d_0    conda-forge
pyyaml                    5.3.1            py37hb5d75c8_1    conda-forge
pyzmq                     19.0.2           py37hac76be4_2    conda-forge
qt                        5.12.9               h1f2b2cb_0    conda-forge
readline                  8.0                  he28a2e2_2    conda-forge
regex                     2020.10.28               pypi_0    pypi
requests                  2.24.0             pyh9f0ad1d_0    conda-forge
rtree                     0.9.4            py37h8526d28_1    conda-forge
ruamel_yaml               0.15.80         py37hb5d75c8_1003    conda-forge
s3fs                      0.5.1                      py_0    conda-forge
scipy                     1.5.3            py37h8911b10_0    conda-forge
send2trash                1.5.0                      py_0    conda-forge
setuptools                49.6.0           py37he5f6b98_2    conda-forge
shapely                   1.7.1            py37hedb1597_1    conda-forge
sia-viewer                0.0.1                    pypi_0    pypi
six                       1.15.0             pyh9f0ad1d_0    conda-forge
snappy                    1.1.8                he1b5a44_3    conda-forge
sortedcontainers          2.2.2              pyh9f0ad1d_0    conda-forge
sqlite                    3.33.0               h4cf870e_1    conda-forge
tblib                     1.6.0                      py_0    conda-forge
tcsh                      6.22.02              he28a2e2_1    conda-forge
terminado                 0.9.1            py37hc8dfbb8_1    conda-forge
testpath                  0.4.4                      py_0    conda-forge
thrift                    0.11.0          py37he1b5a44_1001    conda-forge
tiledb                    2.1.2                h47b529c_0    conda-forge
tk                        8.6.10               hed695b0_1    conda-forge
toml                      0.10.2                   pypi_0    pypi
toolz                     0.11.1                     py_0    conda-forge
tornado                   6.1              py37h4abf009_0    conda-forge
tqdm                      4.51.0             pyh9f0ad1d_0    conda-forge
traitlets                 5.0.5                      py_0    conda-forge
typed-ast                 1.4.1                    pypi_0    pypi
typing-extensions         3.7.4.3                       0    conda-forge
typing_extensions         3.7.4.3                    py_0    conda-forge
tzcode                    2020a                h516909a_0    conda-forge
udunits2                  2.2.27.6          h4e0c4b3_1001    conda-forge
urllib3                   1.25.11                    py_0    conda-forge
wcwidth                   0.2.5              pyh9f0ad1d_2    conda-forge
webencodings              0.5.1                      py_1    conda-forge
wheel                     0.35.1             pyh9f0ad1d_0    conda-forge
wrapt                     1.12.1           py37h8f50634_1    conda-forge
wrf-python                1.3.2            py37h82a5de7_2    conda-forge
xarray                    0.16.1                     py_0    conda-forge
xerces-c                  3.2.3                hfe33f54_1    conda-forge
xorg-imake                1.0.7                         0    conda-forge
xorg-kbproto              1.0.7             h14c3975_1002    conda-forge
xorg-libice               1.0.10               h516909a_0    conda-forge
xorg-libsm                1.2.3             h84519dc_1000    conda-forge
xorg-libx11               1.6.12               h516909a_0    conda-forge
xorg-libxau               1.0.9                h14c3975_0    conda-forge
xorg-libxaw               1.0.13            h516909a_1002    conda-forge
xorg-libxdmcp             1.1.3                h516909a_0    conda-forge
xorg-libxext              1.3.4                h516909a_0    conda-forge
xorg-libxmu               1.1.3                h516909a_0    conda-forge
xorg-libxpm               3.5.13               h516909a_0    conda-forge
xorg-libxrender           0.9.10            h516909a_1002    conda-forge
xorg-libxt                1.1.5             h516909a_1003    conda-forge
xorg-makedepend           1.0.6                he1b5a44_1    conda-forge
xorg-renderproto          0.11.1            h14c3975_1002    conda-forge
xorg-xextproto            7.3.0             h14c3975_1002    conda-forge
xorg-xproto               7.0.31            h14c3975_1007    conda-forge
xz                        5.2.5                h516909a_1    conda-forge
yaml                      0.2.5                h516909a_0    conda-forge
yarl                      1.6.2            py37h8f50634_0    conda-forge
zeromq                    4.3.3                he1b5a44_2    conda-forge
zict                      2.0.0                      py_0    conda-forge
zipp                      3.4.0                      py_0    conda-forge
zlib                      1.2.11            h516909a_1010    conda-forge
zstd                      1.4.5                h6597ccf_2    conda-forge
philippjfr commented 3 years ago

Thanks @tdhopper. Appears to be a projection issue, one simple fix is to project before rasterizing:

p = rasterize(gv.project(dataset.to(
            gv.QuadMesh,
            ["lon", "lat"],
            'air',
        )))

Definitely shouldn't be needed though, it appears this happens because during projection the coordinates are normalized to -180 to 180 and when rasterize tries to update the data in that region it gets back an empty slice because the data longitudes range from 0 to 360.

tdhopper commented 3 years ago

@philippjfr Thank you. That fixes it!

itsgifnotjiff commented 1 year ago

Does anyone know how to fix this using hvplot.quadmesh( ... )?