Commit c8f46758 authored by LAMBERT Jean-charles's avatar LAMBERT Jean-charles
Browse files

new uns_2dplot.py program

parent 6caad3f1
#!/usr/bin/env python
from __future__ import print_function
import numpy as np
import os,time
import sys
import argparse,textwrap
sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
from simulations.c2dplot import *
from simulations.csnapshot import *
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def commandLine():
# help
parser = argparse.ArgumentParser(description="Display 2D image from UNS data",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('snapshot', help="uns input snapshot",default=None)
parser.add_argument('component', help="selected component",default=None)
parser.add_argument('--out', help="if blank display on screen, else on given file ",default="",type=str)
parser.add_argument('--range', help="plot range (X or -A:B) ",default=35,type=str)
parser.add_argument('--mergers', help="file to center, or @sim to get file automatically ",default=None,type=str)
parser.add_argument('--sigma', help="gaussian sigma ",default=6.,type=float)
parser.add_argument('--psort', help="sort particles according to properties",default=0,type=int)
parser.add_argument('--prop', help="properties to plot (age,rho)",default="",type=str)
parser.add_argument('--pfname', help="print filename (1:True, 0:False)",default=1,type=int)
parser.add_argument('--cb', help="display color bar (1:True, 0:False)",default=0,type=int)
parser.add_argument('--cmap', help="color map (see mathplotlib colormap)",default="jet")
parser.add_argument('--verbose',help='verbose mode',dest="verbose", action="store_true", default=False)
# parse
args = parser.parse_args()
# start main funciton
process(args)
# -----------------------------------------------------
# process, is the core function
def process(args):
try:
uns=CSnapshot(args.snapshot,args.component,verbose_debug=args.verbose)
ok=uns.nextFrame("")
if ok:
c=C2dplot(verbose_debug=args.verbose)
c.fullProcess(uns=uns,out=args.out,component=args.component,xrange=int(args.range),sigma=args.sigma, mergers=args.mergers,cmap=args.cmap)
else:
print ("[%s] is not a UNS snapshot ..."%(simname))
except Exception as x :
print (x.message,file=sys.stderr)
except KeyboardInterrupt:
sys.exit()
# -----------------------------------------------------
# main program
if __name__ == '__main__':
commandLine()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment