how to speed up the process of `getvar`
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 28/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- python
- 領域
- data, performance
調査の方向性
まず、Python、wrf.getvar、netCDF4、および記載されている SINALPHA、COSALPHA、uvmet_wspd_wdir 変数を使って、issue のタイミング比較を再現します。getvar のエントリーポイントを追跡し、ALL_TIMES と派生診断の処理を直接読み取る場合と比較します。完了の条件は、ボトルネックを特定し、結果を変更せずにより高速なアプローチを実証することです。
索引モデルが issue の本文から書いたものです。
説明
I found that using wrf.getvar to get variables is quite slow.
For example
import time
import wrf
import netCDF4 as nc
wrfout = nc.Dataset(wrfout_file)
t0 = time.time()
SINALPHA_WRF = wrf.getvar(wrfout, 'SINALPHA', timeidx=wrf.ALL_TIMES, squeeze=False)
COSALPHA_WRF = wrf.getvar(wrfout, 'COSALPHA', timeidx=wrf.ALL_TIMES, squeeze=False)
t1 = time.time()
sinalpha = wrfout['SINALPHA'][:]
cosalpha = wrfout['COSALPHA'][:]
t2 = time.time()
print(f'getvar: {t1 - t0},directly: {t2 - t1}')
In my PC, the time of getvar is about 0.084 s, and the time of directly is about 0.015 s.
To be a little more complicated, to get the wind speed and the wind direction using wrf.getvar(wrfout, 'uvmet_wspd_wdir', timeidx=wrf.ALL_TIMES, squeeze=False) would take the time about 14.596 s, while we first get ua, va, SINALPHA, COSALPHA by wrf.getvarand then using the relation between these variables to get the wspd and wdir, whose values are not significant different from the result of getvar, but it only takes 2.263 s.
So, what reason make it seems that the calculation speed of getvar is slow and how to improve it?
In my case, I want to extract some variables from wrfout and backup, e.g, most of the variables may be the shape of (4,50,300,300), and I want to save some diagnostic variables to be (4, 10, 300, 300)(interpolated on certain pressure level or height). Any suggestion to efficiently accomplish this kind of task.
wrf.__version__='1.3.2'
- 主要言語
- Python
- スター
- 498
- フォーク
- 178
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NCAR/wrf-python のほかの issue
-
NCAR/wrf-python#309 · 担当者 1 名 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
NCAR/wrf-python#307 · コメント 5 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
NCAR/wrf-python#286 · コメント 3 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
NCAR/wrf-python#282 · コメント 1 件 ·
-
PyPI releases オープン
NCAR/wrf-python#274 · コメント 5 件 · リアクション 1 件 · 担当者 1 名 ·
NCAR/wrf-python の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
stephrobert/dsoxlab#238 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
sublimehq/package_control#1780 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
nwg-piotr/nwg-displays#145 ·