|
|
本帖最后由 mynew 于 2026-11-28 21:36 编辑
追踪了一颗 AD584电压数据
- 温度,2.5V,5.0V,7.5V,10.0V
- 28.1,2.49985,5.00155,7.50113,10.00238
- 27.8,2.49985,5.00155,7.50113,10.00238
- 27.5,2.49984,5.00155,7.50114,10.00238
- 26.7,2.49983,5.00153,7.50111,10.00235
- 27.8,2.49985,5.00155,7.50113,10.00238
- 26.9,2.49983,5.00153,7.50111,10.00235
- 26.1,2.49983,5.00152,7.5011,10.00234
- 25.6,2.49982,5.00151,7.50109,10.00233
- 23.2,2.49979,5.00148,7.50105,10.00229
- 22.8,2.49978,5.00147,7.50105,10.00228
- 23.8,2.4998,5.00149,7.50106,10.00229
- 23.4,2.49979,5.00148,7.50105,10.00229
- 19.7,2.49975,5.00141,7.50096,10.00218
- 18.4,2.49972,5.00138,7.50093,10.00213
- 17.2,2.49969,5.00134,7.50088,10.00208
- 17.8,2.49972,5.00138,7.50092,10.00213
- 16.5,2.49971,5.00136,7.5009,10.0021
- 18.5,2.49973,5.0014,7.50094,10.00215
- 16.2,2.49969,5.00135,7.50089,10.00208
- 15,2.49968,5.00134,7.50087,10.00206
复制代码 让chat 绘制了曲线,挺快速的
- import pandas as pd
- import matplotlib.pyplot as plt
- import matplotlib as mpl
- mpl.rcParams['font.sans-serif'] = ['Microsoft YaHei', 'SimHei', 'Arial Unicode MS']
- mpl.rcParams['axes.unicode_minus'] = False
- filename = r'D:\AD584 电压温度记录.csv'
- # 指定 GBK 编码读取(中文 Windows 下 Excel 导出常见编码)
- df = pd.read_csv(filename, encoding='gbk')
- # 按温度升序排序
- df = df.sort_values('温度').reset_index(drop=True)
- cols = ['2.5V', '5.0V', '7.5V', '10.0V']
- # =========================
- # 图1:四个子图,实际电压
- # =========================
- fig, axes = plt.subplots(4, 1, figsize=(10, 12), sharex=True)
- for ax, col in zip(axes, cols):
- ax.plot(df['温度'], df[col], 'o-', linewidth=1.8, markersize=5, label=col)
- ax.set_ylabel('电压 (V)')
- ax.grid(True, linestyle='--', alpha=0.5)
- ax.legend(loc='best')
- axes[-1].set_xlabel('温度 (°C)')
- fig.suptitle('AD584 输出电压—温度曲线', fontsize=16)
- plt.tight_layout()
- plt.savefig(r'D:\AD584_实际电压温度曲线.png', dpi=200)
- plt.show()
- # =========================
- # 图2:相对首点偏差 ppm
- # =========================
- fig2, ax2 = plt.subplots(figsize=(10, 6))
- for col in cols:
- y = df[col].astype(float)
- ppm = (y - y.iloc[0]) / y.iloc[0] * 1e6
- ax2.plot(df['温度'], ppm, 'o-', linewidth=1.8, markersize=5, label=col)
- ax2.set_xlabel('温度 (°C)')
- ax2.set_ylabel('相对最低温点偏差 (ppm)')
- ax2.set_title('AD584 输出电压相对温漂曲线')
- ax2.grid(True, linestyle='--', alpha=0.5)
- ax2.legend()
- plt.tight_layout()
- plt.savefig(r'D:\AD584_相对温漂曲线.png', dpi=200)
- plt.show()
- # =========================
- # 计算首尾平均温度系数 TCR
- # =========================
- T = df['温度'].astype(float)
- T1, T2 = T.iloc[0], T.iloc[-1]
- rows_table = []
- header = ['输出', '首点电压(V)', '末点电压(V)', '变化(V)',
- '相对变化(ppm)', '平均TCR(ppm/°C)']
- print(f'首尾温度范围:{T1:.1f} °C → {T2:.1f} °C\n')
- print(f'{"输出":>6s} {"首点电压(V)":>12s} {"末点电压(V)":>12s} '
- f'{"变化(V)":>10s} {"相对变化(ppm)":>14s} {"平均TCR(ppm/°C)":>18s}')
- for col in cols:
- y = df[col].astype(float)
- y1, y2 = y.iloc[0], y.iloc[-1]
- dv = y2 - y1
- ppm = dv / y1 * 1e6
- tcr = ppm / (T2 - T1)
- rows_table.append([col, f'{y1:.5f}', f'{y2:.5f}', f'{dv:+.5f}',
- f'{ppm:+.2f}', f'{tcr:+.3f}'])
- print(f'{col:>6s} {y1:12.5f} {y2:12.5f} {dv:+10.5f} {ppm:+14.2f} {tcr:+18.3f}')
- # =========================
- # 图3:统计结果表格图片
- # =========================
- fig3, ax3 = plt.subplots(figsize=(11, 4.2))
- ax3.axis('off')
- title = f'AD584 首尾统计(温度范围 {T1:.1f} °C → {T2:.1f} °C)'
- ax3.set_title(title, fontsize=15, pad=16)
- table = ax3.table(
- cellText=rows_table,
- colLabels=header,
- cellLoc='center',
- loc='center',
- bbox=[0.02, 0.05, 0.96, 0.85]
- )
- table.auto_set_font_size(False)
- table.set_fontsize(11)
- table.scale(1.0, 2.0)
- # 表头样式
- for j in range(len(header)):
- cell = table[0, j]
- cell.set_facecolor('#dbe9f6')
- cell.set_text_props(weight='bold')
- # 数据行交替底色
- for i in range(1, len(rows_table) + 1):
- for j in range(len(header)):
- cell = table[i, j]
- if i % 2 == 0:
- cell.set_facecolor('#f4f7fb')
- cell.set_edgecolor('#999999')
- plt.tight_layout()
- plt.savefig(r'D:\AD584_首尾统计表.png', dpi=200, bbox_inches='tight')
- plt.show()
复制代码
还可以让他拟合曲线,很方便。
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
打赏
-
查看全部打赏
|