Skip to content

使用numpy向量化和scikit-image,完全替换cython - #151

Open
IncubatorShokuhou wants to merge 8 commits into
CyanideCN:masterfrom
IncubatorShokuhou:master
Open

IncubatorShokuhou wants to merge 8 commits into
CyanideCN:masterfrom
IncubatorShokuhou:master

Conversation

@IncubatorShokuhou

@IncubatorShokuhou IncubatorShokuhou commented Sep 16, 2026 •

Copy link
Copy Markdown

因为有cython代码的存在,所以每次pip install都得编译之类的。当前代码直接把cython都替换掉了(vil / et 改成 NumPy 向量化,速度退模糊改用 scikit-image),然后安装和打包就都不再编译扩展(wheel 是 py3-none-any)了。

  • 测试用的是 uniquezhiyuan/PyRadar 这份公开 SA 体扫:Z_RADR_I_Z9250_20160701001000_O_DOR_SA_CAP.bin(站号 Z9250,2016-07-01 00:10 UTC,VCP21)。
  • 合成 sa230 / sa460:按 SA 雷达常见尺寸造的测试场。sa230 是反射率 9 × 230 × 360,sa460 是速度 360 × 460。
  • 相对:现实现耗时 ÷ 原 Cython 耗时。小于 1 表示更快,例如 0.54× 大约快一倍。

对齐

量 结果
VIL / VILD 数值几乎一样。加法顺序不同,最大绝对差约 4e-12(合成 sa230);真实 Z9250 大约 7e-15。
ET 每个格子都一样。
退模糊 测试用例每个格子都一样。真实数据的两个速度仰角也一样。

耗时(本机,预热 2 次,取 7 次中位数)

输入 函数 原 Cython 现实现 相对
真实数据 VIL 31.8 ms 17.3 ms 0.54×,更快
真实数据 ET 2.81 ms 2.92 ms 1.04×,相当
真实数据 退模糊 48.8 ms 44.2 ms 0.91×,更快
合成 sa230 VIL 39.1 ms 15.1 ms 0.39×,更快
合成 sa230 ET 2.79 ms 2.81 ms 相当
合成 sa460 退模糊 32.0 ms 28.7 ms 0.90×,更快

cursoragent and others added 8 commits September 16, 2026 09:02
安装和运行不再需要编译扩展;测试对照原 Cython 黄金输出对齐。

Co-authored-by: Hao Lyu <IncubatorShokuhou@users.noreply.github.com>
Co-authored-by: Hao Lyu <IncubatorShokuhou@users.noreply.github.com>
Co-authored-by: Hao Lyu <IncubatorShokuhou@users.noreply.github.com>
cinrad_data 只有字体和地图;改用公开 Z9250 SA 基数据经 cinrad.io 抽出数组,对照侧路 Cython 黄金输出。另附本地 Cython/NumPy 计时脚本。

Co-authored-by: Hao Lyu <IncubatorShokuhou@users.noreply.github.com>
Co-authored-by: Hao Lyu <IncubatorShokuhou@users.noreply.github.com>
Co-authored-by: Hao Lyu <IncubatorShokuhou@users.noreply.github.com>
Co-authored-by: Hao Lyu <IncubatorShokuhou@users.noreply.github.com>
…e-python-a0d2

完全丢弃Cython:VIL/ET 改 NumPy,退模糊改 scikit-image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants