grdsample (pixel to gridline) returns nans
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 45/100
Rechercherichtung
Beginne beim PyGMT grdsample-Einstiegspunkt und reproduziere mit dem Minimalbeispiel den bereitgestellten Pixel-zu-Gitterlinien-Roundtrip. Vergleiche das Python-Ergebnis mit dem Verhalten der GMT-Befehlszeile und füge eine Abdeckung hinzu, die zeigt, dass die Rückkonvertierung zur Gitterlinienregistrierung an keinem der beiden Pole NaNs erzeugt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- Python
- Sterne
- 882
- Forks
- 261
- Ø Merge
- 1 T. 3 Std.
- Gemergte PRs (30 T.)
- 29
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus GenericMappingTools/pygmt
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
GenericMappingTools/pygmt#5014 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
discussions documentation
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 78/100
GenericMappingTools/pygmt#4992 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Improve reporting the GMT version via "pygmt.show_versions()"Evtl. vergeben @yvonnefroehlich hat das vor 113 Tagen übernommen. Offenmaintenance
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
GenericMappingTools/pygmt#4812 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
GenericMappingTools/pygmt#4765 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Add an AGENTS.md fileEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offendiscussions
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
GenericMappingTools/pygmt#4677 · 2 Kommentare · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in GenericMappingTools/pygmt
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
TigreGotico/orthography2ipa#2950 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Unstructured-IO/unstructured#4876 ·
Maintainer antworten meist innerhalb von 6 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
openfoodfacts/openfoodfacts-python#579 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 90/100
fairagro/m4.2_sql_to_arc#388 ·
Maintainer antworten meist innerhalb von 1 Tag