Precision change in regular PP-grid coordinates

オープン
#7,344 コメント 1 件 リアクション 3 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
56/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
numpy, python
領域
data

調査の方向性

Start by reading iris.util.regular_points and the change linked in the issue, then reproduce the reported call with the given zeroth, step, and count values. Compare the first coordinate with the float64 result and inspect the existing tests for regular point generation. Done means the generated coordinates retain the expected precision for this case and the relevant tests pass.

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

説明

Type: Bug

🐛 Bug Report

A change in the handling of dtypes (introduced to iris as part of Numpy 2 upgrade) has resulted in some files being loaded at a lower precision.

The change in behaviour was introduced in iris.util.regular_points, which first attempts to create a regular set of points as float32, and if that is not regular, re-attempts with float64. There are cases where the zeroth and step are float64, but are cast to float32, resulting in a regular array at a lower precision.

How To Reproduce

Steps to reproduce the behaviour:

  1. Start with a UM file with the following field headers:
...
(16) lbcode  :                  101  # Indicates regular lat-lon grid, rotated pole
(17) lbhem   :                    3 
(18) lbrow   :                  190  # Number of points in y
(19) lbnpt   :                  190  # Number of points in x
...
(59) bzy     : -0.27500000000000213  # Zeroth y point
(60) bdy     :                 0.11  # Step in y
(61) bzx     :   341.30499999999995  # Zeroth x point
(62) bdx     :                 0.11  # Step in x
...
  1. In the pp load, in constructing the x coordinate, the following function will be called:
x = iris.util.regular_points(zeroth=341.30499999999995, step=0.11, count=190)
  1. The resulting array has a dtype of float32, even though the inputs were float64. Compare the first element of the array, with the result of doing the calculation with native python floats (or with explicit numpy float64):
>>> x[0]
np.float32(341.41498)
>>> 341.30499999999995 + 0.11
341.41499999999996
>>> np.add(341.30499999999995, 0.11, dtype="float64")
np.float64(341.41499999999996)

The expected start longitude is actually included in the file, as entry 4 of the real constants - and it matches the float64 calculation:

%%%%%%%%%%%%%%%%%%
* real_constants *
%%%%%%%%%%%%%%%%%%
  (1) col_spacing    :                0.11
  (2) row_spacing    :                0.11
  (3) start_lat      : -0.1650000000000027
  (4) start_lon      :  341.41499999999996
  (5) north_pole_lat :               39.25
  (6) north_pole_lon :               198.0

Environment

  • OS & Version: Red Hat Enterprise Linux release 9.8 (Plow)
  • Iris Version: 3.15, but looks to have been introduced from 3.11

Additional context

Click to expand this section... Can provide example file on request.
主要言語
Python
スター
730
フォーク
323
平均マージ
3日 21時間
マージ済み PR(30日)
16

環境構築

はじめの一歩

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

SciTools/iris のほかの issue

SciTools/iris の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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