Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Animate polygon -- create animations using a polygon plotting tool #312

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mrhardman
Copy link
Collaborator

@mrhardman mrhardman commented Feb 20, 2025

This pull request attempts to address the issue highlighted #311 by introducing the ability to make animations with a plotting function based on polygons, not pcolormesh().

This feature is not fully developed and polished compared to what is available through animatplot-ng, but unfortunately that library does not support polygon plotting.

To use this feature on Hermes-3 data, use the following script

#!/usr/bin/env python3

# Following two lines needed so all variables are shown when printing the Dataset
import xarray as xr
import xhermes

xr.set_options(display_max_rows=1000)

# Set better figure size
from matplotlib import pyplot as plt

plt.rcParams["figure.figsize"] = (16,8)

ds = xhermes.open(".", geometry="toroidal",
    gridfilepath="bout.grd.nc",
    keep_yboundaries=False,
    keep_xboundaries=False)

# Get rid of size-1 toroidal direction
ds = ds.squeeze()

# Make an animation
# Note: saving a gif can be slow. Comment out `save_as` argument to disable.
ds.bout.animate_polygon_list(
    ["Nd","Pd"],
    #["Nd"],
    poloidal_plot=True,
    show=False,
    save_as="hermes_animation_new",
)

Please make suggestions to guide the development of this PR. Currently the code is adequate for my needs.

An outstanding issue is the plotting of the separatrix, where the lines do not meet correctly at the X-point, e.g., see below.
image

@mrhardman mrhardman added the enhancement New feature or request label Feb 20, 2025
@mrhardman mrhardman changed the title Animate polygon: create animations using a polygon plotting tool WIP: Animate polygon -- create animations using a polygon plotting tool Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant