grdsample (pixel to gridline) returns nans
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 PyGMT grdsample 入口点开始,使用最小示例复现所提供的像素到网格线往返转换。将 Python 结果与 GMT 命令行行为进行比较,并添加覆盖测试以表明转换回网格线注册不会在任一极点产生 NaNs。
由索引模型根据 Issue 内容生成。
描述
Description of the problem
When using the grdsample routine to translate from pixel registration to gridline registration, the output contains nans at the poles. This does not occur when using the GMT command line utilities.
Minimal Complete Verifiable Example
import numpy as np
import pygmt
ppd = 1 # pixels per degree
nlat = 180 * ppd + 1
nlon = 360 * ppd + 1
array = np.ones((nlat, nlon))
spacing = 1 / ppd
x = np.arange(0, 360 + spacing, spacing)
y = np.arange(-90, 90 + spacing, spacing)
xx, yy = np.meshgrid(x, y)
# create gridline registered dataset
gridline = pygmt.xyz2grd(x=xx.flatten(), y=yy.flatten(), z=array.flatten(), spacing=spacing, region=[0, 360, -90, 90], registration='g', coltypes="g")
# convert to pixel registered
pixel = pygmt.grdsample(grid=gridline, translate=True)
# convert back to gridline registered
gridline2 = pygmt.grdsample(grid=pixel, translate=True)
print(gridline)
print(pixel)
print(gridline2)
Full error message
<xarray.DataArray 'z' (lat: 181, lon: 361)>
array([[1., 1., 1., ..., 1., 1., 1.],
[1., 1., 1., ..., 1., 1., 1.],
[1., 1., 1., ..., 1., 1., 1.],
...,
[1., 1., 1., ..., 1., 1., 1.],
[1., 1., 1., ..., 1., 1., 1.],
[1., 1., 1., ..., 1., 1., 1.]], dtype=float32)
Coordinates:
* lon (lon) float64 0.0 1.0 2.0 3.0 4.0 ... 356.0 357.0 358.0 359.0 360.0
* lat (lat) float64 -90.0 -89.0 -88.0 -87.0 -86.0 ... 87.0 88.0 89.0 90.0
Attributes:
long_name: z
actual_range: [1. 1.]
<xarray.DataArray 'z' (lat: 180, lon: 360)>
array([[1.008623 , 0.99907345, 1. , ..., 1. , 1. ,
1.0083693 ],
[1. , 1. , 1. , ..., 1. , 1. ,
0.99901193],
[1. , 1. , 1. , ..., 1. , 1. ,
1. ],
...,
[1. , 1. , 1. , ..., 1. , 1. ,
1. ],
[1. , 1. , 1. , ..., 1. , 1. ,
1. ],
[1. , 1. , 1. , ..., 1. , 1. ,
1. ]], dtype=float32)
Coordinates:
* lon (lon) float64 0.5 1.5 2.5 3.5 4.5 ... 355.5 356.5 357.5 358.5 359.5
* lat (lat) float64 -89.5 -88.5 -87.5 -86.5 -85.5 ... 86.5 87.5 88.5 89.5
Attributes:
long_name: z
actual_range: [0.99901193 1.008623 ]
<xarray.DataArray 'z' (lat: 181, lon: 361)>
array([[ nan, nan, nan, ..., nan, nan,
nan],
[1.0020888 , 1.0023468 , 0.99943876, ..., 0.99975574, 1.0018516 ,
1.0020888 ],
[0.99972796, 0.9997256 , 1.0000663 , ..., 1.0000675 , 0.99908644,
0.99972796],
...,
[1. , 1. , 1. , ..., 1. , 1. ,
1. ],
[1. , 1. , 1. , ..., 1. , 1. ,
1. ],
[ nan, nan, nan, ..., nan, nan,
nan]], dtype=float32)
Coordinates:
* lon (lon) float64 0.0 1.0 2.0 3.0 4.0 ... 356.0 357.0 358.0 359.0 360.0
* lat (lat) float64 -90.0 -89.0 -88.0 -87.0 -86.0 ... 87.0 88.0 89.0 90.0
Attributes:
long_name: z
actual_range: [0.99908644 1.00234675]
System information
PyGMT information:
version: v0.11.0
System information:
python: 3.12.1 | packaged by conda-forge | (main, Dec 23 2023, 08:01:35) [Clang 16.0.6 ]
executable: /Users/lunokhod/miniconda3/envs/py312/bin/python
machine: macOS-14.3-arm64-arm-64bit
Dependency information:
numpy: 1.26.3
pandas: 2.1.4
xarray: 2023.12.0
netCDF4: 1.6.5
packaging: 23.2
contextily: None
geopandas: None
ipython: None
rioxarray: None
ghostscript: 10.02.1
GMT library information:
binary version: 6.5.0
cores: 10
grid layout: rows
image layout:
library path: /Users/lunokhod/miniconda3/envs/py312/lib/libgmt.dylib
padding: 2
plugin dir: /Users/lunokhod/miniconda3/envs/py312/lib/gmt/plugins
share dir: /Users/lunokhod/miniconda3/envs/py312/share/gmt
version: 6.5.0
- 主要语言
- Python
- 星标
- 882
- 派生
- 261
- 平均合并
- 1 天 3 小时
- 30 天内合并 PR
- 29
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
GenericMappingTools/pygmt 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
GenericMappingTools/pygmt#5014 · 1 条评论 ·
维护者通常 1 天内回复
-
discussions documentation
难度 1/5 1 小时以内 新手友好度 78/100
GenericMappingTools/pygmt#4992 ·
维护者通常 1 天内回复
-
Improve reporting the GMT version via "pygmt.show_versions()"可能已有人在做 @yvonnefroehlich 于 113 天前认领。 未关闭maintenance
难度 2/5 1-3 小时 新手友好度 68/100
GenericMappingTools/pygmt#4812 · 4 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 64/100
GenericMappingTools/pygmt#4765 ·
维护者通常 1 天内回复
-
Add an AGENTS.md file可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭discussions
难度 2/5 1-3 小时 新手友好度 75/100
GenericMappingTools/pygmt#4677 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
查看 GenericMappingTools/pygmt 的全部 Issue
相似的 Issue
-
accepted
难度 2/5 1-3 小时 新手友好度 67/100
future-agi/future-agi#5274 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 66/100
w3c/feedvalidator#204 ·
-
[BUG][Low–Medium] founder_numbers.py silently reads a SAFE discount or pool target given as a fraction (0.2) as 0.2%可能已有人在做 @sumitkhond111-del 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 72/100
bmad-code-org/BMAD-METHOD#3358 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 86/100
open-mmlab/mmcv#3352 ·
-
难度 1/5 1 小时以内 新手友好度 68/100
OpenGithubs/weekly#263 ·
维护者通常 1 天内回复