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

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

Open
jayGG83 opened this issue Jul 7, 2023 · 5 comments
Assignees
Labels

Comments

@jayGG83
Copy link

jayGG83 commented Jul 7, 2023

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

@inigodelportillo
Copy link
Owner

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
Copy link
Owner

This has been fixed now in master.

@jayGG83
Copy link
Author

jayGG83 commented Jul 11, 2023

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)

@inigodelportillo
Copy link
Owner

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.

@jayGG83
Copy link
Author

jayGG83 commented Jul 11, 2023

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)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants