atlite
atlite copied to clipboard
unmanaged out of shape exception in hydro: index 0 is out of bounds for axis 0 with size 0
Dear developers, In the hydro function, I experience the exeption "index 0 is out of bounds..." in hydro.py#34 as some of the plants that I am passing to the hydro function are outside the region delimited by the hydrobasins.
Description
The issue should arise for any problem concerning hydro.py, assuming to give a point in plants outside the region delimited by hydrobasins.
Expected Behavior
I think it would be useful to avoid this issue and simply put a 0.0 for such cases.
Actual Behavior
Currently, instead, the algorithm stops and the exception is thrown
Error Message
File "C:\ProgramData\Miniconda3\envs\toast\lib\site-packages\atlite\convert.py", line 596, in hydro basins = hydrom.determine_basins(plants, hydrobasins, show_progress=show_progress) File "C:\ProgramData\Miniconda3\envs\toast\lib\site-packages\atlite\hydro.py", line 75, in determine_basins hid = find_basin(shapes, p.lon, p.lat) File "C:\ProgramData\Miniconda3\envs\toast\lib\site-packages\atlite\hydro.py", line 34, in find_basin return hids[0] File "C:\ProgramData\Miniconda3\envs\toast\lib\site-packages\pandas\core\indexes\base.py", line 4604, in getitem return getitem(key) IndexError: index 0 is out of bounds for axis 0 with size 0
Your Environment
- The
atliteversion used: 0.2.5 - How you installed
atlite(conda,piporgithub): conda - Operating System: Windows
- My environment: affine 2.3.0 py_0 conda-forge alabaster 0.7.12 py_0 conda-forge amply 0.1.4 py_0 conda-forge appdirs 1.4.4 pyh9f0ad1d_0 conda-forge atlite 0.2.5 pyhd8ed1ab_0 conda-forge atomicwrites 1.4.0 pyh9f0ad1d_0 conda-forge attrs 21.2.0 pyhd8ed1ab_0 conda-forge babel 2.9.1 pyh44b312d_0 conda-forge backcall 0.2.0 pyh9f0ad1d_0 conda-forge backports 1.0 py_2 conda-forge backports.functools_lru_cache 1.6.4 pyhd8ed1ab_0 conda-forge beautifulsoup4 4.9.3 pyhb0f4dca_0 conda-forge blosc 1.21.0 h0e60522_0 conda-forge bokeh 2.3.3 py39hcbf5309_0 conda-forge boost-cpp 1.74.0 h54f0996_3 conda-forge bottleneck 1.3.2 py39h5d4886f_4 conda-forge brotlipy 0.7.0 py39hb82d6ee_1001 conda-forge bzip2 1.0.8 h8ffe710_4 conda-forge ca-certificates 2021.5.30 h5b45459_0 conda-forge cairo 1.16.0 hb19e0ff_1008 conda-forge cartopy 0.19.0.post1 py39hfa2520c_0 conda-forge cdsapi 0.5.1 pyhd8ed1ab_0 conda-forge certifi 2021.5.30 py39hcbf5309_0 conda-forge cffi 1.14.6 py39h0878f49_0 conda-forge cfitsio 3.470 h0af3d06_7 conda-forge cftime 1.5.0 py39h5d4886f_0 conda-forge chardet 4.0.0 py39hcbf5309_1 conda-forge click 7.1.2 pyh9f0ad1d_0 conda-forge click-plugins 1.1.1 py_0 conda-forge cligj 0.7.2 pyhd8ed1ab_0 conda-forge cloudpickle 1.6.0 py_0 conda-forge colorama 0.4.4 pyh9f0ad1d_0 conda-forge conda 4.10.3 py39hcbf5309_2 conda-forge conda-package-handling 1.7.3 py39hb3671d1_0 conda-forge configargparse 1.5.2 pyhd8ed1ab_0 conda-forge connection_pool 0.0.3 pyhd3deb0d_0 conda-forge contextily 1.1.0 pyhd8ed1ab_0 conda-forge country_converter 0.7.3 pyhd8ed1ab_0 conda-forge countrycode 0.2 pypi_0 pypi cryptography 3.4.7 py39hd8d06c1_0 conda-forge curl 7.78.0 h789b8ee_0 conda-forge cycler 0.10.0 py_2 conda-forge cytoolz 0.11.0 py39hb82d6ee_3 conda-forge dask 2021.3.1 pyhd8ed1ab_0 conda-forge dask-core 2021.3.1 pyhd8ed1ab_0 conda-forge datrie 0.8.2 py39hb82d6ee_2 conda-forge debugpy 1.4.1 py39h415ef7b_0 conda-forge decorator 4.4.2 py_0 conda-forge deprecation 2.1.0 pyh9f0ad1d_0 conda-forge descartes 1.1.0 py_4 conda-forge distributed 2021.4.1 py39hcbf5309_1 conda-forge docutils 0.17.1 py39hcbf5309_0 conda-forge entrypoints 0.3 pyhd8ed1ab_1003 conda-forge entsoe-py 0.3.7 pyhd8ed1ab_0 conda-forge esy-osm-pbf 0.0.1 pypi_0 pypi esy-osmfilter 1.0.11 pypi_0 pypi et_xmlfile 1.0.1 py_1001 conda-forge expat 2.4.1 h39d44d4_0 conda-forge filelock 3.0.12 pyh9f0ad1d_0 conda-forge fiona 1.8.18 py39h9f1b043_1 conda-forge fontconfig 2.13.1 h1989441_1005 conda-forge freetype 2.10.4 h546665d_1 conda-forge freexl 1.0.6 ha8e266a_0 conda-forge fsspec 2021.7.0 pyhd8ed1ab_0 conda-forge gdal 3.2.1 py39h6795fcd_7 conda-forge geographiclib 1.52 pyhd8ed1ab_0 conda-forge geopandas 0.9.0 pyhd8ed1ab_1 conda-forge geopandas-base 0.9.0 pyhd8ed1ab_1 conda-forge geoplot 0.4.4 pyhd8ed1ab_0 conda-forge geopy 2.2.0 pyhd8ed1ab_0 conda-forge geos 3.9.1 h39d44d4_2 conda-forge geotiff 1.6.0 hee96dd5_4 conda-forge gettext 0.19.8.1 h1a89ca6_1005 conda-forge gitdb 4.0.7 pyhd8ed1ab_0 conda-forge gitpython 3.1.18 pyhd8ed1ab_0 conda-forge glpk 5.0 h8ffe710_0 conda-forge hdf4 4.2.15 h0e5069d_3 conda-forge hdf5 1.10.6 nompi_h5268f04_1114 conda-forge heapdict 1.0.1 py_0 conda-forge icu 68.1 h0e60522_0 conda-forge idna 2.10 pyh9f0ad1d_0 conda-forge imagesize 1.2.0 py_0 conda-forge importlib-metadata 4.7.1 py39hcbf5309_1 conda-forge iniconfig 1.1.1 pyh9f0ad1d_0 conda-forge intel-openmp 2021.3.0 h57928b3_3372 conda-forge ipykernel 6.3.1 py39h832f523_0 conda-forge ipython 7.26.0 py39h832f523_0 conda-forge ipython_genutils 0.2.0 py_1 conda-forge jdcal 1.4.1 py_0 conda-forge jedi 0.18.0 py39hcbf5309_2 conda-forge jinja2 3.0.1 pyhd8ed1ab_0 conda-forge joblib 1.0.1 pyhd8ed1ab_0 conda-forge jpeg 9d h8ffe710_0 conda-forge jsonschema 3.2.0 pyhd8ed1ab_3 conda-forge jupyter_client 7.0.2 pyhd8ed1ab_0 conda-forge jupyter_core 4.7.1 py39hcbf5309_0 conda-forge kealib 1.4.14 h96bfa42_2 conda-forge kiwisolver 1.3.1 py39h2e07f2f_1 conda-forge krb5 1.19.2 hbae68bd_0 conda-forge lcms2 2.12 h2a16943_0 conda-forge libarchive 3.5.1 h8686738_1 conda-forge libblas 3.9.0 11_win64_mkl conda-forge libcblas 3.9.0 11_win64_mkl conda-forge libclang 11.1.0 default_h5c34c98_1 conda-forge libcurl 7.78.0 h789b8ee_0 conda-forge libffi 3.3 h0e60522_2 conda-forge libgdal 3.2.1 hca2c63a_7 conda-forge libglib 2.68.4 h1e62bf3_0 conda-forge libiconv 1.16 he774522_0 conda-forge libkml 1.3.0 h9859afa_1014 conda-forge liblapack 3.9.0 11_win64_mkl conda-forge libnetcdf 4.7.4 nompi_h3a9aa94_107 conda-forge libpng 1.6.37 h1d00b33_2 conda-forge libpq 13.3 hfcc5ef8_0 conda-forge librttopo 1.1.0 hb340de5_6 conda-forge libsodium 1.0.18 h8d14728_1 conda-forge libsolv 0.7.19 h7755175_5 conda-forge libspatialindex 1.9.3 h39d44d4_4 conda-forge libspatialite 5.0.1 h987baeb_3 conda-forge libssh2 1.9.0 h680486a_6 conda-forge libtiff 4.2.0 h763f289_2 conda-forge libwebp-base 1.2.1 h8ffe710_0 conda-forge libxml2 2.9.12 hf5bbc77_0 conda-forge libxslt 1.1.33 h65864e5_2 conda-forge locket 0.2.0 py_2 conda-forge lxml 4.6.3 py39h4fd7cdf_0 conda-forge lz4-c 1.9.3 h8ffe710_1 conda-forge lzo 2.10 he774522_1000 conda-forge m2w64-gcc-libgfortran 5.3.0 6 conda-forge m2w64-gcc-libs 5.3.0 7 conda-forge m2w64-gcc-libs-core 5.3.0 7 conda-forge m2w64-gmp 6.1.0 2 conda-forge m2w64-libwinpthread-git 5.0.0.4634.697f757 2 conda-forge mamba 0.15.3 py39h006a82b_0 conda-forge mapclassify 2.4.3 pyhd8ed1ab_0 conda-forge markupsafe 2.0.1 py39hb82d6ee_0 conda-forge matplotlib 3.4.3 py39hcbf5309_0 conda-forge matplotlib-base 3.4.3 py39h581301d_0 conda-forge matplotlib-inline 0.1.2 pyhd8ed1ab_2 conda-forge memory_profiler 0.58.0 py_0 conda-forge menuinst 1.4.17 py39hcbf5309_1 conda-forge mercantile 1.2.1 pyhd8ed1ab_0 conda-forge mkl 2021.3.0 hb70f87d_564 conda-forge mock 4.0.3 py39hcbf5309_1 conda-forge more-itertools 8.10.0 pyhd8ed1ab_0 conda-forge msgpack-python 1.0.2 py39h2e07f2f_1 conda-forge msys2-conda-epoch 20160418 1 conda-forge munch 2.5.0 py_0 conda-forge nbformat 5.1.3 pyhd8ed1ab_0 conda-forge nest-asyncio 1.5.1 pyhd8ed1ab_0 conda-forge netcdf4 1.5.6 nompi_py39hc3aef6b_102 conda-forge networkx 2.6.2 pyhd8ed1ab_0 conda-forge numexpr 2.7.3 py39h2e25243_0 conda-forge numpy 1.21.2 py39h6635163_0 conda-forge olefile 0.46 pyh9f0ad1d_1 conda-forge openjpeg 2.4.0 hb211442_1 conda-forge openpyxl 3.0.7 pyhd8ed1ab_0 conda-forge openssl 1.1.1l h8ffe710_0 conda-forge packaging 21.0 pyhd8ed1ab_0 conda-forge pandas 1.3.2 py39h2e25243_0 conda-forge parso 0.8.2 pyhd8ed1ab_0 conda-forge partd 1.2.0 pyhd8ed1ab_0 conda-forge patsy 0.5.1 py_0 conda-forge pcre 8.45 h0e60522_0 conda-forge pickleshare 0.7.5 py_1003 conda-forge pillow 8.2.0 py39h1a9d4f7_1 conda-forge pip 21.2.4 pyhd8ed1ab_0 conda-forge pixman 0.40.0 h8ffe710_0 conda-forge pluggy 1.0.0 py39hcbf5309_1 conda-forge ply 3.11 py_1 conda-forge poppler 0.89.0 h3772339_5 conda-forge poppler-data 0.4.10 0 conda-forge postgresql 13.3 h1c22c4f_0 conda-forge powerplantmatching 0.4.8 pyhd8ed1ab_0 conda-forge progressbar2 3.53.1 pyh9f0ad1d_0 conda-forge proj 7.2.0 h1cfcee9_2 conda-forge prompt-toolkit 3.0.20 pyha770c72_0 conda-forge protobuf 3.17.3 pypi_0 pypi psutil 5.8.0 py39hb82d6ee_1 conda-forge pulp 2.5.0 py39hcbf5309_0 conda-forge py 1.10.0 pyhd3deb0d_0 conda-forge pycosat 0.6.3 py39hb82d6ee_1006 conda-forge pycountry 20.7.3 pyh9f0ad1d_0 conda-forge pycparser 2.20 pyh9f0ad1d_2 conda-forge pygments 2.10.0 pyhd8ed1ab_0 conda-forge pyomo 6.1.2 py39h415ef7b_0 conda-forge pyopenssl 20.0.1 pyhd8ed1ab_0 conda-forge pyparsing 2.4.7 pyh9f0ad1d_0 conda-forge pyproj 3.1.0 py39h41cdc1e_3 conda-forge pypsa 0.18.0 pyhd8ed1ab_0 conda-forge pyqt 5.12.3 py39hcbf5309_7 conda-forge pyqt-impl 5.12.3 py39h415ef7b_7 conda-forge pyqt5-sip 4.19.18 py39h415ef7b_7 conda-forge pyqtchart 5.12 py39h415ef7b_7 conda-forge pyqtwebengine 5.12.1 py39h415ef7b_7 conda-forge pyrsistent 0.17.3 py39hb82d6ee_2 conda-forge pyshp 2.1.3 pyh44b312d_0 conda-forge pysocks 1.7.1 py39hcbf5309_3 conda-forge pytables 3.6.1 py39h42e6cd8_3 conda-forge pytest 6.2.5 py39hcbf5309_0 conda-forge python 3.9.6 h7840368_1_cpython conda-forge python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge python-utils 2.5.6 pyh44b312d_0 conda-forge python_abi 3.9 2_cp39 conda-forge pytz 2021.1 pyhd8ed1ab_0 conda-forge pywin32 301 py39hb82d6ee_0 conda-forge pyyaml 5.4.1 py39hb82d6ee_1 conda-forge pyzmq 22.2.1 py39he46f08e_0 conda-forge qt 5.12.9 h5909a2a_4 conda-forge rasterio 1.2.6 py39h334309b_0 conda-forge ratelimiter 1.2.0 py_1002 conda-forge reproc 14.2.1 h8ffe710_0 conda-forge reproc-cpp 14.2.1 h0e60522_0 conda-forge requests 2.25.1 pyhd3deb0d_0 conda-forge rioxarray 0.7.0 pyhd8ed1ab_0 conda-forge rtree 0.9.7 py39h09fdee3_2 conda-forge ruamel_yaml 0.15.80 py39hb82d6ee_1004 conda-forge scikit-learn 0.24.2 py39he931e04_1 conda-forge scipy 1.7.1 py39hc0c34ad_0 conda-forge seaborn 0.11.2 hd8ed1ab_0 conda-forge seaborn-base 0.11.2 pyhd8ed1ab_0 conda-forge setuptools 57.4.0 py39hcbf5309_0 conda-forge shapely 1.8a1 py39hc6044ec_0 conda-forge/label/shapely_dev six 1.16.0 pyh6c4a22f_0 conda-forge sklearn 0.0 pypi_0 pypi smart_open 5.2.0 pyhd8ed1ab_0 conda-forge smmap 3.0.5 pyh44b312d_0 conda-forge snakemake-minimal 6.7.0 pyhdfd78af_0 bioconda snowballstemmer 2.1.0 pyhd8ed1ab_0 conda-forge snuggs 1.4.7 py_0 conda-forge sortedcontainers 2.4.0 pyhd8ed1ab_0 conda-forge soupsieve 2.0.1 py_1 conda-forge sphinx 4.2.0 pyh6c4a22f_0 conda-forge sphinx_rtd_theme 1.0.0 pyhd8ed1ab_0 conda-forge sphinxcontrib-applehelp 1.0.2 py_0 conda-forge sphinxcontrib-devhelp 1.0.2 py_0 conda-forge sphinxcontrib-htmlhelp 2.0.0 pyhd8ed1ab_0 conda-forge sphinxcontrib-jsmath 1.0.1 py_0 conda-forge sphinxcontrib-qthelp 1.0.3 py_0 conda-forge sphinxcontrib-serializinghtml 1.1.5 pyhd8ed1ab_0 conda-forge sqlite 3.36.0 h8ffe710_0 conda-forge statsmodels 0.12.2 py39h5d4886f_0 conda-forge stopit 1.1.2 py_0 conda-forge tabulate 0.8.9 pyhd8ed1ab_0 conda-forge tbb 2021.3.0 h2d74725_0 conda-forge tblib 1.7.0 pyhd8ed1ab_0 conda-forge threadpoolctl 2.2.0 pyh8a188c0_0 conda-forge tiledb 2.2.9 hf84e3da_0 conda-forge tk 8.6.11 h8ffe710_0 conda-forge toml 0.10.2 pyhd8ed1ab_0 conda-forge toolz 0.11.1 py_0 conda-forge toposort 1.6 pyhd8ed1ab_0 conda-forge tornado 6.1 py39hb82d6ee_1 conda-forge tqdm 4.62.2 pyhd8ed1ab_0 conda-forge traitlets 5.0.5 py_0 conda-forge tsam 1.1.1 pypi_0 pypi typing_extensions 3.10.0.0 pyha770c72_0 conda-forge tzdata 2021a he74cb21_1 conda-forge ucrt 10.0.20348.0 h57928b3_0 conda-forge urllib3 1.26.6 pyhd8ed1ab_0 conda-forge vc 14.2 hb210afc_5 conda-forge vresutils 0.3.1 pypi_0 pypi vs2015_runtime 14.29.30037 h902a5da_5 conda-forge wcwidth 0.2.5 pyh9f0ad1d_2 conda-forge wheel 0.37.0 pyhd8ed1ab_1 conda-forge win_inet_pton 1.1.0 py39hcbf5309_2 conda-forge wrapt 1.12.1 py39hb82d6ee_3 conda-forge xarray 0.19.0 pyhd8ed1ab_1 conda-forge xerces-c 3.2.3 h0e60522_2 conda-forge xlrd 2.0.1 pyhd8ed1ab_3 conda-forge xz 5.2.5 h62dcd97_1 conda-forge yaml 0.2.5 he774522_0 conda-forge zeromq 4.3.4 h0e60522_1 conda-forge zict 2.0.0 py_0 conda-forge zipp 3.5.0 pyhd8ed1ab_0 conda-forge zlib 1.2.11 h62dcd97_1010 conda-forge zstd 1.4.9 h6255e5f_0 conda-forge
thanks for reporting @davide-f, since you seem to have dived into the code a bit, would you mind making a PR on this issue?
closing this, please reopen if issue remains