Skip to content

Command line mapc2p not working in some geometries #155

@tnbernard

Description

@tnbernard

Shawn Zamperini and I discovered that attempting to plot from the command line with --c2p input does not always produce the desired results.

For example, after running the regression test rt_gk_sheath_3x2v_p1.c, which uses a simple helical geometry, the following command was run:
gk_sheath_3x2v_p1-bmag.gkyl --c2p gk_sheath_3x2v_p1-mapc2p.gkyl interp sel --z1 0 pl --ylim -1,1 which produces:

Image

However, we get the expected results from the following python script:

import postgkyl as pg
import numpy as np
import matplotlib.pyplot as plt       

# Load data with mapc2p information.
data = pg.data.GData("gk_sheath_3x2v_p1-bmag.gkyl", mapc2p_name="gk_sheath_3x2v_p1-mapc2p.gkyl")                      
dg = pg.GInterpModal(data)
dg.interpolate(overwrite=True)  

# Get grid and (x,y) coordinates
grid = data.get_grid()
print(np.shape(grid[0]))
x = grid[0][:,0,:].flatten()
y = grid[1][:,0,:].flatten()
r = np.sqrt(np.square(x) + np.square(y))

values = data.get_values()

fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x,y)
ax.set_aspect('equal')
plt.show()
plt.close()

vals2d = values[:,0,:,0]
print(np.shape(vals2d))
X = grid[0][:,0,:]
Y = grid[1][:,0,:]

fig = plt.figure(figsize=(5,6))
ax = plt.pcolormesh(X, Y, vals2d)
ax.axes.set_aspect('equal')
plt.title('Magnetic field')
plt.colorbar()
plt.savefig('mapc2p_sheath3x_bmag.png')
plt.show()

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions