吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 4229|回复: 1
收起左侧

[会员申请] 申请会员ID:snail5417

[复制链接]
吾爱游客  发表于 2019-12-23 12:15
1.申请会员ID:snail5417
2.邮箱:605427036@qq.com

python学习:
三次样条插值算法:
用低精度传感器gps时间插值高精度传感器gps时间对应的位置和姿态
[Python] 纯文本查看 复制代码
#!/usr/bin/env python
# encoding: utf-8
"""
@author: shiqi
@file: interpolate_utils
@time: 2019-12-11 15:34
@desc: 
"""
import pandas as pd
from scipy.interpolate import interp1d
from pathlib import Path
from test_interface.algorithm import post, tmt


def my_interpolate():
    post_path = Path(r"C:\Users\Administrator\Desktop\0027-1-02-0001-20191205-154946-TC.PosT")
    tmt_path = Path(r"C:\Users\Administrator\Desktop\0027-1-02-0001-20191205-154950_2019_12_5_20_14_52.tmt")
    post_gps_list, post_latitude_list, post_longitude_list, \
        post_h_ell_list, post_roll_list, post_pitch_list, post_heading_list = post.read_post(post_path)
    tmt_gps_list = tmt.read_tmt(tmt_path)
    print(len(post_gps_list), len(post_latitude_list))
    # 对xyzrph进行关于gps的cubic差值(三次样条差值)
    # f_latitude = scipy.interpolate.CubicSpline(post_gps_list, post_latitude_list)
    f_latitude = interp1d(post_gps_list, post_latitude_list, kind="cubic")
    f_longitude = interp1d(post_gps_list, post_longitude_list, kind="cubic")
    f_h_ell = interp1d(post_gps_list, post_h_ell_list, kind="cubic")
    f_roll = interp1d(post_gps_list, post_roll_list, kind="cubic")
    f_pitch = interp1d(post_gps_list, post_pitch_list, kind="cubic")
    f_heading = interp1d(post_gps_list, post_heading_list, kind="cubic")
    tmt_latitude_list = []
    tmt_longitude_list = []
    tmt_h_ell_list = []
    tmt_roll_list = []
    tmt_pitch_list = []
    tmt_heading_list = []
    for gps in tmt_gps_list:
        latitude = f_latitude(gps)
        longitude = f_longitude(gps)
        h_ell = f_h_ell(gps)
        roll = f_roll(gps)
        pitch = f_pitch(gps)
        heading = f_heading(gps)
        tmt_latitude_list.append(latitude)
        tmt_longitude_list.append(longitude)
        tmt_h_ell_list.append(h_ell)
        tmt_roll_list.append(roll)
        tmt_pitch_list.append(pitch)
        tmt_heading_list.append(heading)
    return tmt_gps_list, tmt_latitude_list, tmt_longitude_list, tmt_h_ell_list, \
        tmt_roll_list, tmt_pitch_list, tmt_heading_list
    pass


def interpolate_result():
    g, n, e, u, r, p, h = my_interpolate()
    cam = pd.DataFrame({"GPSTime": g, "Latitude": n, "Longitude": e, "H-Ell": u, "Roll": r, "Pitch": p, "Heading": h},
                       dtype="float64")
    # decimals = pd.Series([4, 11, 11, 3, 5, 5, 5],
    #                      index=["GPSTime", "Latitude", "Longitude", "H-Ell", "Roll", "Pitch", "Heading"])
    # cam = cam.round(decimals)
    cam["GPSTime"] = cam["GPSTime"].map(lambda x: '%.4f' % x)
    cam["Latitude"] = cam["Latitude"].map(lambda x: '%.11f' % x)
    cam["Longitude"] = cam["Longitude"].map(lambda x: '%.11f' % x)
    cam["H-Ell"] = cam["H-Ell"].map(lambda x: '%.3f' % x)
    cam["Roll"] = cam["Roll"].map(lambda x: '%.5f' % x)
    cam["Pitch"] = cam["Pitch"].map(lambda x: '%.5f' % x)
    cam["Heading"] = cam["Heading"].map(lambda x: '%.5f' % x)
    # cam1 为奇数行,reset_index(drop=True) 添加索引 True丢失原始索引
    cam1 = cam.iloc[0::2]  # .reset_index(drop=True)
    # cam2 为偶数行,reset_index(drop=True) 添加索引 True丢失原始索引
    cam2 = cam.iloc[1::2]  # .reset_index(drop=True)
    print(cam1)
    cam1.to_csv(r"C:\Users\Administrator\Desktop\cam1.PosT", encoding="utf-8", index=None)
    cam2.to_csv(r"C:\Users\Administrator\Desktop\cam2.PosT", encoding="utf-8", index=None)
    pass


if __name__ == '__main__':
    # a3 = pd.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6], 'c': [7, 8, 9]})
    # print(a3)
    interpolate_result()
    pass

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

Hmily 发表于 2019-12-24 17:10
抱歉,未能达到申请要求,申请不通过,可以关注论坛官方微信(吾爱破解论坛),等待开放注册通知。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-15 06:52

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表