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

new inert program

parent d8c67942
#!/usr/bin/env python
from __future__ import print_function
import sys
#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 *
import argparse
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def commandLine():
dbname=None
# help
parser = argparse.ArgumentParser(description="Build simulation movie after smart analysis",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
# options
parser.add_argument('simname', help='Simulation name')
parser.add_argument('--dbname',help='UNS database file name', default=dbname)
parser.add_argument('--verbose',help='verbose mode on', dest="verbose", action="store_true", default=False)
parser.add_argument('--overwrite',help='overwrite file if exist', dest="overwrite", action="store_true", default=False)
parser.add_argument('--ncores', help='#cores used, 0 means all',default=4,type=int)
#parser.add_argument('--no-verbose',help='verbose mode off', dest="verbose", action="store_false", default=True)
# parse
args = parser.parse_args()
# start main funciton
process(args)
# -----------------------------------------------------
# process, is the core function
def process(args):
movie = C2dplot(verbose_debug=args.verbose)
try:
movie.buildMovie(args.simname,overwrite=args.overwrite,ncores=args.ncores)
pass
except Exception as x :
print(x.message)
sys.exit()
# -----------------------------------------------------
# main program
if __name__ == '__main__':
commandLine()
#!/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/']+sys.path
import simulations.cinert as cinert
import simulations.csnapshot as csnap
#from IPython import embed
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# 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('outfile', help="output file name",default=None)
parser.add_argument('--ncut', help="#cuts ",default=10,type=int)
parser.add_argument('--fmin', help="fract min ",default=0.1,type=float)
parser.add_argument('--fmax', help="fract max ",default=0.9,type=float)
parser.add_argument('--out', help="if blank display on screen, else on given file ",default="",type=str)
parser.add_argument('--cod', help="use COD file to re-center, or @sim (ex; @mdf648) to get file automatically from simulation ",default=None)
parser.add_argument('--nocom', help='dont use com if no COD file requested',dest="nocom", action="store_true", default=False)
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):
# select matplotlib backend
try:
uns=csnap.CSnapshot(args.snapshot,args.component,verbose_debug=args.verbose)
inert=cinert.CInert(verbose_debug=args.verbose)
f=inert.buildRes(args.outfile)
while(uns.nextFrame("")):
inert.fullProcess(uns=uns,ncut=args.ncut,component=args.component,center_file=args.cod,
fract_min=args.fmin,fract_max=args.fmax,com=not args.nocom)
# 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