10 相干函数 cohere

10 相干函数 cohere

用途

两信号在各频率上的线性相关程度,取值 0~1。

示例(5 张)

10-1 系统输入与输出的相干函数

系统输入与输出的相干函数

10-2 两个电压测点之间的相干函数

两个电压测点之间的相干函数

10-3 风速与风电出力的相干函数

风速与风电出力的相干函数

10-4 振动与电流信号的相干函数

振动与电流信号的相干函数

10-5 气温与负荷的相干函数

气温与负荷的相干函数

代码

以下 5 个函数取自 code/第二批_信号分析261107.py,直接调用即可出图。样式(宋体 + Times、10 磅、刻度朝内四边、留白自检)由 code/公共配置261107.py 的 setup_cn_style() 和 save() 统一提供,本节不再重复。

# 摘自 code/第二批_信号分析261107.py

def co_01():
    """系统输入与输出的相干函数。"""
    fig, ax = new_fig()
    t, u = _sig(seed=1001)
    i = 0.9 * u + 0.25 * np.random.default_rng(10011).normal(0, 1, t.size)
    ax.cohere(u, i, NFFT=512, Fs=2000, color=C1, lw=0.9)
    ax.grid(False)
    ax.set_xscale("log")
    ax.set_xlim(20, 1000)
    ax.set_ylim(0, 1.05)
    ax.set_xlabel("频率 " + IT["f"] + " / Hz")
    ax.set_ylabel("相干系数 " + IT["gamma"] + "²")
    save(fig, "10_相干函数", "10_相干函数_输入输出相干")

def co_02():
    """两个电压测点之间的相干函数。"""
    fig, ax = new_fig()
    t, u1 = _sig(seed=1002)
    rng = np.random.default_rng(10021)
    u2 = 0.94 * u1 + rng.normal(0, 0.09, u1.size)
    ax.cohere(u1, u2, NFFT=512, Fs=2000, color=C5, lw=0.9)
    ax.grid(False)
    ax.set_xscale("log")
    ax.set_xlim(20, 1000)
    ax.set_ylim(0, 1.05)
    ax.set_xlabel("频率 " + IT["f"] + " / Hz")
    ax.set_ylabel("相干系数 " + IT["gamma"] + "²")
    save(fig, "10_相干函数", "10_相干函数_双测点电压相干")

def co_03():
    """风速与风电出力的相干函数。"""
    fig, ax = new_fig()
    rng = np.random.default_rng(1003)
    fs = 1.0
    t = np.arange(0, 2048, 1 / fs)
    v = 8.5 + 1.8 * np.sin(2 * np.pi * t / 220) + rng.normal(0, 0.7, t.size)
    p = 0.45 * v ** 3 + rng.normal(0, 300, t.size)
    ax.cohere(v, p, NFFT=256, Fs=fs, color=C3, lw=0.9)
    ax.grid(False)
    ax.set_xscale("log")
    ax.set_ylim(0, 1.05)
    ax.set_xlabel("频率 " + IT["f"] + " / Hz")
    ax.set_ylabel("相干系数 " + IT["gamma"] + "²")
    save(fig, "10_相干函数", "10_相干函数_风速功率相干")

def co_04():
    """振动与电流信号的相干函数。"""
    fig, ax = new_fig()
    rng = np.random.default_rng(1004)
    fs = 4000
    t = np.arange(0, 2, 1 / fs)
    i = np.sin(2 * np.pi * 50 * t) + 0.3 * np.sin(2 * np.pi * 100 * t) + rng.normal(0, 0.1, t.size)
    vib = 0.7 * i + 0.4 * np.sin(2 * np.pi * 620 * t) + rng.normal(0, 0.25, t.size)
    ax.cohere(i, vib, NFFT=512, Fs=fs, color=C1, lw=0.9)
    ax.grid(False)
    ax.set_xscale("log")
    ax.set_xlim(10, 1800)
    ax.set_ylim(0, 1.05)
    ax.set_xlabel("频率 " + IT["f"] + " / Hz")
    ax.set_ylabel("相干系数 " + IT["gamma"] + "²")
    save(fig, "10_相干函数", "10_相干函数_振动电流相干")

def co_05():
    """气温与负荷的相干函数。"""
    fig, ax = new_fig()
    rng = np.random.default_rng(1005)
    fs = 24.0
    t = np.arange(0, 400, 1 / fs)
    temp = 28 + 6 * np.sin(2 * np.pi * t / 24) + rng.normal(0, 1.2, t.size)
    load = 420 + 8.4 * temp + 90 * np.sin(2 * np.pi * t / 24) + rng.normal(0, 30, t.size)
    ax.cohere(temp, load, NFFT=256, Fs=fs, color=C3, lw=0.9)
    ax.grid(False)
    ax.set_xscale("log")
    ax.set_ylim(0, 1.05)
    ax.set_xlabel("频率 " + IT["f"] + " / (1/h)")
    ax.set_ylabel("相干系数 " + IT["gamma"] + "²")
    save(fig, "10_相干函数", "10_相干函数_气温负荷相干")

说明

  • 图片尺寸 1181×944 px(100 mm × 80 mm @ 300 dpi),三维图为 1181×1122 px。
  • 图内不放标题,图题由本文件的二级/三级标题承担。
  • 数据为贴近广东实际量级的仿真算例,随机种子固定,重跑结果一致。
posted @ 2026-11-07 08:35  小青蛙电气  阅读(3)  评论(0)    收藏  举报