Jimmy's plot software
From OpenGGCM
[edit]
Making 2d plots and movies from OpenGGCM px_***, py_***, pz_*** and iof files
Here is how it works:
- The top level is always a csh script, although this could also be perl.
- This csh script figures out where the files are, etc, and runs utilities to convert formats, move files around, etc.
- apl.2d_xxx is the perl utility that takes a bunch of parameters and generates the plot. There are several versions of this around, but nowadays the latest one should be in OpenGGCM_utilities under SVN control.
#!/bin/csh
# begin plotting at step 4080 (as in xxxxx.py_yy.004800, or 4800 seconds
# after the start of the run)
set START=4800
# ditto for the end
set MAX=10800
# in steps of DT
set DT=240
# remember where we are
set HH=`pwd`
# Some parameters can be passed as environment variables (Perl can pick them up).
# There is no harm in not setting them, defaults wioll be used
setenv NOGLITTER 1 # minimal labelling
setenv FC_RESOLUTION 140 # resolution of the color contours
setenv KEEPFRAMES all # keep all individual frames after making a movie
setenv MPEG_BITRATE 10 # movie mbitrate
setenv MOVIEREPEATFRAMES 2 # repeat frames in movie to slow it down
#.... generate a 'side-by-side' movie
# loop over different runs, here we want to compare 2 runs
foreach RUN ( jxr0400 jxr0402 )
# what files to use
foreach PP ( py_0 )
# clean up beforehand, del is aliased to /bin/rm
del ${RUN}*${PP}*.ps
# where we find the input data files from the simulation
set IN=$HOME/4/$RUN
# smf is a utility to extract various simple things from "$RUN.smf" (generated at precompile time).
# it expects $RUN.smf in ./
smf $RUN 0 grid >! $IN/$RUN.grid
# LTMP is just a directory to hold temporary files. It can be ./ Sometime useful for movies
# that generate a lot of frames.
set LTMP=/mnt/d02/jr/ltmp6
/bin/rm -f -r $LTMP; mkdir $LTMP
# this is our executable statement, apl.2d_xxx could be in different places depending on which machine,...
set MM="nice -20 /usr/local/public/bin/apl.2d_n6 "
# now the parameters:
# prefix for output files run name directory of input files
set MM="$MM ./$RUN.2d-$PP $RUN $IN "
# directory for output files EXTRAS before-mentioned directory for temps
set MM="$MM ./ none $LTMP "
# start/send/step as defined above plotting regionn (BOX, see below)
set MM="$MM ${START}:${MAX}:$DT 0:15:-10:10"
# unused input file type (px_nnn, ..., iof, ioc)
set MM="$MM 2 $PP "
# how to arrange things:
# a) NNN:step NNN time steps of one quantity are put on a page
# b) NNN:vars NNN variables are put on one page, new page for next step
# c) NNN:movie creates a movie for one var for all steps, NNN is the size (set to about 100)
set MM="$MM 1:step"
# what now follows is one parameter for each variable, only one for a) and c), but possibly
# multiple for b), so either:
$MM 'rr($cmap="log3";$fmi=0.2;$fma=150;$log=1;$lab="N[1/cc]")'
# or for b):
$MM 'ent($cmap="log3";$fmi=222;$fma=1.0e10;$log=1;$lab="Entropy")' \
':Mvms($cmap="log3";$fmi=0.02;$fma=25;$log=1;$lab="Mach_vms";$con3="Mvms,1,1,1";)' \
':tkev($cmap="log3";$fmi=0.02;$fma=250;$log=1;$lab="T[keV]/Bz";$con3="bz,3,12,3";)' \
':ctot($cmap="log3";$fmi=0.0005;$fma=0.11;$log=1;$lab="J[?]")'
# Note the use of the shell \ continuation character and the careful quoting with single/double quotes. The csh
# does not expand in single quotes! Also not the 'continuation' colon.
# in the parentheses are the parameters that contol the plotting:
# * cmap: color map (log1, log2, log3, lin1, sym1)
# * fmi/fma: color scale from/to, use 1.0e31 for auto scale
# * log (0/1) lin/log scale
# * lab: label
# The stuff in the parentheses is executed in the Perl script withi 'eval', so this makes it easy to extend, and to
# modify other variables in the script without having to edit the script itself!
# here are a few more examples
# $MM 'vx($cmap="sym1";$fmi=-650;$fma=650;$log=0;$lab="Vxgse[km/s]")'
# $MM 'vy($cmap="sym1";$fmi=-150;$fma=150;$log=0;$lab="Vygse[km/s]")'
# $MM 'vz($cmap="sym1";$fmi=-150;$fma=150;$log=0;$lab="Vzgse[km/s]")'
# $MM 'bz($cmap="sym1";$fmi=-15;$fma=15;$log=0;$lab="Bzgse[nT]")'
# $MM 'by($cmap="sym1";$fmi=-15;$fma=15;$log=0;$lab="Bygse[nT]")'
# $MM 'bx($cmap="sym1";$fmi=-55;$fma=55;$log=0;$lab="Bxgse[nT]")'
# $MM 'ey($cmap="sym1";$fmi=-5;$fma=5;$log=0;$lab="Eygse[mV/m]")'
# $MM 'pp($cmap="log3";$fmi=3;$fma=3000;$log=1;$fl="0.3,0.3,200,0.05,5,0.05";$lab="P[pPa]")'
# $MM 'pp($cmap="log3";$fmi=3;$fma=3000;$log=1;$lab="P[pPa]")'
#
# The last two also plot field lines, with parameters: (i) density of lines, the smaller the denser
# (ii) size of center hole to cut out
# (iii) length limit for lines
# (iv) trace step length
# (v) step decimation for plotting
# (vi) line witdh (in points)
#
# There are more options like that: contour lines, flow lines, etc. Look in the script for that.
end
end
# Now some post-processing:
/bin/mv jxr0402.2d-py_0.2d.pp.1:3:3000.py_0.10.ps fig01_notilt.eps
/bin/mv jxr0400.2d-py_0.2d.pp.1:3:3000.py_0.10.ps fig01_tilt.eps
# amak.bbox uses ghostscript to get the bounding box right in ps/eps files, important for import to
# Latex, since Latex depends on bbox to place figures right.
amak.bbox fig01_notilt.eps
amak.bbox fig01_tilt.eps
# psnto1d places several ps figures on one page, including scaling and text annotation, good for final
# poublication plots.
psnto1d -NX 1 -NY 2 -scale 1.0 -spready 1.03 \
-txt '80:760:Helvetica:26:(a)' \
-txt '80:370:Helvetica:26:(b)' \
-- fig01_notilt.eps fig01_tilt.eps >! fig01.eps
del -f fig01_notilt.eps fig01_tilt.eps
amak.bbox fig01.eps
del fig01.pdf
# convert to pdf
eps2pdf fig01.eps
# show it
acrioread fig01.pdf
