活动介绍

plt.plot(np.linspace(-4,10,100),stats.uniform.pdf(np.linspace(-4,10,100),loc=3,scale=2),label='pdf(uniform(3,5))')什么意思

时间: 2024-04-27 14:19:57 浏览: 188
这行代码的作用是绘制一个横坐标范围为-4到10、纵坐标为均匀分布概率密度函数的图像,其中均匀分布的参数为loc=3和scale=2,表示这个均匀分布的取值范围为[3,3+2]=[3,5]。plt.plot() 是 matplotlib 库中的一个函数,用于绘制图像,np.linspace() 是 numpy 库中的函数,用于生成一组等间隔的数值,而 stats.uniform.pdf() 是 scipy 库中的函数,用于计算概率密度函数的值。这行代码的目的是帮助我们可视化一个均匀分布的概率密度函数。
相关问题

import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import numpy as np import matplotlib matplotlib.use('TkAgg') # 或 'Qt5Agg'、'WxAgg' 等 import matplotlib.pyplot as plt """ax + by + cz = 0""" np.random.seed() x = np.random.uniform(-5,5,300) y = np.random.uniform(-5,5,300) a = 2 b = 3 c = 4 z = -(a * x + b * y )/c print(z) fig = plt.figure() ax = Axes3D(fig) ax.scatter(x,y,z) ax.set_xlabel("x") ax.set_ylabel("y") ax.set_zlabel("z") plt.show()

<think>好的,我现在需要回答用户的问题,关于如何使用Matplotlib和mpl_toolkits.mplot3d绘制三维散点图,特别是展示平面方程ax + by + cz = 0的示例代码。首先,我要理清用户的需求。用户可能希望生成一个三维散点图,其中点分布在给定的平面上,即满足ax + by + cz = 0。不过,平面方程本身是一个无限延伸的平面,而散点图通常显示离散的点,所以可能需要生成满足该方程的点集,并在三维空间中绘制这些点。 接下来,我需要回忆Matplotlib中三维绘图的步骤。根据之前提供的引用内容,创建三维坐标轴的方法是使用fig.add_subplot(111, projection='3d')。例如,引用[1]和[5]都提到了这一点。然后,绘制三维线图或网格线图使用的是plot或plot_wireframe函数,但用户需要的是散点图,应该使用scatter方法。 接下来,如何生成满足平面方程的点呢?平面方程ax + by + cz = 0可以解为z = (-a x - b y)/c(假设c不为0)。如果c为0,可能需要不同的处理方式,比如平面垂直于z轴的情况。不过为了简单起见,可能先假设c≠0,生成x和y的网格点,然后计算对应的z值,从而得到点坐标。 例如,可以生成x和y的值范围,使用numpy的linspace函数,然后创建网格网格X和Y,再计算Z。但这里用户可能需要的是散点,所以可能需要随机生成x和y的值,然后计算对应的z,或者生成网格点并用scatter绘制。 不过,平面方程对应的点可能更适合用曲面图来展示,但用户明确要求散点图,所以需要生成离散的点。例如,可以随机生成x和y的值,然后根据方程计算z,这样得到的点会分布在平面上,形成散点图。 现在,整合这些步骤到代码中。首先导入必要的库:matplotlib.pyplot,numpy,以及Axes3D。然后创建图形和三维坐标轴。生成数据部分,可能需要创建x和y的随机样本,然后计算z的值。例如,设定a、b、c的值,这里可以选择a=1,b=2,c=3,或者其他值。然后生成x和y的值,比如在某个范围内随机生成一些点,然后计算对应的z值。 注意,当c=0时,平面方程可能变成ax + by =0,这时候z可以自由取值,所以可能需要调整生成数据的方式。但为了简化,可能先假设c≠0的情况。 然后使用ax.scatter(X, Y, Z)来绘制散点,并设置坐标轴标签等。 此外,引用[2]中使用了plot_wireframe来绘制网格线图,而用户需要的是散点图,所以应该使用scatter函数。引用[3]提到旧版本可能需要使用Axes3D(fig),但现在推荐用projection='3d'的方式。 现在,编写示例代码的大纲: 1. 导入必要的库:matplotlib.pyplot,numpy,以及Axes3D。 2. 创建图形和三维坐标轴。 3. 定义平面方程的系数a、b、c。 4. 生成x和y的数据点(随机或网格)。 5. 根据方程计算z的值。 6. 使用scatter绘制散点。 7. 添加标签和显示图形。 其中,生成数据部分,可以使用numpy的随机函数生成x和y的值,比如生成100个点,x和y在某个范围内随机,然后计算z。例如: x = np.random.uniform(-5, 5, 100) y = np.random.uniform(-5, 5, 100) z = (-a * x - b * y) / c 或者,也可以生成网格点,但这样生成的散点会比较规则。但用户可能更希望看到的是随机分布的点,所以随机生成可能更好。 另外,需要注意当系数a、b、c不同时,平面的方向会变化,但示例代码可以固定一组系数,比如a=1,b=2,c=3,或者其他方便的值,确保分母不为零。 然后,绘制散点图时,可能需要设置点的颜色、大小等参数,但用户可能只需要基本示例,所以暂时保持简单。 现在,将这些步骤写成代码: import matplotlib.pyplot as plt import numpy as np from mpl_toolkits.mplot3d import Axes3D # 设置平面方程系数 a, b, c = 1, 2, 3 # 生成随机数据点 np.random.seed(42) # 保证可重复性 x = np.random.uniform(-5, 5, 100) y = np.random.uniform(-5, 5, 100) z = (-a * x - b * y) / c # 创建图形和坐标轴 fig = plt.figure() ax = fig.add_subplot(111, projection='3d') # 绘制散点图 ax.scatter(x, y, z, c='r', marker='o', label='ax + by + cz = 0') # 设置标签和图例 ax.set_xlabel('X') ax.set_ylabel('Y') ax.set_zlabel('Z') ax.legend() plt.show() 这样应该可以生成满足平面方程的三维散点图。但是否需要更多的调整?例如,颜色、透明度、点的大小等。但用户可能只需要基础代码,所以保持简洁。 另外,需要考虑平面方程的不同情况,比如当c=0时如何处理,但示例中可以假设c≠0,或者在注释中说明用户需要根据情况调整。 现在,检查代码是否正确。引用[1]中的代码使用add_subplot(111, projection='3d')是正确的,符合当前的Matplotlib版本。引用[5]也确认了这一点。所以代码的结构是正确的。 此外,是否正确计算了z的值?是的,方程ax + by + cz =0解为z=(-a x -b y)/c。 然后,绘制散点图时,使用的是ax.scatter(x, y, z),参数正确。设置标签也正确。 现在,测试这个代码是否能运行。假设没问题,应该可以显示三维散点图,所有点位于平面上。 最后,用户可能需要的是更复杂的例子,比如不同颜色或不同平面,但根据用户的问题,示例代码应该足够。 现在,总结步骤:导入库,创建三维坐标轴,生成数据,绘制散点图,设置标签,显示图形。代码应该没问题,符合引用中的示例结构。</think>要使用 Matplotlib 绘制三维散点图并展示平面方程 $ax + by + cz = 0$,可以按照以下步骤实现: ### 步骤说明 1. **导入库**:引入 `matplotlib.pyplot` 和 `numpy`,并导入三维坐标轴支持模块 `Axes3D`。 2. **创建三维坐标轴**:通过 `fig.add_subplot(111, projection='3d')` 生成三维绘图区域[^1][^5]。 3. **生成数据**: - 随机生成 $x$ 和 $y$ 的坐标值。 - 根据平面方程 $z = (-ax - by)/c$ 计算对应的 $z$ 值。 4. **绘制散点图**:使用 `ax.scatter()` 绘制满足平面方程的散点。 5. **设置标签和样式**:添加坐标轴标签和图例。 ### 示例代码 ```python import matplotlib.pyplot as plt import numpy as np from mpl_toolkits.mplot3d import Axes3D # 定义平面方程系数 (示例: 1x + 2y + 3z = 0) a, b, c = 1, 2, 3 # 生成随机数据点 np.random.seed(42) # 固定随机种子以保证结果可重复 x = np.random.uniform(-5, 5, 200) # 生成200个随机x值 y = np.random.uniform(-5, 5, 200) # 生成200个随机y值 z = (-a * x - b * y) / c # 根据平面方程计算z值 # 创建三维坐标轴 fig = plt.figure(figsize=(10, 7)) ax = fig.add_subplot(111, projection='3d') # 添加三维子图[^5] # 绘制散点图 ax.scatter(x, y, z, c='blue', s=20, alpha=0.6, label=f'{a}x + {b}y + {c}z = 0') # 设置坐标轴标签 ax.set_xlabel('X', fontsize=12) ax.set_ylabel('Y', fontsize=12) ax.set_zlabel('Z', fontsize=12) ax.legend() plt.title("三维散点图:平面方程示例") plt.show() ``` ### 说明 - **数据生成**:通过 `np.random.uniform` 在区间 $[-5, 5]$ 内生成 $x$ 和 $y$ 的随机值,确保散点分布广泛。 - **平面方程**:$z = (-ax - by)/c$ 将每个 $(x, y)$ 映射到平面上对应的 $z$,从而保证所有点都满足方程。 - **可视化调整**:`s=20` 设置点的大小,`alpha=0.6` 调整透明度,`c='blue'` 定义颜色。 ### 效果 运行代码后,会显示一个三维坐标系,其中蓝色散点分布在平面 $x + 2y + 3z = 0$ 上,用户可通过鼠标拖动视角观察平面结构[^3]。 ---

