Polar stereo stipple() fails for data on curvilinear/2d grid
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 42/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- matplotlib, python
- Bereich
- data-visualization
Rechercherichtung
Reproduziere den Fehler mit polar_test_2d_coord_data.py aus dem angehängten Archiv und vergleiche ihn anschließend mit dem funktionierenden Fall polar_test_1d_coord_data.py. Lies die Vorschläge in stipple_fix.py und regrid_fix.py zusammen mit den Pfaden stipple() und regrid() in cfplot.py; abgeschlossen bedeutet, dass das Stippling auf krummlinigen Gittern einen Plot erzeugt, ohne den Fall mit 1D-Koordinaten zu beeinträchtigen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Hi Sadie!
Subject of the issue
Attempting to stipple() over a polar stereo contour plot from data that had 2d lon and lat grid (e.g lon(i,j)) fails.
Steps to reproduce
See attached code
Your environment
The version of cf-plot and its dependencies in which you are encountering an issue.
cf.environment(paths=False) Platform: Linux-5.14.0-503.38.1.el9_5.x86_64-x86_64-with-glibc2.34 HDF5 library: 1.14.2 netcdf library: 4.9.4-development udunits2 library: libudunits2.so.0 esmpy/ESMF: not available Python: 3.10.16 dask: 2025.3.0 netCDF4: 1.7.2 h5netcdf: 1.6.3 h5py: 3.14.0 s3fs: 2025.5.1 psutil: 7.0.0 packaging: 24.2 numpy: 2.2.4 scipy: 1.15.3 matplotlib: 3.10.3 cftime: 1.6.4.post1 cfunits: 3.3.7 cfplot: 3.4.0 cfdm: 1.12.1.0 cf: 3.17.0
Expected behaviour
A stippled plot should be produced
Actual behaviour
Tell us what happens instead. If you see an error please provide the traceback, ideally in full.
`Traceback (most recent call last):
File "/apps/jasmin/jaspy/miniforge_envs/jaspy3.11/mf3-23.11.0-0/envs/jaspy3.11-mf3-23.11.0-0-v20240815/lib/python3.11/site-packages/cfplot/cfplot.py", line 9579, in add_cyclic
field, lons = cartopy_util.add_cyclic_point(field, lons)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/apps/jasmin/jaspy/miniforge_envs/jaspy3.11/mf3-23.11.0-0/envs/jaspy3.11-mf3-23.11.0-0-v20240815/lib/python3.11/site-packages/cartopy/util.py", line 69, in add_cyclic_point
raise ValueError('The coordinate must be 1-dimensional.')
ValueError: The coordinate must be 1-dimensional.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/gws/nopw/j04/canari/users/dlrhodso/spring2025/analysis/FWC/polar_plot_example/./polar_test_2d_coord_data.py", line 10, in
cfp.stipple(f=data,min=28.0,max=40.0)
File "/apps/jasmin/jaspy/miniforge_envs/jaspy3.11/mf3-23.11.0-0/envs/jaspy3.11-mf3-23.11.0-0-v20240815/lib/python3.11/site-packages/cfplot/cfplot.py", line 5073, in stipple
field, xpts = add_cyclic(field, xpts)
^^^^^^^^^^^^^^^^^^^^^^^
File "/apps/jasmin/jaspy/miniforge_envs/jaspy3.11/mf3-23.11.0-0/envs/jaspy3.11-mf3-23.11.0-0-v20240815/lib/python3.11/site-packages/cfplot/cfplot.py", line 9583, in add_cyclic
field, lons = cartopy_util.add_cyclic_point(field, lons)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/apps/jasmin/jaspy/miniforge_envs/jaspy3.11/mf3-23.11.0-0/envs/jaspy3.11-mf3-23.11.0-0-v20240815/lib/python3.11/site-packages/cartopy/util.py", line 69, in add_cyclic_point
raise ValueError('The coordinate must be 1-dimensional.')
ValueError: The coordinate must be 1-dimensional.
`
Relevant data
The attached tar file contains polar_test_2d_coord_data.py which attempts to plot a stipple over data on a curvilinear grid (and fails). polar_test_1d_coord_data.py attempts to do the same, but after regridding the data to a standard lon-lat grid (ie 1d coordinate arrays). This works.
The proposed fix is stipple_fix.py adn regrid_fix.py which only makes minor changes to stipple() - to avoid applying cyclic corrections to the longitude coordinates for a 2d longitude array, but also re-writes regrid() to allow the regridding of data on a curvilinear grid (disclosure: I asked co-pilot to write this for me!) - this seems to work!
- Vorherrschende Sprache
- Python
- Sterne
- 21
- Forks
- 11
- Ø Merge
- 2 Std. 59 Min.
- Gemergte PRs (30 T.)
- 11
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine 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 NCAS-CMS/cf-plot
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Maintainer antworten meist innerhalb von 1 Tag
-
dependencies infrastructure installation testing
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
Maintainer antworten meist innerhalb von 1 Tag
-
docs enhancement
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in NCAS-CMS/cf-plot
Ähnliche Issues
-
app: scripts Bucket: KTLO status: backlog type: housekeeping
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
netbox-community/netbox-scripts#217 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
-
ApacheTomcatImporterPipeline truncates milestone fixed versions (e.g. 11.0.0-M6 -> 11.0.0)Evtl. vergeben @nikolya-ctrl hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
aboutcode-org/vulnerablecode#2533 ·
Maintainer antworten meist innerhalb von 5 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
PermafrostDiscoveryGateway/water-timeseries-v2#312 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
ClickHouse/dbt-clickhouse#829 ·
Maintainer antworten meist innerhalb von 1 Tag