Communitygithub.com

d3v-null/wsclean-skill

一個全面的 Cursor 代理技能,用於 WSClean 無線電干涉測量成像。

wsclean-skill 是什麼?

此技能為 WSClean(一款高效能的無線電干涉測量成像工具)提供完整的代理支援。它專為處理從 LOFAR、MWA、VLA、ASKAP 或 SKA 等望遠鏡獲得的 Measurement Set (.ms) 檔案而設計。技能涵蓋從基本髒圖像生成、CLEAN 解卷積、多尺度清潔、多頻率合成到偏振測量成像和自校準迴圈等所有內容。基於命令列的工具(如 Cursor 或 Claude Code)可以使用此技能,透過 Docker 容器執行 WSClean。技能包含常見工作流程、最佳實務、故障排除技巧,以及指向更詳細參考文件的鏈接,使其成為處理無線電天文學資料的開發人員和研究人員的必備工具。

相容平台~Claude Code~Codex CLI✓Cursor
npx skills add d3v-null/wsclean-skill

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

WSClean 技能

WSClean 是一款無線電干涉測量成像工具,可從 Measurement Set 建立清潔後的影像。當處理來自 LOFAR、MWA、VLA、ASKAP 或 SKA 等望遠鏡的無線電天文資料時,請使用此技能。

使用時機

  • 對來自 Measurement Set (.ms) 檔案的無線電干涉資料進行成像
  • 對可見度資料進行 CLEAN 解卷積
  • 對解析源進行多尺度清潔
  • 多頻率合成(寬頻成像)
  • 偏振測量成像
  • 基於面元的成像,包含方向相關校正
  • 自校準迴圈(模型生成)

Docker 存取

WSClean 編譯較複雜。建議使用 Docker:

docker run --rm -it d3vnull0/rapthor-mildtec:smoke wsclean [options] <input.ms>

掛載資料目錄:-v /host/path:/container/path:rw

基本命令結構

wsclean [options] <input-ms> [<2nd-ms> [...]]

關鍵:多個測量集必須相位旋轉至相同位置。

必要參數

影像設定(務必提供)

  • -size <w> <h> - 影像像素尺寸(必須為偶數)
  • -scale <value> - 像素比例(例如 2asec、1amin、0.01deg)
  • -name <prefix> - 輸出檔案名稱前置詞(預設:'wsclean')

解卷積控制

  • -niter <n> - 最大迭代次數(設定較高值,例如 1000000)
  • -auto-threshold <sigma> - 在 sigma×RMS 處停止(建議:1-5)
  • -mgain <gain> - 主要迴圈增益:0.85(安全)、0.95(積極)
    • 關鍵:mgain=1.0 會阻止自校準(不更新 MODEL_DATA)
  • -auto-mask <sigma> - 自動遮罩閾值(建議與 -auto-threshold 一起使用)

加權

  • -weight briggs <robust> - Briggs 加權(-2 到 +2,常見:-0.5、0、0.5)
  • -weight uniform - 最大解析度
  • -weight natural - 最大靈敏度

進階功能

  • -multiscale - 用於解析源的多尺度 CLEAN
  • -channels-out <n> - 將頻寬分割成 N 個影像
  • -join-channels - 多頻率解卷積
  • -pol <list> - 偏振:I、Q、U、V,或 XX、XY、YX、YY
  • -join-polarizations - 偏振測量解卷積

常見工作流程

1. 快速髒圖像(不清潔)

docker run --rm -v $(pwd):/data:rw d3vnull0/rapthor-mildtec:smoke \
  wsclean -size 2048 2048 -scale 5asec -name quick /data/obs.ms

2. 標準清潔

wsclean -size 4096 4096 -scale 2asec \
  -niter 100000 -auto-threshold 3 \
  -weight briggs 0 -mgain 0.85 \
  -name standard obs.ms

3. 深度多尺度清潔(最佳品質)

wsclean -size 8192 8192 -scale 1asec \
  -multiscale -multiscale-scale-bias 0.7 \
  -niter 1000000 -auto-threshold 1 -auto-mask 5 \
  -weight briggs -0.5 -mgain 0.85 \
  -name deep obs.ms

4. 多頻率合成(4 個通道)

wsclean -size 4096 4096 -scale 2asec \
  -channels-out 4 -join-channels \
  -multiscale -niter 500000 \
  -auto-threshold 3 -mgain 0.85 \
  -name mfs obs.ms

5. 偏振測量成像

wsclean -size 4096 4096 -scale 2asec \
  -pol xx,yy -join-polarizations \
  -niter 100000 -auto-threshold 3 \
  -mgain 0.85 -name pol obs.ms

6. 自校準成像

# 關鍵:mgain < 1.0 以更新 MODEL_DATA
wsclean -size 4096 4096 -scale 2asec \
  -niter 100000 -auto-threshold 3 \
  -mgain 0.85 -multiscale -auto-mask 5 \
  -name selfcal obs.ms

輸出檔案

使用 -name myimage:

  • myimage-dirty.fits - 髒圖像
  • myimage-image.fits - 清潔/還原後的影像
  • myimage-model.fits - 模型(CLEAN 分量)
  • myimage-residual.fits - 清潔後的殘差
  • myimage-psf.fits - 點擴散函數

多通道:myimage-0000-image.fits、myimage-0001-image.fits 等。 多偏振:myimage-I-image.fits、myimage-Q-image.fits 等。

快速參考 - 關鍵參數

參數用途典型值
-niter最大迭代次數100000-1000000
-auto-threshold在 N×sigma 處停止1-5(數值越低越深)
-mgain主要迴圈增益0.85(安全)、0.95(快速)
-auto-mask遮罩閾值3-5 sigma
-weight briggs加權穩健性-0.5(解析度)、0(平衡)、0.5(靈敏度)
-multiscale-scale-bias尺度偏好0.6-0.7
-channels-out輸出通道數通常 4-16
-jCPU 執行緒數預設:所有核心

常見問題

清潔發散

  • 將 -mgain 降低至 0.7 或 0.8
  • 若使用多尺度,請加上 -multiscale-gain 0.1
  • 嘗試 -major-iteration-mode single

記憶體不足

  • 使用 -abs-mem 32(或適當的 GB 數)
  • 減少 -size 或增加 -scale
  • 光譜成像請使用 -deconvolution-channels

無法自校準

  • 確保 mgain < 1.0(不是 1.0!)
  • 只有當 mgain < 1 時,MODEL_DATA 欄位才會更新

成像品質不佳

  • 對解析源使用 -multiscale
  • 深度清潔請加上 -auto-mask 5
  • 檢查加權:嘗試 -weight briggs 0

何時查閱詳細參考資料

對於複雜情境,請參考此目錄中的參考檔案:

  • reference/parameters.md - 完整參數文件
  • reference/workflows.md - 進階工作流程(面元、主波束等)
  • reference/troubleshooting.md - 詳細故障排除指南

需要時請使用 Read 工具存取這些檔案。

最佳實務

  1. 始終使用 -auto-threshold(不要使用絕對閾值)
  2. 設定較高的 -niter 並讓閾值停止清潔
  3. 使用 mgain 0.85 以獲得穩健的 Cotton-Schwab 清潔
  4. 對解析源使用多尺度 - 總是優於 Högbom
  5. 將 -auto-mask 5 與 -auto-threshold 1 結合使用 以進行深度清潔
  6. 影像維度必須為偶數 - 最好是 2 的冪次
  7. 每個合成波束約 5-6 個像素 以確保適當的取樣

文件

相關技能