时间戳 用电量(kW) 2023-01-01 00:00 150.2 2023-01-01 01:00 148.5 ... 2023-01-07 23:00 210.7生成这种数据的

<think>好的,我现在需要帮助用户生成一个时间序列的用电量数据。用户给出的例子是时间戳和用电量,看起来像是一周内每小时的用电记录。首先,我需要确定用户的具体需求是什么。他们可能是在做某种数据分析项目,或者是需要模拟数据来测试他们的应用程序。用户可能希望生成看起来真实的数据,用于机器学习模型训练、可视化演示,或者系统测试。 接下来,我需要考虑如何生成这样的数据。真实世界的用电量通常会有周期性,比如每天的用电高峰和低谷。例如,早上和晚上用电量可能较高,而深夜则较低。此外,可能还会有周模式,比如周末的用电模式与工作日不同。另外,还需要考虑加入一些随机噪声,使数据更真实。 用户给出的例子是从2023-01-01开始,到2023-01-07结束,每小时一个数据点。总共有7天*24小时=168个数据点。生成这样的数据需要构造时间戳和对应的用电量值。 首先,时间戳的生成可以使用pandas的date_range函数,指定起始时间和频率为每小时。然后,用电量的生成需要模拟日周期和周周期的影响。例如,使用正弦函数来模拟每天的波动,可能使用不同频率的正弦波叠加。同时,工作日和周末可能会有不同的基线用电量,比如周末整体用电量可能更高或更低。 还需要考虑趋势项,比如整个星期内用电量可能逐渐增加,例如因为某个活动导致用电量上升。此外,加入随机噪声,可以使用正态分布,并可能加入一些突变的异常值,使数据更真实。 然后,需要将这些因素结合起来,生成一个综合的用电量序列。例如,用电量=基线+日周期成分+周周期成分+趋势+噪声+异常值。每个部分的具体参数需要调整,以生成合理的数据。 还需要注意参数的调整,比如日周期的幅度、周周期的幅度、趋势的斜率、噪声的大小等,这些参数需要根据实际情况调整,使生成的数据看起来合理。 最后,将生成的时间戳和用电量组合成DataFrame,并保存为CSV文件,或者直接展示出来。用户可能需要代码示例来实现这个功能,所以需要提供一个Python函数,使用pandas和numpy库来生成数据。 需要检查用户是否可能需要的其他功能,比如调整时间范围、更改周期性的参数、控制噪声水平或异常值的频率等。因此,函数应该设计为可配置的,允许用户自定义这些参数。 总结步骤: 1. 生成时间戳序列 2. 模拟日周期性(例如,早晚高峰) 3. 添加周周期差异(区分工作日和周末) 4. 加入趋势项(随时间逐渐变化) 5. 添加随机噪声 6. 插入异常值(可选) 7. 组合所有成分生成最终用电量 8. 封装为可配置的函数 9. 生成示例数据并验证合理性 需要确保生成的用电量数值在合理范围内,比如家庭用电可能在几十到几百千瓦之间,而工业用电可能更高。根据用户给出的例子,数值在150到210之间,所以应该设置基线在合理范围,并根据周期波动调整。 可能遇到的问题:如何模拟复杂的周期模式,比如午间用电量下降,或者夜间极低。可能需要使用多个正弦波叠加,或者使用分段函数。不过为了简化,使用单一的正弦函数模拟日周期,再结合周末的调整可能足够。 另外,异常值的处理,比如随机选择几个时间点,将其用电量显著提高或降低,以模拟特殊事件的影响。 最后,代码实现需要使用到pandas和numpy,确保用户安装了这些库。如果用户没有安装,可能需要提示,但通常这些库在数据科学环境中是常见的。</think>以下是一个生成小时级用电量时间序列数据的Python实现方案,该方案包含周期性模式、趋势项和随机噪声: ```python import pandas as pd import numpy as np def generate_electricity_data(start_date='2023-01-01', days=7, base_range=(150, 200), daily_amplitude=30, weekly_factor=0.2, trend_slope=0.5, noise_scale=3, anomaly_prob=0.02): """ 生成具有时间特征的用电量数据 参数: start_date: 起始日期(默认'2023-01-01') days: 生成天数(默认7) base_range: 基础用电量范围(默认150-200kW) daily_amplitude: 日波动幅度(默认±30kW) weekly_factor: 周末效应系数(默认0.2) trend_slope: 每日趋势斜率(默认0.5kW/日) noise_scale: 噪声标准差(默认3kW) anomaly_prob: 异常值概率(默认2%) 返回: DataFrame包含时间戳和用电量两列 """ # 生成时间序列 date_range = pd.date_range(start=start_date, periods=days*24, freq='H') # 基础信号 base = np.linspace(base_range[0], base_range[1], len(date_range)) # 日周期分量(使用正弦波模拟昼夜波动) hour_of_day = date_range.hour.values daily_cycle = daily_amplitude * np.sin(2 * np.pi * hour_of_day / 24) # 周周期分量(周末用电量变化) day_of_week = date_range.dayofweek.values weekly_cycle = weekly_factor * base * ((day_of_week >= 5) * 2 - 1) # 周末标记 # 长期趋势 trend = trend_slope * np.arange(len(date_range)) / 24 # 按小时递增 # 合成信号 electricity = base + daily_cycle + weekly_cycle + trend # 添加高斯噪声 electricity += np.random.normal(0, noise_scale, size=len(date_range)) # 插入异常值 anomaly_mask = np.random.rand(len(date_range)) < anomaly_prob electricity[anomaly_mask] += np.random.choice([-1, 1], sum(anomaly_mask)) * np.random.uniform(20, 50, sum(anomaly_mask)) # 创建DataFrame return pd.DataFrame({ '时间戳': date_range, '用电量(kW)': np.round(np.clip(electricity, base_range[0]-50, base_range[1]+50), 1) }) ``` **核心功能解析**: 1. **基础波动**: - 日周期:通过正弦波模拟 $y = A \sin(\frac{2πt}{24})$,其中A控制波动幅度 - 周周期:周末(周六、周日)用电量增加20%(通过`weekly_factor`参数调节) 2. **趋势项**: - 线性趋势项使用公式:$trend = slope \times \frac{hour\_index}{24}$ - 实现每日平均增长指定斜率的趋势 3. **异常值处理**: ```python # 概率性生成正负异常值(幅度20-50kW) anomaly_mask = np.random.rand(len(date_range)) < anomaly_prob electricity[anomaly_mask] += np.random.choice([-1, 1]) * np.random.uniform(20, 50) ``` 4. **数据约束**: ```python # 确保用电量不低于基础值-50,不高于基础值+50 np.clip(electricity, base_range[0]-50, base_range[1]+50) ``` **使用示例**: ```python df = generate_electricity_data(days=7, noise_scale=5) print(df.head(3)) ``` **输出示例**: ``` 时间戳 用电量(kW) 0 2023-01-01 00:00:00 148.2 1 2023-01-01 01:00:00 145.7 2 2023-01-01 02:00:00 143.5 ``` **可视化验证**: ```python import matplotlib.pyplot as plt plt.figure(figsize=(12, 6)) plt.plot(df['时间戳'], df['用电量(kW)']) plt.title('模拟用电量时序数据') plt.xlabel('时间') plt.ylabel('用电量(kW)') plt.grid(True) plt.show() ``` **参数调节建议**: 1. 增大`daily_amplitude`:增强昼夜波动幅度 2. 调节`weekly_factor`:改变周末效应强度 3. 设置`trend_slope=0`:去除长期趋势 4. 减小`noise_scale`:降低数据噪声 5. 设置`anomaly_prob=0`:去除异常值 该方案生成的时序数据包含: - 明显的昼夜周期波动(正弦波模式) - 周末效应(周末用电量整体抬升) - 长期增长趋势(可通过参数关闭) - 随机噪声(模拟测量误差) - 概率性异常值(模拟设备故障等特殊情况) 可通过调整参数生成不同场景下的用电数据,适用于: - 时间序列预测模型测试 - 异常检测算法验证 - 电力系统仿真 - 数据可视化教学等场景
阅读全文

