Browse Source

Catch arctan2 errors

tags/nilmtools-1.0
Jim Paris 9 years ago
parent
commit
348c435d1e
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      src/sinefit.py

+ 5
- 1
src/sinefit.py View File

@@ -172,7 +172,11 @@ def sfit4(data, fs):
## Extract results
A = sqrt(s[0]*s[0] + s[1]*s[1]) # eqn B.21
f0 = w / (2*pi)
phi = -arctan2(s[1], s[0]) # eqn B.22
try:
phi = -arctan2(s[1], s[0]) # eqn B.22
except TypeError:
# something broke down, just return zeros
return (0, 0, 0, 0)
C = s[2]

return (A, f0, phi, C)


Loading…
Cancel
Save