Alan dispersion is used to know the noise and bias characteristics of MEMS sensors such as angular velocity sensors. The sensor output obtained from the test that is allowed to stand for 1 hour is summarized in CSV, and the Alan variance is calculated from it.
Language used python Modules used allantools, pylab, numpy, pandas, csv Environment windows 10 64bit
Install the Alan distribution calculation module with the following command.
python -m pip install AllanTools
In the following example, the time-series sensor information written in a comma-separated text file called LOG00.TXT is read, and the Alan variance is calculated from it.
import allantools
import matplotlib.pyplot as plt
#import pylab as plt
import numpy as np
import pandas as pd
import csv
#Graph font settings
col_names = ['a{0:02d}'.format(i) for i in range(15)] #By specifying the column name, pandas can be read even if there is empty data.
#Read txt file and convert to pandas data frame format. No header, column name col_names(a0 ~ a15)Designated to
df = pd.read_table('LOG00031.TXT',sep=',',header=None, names=col_names)
print(df)
#Extract only specific columns of the relevant data
sim_time = df.iloc[:,0]
gyro_x_df = df.iloc[:,6]
gyro_y_df = df.iloc[:,7]
gyro_z_df = df.iloc[:,8]
#df(Data frame format)Convert from to list format
gyro_x = gyro_x_df.values.tolist()
gyro_y = gyro_y_df.values.tolist()
gyro_z = gyro_z_df.values.tolist()
#plt.plot(sim_time, gyro_x)
#-------------------------
#Alan variance calculation
#-------------------------
#numpy logspace creates an even array on the log scale
#np.logspace(Start point, end point, number of elements, radix)
t = np.logspace(0, 4, 100)
#y = allantools.noise.white(10000) # Generate some frequency data
r = 30 # sample rate in Hz of the input data
(t2_x, ad_x, ade, adn) = allantools.mdev(gyro_x, rate=r, data_type="freq", taus=t) # Compute the overlapping ADEV
(t2_y, ad_y, ade, adn) = allantools.mdev(gyro_y, rate=r, data_type="freq", taus=t) # Compute the overlapping ADEV
(t2_z, ad_z, ade, adn) = allantools.mdev(gyro_z, rate=r, data_type="freq", taus=t) # Compute the overlapping ADEV
#fig = plt.loglog(t2, ad) # Plot the results
#plt.rcParams['text.usetex'] = True
#Font specification
plt.rcParams['font.family'] = 'Times New Roman'
#figure()Create a graph display area with. Specify an object called fig.
fig = plt.figure()
#plt.title('$f(x) = \sin(\pi x)$')
#Positioning the graph to plot(Height 2,Width 2,Quadrant)
ax1 = fig.add_subplot(2,2,1)
ax2 = fig.add_subplot(2,2,2)
ax3 = fig.add_subplot(2,2,3)
#ax4 = fig.add_subplot(2,2,4)
#Graph plot (this time loglog graph)
ax1.loglog(t2_x,ad_x, color="black")
ax2.loglog(t2_y,ad_y, color="black")
ax3.loglog(t2_z,ad_z, color="black")
#ax4.loglog(t2,ad)
#Show scale on graph
ax1.grid(which='minor')
ax2.grid()
ax3.grid()
#Graph range setting
ax1.set_ylim([0.001,0.01])
ax2.set_ylim([0.0001,0.01])
ax3.set_ylim([0.0001,0.01])
#Graph title
ax1.set_xlabel(r"$\tau$ [s]")
ax1.set_ylabel(r"Gyro X $\sigma(\tau)$ [deg/hr]") #Writing formulas in LaTex format
ax2.set_xlabel(r"$\tau$ [s]")
ax2.set_ylabel(r"Gyro Y $\sigma(\tau)$ [deg/hr]")
ax3.set_xlabel(r"$\tau$ [s]")
ax3.set_ylabel(r"Gyro Z $\sigma(\tau)$ [deg/hr]")
#graph display
#plt.legend()#Legend display
plt.show()
Alan variance of the angular velocity sensor output in the 3-axis direction.
Recommended Posts