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

sqrt Runtimewarning error #8

Open
davidh- opened this issue Dec 19, 2022 · 1 comment
Open

sqrt Runtimewarning error #8

davidh- opened this issue Dec 19, 2022 · 1 comment

Comments

@davidh-
Copy link

davidh- commented Dec 19, 2022

Hi,

I have the code working with my T3 Search. Just fixing errors that are popping up and one of them is the following:

/home/pi/ht301_hacklib/ht301_hacklib.py:94: RuntimeWarning: invalid value encountered in sqrt
np_Ttot = np_v8**0.5 - l_flt_1000337C - ABSOLUTE_ZERO_CELSIUS

I added some print statements to see what's the issue and found np_v8 is a numpy array instantiated to have negative values for the first ~16384 entries. The sqrt throws an error when it encounters these. Would you agree is is fine to set all of the negative values in the numpy array to 0? Or do you have a better fix for this?

testing device nr: 0
width: 384.0 height: 292.0
width: 384.0 height: 292.0
device_info: ['2.01.220420', '', '', '', '', 'LF1452']
m3: [  0   0   0   0   0   0 200  65   0   0 200  65 102 102 230  62  72 225
 122  63   1   0 128  63   0   0   0  65   0   0]
Fix_ 0.0
refltmp_ 25.0
airtmp_ 25.0
Humi_ 0.44999998807907104
Emiss_ 0.9800000190734863
Distance_ 1

v5 6000
coretmp_ 36.35000000000002 3095

flt_10003360 0.20020000636577606
flt_1000335C 26.92799949645996
flt_1000339C -5.999999848427251e-05
flt_10003398 0.008899999782443047
flt_10003394 0.670199990272522
water vapour content coefficient: 10.296338751668296
transmittance of atmosphere:      0.993438244014494
np_v8: [-16370.89846022 -16366.28886379 -16361.67926736 ...  59138.90062188
  59143.51021831  59148.11981474] np_v5: [-5880. -5879. -5878. ... 10501. 10502. 10503.] v22: 0.9228412341685726 v23: 1243.3615546075637 flt_10003360 0.20020000636577606 l_flt_1000337C_2: 4522.931556256735
/home/pi/ht301_hacklib/ht301_hacklib.py:94: RuntimeWarning: invalid value encountered in sqrt
  np_Ttot = np_v8**0.5 - l_flt_1000337C - ABSOLUTE_ZERO_CELSIUS
[         nan          nan          nan ... 449.08216649 449.09164386
 449.10112086]
cx: 6000 v2: 120
v5: -5880
flt_1000339C -5.999999848427251e-05 flt_10003398 0.008899999782443047 flt_10003394 0.670199990272522 fpatmp_ 38.25
v22: 0.9228412341685726
v23: 1243.3615546075637
np1: [nan, nan, nan, nan, nan, nan, nan, nan, nan, nan]
@stawel
Copy link
Owner

stawel commented Dec 19, 2022

nice finding!

Would you agree is is fine to set all of the negative values in the numpy array to 0?

yes, adding:

np_v8[np_v8 < 0] = 0 

definitely won't hurt.

Or do you have a better fix for this?

unfortunately not, for now at least

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

No branches or pull requests

2 participants