climate_indices
climate_indices copied to clipboard
ZeroDivisionError: integer division or modulo by zero
While calculating SPI from IMERG precipitation data I encountered the following error:
My input: (indices_env) saumikmallik@alterbliss:~/my_works/imerg_drywet_periods/climate_indices-master$ process_climate_indices --index spi --periodicity monthly --netcdf_precip imerg/IMERG_fix_mm.nc --var_name_precip precipitation --output_file_base results/IMERG --scales 3 --calibration_start_year 2000 --calibration_end_year 2020
Output:
2020-11-16 00:37:29 INFO Start time: 2020-11-16 00:37:29.894405
2020-11-16 00:37:30 INFO Computing 3-month SPI/Pearson
2020-11-16 00:37:31 ERROR Failed to complete
Traceback (most recent call last):
File "/home/saumikmallik/anaconda3/envs/indices_env/lib/python3.8/site-packages/climate_indices/main.py", line 1687, in main
_compute_write_index(kwrgs)
File "/home/saumikmallik/anaconda3/envs/indices_env/lib/python3.8/site-packages/climate_indices/main.py", line 1014, in _compute_write_index
_parallel_process(keyword_arguments["index"],
File "/home/saumikmallik/anaconda3/envs/indices_env/lib/python3.8/site-packages/climate_indices/main.py", line 1188, in _parallel_process
d, m = divmod(shape[0], _NUMBER_OF_WORKER_PROCESSES)
ZeroDivisionError: integer division or modulo by zero
Traceback (most recent call last):
File "/home/saumikmallik/anaconda3/envs/indices_env/bin/process_climate_indices", line 8, in
I have edited compute.py and indices.py according to Seven-milk, but still encountering the issue. Am I doing anything wrong or is it a bug?
Thanks @Saumik43 Please send a link to your data so I can try to reproduce this and debug.
This is just a preliminary guess: somehow the _NUMBER_OF_WORKER_PROCESSES
value has been set to zero or never declared at all, based on this error message:
File "/home/saumikmallik/anaconda3/envs/indices_env/lib/python3.8/site-packages/climate_indices/main.py", line 1188, in _parallel_process
d, m = divmod(shape[0], _NUMBER_OF_WORKER_PROCESSES)
ZeroDivisionError: integer division or modulo by zero
So maybe the first thing to do is to add a line to log this value (or step through the code in a debugger) to rule this out as the culprit?