Inconsistent ZeroDivisionError: float division

What is the issue or question you have?

running sdr in batch mode using the InVEST guide, the model works fine (except I cannot get the log file working, for some reason).

However, for a bit of experimentation, I changed all the usle_c values in the biophysical table to 1. To see what happens to my results.

The model runs (iterating over 3-parameter space, like this:
x = np.array([(k, i, s) for k in np.linspace(0.01,3,5) for i in np.linspace(0.1,1,5) for s in np.linspace(0.5, 1, 5)])
and


if __name__ == '__main__':
    for ii  in range (0,125):
        args['ic_0_param'] = x[ii,1]
        args['k_param'] = x[ii,0]
        args['sdr_max'] = x[ii,2]
        args['results_suffix'] = 'hydro_dem_10m_qgis_lulu_1_' + str(ii)
        args['workspace_dir'] = 'C:\\...\\sdr\\allowed_to_model\\run_90'
        natcap.invest.sdr.sdr.execute(args)

When running the model with usle_c = 1, the model fails at a random point, with the error
inconsistent ZeroDivisionError: float division

sometimes it fails at ii = 4
sometimes ii=6

the invest app always runs the model (same inputs).

I am losing my mind. Anyone got an idea?

What do you expect to happen?

the model to run

What have you tried so far?

pulling out my hair.

but also, I try

for ii in range(4,10):
and that works
and then the next time it might not work

Attach the logfile here:

1 Like

well I don’t have all the answers, but changing the sdrmax from 1 to 0.99 seems to have done the trick, in case anyone else gets here and wonders what happened…

m

what I mean is, I changed my array:

from:
x = np.array([(k, i, s) for k in np.linspace(0.01,3,5) for i in np.linspace(0.1,1,5) for s in np.linspace(0.5, 1, 5)])

to:
x = np.array([(k, i, s) for k in np.linspace(0.01,3,5) for i in np.linspace(0.1,1,5) for s in np.linspace(0.5, 0.99, 5)])

@gismat, thanks for reporting this. Do you get any traceback showing where the ZeroDivisionError is happening?

I had a traceback, but didn’t copy it down. I’ll try to reproduce the error today