ITU-Rpy icon indicating copy to clipboard operation
ITU-Rpy copied to clipboard

[BUG] bisect returning ValueError: f(a) and f(b) must have different signs

Open jayGG83 opened this issue 11 months ago • 5 comments

Im trying to use inverse_rain_attenuation function from ITU-R P.530 but I'm getting this error:

File "./lib/link_budget.py", line 341, in inverse_rain_attenuation return bisect(func_bisect, 0.000001, 100) File ".venv/lib/python3.10/site-packages/scipy/optimize/_zeros_py.py", line 557, in bisect r = _zeros._bisect(f, a, b, xtol, rtol, maxiter, args, full_output, disp) ValueError: f(a) and f(b) must have different signs

Here is an example:

from itur.models.itu530 import inverse_rain_attenuation
f = 22.5   # Link frequency
d = 2.6  # Distance
el = 60  # Elevation angle constanf 60 degrees
Ap = 30  #Fade depth
lat = 50.3515944444
lon = 10.9511027778
inverse_rain_attenuation(lat, lon, d, f, el, Ap, tau=90, R001=None)

Thanks in advance

jayGG83 avatar Jul 07 '23 15:07 jayGG83

Thanks for reporting this issue.

In this case, the error is caused because the probability of occurrence of this event (attenuation > 30 for the 2.6 km path) is 0.

I will correct the code accordingly.

inigodelportillo avatar Jul 08 '23 19:07 inigodelportillo

This has been fixed now in master.

inigodelportillo avatar Jul 08 '23 19:07 inigodelportillo

Thanks!

I tried using this function as it an example to obtain the link availabilty (100 - inverse_rain_attenuation). After various tests with the modified function, with various distances and fade depth tested, the result is always 0.

To get the fade depth, this is the formula I used (I'd appreciate if it is correct): fd = TX power + antenna gains (both) - receiver sensitivity - 20log10(4pidistance / wavelength)

jayGG83 avatar Jul 11 '23 14:07 jayGG83

The method returns the probability of the fade due to rain to exceed the value.

The value of Ap is not the total fade (including FSPL) but just the attenuation due to rain events. Try small values of Ap (1dB, 2dB) and see if that gives you a non-zero value.

inigodelportillo avatar Jul 11 '23 14:07 inigodelportillo

I tried using Ap small values as you mentioned but the results are the same (0).

If Ap value is the attenuation due to rain events, then the resulting value from rain_attenuation (I have to calculate both horizontal and vertical polarization) is a valid value (though that value is not small as im getting 27 and 28 dBm)?

jayGG83 avatar Jul 11 '23 14:07 jayGG83