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

Add support for plotting isocontours of vector potential in snap.py #7

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions script/analysis/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def quiver_xy(ax, geom, dump, varx, vary, C=None,
coordinates='figure')

def overlay_field(ax, geom, dump, NLEV=20, linestyle='-', linewidth=1,
linecolor='k'):
linecolor='k', zorder=2):
from scipy.integrate import trapz
hdr = dump['hdr']
N1 = hdr['N1']//2; N2 = hdr['N2']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you dividing hdr['N1'] by 2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is the line that I wanted to check with you.

Is A_phi[j,N1-1-i] calculating A in the -ve direction and A_phi[j,i+N1] in the +ve direction? So if I don't divide by 2, ultimately, in line 363, rcyl and z ends up having dimensions 256 X 256, and A_phi is 256 X 512. So I divided by 2 to make N1 represent cells in either the +ve/-ve direction only.

Expand Down Expand Up @@ -361,7 +361,7 @@ def overlay_field(ax, geom, dump, NLEV=20, linestyle='-', linewidth=1,
levels = np.concatenate((np.linspace(-Apm,0,NLEV)[:-1],
np.linspace(0,Apm,NLEV)[1:]))
ax.contour(rcyl, z, A_phi, levels=levels, colors=linecolor, linestyles=linestyle,
linewidths=linewidth, zorder=2)
linewidths=linewidth, zorder=zorder)

def plot_xy(ax, geom, var, dump, cmap='jet', vmin=None, vmax=None, cbar=True,
label=None, ticks=None, shading='gouraud', fix_bounds=True):
Expand Down
7 changes: 5 additions & 2 deletions script/analysis/snap.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
parser.add_argument('--linecolor',
type=str, default='k',
help='Linecolor of A-contours. Needed only if using --A-contours')
parser.add_argument('--zorder',
type=str, default='k',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be type=int and default=2

Copy link
Collaborator Author

@soumide1102 soumide1102 Oct 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops! result of copy pasting the previous line to avoid typing, and then forgetting to update it completely. :)

help='zorder for A-contours. Needed only if using --A-contours')
parser.add_argument('--save',
type=str,default=None,
help='Figure filename if you want to save the figure')
Expand Down Expand Up @@ -119,7 +122,7 @@ def make_snap(dfnam,vnam,coords,size,cmap,logplot,
if args.A_contours:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that args is referenced in make_snap now. This is going to break movie.py which calls this method. Can you pass these through as optional arguments to make_snap so that the args object isn't used in scope it might not be available?

bplt.overlay_field(ax, geom, dump, NLEV=args.nlev,
linestyle=args.linestyle, linewidth=args.linewidth,
linecolor=args.linecolor)
linecolor=args.linecolor, zorder=args.zorder)
ax = a1
if coords == 'mks':
bplt.plot_X1X3(ax, geom, var, dump, cmap=cmap, vmin=vmin, vmax=vmax,
Expand All @@ -142,7 +145,7 @@ def make_snap(dfnam,vnam,coords,size,cmap,logplot,
if args.A_contours:
bplt.overlay_field(ax, geom, dump, NLEV=args.nlev,
linestyle=args.linestyle, linewidth=args.linewidth,
linecolor=args.linecolor)
linecolor=args.linecolor, zorder=args.zorder)

if savefig == False:
plt.show()
Expand Down