creare-com / pydem

Python library for Global Hydrology Analysis. Used to calculate upstream contributing area, aspect, slope, and topographic wetness index.
Apache License 2.0
114 stars 35 forks source link

Error in calc_uca() #9

Closed tzoiker closed 6 years ago

tzoiker commented 7 years ago

When I try to run calc_uca, I get the following error:

pydem/cyfuncs/cyutils.pyx in pydem.cyfuncs.cyutils.drain_area (/private/var/folders/1j/r_xd9vp15td_mdt_3rgrx13w0000gp/T/pip-rmLTHG-build/pydem/cyfuncs/cyutils.cpp:2470)() ValueError: Item size of buffer (8 bytes) does not match size of 'int' (4 bytes)

Installed pydem via pip install --ignore-installed git+git://github.com/creare-com/pydem.git@develop as in here https://github.com/creare-com/pydem/issues/7 to solve the same problem: TypeError: Cannot cast ufunc add output from dtype('float64') to dtype('bool') with casting rule 'same_kind'.

Python 2.7.12, MacOS 10.12.3, 64-bit.

Note: GeoTIFFs I provide as an input are of float32 type, but calc_slopes_directions outputs float64.

mpu-creare commented 7 years ago

What version of numpy are you using?

tzoiker commented 7 years ago

@mpu-creare, 1.13.0

mpu-creare commented 7 years ago

Okay, I'll have a look. Little swamped over here, it may take a few weeks. There are a couple of enhancements in the pipeline I haven't had a chance to push through. I'll lump that in the update that's coming.

mpu-creare commented 7 years ago

Actually, could also please copy the output from: pip install --ignore-installed git+git://github.com/creare-com/pydem.git@develop ?

Thanks.

tzoiker commented 7 years ago

@mpu-creare Thank you!

Output of pip install --ignore-installed git+git://github.com/creare-com/pydem.git@develop:

"Collecting git+git://github.com/creare-com/pydem.git@develop Cloning git://github.com/creare-com/pydem.git (to develop) to /private/var/folders/1j/r_xd9vp15td_mdt_3rgrx13w0000gp/T/pip-cO7HPq-build Collecting numpy (from pyDEM==0.1.1) Using cached numpy-1.13.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl Collecting scipy (from pyDEM==0.1.1) Downloading scipy-0.19.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (16.2MB) 100% |████████████████████████████████| 16.2MB 42kB/s Collecting geopy (from pyDEM==0.1.1) Using cached geopy-1.11.0-py2.py3-none-any.whl Collecting traits (from pyDEM==0.1.1) Installing collected packages: numpy, scipy, geopy, traits, pyDEM Running setup.py install for pyDEM ... done Successfully installed geopy-1.11.0 numpy-1.13.0 pyDEM-0.1.1 scipy-0.19.0 traits-4.6.0"

mpu-creare commented 7 years ago

Mmm... it doesn't look like cython was run when installing pydem... perhaps the old version of the binaries are being used (or perhaps the output is being suppressed on the MAC, I don't have a MAC immediately handy.)

Can you please try completely removing pydem and reinstalling? Please copy the output of the installation again.

tzoiker commented 7 years ago

@mpu-creare output is the same...

But now calc_uca() gives:

"pydem/cyfuncs/cyutils.pyx in pydem.cyfuncs.cyutils.drain_area (/private/var/folders/1j/r_xd9vp15td_mdt_3rgrx13w0000gp/T/pip-rmLTHG-build/pydem/cyfuncs/cyutils.cpp:2465)()

ValueError: Buffer has wrong number of dimensions (expected 1, got 2)"

UPD: OK, for some reason now it is the same error as the first one.

mpu-creare commented 7 years ago

@tzoiker any chance you can share your input data?

Incidentally, this is where I've tried to fix the problem in #5: https://github.com/creare-com/pydem/commit/311d2171f07ce1fe0955bff194bde573ec1e3d42 I'm not sure why it's showing up again. I also just did a fresh install on Windows using:

conda install gdal numpy scipy traits
pip install geopy
pip install --no-deps --ignore-installed git+git://github.com/creare-com/pydem.git@develop

And now running a calculation on an Nasa SRTM geotiff seems just fine... I am working on a new release as well...

mpu-creare commented 7 years ago

Ok, figured out how to reproduce the error. Working on it...

mpu-creare commented 7 years ago

Ok, think we finally solved it. Just pushed a new version of pydem. Let me know if the new version solves your problem.

mpu-creare commented 6 years ago

Closing this out.