相关推荐

import matplotlib.pyplot as plt import numpy as np from matplotlib.patches import Circle, Rectangle # 创建画布 fig = plt.figure(figsize=(14, 8)) fig.suptitle("Drone Environment Perception System", fontsize=16, fontweight='bold') # 创建子图布局 gs = fig.add_gridspec(3, 4) ax_cam = fig.add_subplot(gs[:, 0:2]) # 摄像头视图 ax_radar = fig.add_subplot(gs[0, 2:4], projection='polar') # 雷达图(极坐标) ax_path = fig.add_subplot(gs[1:, 2:4]) # 路径规划图 # 模拟摄像头画面(带YOLO检测结果) def plot_camera_view(ax): # 生成随机障碍物 np.random.seed(42) for _ in range(5): x = np.random.randint(20, 180) y = np.random.randint(20, 180) w = np.random.randint(10, 30) h = np.random.randint(10, 30) cls = np.random.choice(['person', 'car', 'tree', 'building']) conf = np.random.uniform(0.7, 0.95) # 绘制检测框 ax.add_patch(Rectangle((x, y), w, h, linewidth=2, edgecolor='r', facecolor='none')) ax.text(x, y - 5, f"{cls} {conf:.2f}", color='white', fontsize=8, bbox=dict(facecolor='red', alpha=0.7)) # 无人机位置 ax.plot(100, 100, 'ro', markersize=10) ax.text(105, 105, 'Drone', color='white', fontsize=10) # 设置参数 ax.set_title("Live Camera View with YOLO Detection") ax.set_facecolor('black') ax.set_xlim(0, 200) ax.set_ylim(0, 200) ax.set_xticks([]) ax.set_yticks([]) # 雷达图 def plot_radar(ax): ax.set_title("Obstacle Radar", pad=20) ax.set_theta_zero_location('N') # 设置0度方向为北方 ax.set_theta_direction(-1) # 设置顺时针方向 ax.set_rlim(0, 50) # 设置半径范围 # 生成障碍物极坐标 angles = np.random.rand(5) * 2 * np.pi distances = np.random.randint(5, 50, 5) sizes = np.random.randint(10, 50, 5) ax.scatter(angles, distances, s=sizes, c='r', alpha=0.6) ax.fill_between(np.linspace(0, 2 * np.pi, 100), 0, 50, color='g', alpha=0.1) # 路径规划图 def plot_path_planning(ax): # 生成路径 x = np.linspace(0, 100, 100) y = 5 * np.sin(x / 10) + 0.1 * (x - 50) ** 2 # 障碍物 ax.add_patch(Circle((30, 30), 10, color='gray')) ax.add_patch(Rectangle((60, 40), 15, 15, color='gray')) # 路径 ax.plot(x, y, 'g-', linewidth=2, label='Planned Path') ax.plot(0, 0, 'bo', markersize=10, label='Start') ax.plot(100, 100, 'y*', markersize=15, label='Goal') ax.set_title("Path Planning (A* Algorithm)") ax.set_xlim(0, 100) ax.set_ylim(0, 100) ax.legend(loc='upper right') ax.grid(True) # 状态信息 status_text = """Status: Altitude: 50.2m Speed: 8.4m/s Obstacles Detected: 5 Battery: 78% GPS Satellites: 12 """ fig.text(0.05, 0.15, status_text, fontfamily='monospace', bbox=dict(facecolor='lightgray', alpha=0.8)) # 绘制所有组件 plot_camera_view(ax_cam) plot_radar(ax_radar) plot_path_planning(ax_path) plt.tight_layout() plt.show() 圈框的图片不合适,我想自己加入 图片然后框选在生成剩下的效果

# traffic_optimization.py import matplotlib.pyplot as plt import numpy as np import seaborn as sns from matplotlib.font_manager import FontProperties # 中文字体配置 plt.rcParams['font.sans-serif'] = ['SimHei'] plt.rcParams['axes.unicode_minus'] = False # 生成模拟数据 np.random.seed(2023) hours = np.arange(24) traffic_before = np.random.randint(800, 1200, 24) # 优化前车流量 traffic_after = traffic_before * np.random.uniform(0.6, 0.9, 24) # 优化后车流量 # 创建可视化画布 fig = plt.figure(figsize=(15, 10), dpi=100) fig.suptitle('城市大脑交通优化效果分析', fontsize=16, y=1.03) # 子图1:车流量变化对比 ax1 = plt.subplot(2, 2, 1) sns.lineplot(x=hours, y=traffic_before, label='优化前', marker='o') sns.lineplot(x=hours, y=traffic_after, label='优化后', marker='x') ax1.set_title('早晚高峰时段车流量变化') ax1.set_xlabel('时间(小时)') ax1.set_ylabel('车流量(辆/小时)') ax1.fill_between(hours, traffic_before, traffic_after, alpha=0.1) # 子图2:通行时间对比 ax2 = plt.subplot(2, 2, 2) categories = ['主干道', '快速路', '匝道'] before_time = [45, 30, 15] after_time = [28, 22, 8] x = np.arange(len(categories)) ax2.bar(x - 0.2, before_time, 0.4, label='优化前') ax2.bar(x + 0.2, after_time, 0.4, label='优化后') ax2.set_xticks(x) ax2.set_xticklabels(categories) ax2.set_title('不同类型道路平均通行时间(分钟)') ax2.legend() # 子图3:拥堵指数热力图 ax3 = plt.subplot(2, 2, (3,4)) data = np.random.rand(6, 24) # 模拟6个区域24小时数据 sns.heatmap(data, cmap='YlOrRd', xticklabels=hours, yticklabels=['CBD','开发区','住宅区','工业区','交通枢纽','文教区']) ax3.set_title('区域拥堵指数热力图') ax3.set_xlabel('时间段') ax3.set_ylabel('区域分布') plt.tight_layout() plt.show()把里面的数据弄成csv文件

最后一幅图的坐标轴和之前的不一致,帮我在最后一幅,倒数第二幅图生成横坐标,注意前面的横坐标需要一致 def onemergeimage_1(target_df,turbine_id,channellist,T=True,time_span = None,Savedir=None,angles=None): h = len(channellist) fig1, axs1 = plt.subplots(nrows=h+1, figsize=(4,h*2), dpi=100) parts = turbine_id.split('-') farm_name = parts[0]+'-'+parts[1] plt_df = target_df[farm_name][turbine_id] plt_df = plt_df.sort_values('plc_time',ascending=True) if time_span !=None: start_time = time_span[0] end_time = time_span[1] plt_df = plt_df[((pd.to_datetime(plt_df['plc_time'])>= pd.to_datetime(start_time))&(pd.to_datetime(plt_df['plc_time'])<= pd.to_datetime(end_time)))] else: plt_df = plt_df start_time = plt_df['plc_time'].iloc[0] end_time = plt_df['plc_time'].iloc[-1] time_datetime = pd.to_datetime(plt_df['plc_time'].values) # 定义通用绘图配置 plot_config = { 's' : 20, 'alpha': 0.5 } marker = ('.','x','*') color = [ '#648FFF', # 钴蓝 '#785EF0', # 紫罗兰 '#DC267F', # 洋红 '#FE6100', # 橙 '#FFB000', # 金 '#42B4CA', # 蓝绿 '#336633', # 墨绿 '#999999', # 中灰 '#000000' # 黑色 ] # 配置-------------------------------------------------------------------------- axs1[0].set_title(f'{turbine_id}:{start_time}-{end_time}', fontsize=8, pad=10) channel_number = 0 for i , channel in enumerate(channellist): if isinstance(channel, str): axs1[i].scatter( time_datetime, plt_df[channel], **plot_config, color=color[channel_number], marker = marker[0], label = channel ) axs1[i].legend(loc='upper right', fontsize=6) if channel == angles: axs1[i].set_yticks([-180, -100, -50, 0, 50, 100, 180]) axs1[i].set_yticklabels([-180, -100, -50, 0, 50, 100, 180]) axs1[i].set_ylim(-200, 200) else: for channel_sub in channel: axs1[i].scatter( time_datetime, plt_df[channel_sub], **plot_config, color=color[channel_number], marker = marker[0], label = channel_sub ) axs1[i].legend(loc='upper right', fontsize=6) if channel_sub == angles: axs1[i].set_yticks([-180, -100, -50, 0, 50, 100, 180]) axs1[i].set_yticklabels([-180, -100, -50, 0, 50, 100, 180]) axs1[i].set_ylim(-200, 200) channel_number = channel_number + 1 channel_number = channel_number + 1 # for row_idx in range(h): # ax = axs1[row_idx] # ax.grid(True, linestyle=':', alpha=0.5) # ax.tick_params(axis='both', which='major', labelsize=6) # ax.set_xlim(pd.to_datetime(start_time), pd.to_datetime(end_time)) # # if row_idx != len(axs1)-1: # # ax.set_xticklabels([]) # 2. 计算相对于起始时间的秒数 base_time = time_datetime[0] time_deltas = (time_datetime - base_time).total_seconds() # 4. 执行时频转换 freq_x, mag_x = non_uniform_fft(time_deltas, plt_df['PRE_NacAccel_X']) freq_y, mag_y = non_uniform_fft(time_deltas, plt_df['PRE_NacAccel_Y']) # 可视化 axs1[h].scatter(freq_x, mag_x, **plot_config, color=color[channel_number+1], marker = marker[0], label = freq_x) axs1[h].scatter(freq_x, mag_x, **plot_config, color=color[channel_number+2], marker = marker[0], label = freq_y) # 配置-------------------------------------------------------------------------- # ===== 统一样式配置 ===== # 优化时间轴显示 # plt.gcf().autofmt_xdate() # fig.suptitle(f'{turbine_id}',fontsize=12) plt.tight_layout() plt.gcf().autofmt_xdate() plt.tight_layout() if Savedir: plt.savefig(Savedir+'/'+turbine_id.replace('/','_')+'_'+start_time.replace('/','')+'.png') plt.show()

