I included an unreachable condition in this function. The problem is that it was just reached. I don't know how to troubleshoot it.
def bcirrus_func1(Qn):
if Qn <= -1:
bcirrus = 0
elif Qn > -1 and Qn <= 0:
bcirrus = 0.5*(1-Qn)**2
elif Qn > 0 and Qn < 1:
bcirrus = 1 - 0.5*(1-Qn)**2
elif Qn >= 1:
bcirrus = 1
else:
print('Something has gone very wrong')
return(bcirrus)
How could 'Something has gone very wrong' have been triggered?
Here is the error:
/.local/lib/python3.6/site-packages/pint/numpy_func.py:289: RuntimeWarning: overflow encountered in exp
result_magnitude = func(*stripped_args, **stripped_kwargs)
/.local/lib/python3.6/site-packages/pint/quantity.py:1160: RuntimeWarning: invalid value encountered in double_scalars
magnitude = magnitude_op(new_self._magnitude, other._magnitude)
Something has gone very wrong
Traceback (most recent call last):
File "./make_pcc_layer.py", line 122, in <module>
pcc1, pcc2 = cc.PCC(layer_pressure,layer[i][j].tmp-273.15,layer[i][j].rh,layer[i][j].icmr)
File "//weather_box/earth/clouds_and_contrails.py", line 119, in PCC
PCC1 = bcirrus_func1(Qnstar)-bcirrus_func1(Qn)
File "//weather_box/earth/clouds_and_contrails.py", line 39, in bcirrus_func1
return(bcirrus)
UnboundLocalError: local variable 'bcirrus' referenced before assignment
EDIT: I added Qn to the "unreachable" print statement and it is NaN as was suggested. Here is the output:
Something has gone very wrong: Qn nan dimensionless
It says "dimensionless" because it is using Pint.