CNES/demcompare

AxisError

Closed this issue · 4 comments

If you run the demcompare with example data, you will get an error:

demcompare sample_config.json --loglevel DEBUG

2024-10-15/15:32:30 :: ERROR ::  Demcompare Traceback (most recent call last):
  File "/home/roman/gitrepo/dems/.venv/lib/python3.12/site-packages/demcompare/demcompare.py", line 85, in main
    demcompare.run(args.config, loglevel=args.loglevel)
  File "/home/roman/gitrepo/dems/.venv/lib/python3.12/site-packages/demcompare/__init__.py", line 177, in run
    input_stats_ref = compute_dem_slope(input_stats_ref)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/roman/gitrepo/dems/.venv/lib/python3.12/site-packages/demcompare/dem_tools.py", line 1011, in compute_dem_slope
    lonr = np.roll(lon, 1, 1)
           ^^^^^^^^^^^^^^^^^^
  File "/home/roman/gitrepo/dems/.venv/lib/python3.12/site-packages/numpy/_core/numeric.py", line 1268, in roll
    axis = normalize_axis_tuple(axis, a.ndim, allow_duplicate=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/roman/gitrepo/dems/.venv/lib/python3.12/site-packages/numpy/_core/numeric.py", line 1439, in normalize_axis_tuple
    axis = tuple([normalize_axis_index(ax, ndim, argname) for ax in axis])
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
numpy.exceptions.AxisError: axis 1 is out of bounds for array of dimension 1

Hello @skimprem,
Thank you for the issue. We haven't tested demcompare in python 3.12 and it appears that rasterio is upgraded and some rasterio functions have not the same output, which breaks some internal slope computation function in demcompare.
The quickest fix is to downgrade rasterio to 1.3.11:

pip uninstall rasterio pip install rasterio==1.3.11
We shall produce a fix through an upcoming commit, but no release is foreseen yet.

Thanks again for the bug anyway, hope the quick fix answers your need.

The bug is dealt in last commit : be440b7

Please tell me if it is ok, so that I can close the issue

The bug is dealt in last commit : be440b7

Please tell me if it is ok, so that I can close the issue

It is ok. This issue can be closed.

thanks for the bug ! I close the issue