Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero division when creating the spatial grid #37

Closed
4 tasks done
Andreas-Piter opened this issue Feb 10, 2025 · 0 comments · Fixed by #38
Closed
4 tasks done

Zero division when creating the spatial grid #37

Andreas-Piter opened this issue Feb 10, 2025 · 0 comments · Fixed by #38
Labels
bug Something isn't working

Comments

@Andreas-Piter
Copy link
Member

Andreas-Piter commented Feb 10, 2025

Problem:

A ZeroDivisionError appeared during creating a spatial grid.
The reason is that the grid size is bigger than the size of the study area covered by the images in at least one dimension.

Traceback (most recent call last):
  File "/opt/pycharm-community-2024.1.4/plugins/python-ce/helpers/pydev/pydevd.py", line 1551, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/opt/pycharm-community-2024.1.4/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/home/piter/develop/sar4infra/sarvey_dev/sarvey/sarvey_mti.py", line 334, in <module>
    main()
  File "/home/piter/develop/sar4infra/sarvey_dev/sarvey/sarvey_mti.py", line 330, in main
    run(config=config, args=args, logger=logger)
  File "/home/piter/develop/sar4infra/sarvey_dev/sarvey/sarvey_mti.py", line 160, in run
    proc_obj.runFiltering()
  File "/home/piter/develop/sar4infra/sarvey_dev/sarvey/processing.py", line 595, in runFiltering
    box_list, num_box = ut.createSpatialGrid(coord_utm_img=coord_utm_obj.coord_utm, length=point1_obj.length,
  File "/home/piter/develop/sar4infra/sarvey_dev/sarvey/utils.py", line 538, in createSpatialGrid
    box_list, num_box = splitImageIntoBoxesRngAz(length=length, width=width,
  File "/home/piter/develop/sar4infra/sarvey_dev/sarvey/utils.py", line 391, in splitImageIntoBoxesRngAz
    x_step = int(np.rint((width / num_box_az) / 10) * 10)
ZeroDivisionError: division by zero

ToDo:

  • Catch this error in createSpatialGrid
    • check if num_box_az or num_box_rng are zero
    • if yes, set num_box_az or num_box_rng to 1
  • Inform the user if the chosen grid size is too small for the given study area.
@Andreas-Piter Andreas-Piter added the bug Something isn't working label Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant