Allan方差计算(python实现源码)

# -*- coding: utf-8 -*-
# @Author  : 十年
# @Site    : https://gitee.com/chshao/aiplotest
# @CSDN    : https://blog.csdn.net/m0_37576542?type=blog
# @File    : Allan.py
# @Description  : Allan方差计算
import math
import numpy as np
import pandas as pd
from pandas import DataFrame
import matplotlib.pyplot as plt


class Allan(object):

    @staticmethod
    def fitAllanPic(tau, av, title, xlabel, ylabel, picName=''):
        # 绘制Allan方差曲线图
        plt.clf()
        plt.loglog(tau, av, marker="o")
        plt.grid(True, which="both", ls="-")
        plt.title(title)
        plt.xlabel(xlabel)
        plt.ylabel(ylabel)
        plt.legend(['x', 'y', 'z'])
        plt.savefig(picName)
        # plt.show()

    def allan(self, data: DataFrame, fs):
        """
        @summary: 计算allan方差、随机游走噪声
        @param data: imu原始数据
        @param fs: imu输出频率
        @return:
        """
        # 开始计算allan方差----------------------------------------------------------------------------------------------
        data = np.asarray(data, dtype=float)
        data[:, 0:3] = data[:, 0:3] * 180 / math.pi
        data_int = np.cumsum(data, axis=0) / fs  # 1/freq=dt, p.78 (4.6)
        N = len(data_int)
        taunum = math.floor(np.log((N - 1) / 3) / np.log(2))  # how many kind of tau
        allan_a = np.empty((taunum + 1, 6))
        for k in range(0, 6):
            for i in range(taunum + 1):
                n = 2 ** i  # data number in one box is qrow with 2 square to reduce the counter
                # use matrix [] added and  col.27 mean to replace sumation in p.78 (4.9)
                temp2 &#
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值