Creating a linear phase from frequency using python and allantools

After developing those boards ( http://www.sidmonitor.net/gallery/mains.html, ) using 50 Hz,like in most Europe country ,i’ve tried to create a program that could even calculate the phase in real time. Although there are online excellent Windows  software such as Stable32 from Hamilton Technical Services  and John Miles Timelab I needed a program running under Linux/Unix and Python. Luckly there was  an online  library that came close to what I was looking for : Allantools (   https://github.com/aewallin/allantools  ) , for calculating allan deviation and related time & frequency statistics,  using the frequency to phase function inside allantools from a frequency data file did not create the linear phase. A linear phase slope corresponds to a constant frequency offset, which can be removed using a linear least-squares fit to the phase data or the ordinary arithmetic mean for the frequency. So i wrote a small program in python. You will need Allantools libraries and Numpy . The software come with   GPLv3 license,  you can use it freely just give credit to the author (me). A special thanks to William Riley from Stable32 that helped  to develop the correct mathematical theory behind the code. Here is the overall result expressed in milliseconds. Inside the program i’ve added also a subroutine for Pandas if you need it instead of numpy. (now commented )

phase

You can finde the python code here

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s