粗匹配完成 (0.00s) ADE优化完成 (0.02s) 时间步 8: 执行重采样 (N_eff=180.0/1200) 时间步 11: 执行重采样 (N_eff=148.4/1200) 时间步 14: 执行重采样 (N_eff=120.2/1200) 时间步 17: 执行重采样 (N_eff=172.0/1200) 时间步 20: 执行重采样 (N_eff=157.1/1200) 时间步 23: 执行重采样 (N_eff=117.2/1200) 时间步 26: 执行重采样 (N_eff=98.6/1200) 时间步 29: 执行重采样 (N_eff=55.7/1200) 时间步 31: 执行重采样 (N_eff=151.1/1200) 时间步 34: 执行重采样 (N_eff=49.9/1200) 时间步 37: 执行重采样 (N_eff=179.9/1200) 时间步 43: 执行重采样 (N_eff=191.1/1200) 时间步 54: 执行重采样 (N_eff=204.9/1200) 时间步 58: 执行重采样 (N_eff=149.2/1200) 粒子滤波完成 (2.27s), 平均有效样本数: 579.7/1200 Backend qtagg is interactive backend. Turning interactive mode on. PS E:\网页下载> ^C PS E:\网页下载> PS E:\网页下载> e:; cd 'e:\网页下载'; & 'd:\A\python.exe' 'c:\Users\86181\.vscode\extensions\ms-python.debugpy-2025.10.0-win32-x64\bundled\libs\debugpy\launcher' '57054' '--' 'E:\网页下载\Magnetic Matching with ADE and Particle Filter.py' === 开始地磁匹配优化 === 粗匹配完成 (0.00s) ADE优化完成 (0.02s) 时间步 25: 执行重采样 (N_eff=229.3/1200) 时间步 27: 执行重采样 (N_eff=217.5/1200) 时间步 29: 执行重采样 (N_eff=185.1/1200) 时间步 31: 执行重采样 (N_eff=147.0/1200) 时间步 33: 执行重采样 (N_eff=68.7/1200) 时间步 35: 执行重采样 (N_eff=43.7/1200) 时间步 37: 执行重采样 (N_eff=75.1/1200) 时间步 39: 执行重采样 (N_eff=50.1/1200) 时间步 41: 执行重采样 (N_eff=21.9/1200) 时间步 42: 执行重采样 (N_eff=225.1/1200) 时间步 43: 执行重采样 (N_eff=62.9/1200) 时间步 44: 执行重采样 (N_eff=114.7/1200) 时间步 45: 执行重采样 (N_eff=111.6/1200) 时间步 46: 执行重采样 (N_eff=103.1/1200) 时间步 47: 执行重采样 (N_eff=115.0/1200) 警告: 时间步 48 所有权重接近零,执行粒子恢复 时间步 49: 执行重采样 (N_eff=226.4/1200) 时间步 53: 执行重采样 (N_eff=115.9/1200) 时间步 56: 执行重采样 (N_eff=138.4/1200) 时间步 59: 执行重采样 (N_eff=95.3/1200) 粒子滤波完成 (2.21s), 平均有效样本数: 426.1/1200 禁忌搜索完成 (0.00s) 最终轨迹与真实轨迹的平均偏差: 0.20438 总耗时: 2.23s 轨迹完整性检查: 输入INS轨迹点数: 60 粗匹配轨迹点数: 60 粒子滤波轨迹点数: 60 精细轨迹点数: 60 真实轨迹点数: 60 E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 36712 (\N{CJK UNIFIED IDEOGRAPH-8F68}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 36857 (\N{CJK UNIFIED IDEOGRAPH-8FF9}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 23545 (\N{CJK UNIFIED IDEOGRAPH-5BF9}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 27604 (\N{CJK UNIFIED IDEOGRAPH-6BD4}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 31895 (\N{CJK UNIFIED IDEOGRAPH-7C97}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 21305 (\N{CJK UNIFIED IDEOGRAPH-5339}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 37197 (\N{CJK UNIFIED IDEOGRAPH-914D}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 20248 (\N{CJK UNIFIED IDEOGRAPH-4F18}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 21270 (\N{CJK UNIFIED IDEOGRAPH-5316}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 31890 (\N{CJK UNIFIED IDEOGRAPH-7C92}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 23376 (\N{CJK UNIFIED IDEOGRAPH-5B50}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 28388 (\N{CJK UNIFIED IDEOGRAPH-6EE4}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 27874 (\N{CJK UNIFIED IDEOGRAPH-6CE2}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 31934 (\N{CJK UNIFIED IDEOGRAPH-7CBE}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 32454 (\N{CJK UNIFIED IDEOGRAPH-7EC6}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 30495 (\N{CJK UNIFIED IDEOGRAPH-771F}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 23454 (\N{CJK UNIFIED IDEOGRAPH-5B9E}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 38170 (\N{CJK UNIFIED IDEOGRAPH-951A}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 28857 (\N{CJK UNIFIED IDEOGRAPH-70B9}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 26102 (\N{CJK UNIFIED IDEOGRAPH-65F6}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 38388 (\N{CJK UNIFIED IDEOGRAPH-95F4}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 27493 (\N{CJK UNIFIED IDEOGRAPH-6B65}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 35823 (\N{CJK UNIFIED IDEOGRAPH-8BEF}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 24046 (\N{CJK UNIFIED IDEOGRAPH-5DEE}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 20301 (\N{CJK UNIFIED IDEOGRAPH-4F4D}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 32622 (\N{CJK UNIFIED IDEOGRAPH-7F6E}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 26377 (\N{CJK UNIFIED IDEOGRAPH-6709}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 25928 (\N{CJK UNIFIED IDEOGRAPH-6548}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 26679 (\N{CJK UNIFIED IDEOGRAPH-6837}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 26412 (\N{CJK UNIFIED IDEOGRAPH-672C}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 25968 (\N{CJK UNIFIED IDEOGRAPH-6570}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 21464 (\N{CJK UNIFIED IDEOGRAPH-53D8}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 37325 (\N{CJK UNIFIED IDEOGRAPH-91CD}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 37319 (\N{CJK UNIFIED IDEOGRAPH-91C7}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 38408 (\N{CJK UNIFIED IDEOGRAPH-9608}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 20540 (\N{CJK UNIFIED IDEOGRAPH-503C}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 30913 (\N{CJK UNIFIED IDEOGRAPH-78C1}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 22330 (\N{CJK UNIFIED IDEOGRAPH-573A}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 24378 (\N{CJK UNIFIED IDEOGRAPH-5F3A}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 24230 (\N{CJK UNIFIED IDEOGRAPH-5EA6}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 27979 (\N{CJK UNIFIED IDEOGRAPH-6D4B}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 37327 (\N{CJK UNIFIED IDEOGRAPH-91CF}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 19982 (\N{CJK UNIFIED IDEOGRAPH-4E0E}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 39044 (\N{CJK UNIFIED IDEOGRAPH-9884}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 36712 (\N{CJK UNIFIED IDEOGRAPH-8F68}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 36857 (\N{CJK UNIFIED IDEOGRAPH-8FF9}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 23545 (\N{CJK UNIFIED IDEOGRAPH-5BF9}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 27604 (\N{CJK UNIFIED IDEOGRAPH-6BD4}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 31895 (\N{CJK UNIFIED IDEOGRAPH-7C97}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 21305 (\N{CJK UNIFIED IDEOGRAPH-5339}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 37197 (\N{CJK UNIFIED IDEOGRAPH-914D}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 20248 (\N{CJK UNIFIED IDEOGRAPH-4F18}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 21270 (\N{CJK UNIFIED IDEOGRAPH-5316}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 31890 (\N{CJK UNIFIED IDEOGRAPH-7C92}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 23376 (\N{CJK UNIFIED IDEOGRAPH-5B50}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 28388 (\N{CJK UNIFIED IDEOGRAPH-6EE4}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 27874 (\N{CJK UNIFIED IDEOGRAPH-6CE2}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 31934 (\N{CJK UNIFIED IDEOGRAPH-7CBE}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 32454 (\N{CJK UNIFIED IDEOGRAPH-7EC6}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 30495 (\N{CJK UNIFIED IDEOGRAPH-771F}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 23454 (\N{CJK UNIFIED IDEOGRAPH-5B9E}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 38170 (\N{CJK UNIFIED IDEOGRAPH-951A}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 28857 (\N{CJK UNIFIED IDEOGRAPH-70B9}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 35823 (\N{CJK UNIFIED IDEOGRAPH-8BEF}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 24046 (\N{CJK UNIFIED IDEOGRAPH-5DEE}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 20301 (\N{CJK UNIFIED IDEOGRAPH-4F4D}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 32622 (\N{CJK UNIFIED IDEOGRAPH-7F6E}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 26102 (\N{CJK UNIFIED IDEOGRAPH-65F6}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 38388 (\N{CJK UNIFIED IDEOGRAPH-95F4}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 27493 (\N{CJK UNIFIED IDEOGRAPH-6B65}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 26377 (\N{CJK UNIFIED IDEOGRAPH-6709}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 25928 (\N{CJK UNIFIED IDEOGRAPH-6548}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 26679 (\N{CJK UNIFIED IDEOGRAPH-6837}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 26412 (\N{CJK UNIFIED IDEOGRAPH-672C}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 25968 (\N{CJK UNIFIED IDEOGRAPH-6570}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 21464 (\N{CJK UNIFIED IDEOGRAPH-53D8}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 37325 (\N{CJK UNIFIED IDEOGRAPH-91CD}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 37319 (\N{CJK UNIFIED IDEOGRAPH-91C7}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 38408 (\N{CJK UNIFIED IDEOGRAPH-9608}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 20540 (\N{CJK UNIFIED IDEOGRAPH-503C}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 30913 (\N{CJK UNIFIED IDEOGRAPH-78C1}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 22330 (\N{CJK UNIFIED IDEOGRAPH-573A}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 24378 (\N{CJK UNIFIED IDEOGRAPH-5F3A}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 24230 (\N{CJK UNIFIED IDEOGRAPH-5EA6}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 27979 (\N{CJK UNIFIED IDEOGRAPH-6D4B}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 37327 (\N{CJK UNIFIED IDEOGRAPH-91CF}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 19982 (\N{CJK UNIFIED IDEOGRAPH-4E0E}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 39044 (\N{CJK UNIFIED IDEOGRAPH-9884}) missing from font(s) DejaVu Sans. plt.show() 优化完成! PS E:\网页下载> ^C PS E:\网页下载> PS E:\网页下载> e:; cd 'e:\网页下载'; & 'd:\A\python.exe' 'c:\Users\86181\.vscode\extensions\ms-python.debugpy-2025.10.0-win32-x64\bundled\libs\debugpy\launcher' '57107' '--' 'E:\网页下载\Magnetic Matching with ADE and Particle Filter.py' === 开始地磁匹配优化 === 粗匹配完成 (0.00s) ADE优化完成 (0.02s) 时间步 3: 执行重采样 (N_eff=147.4/1200) 时间步 5: 执行重采样 (N_eff=46.4/1200) 时间步 7: 执行重采样 (N_eff=217.0/1200) 时间步 14: 执行重采样 (N_eff=162.6/1200) 时间步 19: 执行重采样 (N_eff=110.8/1200) 时间步 20: 执行重采样 (N_eff=216.5/1200) 时间步 21: 执行重采样 (N_eff=219.9/1200) 时间步 22: 执行重采样 (N_eff=220.4/1200) 时间步 23: 执行重采样 (N_eff=201.4/1200) 警告: 时间步 24 所有权重接近零,执行粒子恢复 时间步 29: 执行重采样 (N_eff=187.7/1200) 时间步 32: 执行重采样 (N_eff=234.9/1200) 时间步 35: 执行重采样 (N_eff=86.6/1200) 时间步 37: 执行重采样 (N_eff=156.7/1200) 时间步 39: 执行重采样 (N_eff=157.2/1200) 时间步 41: 执行重采样 (N_eff=157.8/1200) 时间步 43: 执行重采样 (N_eff=123.0/1200) 时间步 45: 执行重采样 (N_eff=83.3/1200) 时间步 47: 执行重采样 (N_eff=75.8/1200) 时间步 49: 执行重采样 (N_eff=58.0/1200) 时间步 51: 执行重采样 (N_eff=47.7/1200) 时间步 53: 执行重采样 (N_eff=16.4/1200) 警告: 时间步 54 所有权重接近零,执行粒子恢复 时间步 58: 执行重采样 (N_eff=177.3/1200) 粒子滤波完成 (2.26s), 平均有效样本数: 474.7/1200 禁忌搜索完成 (0.00s) 最终轨迹与真实轨迹的平均偏差: 0.21105 总耗时: 2.28s 轨迹完整性检查: 输入INS轨迹点数: 60 粗匹配轨迹点数: 60 粒子滤波轨迹点数: 60 精细轨迹点数: 60 真实轨迹点数: 60 E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 36712 (\N{CJK UNIFIED IDEOGRAPH-8F68}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 36857 (\N{CJK UNIFIED IDEOGRAPH-8FF9}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 23545 (\N{CJK UNIFIED IDEOGRAPH-5BF9}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 27604 (\N{CJK UNIFIED IDEOGRAPH-6BD4}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 31895 (\N{CJK UNIFIED IDEOGRAPH-7C97}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 21305 (\N{CJK UNIFIED IDEOGRAPH-5339}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 37197 (\N{CJK UNIFIED IDEOGRAPH-914D}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 20248 (\N{CJK UNIFIED IDEOGRAPH-4F18}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 21270 (\N{CJK UNIFIED IDEOGRAPH-5316}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 31890 (\N{CJK UNIFIED IDEOGRAPH-7C92}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 23376 (\N{CJK UNIFIED IDEOGRAPH-5B50}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 28388 (\N{CJK UNIFIED IDEOGRAPH-6EE4}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 27874 (\N{CJK UNIFIED IDEOGRAPH-6CE2}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 31934 (\N{CJK UNIFIED IDEOGRAPH-7CBE}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 32454 (\N{CJK UNIFIED IDEOGRAPH-7EC6}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 30495 (\N{CJK UNIFIED IDEOGRAPH-771F}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 23454 (\N{CJK UNIFIED IDEOGRAPH-5B9E}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 38170 (\N{CJK UNIFIED IDEOGRAPH-951A}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 28857 (\N{CJK UNIFIED IDEOGRAPH-70B9}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 26102 (\N{CJK UNIFIED IDEOGRAPH-65F6}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 38388 (\N{CJK UNIFIED IDEOGRAPH-95F4}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 27493 (\N{CJK UNIFIED IDEOGRAPH-6B65}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 35823 (\N{CJK UNIFIED IDEOGRAPH-8BEF}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 24046 (\N{CJK UNIFIED IDEOGRAPH-5DEE}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 20301 (\N{CJK UNIFIED IDEOGRAPH-4F4D}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 32622 (\N{CJK UNIFIED IDEOGRAPH-7F6E}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 26377 (\N{CJK UNIFIED IDEOGRAPH-6709}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 25928 (\N{CJK UNIFIED IDEOGRAPH-6548}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 26679 (\N{CJK UNIFIED IDEOGRAPH-6837}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 26412 (\N{CJK UNIFIED IDEOGRAPH-672C}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 25968 (\N{CJK UNIFIED IDEOGRAPH-6570}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 21464 (\N{CJK UNIFIED IDEOGRAPH-53D8}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 37325 (\N{CJK UNIFIED IDEOGRAPH-91CD}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 37319 (\N{CJK UNIFIED IDEOGRAPH-91C7}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 38408 (\N{CJK UNIFIED IDEOGRAPH-9608}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 20540 (\N{CJK UNIFIED IDEOGRAPH-503C}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 30913 (\N{CJK UNIFIED IDEOGRAPH-78C1}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 22330 (\N{CJK UNIFIED IDEOGRAPH-573A}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 24378 (\N{CJK UNIFIED IDEOGRAPH-5F3A}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 24230 (\N{CJK UNIFIED IDEOGRAPH-5EA6}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 27979 (\N{CJK UNIFIED IDEOGRAPH-6D4B}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 37327 (\N{CJK UNIFIED IDEOGRAPH-91CF}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 19982 (\N{CJK UNIFIED IDEOGRAPH-4E0E}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:498: UserWarning: Glyph 39044 (\N{CJK UNIFIED IDEOGRAPH-9884}) missing from font(s) DejaVu Sans. plt.tight_layout() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 36712 (\N{CJK UNIFIED IDEOGRAPH-8F68}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 36857 (\N{CJK UNIFIED IDEOGRAPH-8FF9}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 23545 (\N{CJK UNIFIED IDEOGRAPH-5BF9}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 27604 (\N{CJK UNIFIED IDEOGRAPH-6BD4}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 31895 (\N{CJK UNIFIED IDEOGRAPH-7C97}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 21305 (\N{CJK UNIFIED IDEOGRAPH-5339}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 37197 (\N{CJK UNIFIED IDEOGRAPH-914D}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 20248 (\N{CJK UNIFIED IDEOGRAPH-4F18}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 21270 (\N{CJK UNIFIED IDEOGRAPH-5316}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 31890 (\N{CJK UNIFIED IDEOGRAPH-7C92}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 23376 (\N{CJK UNIFIED IDEOGRAPH-5B50}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 28388 (\N{CJK UNIFIED IDEOGRAPH-6EE4}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 27874 (\N{CJK UNIFIED IDEOGRAPH-6CE2}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 31934 (\N{CJK UNIFIED IDEOGRAPH-7CBE}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 32454 (\N{CJK UNIFIED IDEOGRAPH-7EC6}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 30495 (\N{CJK UNIFIED IDEOGRAPH-771F}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 23454 (\N{CJK UNIFIED IDEOGRAPH-5B9E}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 38170 (\N{CJK UNIFIED IDEOGRAPH-951A}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 28857 (\N{CJK UNIFIED IDEOGRAPH-70B9}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 35823 (\N{CJK UNIFIED IDEOGRAPH-8BEF}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 24046 (\N{CJK UNIFIED IDEOGRAPH-5DEE}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 20301 (\N{CJK UNIFIED IDEOGRAPH-4F4D}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 32622 (\N{CJK UNIFIED IDEOGRAPH-7F6E}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 26102 (\N{CJK UNIFIED IDEOGRAPH-65F6}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 38388 (\N{CJK UNIFIED IDEOGRAPH-95F4}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 27493 (\N{CJK UNIFIED IDEOGRAPH-6B65}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 26377 (\N{CJK UNIFIED IDEOGRAPH-6709}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 25928 (\N{CJK UNIFIED IDEOGRAPH-6548}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 26679 (\N{CJK UNIFIED IDEOGRAPH-6837}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 26412 (\N{CJK UNIFIED IDEOGRAPH-672C}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 25968 (\N{CJK UNIFIED IDEOGRAPH-6570}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 21464 (\N{CJK UNIFIED IDEOGRAPH-53D8}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 37325 (\N{CJK UNIFIED IDEOGRAPH-91CD}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 37319 (\N{CJK UNIFIED IDEOGRAPH-91C7}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 38408 (\N{CJK UNIFIED IDEOGRAPH-9608}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 20540 (\N{CJK UNIFIED IDEOGRAPH-503C}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 30913 (\N{CJK UNIFIED IDEOGRAPH-78C1}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 22330 (\N{CJK UNIFIED IDEOGRAPH-573A}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 24378 (\N{CJK UNIFIED IDEOGRAPH-5F3A}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 24230 (\N{CJK UNIFIED IDEOGRAPH-5EA6}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 27979 (\N{CJK UNIFIED IDEOGRAPH-6D4B}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 37327 (\N{CJK UNIFIED IDEOGRAPH-91CF}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 19982 (\N{CJK UNIFIED IDEOGRAPH-4E0E}) missing from font(s) DejaVu Sans. plt.show() E:\网页下载\Magnetic Matching with ADE and Particle Filter.py:499: UserWarning: Glyph 39044 (\N{CJK UNIFIED IDEOGRAPH-9884}) missing from font(s) DejaVu Sans. plt.show() 优化完成! PS E:\网页下载> 给你看看终端内容,怎么说,就是可视化图形是不是太密了感觉有点乱码,然后好像数据也有点不行,但比以前好了好像,然后用来实验的数据是不是随机的?我希望是随机的

import torch import torch.nn as nn import torch.optim as optim import numpy as np import matplotlib.pyplot as plt # 固定随机种子 torch.manual_seed(42) # 仿真电机模型 class MotorModel: def __init__(self): self.T = 0.1 self.dt = 0.01 self.speed = 0.0 def update(self, u): self.speed += (u - self.speed) * self.dt / self.T return self.speed # PyTorch 实现的 BP 神经网络 class BPNN_PID(nn.Module): def __init__(self): super(BPNN_PID, self).__init__() self.hidden_size = 5 self.fc1 = nn.Linear(3, self.hidden_size) # 输入层到隐藏层 self.fc2 = nn.Linear(self.hidden_size, 3) # 隐藏层到输出层 self.sigmoid = nn.Sigmoid() self.tanh = nn.Tanh() def forward(self, inputs): x = self.tanh(self.fc1(inputs)) x = self.sigmoid(self.fc2(x)) Kp = x[:, 0] * 10 Ki = x[:, 1] * 0.2 Kd = x[:, 2] * 0.5 Kp = torch.clamp(Kp, 0.1, 8) Ki = torch.clamp(Ki, 0.01, 0.15) Kd = torch.clamp(Kd, 0.05, 0.4) return Kp, Ki, Kd # 增量式PID控制器 class IncrementalPID: def __init__(self): self.Kp = 0.0 self.Ki = 0.0 self.Kd = 0.0 self.e_prev = [0.0, 0.0] self.u_prev = 0.0 def compute(self, error, dt): _u = self.Kp * (error - self.e_prev[0]) + \ self.Ki * error + \ self.Kd * (error - 2 * self.e_prev[0] + self.e_prev[1]) self.e_prev[1] = self.e_prev[0] self.e_prev[0] = error u = self.u_prev + _u u = np.clip(u, -1000, 1000) self.u_prev = u return u # 生成训练数据 def generate_dataset(): X = [] y = [] motor = MotorModel() for _ in range(1000): target = np.random.uniform(-500, 500) actual = motor.speed error = target - actual X.append([target / 1000, actual / 1000, error / 1000]) ideal_Kp = 5 * (1 - abs(error) / 1000) ideal_Ki = 0.1 * (1 - abs(error) / 1000) ideal_Kd = 0.2 * (abs(error) / 1000) y.append([ideal_Kp / 10, ideal_Ki / 0.2, ideal_Kd / 0.5]) motor.update(np.clip(error * 0.5, -1000, 1000)) return np.array(X), np.array(y) # 训练模型 def train_bpnn(model, epochs=100): X, y = generate_dataset() X_train = torch.tensor(X, dtype=torch.float32) y_train = torch.tensor(y, dtype=torch.float32) optimizer = optim.Adam(model.parameters(), lr=0.005) criterion = nn.MSELoss() for epoch in range(epochs): model.train() optimizer.zero_grad() # 前向传播 output = model(X_train) # 计算损失 # 正确写法应保持批次维度 kp_pred, ki_pred, kd_pred = output loss = criterion(kp_pred, y_train[:, 0]) + \ criterion(ki_pred, y_train[:, 1]) + \ criterion(kd_pred, y_train[:, 2]) # 反向传播 loss.backward() optimizer.step() if epoch % 10 == 0: print(f"Epoch [{epoch}/{epochs}], Loss: {loss.item():.4f}") # 主控制循环 def main(): motor = MotorModel() pid = IncrementalPID() model = BPNN_PID() train_bpnn(model, epochs=100) # 训练模型 # 导出模型为 ONNX 文件 dummy_input = torch.tensor([[0.5, 0.0, 0.0]], dtype=torch.float32) # 假设的输入 torch.onnx.export(model, dummy_input, "bpnn_pid_model.onnx", verbose=True) print("ONNX model has been saved as 'bpnn_pid_model.onnx'.") if __name__ == "__main__": main() 我想看到数据的变化情况

最新推荐

recommend-type

新能源车电机控制器:基于TI芯片的FOC算法源代码与实际应用

内容概要:本文详细介绍了基于TI芯片的FOC(场向量控制)算法在新能源车电机控制器中的应用。文章首先阐述了新能源车电机控制器的重要性及其对车辆性能的影响,接着深入探讨了FOC算法的工作原理,强调其在提高电机控制精度和能效方面的优势。随后,文章展示了完整的源代码资料,涵盖采样模块、CAN通信模块等多个关键部分,并指出这些代码不仅限于理论演示,而是来自实际量产的应用程序。此外,文中还特别提到代码遵循严格的规范,有助于读者理解和学习电机控制软件的最佳实践。 适合人群:从事新能源车研发的技术人员、电机控制工程师、嵌入式系统开发者以及对电机控制感兴趣的电子工程学生。 使用场景及目标:① 学习并掌握基于TI芯片的FOC算法的具体实现;② 理解电机控制器各模块的功能和交互方式;③ 提升实际项目开发能力,减少开发过程中遇到的问题。 其他说明:本文提供的源代码资料来源于早期已量产的新能源车控制器,因此具有较高的实用价值和参考意义。
recommend-type

掌握XFireSpring整合技术:HELLOworld原代码使用教程

标题:“xfirespring整合使用原代码”中提到的“xfirespring”是指将XFire和Spring框架进行整合使用。XFire是一个基于SOAP的Web服务框架,而Spring是一个轻量级的Java/Java EE全功能栈的应用程序框架。在Web服务开发中,将XFire与Spring整合能够发挥两者的优势,例如Spring的依赖注入、事务管理等特性,与XFire的简洁的Web服务开发模型相结合。 描述:“xfirespring整合使用HELLOworld原代码”说明了在这个整合过程中实现了一个非常基本的Web服务示例,即“HELLOworld”。这通常意味着创建了一个能够返回"HELLO world"字符串作为响应的Web服务方法。这个简单的例子用来展示如何设置环境、编写服务类、定义Web服务接口以及部署和测试整合后的应用程序。 标签:“xfirespring”表明文档、代码示例或者讨论集中于XFire和Spring的整合技术。 文件列表中的“index.jsp”通常是一个Web应用程序的入口点,它可能用于提供一个用户界面,通过这个界面调用Web服务或者展示Web服务的调用结果。“WEB-INF”是Java Web应用中的一个特殊目录,它存放了应用服务器加载的Servlet类文件和相关的配置文件,例如web.xml。web.xml文件中定义了Web应用程序的配置信息,如Servlet映射、初始化参数、安全约束等。“META-INF”目录包含了元数据信息,这些信息通常由部署工具使用,用于描述应用的元数据,如manifest文件,它记录了归档文件中的包信息以及相关的依赖关系。 整合XFire和Spring框架,具体知识点可以分为以下几个部分: 1. XFire框架概述 XFire是一个开源的Web服务框架,它是基于SOAP协议的,提供了一种简化的方式来创建、部署和调用Web服务。XFire支持多种数据绑定,包括XML、JSON和Java数据对象等。开发人员可以使用注解或者基于XML的配置来定义服务接口和服务实现。 2. Spring框架概述 Spring是一个全面的企业应用开发框架,它提供了丰富的功能,包括但不限于依赖注入、面向切面编程(AOP)、数据访问/集成、消息传递、事务管理等。Spring的核心特性是依赖注入,通过依赖注入能够将应用程序的组件解耦合,从而提高应用程序的灵活性和可测试性。 3. XFire和Spring整合的目的 整合这两个框架的目的是为了利用各自的优势。XFire可以用来创建Web服务,而Spring可以管理这些Web服务的生命周期,提供企业级服务,如事务管理、安全性、数据访问等。整合后,开发者可以享受Spring的依赖注入、事务管理等企业级功能,同时利用XFire的简洁的Web服务开发模型。 4. XFire与Spring整合的基本步骤 整合的基本步骤可能包括添加必要的依赖到项目中,配置Spring的applicationContext.xml,以包括XFire特定的bean配置。比如,需要配置XFire的ServiceExporter和ServicePublisher beans,使得Spring可以管理XFire的Web服务。同时,需要定义服务接口以及服务实现类,并通过注解或者XML配置将其关联起来。 5. Web服务实现示例:“HELLOworld” 实现一个Web服务通常涉及到定义服务接口和服务实现类。服务接口定义了服务的方法,而服务实现类则提供了这些方法的具体实现。在XFire和Spring整合的上下文中,“HELLOworld”示例可能包含一个接口定义,比如`HelloWorldService`,和一个实现类`HelloWorldServiceImpl`,该类有一个`sayHello`方法返回"HELLO world"字符串。 6. 部署和测试 部署Web服务时,需要将应用程序打包成WAR文件,并部署到支持Servlet 2.3及以上版本的Web应用服务器上。部署后,可以通过客户端或浏览器测试Web服务的功能,例如通过访问XFire提供的服务描述页面(WSDL)来了解如何调用服务。 7. JSP与Web服务交互 如果在应用程序中使用了JSP页面,那么JSP可以用来作为用户与Web服务交互的界面。例如,JSP可以包含JavaScript代码来发送异步的AJAX请求到Web服务,并展示返回的结果给用户。在这个过程中,JSP页面可能使用XMLHttpRequest对象或者现代的Fetch API与Web服务进行通信。 8. 项目配置文件说明 项目配置文件如web.xml和applicationContext.xml分别在Web应用和服务配置中扮演关键角色。web.xml负责定义Web组件,比如Servlet、过滤器和监听器,而applicationContext.xml则负责定义Spring容器中的bean,包括数据源、事务管理器、业务逻辑组件和服务访问器等。 总之,通过上述整合使用原代码的知识点,可以深入理解XFire与Spring框架的结合使用,以及如何开发和部署基本的Web服务。这些技术知识有助于进行更高层次的Web服务开发,以及在复杂的IT环境中灵活运用各种框架和工具。
recommend-type

【Unity2018汉化大揭秘】:一步到位优化中文用户体验

# 摘要 本论文详细介绍了Unity2018汉化项目的实施过程,从理论准备到实践步骤,再到后期的测试与优化,最终分享了汉化经验和心得。首先,强调了汉化项目对于用户体验提升和产品国际化的重要性,并分析了汉化资源的分类、识别与管理方法。接着,详细阐述了汉化工具的选择、脚本编写、资源手动调整等实践步骤,以及汉化质量测试、体验优化和项目维护更新的重要性。论文最后通过案例研究,分析了汉化中的挑战和应对策略,并预测了汉化技术未来的发展方向。整个汉化过程不仅涉及技术层面的操作,还包含了深入的理论研究和实践心得分享,对提升汉化项目的效率和质量具有指导意义。 # 关键字 Unity汉化;用户体验;国际化;资源
recommend-type

iPhone

<think>我们注意到用户意图不明确,但提到了“照片提取”和“其他功能帮助”。因此,我们需要通过搜索来获取关于iPhone照片提取的常见方法以及其他可能的功能帮助。由于用户问题比较宽泛,我们将重点放在照片提取上,因为这是明确提到的关键词。同时,我们也会考虑一些其他常用功能的帮助。首先,针对照片提取,可能涉及从iPhone导出照片、从备份中提取照片、或者从损坏的设备中恢复照片等。我们将搜索这些方面的信息。其次,关于其他功能帮助,我们可以提供一些常见问题的快速指南,如电池优化、屏幕时间管理等。根据要求,我们需要将答案组织为多个方法或步骤,并在每个步骤间换行。同时,避免使用第一人称和步骤词汇。由于
recommend-type

驾校一点通软件:提升驾驶证考试通过率

标题“驾校一点通”指向的是一款专门为学员考取驾驶证提供帮助的软件,该软件强调其辅助性质,旨在为学员提供便捷的学习方式和复习资料。从描述中可以推断出,“驾校一点通”是一个与驾驶考试相关的应用软件,这类软件一般包含驾驶理论学习、模拟考试、交通法规解释等内容。 文件标题中的“2007”这个年份标签很可能意味着软件的最初发布时间或版本更新年份,这说明了软件具有一定的历史背景和可能经过了多次更新,以适应不断变化的驾驶考试要求。 压缩包子文件的文件名称列表中,有以下几个文件类型值得关注: 1. images.dat:这个文件名表明,这是一个包含图像数据的文件,很可能包含了用于软件界面展示的图片,如各种标志、道路场景等图形。在驾照学习软件中,这类图片通常用于帮助用户认识和记忆不同交通标志、信号灯以及驾驶过程中需要注意的各种道路情况。 2. library.dat:这个文件名暗示它是一个包含了大量信息的库文件,可能包含了法规、驾驶知识、考试题库等数据。这类文件是提供给用户学习驾驶理论知识和准备科目一理论考试的重要资源。 3. 驾校一点通小型汽车专用.exe:这是一个可执行文件,是软件的主要安装程序。根据标题推测,这款软件主要是针对小型汽车驾照考试的学员设计的。通常,小型汽车(C1类驾照)需要学习包括车辆构造、基础驾驶技能、安全行车常识、交通法规等内容。 4. 使用说明.html:这个文件是软件使用说明的文档,通常以网页格式存在,用户可以通过浏览器阅读。使用说明应该会详细介绍软件的安装流程、功能介绍、如何使用软件的各种模块以及如何通过软件来帮助自己更好地准备考试。 综合以上信息,我们可以挖掘出以下几个相关知识点: - 软件类型:辅助学习软件,专门针对驾驶考试设计。 - 应用领域:主要用于帮助驾考学员准备理论和实践考试。 - 文件类型:包括图片文件(images.dat)、库文件(library.dat)、可执行文件(.exe)和网页格式的说明文件(.html)。 - 功能内容:可能包含交通法规知识学习、交通标志识别、驾驶理论学习、模拟考试、考试题库练习等功能。 - 版本信息:软件很可能最早发布于2007年,后续可能有多个版本更新。 - 用户群体:主要面向小型汽车驾照考生,即C1类驾照学员。 - 使用方式:用户需要将.exe安装文件进行安装,然后根据.html格式的使用说明来熟悉软件操作,从而利用images.dat和library.dat中的资源来辅助学习。 以上知识点为从给定文件信息中提炼出来的重点,这些内容对于了解“驾校一点通”这款软件的功能、作用、使用方法以及它的发展历史都有重要的指导意义。
recommend-type

【DFLauncher自动化教程】:简化游戏启动流程,让游戏体验更流畅

# 摘要 DFLauncher是一个功能丰富的游戏启动和管理平台,本论文将介绍其安装、基础使用、高级设置、社区互动以及插件开发等方面。通过对配置文件的解析、界面定制、自动化功能的实现、高级配置选项、安全性和性能监控的详细讨论,本文阐述了DFLauncher如何帮助用户更高效地管理和优化游戏环境。此外,本文还探讨了DFLauncher社区的资源分享、教育教程和插件开发等内容,
recommend-type

自适应卡尔曼滤波是什么意思

<think>嗯,用户这次想深入了解自适应卡尔曼滤波(AKF)的概念和原理。从对话历史看,用户之前研究过相机自动对焦系统的降噪技术,其中提到过自适应卡尔曼滤波的应用场景。用户可能是个工程师或研究者,正在探索信号处理在具体场景的实现细节。 用户提供的三篇参考文献很有价值:[1]是基础理论综述,[2]聚焦多传感器场景,[3]讨论噪声协方差自适应方法。需要特别注意相机AF系统的特殊需求——实时性要求高(每秒数十次对焦计算)、噪声环境复杂(机械振动/弱光干扰),这些在解释原理时要结合具体案例。 技术要点需要分层解析:先明确标准卡尔曼滤波的局限(固定噪声参数),再展开自适应机制。对于相机AF场景,重
recommend-type

EIA-CEA 861B标准深入解析:时间与EDID技术

EIA-CEA 861B标准是美国电子工业联盟(Electronic Industries Alliance, EIA)和消费电子协会(Consumer Electronics Association, CEA)联合制定的一个技术规范,该规范详细规定了视频显示设备和系统之间的通信协议,特别是关于视频显示设备的时间信息(timing)和扩展显示识别数据(Extended Display Identification Data,简称EDID)的结构与内容。 在视频显示技术领域,确保不同品牌、不同型号的显示设备之间能够正确交换信息是至关重要的,而这正是EIA-CEA 861B标准所解决的问题。它为制造商提供了一个统一的标准,以便设备能够互相识别和兼容。该标准对于确保设备能够正确配置分辨率、刷新率等参数至关重要。 ### 知识点详解 #### EIA-CEA 861B标准的历史和重要性 EIA-CEA 861B标准是随着数字视频接口(Digital Visual Interface,DVI)和后来的高带宽数字内容保护(High-bandwidth Digital Content Protection,HDCP)等技术的发展而出现的。该标准之所以重要,是因为它定义了电视、显示器和其他显示设备之间如何交互时间参数和显示能力信息。这有助于避免兼容性问题,并确保消费者能有较好的体验。 #### Timing信息 Timing信息指的是关于视频信号时序的信息,包括分辨率、水平频率、垂直频率、像素时钟频率等。这些参数决定了视频信号的同步性和刷新率。正确配置这些参数对于视频播放的稳定性和清晰度至关重要。EIA-CEA 861B标准规定了多种推荐的视频模式(如VESA标准模式)和特定的时序信息格式,使得设备制造商可以参照这些标准来设计产品。 #### EDID EDID是显示设备向计算机或其他视频源发送的数据结构,包含了关于显示设备能力的信息,如制造商、型号、支持的分辨率列表、支持的视频格式、屏幕尺寸等。这种信息交流机制允许视频源设备能够“了解”连接的显示设备,并自动设置最佳的输出分辨率和刷新率,实现即插即用(plug and play)功能。 EDID的结构包含了一系列的块(block),其中定义了包括基本显示参数、色彩特性、名称和序列号等在内的信息。该标准确保了这些信息能以一种标准的方式被传输和解释,从而简化了显示设置的过程。 #### EIA-CEA 861B标准的应用 EIA-CEA 861B标准不仅适用于DVI接口,还适用于HDMI(High-Definition Multimedia Interface)和DisplayPort等数字视频接口。这些接口技术都必须遵循EDID的通信协议,以保证设备间正确交换信息。由于标准的广泛采用,它已经成为现代视频信号传输和显示设备设计的基础。 #### EIA-CEA 861B标准的更新 随着技术的进步,EIA-CEA 861B标准也在不断地更新和修订。例如,随着4K分辨率和更高刷新率的显示技术的发展,该标准已经扩展以包括支持这些新技术的时序和EDID信息。任何显示设备制造商在设计新产品时,都必须考虑最新的EIA-CEA 861B标准,以确保兼容性。 #### 结论 EIA-CEA 861B标准是电子显示领域的一个重要规范,它详细定义了视频显示设备在通信时所使用的信号时序和设备信息的格式。该标准的存在,使得不同厂商生产的显示设备可以无缝连接和集成,极大地增强了用户体验。对于IT专业人士而言,了解和遵守EIA-CEA 861B标准是进行视频系统设计、故障诊断及设备兼容性测试的重要基础。
recommend-type

【DFLauncher应用实战】:如何将DFLauncher融入矮人要塞并提升效率

# 摘要 DFLauncher是一款功能全面的游戏管理工具,旨在简化游戏安装、启动和维护过程。本文介绍了DFLauncher的基本使用方法,详细解析了其核心功能,包括游戏库管理、游戏配置优化、更新机制等。同时,文章探讨了DFLauncher在特定游戏“矮人要塞”中的集成应用,以及通过插件和脚本进行的高级定制。故障诊断与系统优化章节提供了实用的诊断方法和性能提升技巧。最后,本文展望了DFLauncher的未来发展方向,并鼓励社区贡献和用户反馈,以满足不断变化的用户需求。 # 关键字 DFLauncher;游戏管理工具;安装配置;性能优化;故障诊断;社区贡献;定制化扩展;网络功能集成 参考资源
recommend-type

银河麒麟系统打开屏保

<think>嗯,用户的问题是关于银河麒麟操作系统如何开启屏幕保护程序。这个问题其实挺实用的,毕竟长时间盯着电脑屏幕容易造成视觉疲劳,屏幕保护能起到一定的保护作用。 从用户提供的引用内容来看,引用[2]提到了银河麒麟系统的常见问题处理,包括重启输入法和双屏配置问题,虽然不直接相关,但说明用户对系统设置有一定了解。引用[3]是关于安装cmake的,可能用户之前尝试过其他系统配置操作。 用户可能是在办公环境中使用银河麒麟系统,需要保护视力。考虑到银河麒麟是基于Linux开发的国产操作系统,它的屏幕保护设置应该和主流Linux发行版类似,但可能有自己的特色功能。 我回忆了一下Linux系统的屏