xBOUT icon indicating copy to clipboard operation
xBOUT copied to clipboard

Polygonal 2D poloidal plots

Open mikekryjak opened this issue 2 years ago • 2 comments

xBOUT's default pcolormesh() method creates plotting artifacts around the X-point due to having to plot the grid on a per-region basis and not having corner information.

This new method uses a different approach, and is more like what UEDGE, SOLEDGE2D and SOLPS users do. Using coordinates of cell centres and cell corners, a Matplotlib Polygon is created for each cell independently and put into a PatchCollection . With each cell being independently plotted, there are no issues arising from the poloidal ordering of the cells or from the X-point.

The polygon plotting routine was adapted from this PR which was itself based on a UEDGE routine. The cell corners were obtained using this Hypnotoad PR. It adds a new plot method accessed by da.bout.polygon() which creates fast, pretty 2D plots without visual artefacts around the X-point.

  • [x] Add facility to read the cell corners into dataset coords in geometry.py
  • [x] Create plot2d_polygon in plotfuncs.py
  • [x] Test on single null
  • [x] Make sure it works when plotting with guard cells as well as without

Decided to not integrate it with plot2d_wrapper as polygon doesn't plot on a region basis and does not wrap Xarray plot routines.

Example output: image

mikekryjak avatar Mar 01 '23 14:03 mikekryjak

Codecov Report

Merging #280 (5391d64) into master (212b407) will decrease coverage by 1.24%. The diff coverage is 4.76%.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master     #280      +/-   ##
==========================================
- Coverage   68.94%   67.71%   -1.24%     
==========================================
  Files          15       15              
  Lines        3214     3277      +63     
  Branches      792      808      +16     
==========================================
+ Hits         2216     2219       +3     
- Misses        734      793      +59     
- Partials      264      265       +1     
Impacted Files Coverage Δ
xbout/geometries.py 68.87% <0.00%> (-1.08%) :arrow_down:
xbout/plotting/plotfuncs.py 16.19% <1.75%> (-2.48%) :arrow_down:
xbout/boutdataarray.py 78.20% <50.00%> (-0.16%) :arrow_down:
xbout/region.py 83.59% <100.00%> (+0.03%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov-commenter avatar Mar 15 '23 14:03 codecov-commenter

Hello @mikekryjak! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 886:89: E501 line too long (90 > 88 characters) Line 894:89: E501 line too long (103 > 88 characters) Line 914:89: E501 line too long (90 > 88 characters) Line 935:23: E711 comparison to None should be 'if cond is None:' Line 938:22: E711 comparison to None should be 'if cond is not None:'

Line 124:89: E501 line too long (116 > 88 characters)

Line 223:37: E701 multiple statements on one line (colon)

Line 475:5: E704 multiple statements on one line (def) Line 625:5: E704 multiple statements on one line (def)

Comment last updated at 2024-05-28 15:22:58 UTC

pep8speaks avatar Mar 22 '24 15:03 pep8speaks

This is ready for review & merge

mikekryjak avatar May 25 '24 09:05 mikekryjak