-
Notifications
You must be signed in to change notification settings - Fork 32
Pre made plotting routines
A number of plotting routines are to be found within the pt.plot
module. They have a number of user-definable options which can be set on the command line. Help for these routines is available on the command line by typing e.g. pt.plot.plot_colormap?
This is the basic 2-dimensional data plotting routine. Detailed instructions for plot_colormap. Sample use:
pt.plot.plot_colormap(filename='/path/to/file/bulk.0001234.vlsv', var='proton/vg_rho', draw=1)
Example Code
import pytools as pt
# Defining source and output file locations
run = 'BCH'
dim = '2D'
bulk = 'bulk'
bulkLocation = '/wrk/group/spacephysics/vlasiator/{}/{}/bulk/'.format(dim, run)
fluxLocation = '/wrk/group/spacephysics/vlasiator/{}/{}/flux/'.format(dim, run)
outputLocation = './'
j = 4000 # time step (*2?)
bulkname = '{}.{}.vlsv'.format(bulk,str(j).zfill(7)) # Bulk file name
pt.plot.plot_colormap(filename=bulkLocation+bulkname,var='Temperature',boxre=[-7,13,-10,10],run=run,colormap='hot_desaturated',vmin=5e5,vmax=5e8,step=j,outputdir=outputLocation,outputfile='test_colormap_{}_{}.png'.format(run,j),fluxdir=fluxLocation,fluxlines=6,Earth=1)
This is an extension of plot_colormap, used to plot two-dimensional slices of 3D AMR data. Detailed instructions for plot_colormap3dslice. Sample use:
pt.plot.plot_colormap3dslice(filename='/path/to/file/bulk.0001234.vlsv', var='proton/vg_rho', draw=1, normal='y')
Example Code
import pytools as pt
# Defining source and output file locations
run = 'EGL'
dim = '3D'
bulk = 'bulk1.egl'
bulkLocation = '/wrk/group/spacephysics/vlasiator/{}/{}/bulk/'.format(dim, run)
fluxLocation = '/wrk/group/spacephysics/vlasiator/{}/{}/flux/'.format(dim, run)
outputLocation = './'
#plot paramteers
normal = 'y' # x-z plot
cutpoint = 0 # y=0 plane
streamlines = 'vg_b_vol' # overplot magnetic field
j=800
bulkname = '{}.{}.vlsv'.format(bulk,str(j).zfill(7)) # Bulk file name
pt.plot.plot_colormap3dslice(filename=bulkLocation+bulkname,var='proton/vg_rho', boxre=[-15,15,-15,15], normal =normal, run=run,colormap='plasma',vmin=5e5,vmax=2e7,step=j,outputdir=outputLocation,outputfile='test_colormap_3dslice_rho_{}eq{}_{}_{}.png'.format(normal,cutpoint, run, j), Earth=1, streamlines = streamlines, cutpointre=cutpoint)
Example Code
import pytools as pt
# Defining source and output file locations
run = 'EGL'
dim = '3D'
bulk = 'bulk1.egl'
bulkLocation = '/wrk/group/spacephysics/vlasiator/{}/{}/bulk/'.format(dim, run)
fluxLocation = '/wrk/group/spacephysics/vlasiator/{}/{}/flux/'.format(dim, run)
outputLocation = './'
j=857 #EGL --- pressure pulse arrival time
bulkname = '{}.{}.vlsv'.format(bulk,str(j).zfill(7))
pt.plot.plot_threeslice(filename=bulkLocation+bulkname, var ='proton/vg_rho', colormap = 'plasma', vmin = 1e4,vmax=5e6, step=j, outputdir=outputLocation,outputfile='test_threeslice_{}_{}.png'.format(run,j), Earth=1,cutpointre=[0,0,0], slices='yz' )
This routine plots slices or projections of a 3V velocity distribution function. Detailed instructions for plot_vdf.
Example Code
import pytools as pt
# Defining source and output file locations
run = 'EGL'
dim = '3D'
bulk = 'bulk1.egl'
bulkLocation = '/wrk/group/spacephysics/vlasiator/{}/{}/bulk/'.format(dim, run)
fluxLocation = '/wrk/group/spacephysics/vlasiator/{}/{}/flux/'.format(dim, run)
outputLocation = './'
f=pt.vlsvfile.VlsvReader(bulkLocation+bulkname)
#find simulation cell near specified x,y,z coordinates
R_EARTH = 6.371e6
x = -10
y = 0
z = 0
VDFlim = 2e6
cidrequest = f.get_cellid([x*R_EARTH, y*R_EARTH, z*R_EARTH])
cid = plot_vdf.getNearestCellWithVspace(f, cidrequest)
j = 1000
bulkname = '{}.{}.vlsv'.format(bulk,str(j).zfill(7)) # Bulk file name
pt.plot.plot_vdf(filename=bulkLocation+bulkname,cellids=[cid],box=[-VDFlim,VDFlim,-VDFlim,VDFlim],xz=1,axisunit=6,colormap='nipy_spectral',cbulk=True, reducer ='average',slicethick=None, outputdir=outputLocation, outputfile='test_vdf_xz_{}_{}.png'.format(run,j))
This routine plots line profile cuts across a 3V velocity distribution function.
This routine plots polar-cap views of ionosphere quantities (from 3D simulations with the new ionosphere model).
These can stand on their own, like:
pt.plot.plot_ionosphere(filedir="./", step=1023, run="EGI", outputdir="./ionosphereplot", var="ig_fac",vmin=-1e-7,vmax=1e-7, lin=True, wmark="NE", viewdir=-1)
Or they can be used as insets in larger plots:
Example code
fig = plt.figure(figsize=(10.,10.*(3./4.)), dpi=150)
ax_bg = fig.add_axes([.1,.1,.9,.9])
f=pt.vlsvfile.VlsvReader(filename)
stepstr = '_'+filename[-12:-5]
pt.plot.plot_colormap3dslice(filename=filename, run="fixedmoments", outputdir="./", var="proton/vg_rho",colormap="hot_desaturated", boxre=[-45,15,-25,25], vmin=1e4, vmax=1e7, axes=ax_bg)
# FACS
ax_fac_north = inset_axes(ax_bg, width="30%", height="25%", loc='upper left', bbox_transform=ax_bg.transAxes)
pt.plot.plot_ionosphere(filename=filename,run="fixedmoments",axes=ax_fac_north,var="ig_fac", vmin=-5e-7, vmax=5e-7, viewdir=1, lin=True, usesci=False)
ax_fac_south = inset_axes(ax_bg, width="30%", height="25%", loc='lower left', bbox_transform=ax_bg.transAxes)
pt.plot.plot_ionosphere(filename=filename,run="fixedmoments",axes=ax_fac_south,var="ig_fac", vmin=-5e-7, vmax=5e-7, viewdir=-1, lin=True, usesci=False)
# sigmah
ax_sigma_north = inset_axes(ax_bg, width="30%", height="25%", loc='upper center', bbox_transform=ax_bg.transAxes)
pt.plot.plot_ionosphere(filename=filename,run="fixedmoments",axes=ax_sigma_north,var="ig_sigmah", vmin=0, vmax=10, viewdir=1, lin=True, colormap="viridis", scale=0.7, usesci=False)
ax_sigma_south = inset_axes(ax_bg, width="30%", height="25%", loc='lower center', bbox_transform=ax_bg.transAxes)
pt.plot.plot_ionosphere(filename=filename,run="fixedmoments",axes=ax_sigma_south,var="ig_sigmah", vmin=0, vmax=10, viewdir=-1, lin=True, colormap="viridis", scale=0.7, usesci=False)
# Potential
ax_potential_north = inset_axes(ax_bg, width="30%", height="25%", loc='upper right', bbox_transform=ax_bg.transAxes)
pt.plot.plot_ionosphere(filename=filename,run="fixedmoments",axes=ax_potential_north,var="ig_potential", viewdir=1, colormap="PuOr", vmin=-1.2e4, vmax=1.2e4, lin=True, usesci=False)
ax_potential_south = inset_axes(ax_bg, width="30%", height="25%", loc='lower right', bbox_transform=ax_bg.transAxes)
pt.plot.plot_ionosphere(filename=filename,run="fixedmoments",axes=ax_potential_south,var="ig_potential", viewdir=-
1, colormap="PuOr", vmin=-1.2e4, vmax=1.2e4, lin=True, usesci=False)
outputfile = "./fixedmoments_proton_vg_rho_plus_ionosphere"+stepstr+".png"
savefig_pad=0.01
bbox_inches='tight'
plt.savefig(outputfile,dpi=300, bbox_inches=bbox_inches, pad_inches=savefig_pad)