# Copyright (C) 2021 Predrag PejoviÄ‡
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
from pylab import *
def continuate(phi, unit = 'deg'):
n = len(phi)
if unit == 'rad':
for i in range(n - 1):
if phi[i + 1] - phi[i] < - pi:
phi[i + 1 :] += 2 * pi
elif phi[i + 1] - phi[i] > pi:
phi[i + 1 :] -= 2 * pi
elif unit == 'deg':
for i in range(n - 1):
if phi[i + 1] - phi[i] < - 180:
phi[i + 1 :] += 360
elif phi[i + 1] - phi[i] > 180:
phi[i + 1 :] -= 360
else:
raise SystemExit('\nWrong unit ' + unit +
": use either 'deg' or 'rad'. \n")
return phi