Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Error in vertical interpolation on a 3D grid

オープン
#254 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
python
領域
data

調査の方向性

681行目付近の specialdec.py にある interplevel 呼び出しと検証から始めます。報告された height_levels の shape (10, 159, 154) と Z の shape (49, 159, 154) を比較し、3D の鉛直レベルに必要な次元を特定します。報告された補間ケースが一貫して処理されるか、必要な入力 shape が明確に確立されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Hello all,

I'm trying to vertically interpolate few variables on a 3D grid. I have created 10 vertical levels between the 5m to mixing height. The height_levels are defined separately for each grid point. It is a 3D array with shape (10,159,154), where 159 are the latitudes and 154 are the longitudes.

num_levels= 10
for t in range(len(ds['Time'])):

        pblh_t = ds['PBLH'].isel(Time=t).values
        height_levels = np.logspace(np.log10(5), np.log10(pblh_t), num_levels)

        field = ds[var].isel(Time=t)
        Z = ds['Z_center'].isel(Time=t)

        interpolated_data = interplevel(field, Z, height_levels)

The shape and the dimension of field and Z is matching exactly. However, this code is giving the following error:

File ~/miniconda3/envs/spyder-env/lib/python3.9/site-packages/wrf/specialdec.py:685 in func_wrapper
"the same leftmost and rightmost "

ValueError: argument 1 and 2 must have the same leftmost and rightmost dimensions.

If i give a list of values to interpolate, for example: height_levels = [50, 100,200,300]. code works fine and give the results without any error.

on inspecting the specialdec.py file, following are the lines which are raising the error

line:681

if is2dlev:
if levels.ndim != 2:

            if (levels.shape[0:-2] != z.shape[0:-3] or
                    levels.shape[-2:] != z.shape[-2:]):
                raise ValueError("argument 1 and 2 must have "
                                 "the same leftmost and rightmost "
                                 "dimensions")

For my case, levels.shape[-2:] = z.shape[-2:]),

height_levels.shape[-2:]
Out[99]: (159, 154)

Z.shape[-2:]
Out[100]: (159, 154)

but,
height_levels.shape[0:-2]
Out[101]: (10,)

Z.shape[0:-3]
Out[102]: ()

Z.shape[0:-3] is empty since the Z has only 3 dimensions (49,159,154). Here, 49 is the number of the model levels.

Can anyone please help me fix this.

Thank you for your time!!!

主要言語
Python
スター
498
フォーク
178
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NCAR/wrf-python のほかの issue

NCAR/wrf-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。