| Conditions | 4 |
| Total Lines | 20 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | # Licensed under a 3-clause BSD style license - see LICENSE |
||
| 12 | def pol_angle_reshape(s): |
||
| 13 | """ |
||
| 14 | Reshape a signal as a polarization angle: shifting by 180 degrees in a way it varies as smoothly as possible. |
||
| 15 | """ |
||
| 16 | |||
| 17 | s = np.array(s) |
||
| 18 | s = np.mod(s,180) # s % 180 |
||
| 19 | print(np.amax(s)) |
||
| 20 | sn = np.empty(s.shape) |
||
| 21 | for i in range(1,len(s)): |
||
| 22 | #if t[i]-t[i-1] < 35: |
||
| 23 | d = 181 |
||
| 24 | n = 0 |
||
| 25 | for m in range(0,100): |
||
| 26 | m2 = (-1)**(m+1)*np.floor((m+1)/2) |
||
| 27 | if np.abs(s[i]+180*m2-sn[i-1]) < d: |
||
| 28 | d = np.abs(s[i]+180*m2-sn[i-1]) |
||
| 29 | n = m2 |
||
| 30 | sn[i] = s[i]+180*n |
||
| 31 | return sn |
||