Commit 68f7f3ef authored by jclamber's avatar jclamber
Browse files

more uns python based programs

git-svn-id: http://svn.oamp.fr/repos/uns_projects/trunk@108 f264a43e-d52d-4b82-913b-c2bd5215a18a
parent ff16e1b9
......@@ -18,21 +18,21 @@ def commandLine():
parser = argparse.ArgumentParser(description="Save stars particles born before/after a specific time")
parser.add_argument('input', help='UNS input file with stars particle')
parser.add_argument('output', help="NEMO output file ")
parser.add_argument('time', help="time of reference to keep stars particles")
#parser.add_argument('time', help="time of reference to keep stars particles")
args = parser.parse_args()
compute(args.input,args.output,args.time)
compute(args.input,args.output)#,args.time)
# -----------------------------------------------------
# compute, is the core function
def compute(simname,out,times):
def compute(simname,out): #,times):
components="stars"
verbose=False
timef=float(times)
#timef=float(times)
# Create a UNSIO object
uns = CunsIn(simname,components,"all",verbose)
......@@ -41,7 +41,7 @@ def compute(simname,out,times):
# get file name
# sim_name=uns.getFileName()
print "simname=",simname, " out=",out," times=",times
print "simname=",simname, " out=",out #," times=",times
# load frame
ok=uns.nextFrame("")
......
#!/usr/bin/python
from __future__ import print_function
import sys
from py_unsio import * # import py_unsio package (UNSIO)
import argparse
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def commandLine():
time="0.0"
verbose=False
# help
parser = argparse.ArgumentParser(description="Return mass of a component from uns simulation",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
# options
parser.add_argument('simname', help='Simulation name')
parser.add_argument('component', help='Simulation component')
parser.add_argument('--time',help='simulation time', default=time)
parser.add_argument('--verbose',help='verbosity', default=verbose)
# parse
args = parser.parse_args()
# start main funciton
process(args.simname,args.component,args.time,args.verbose)
# -----------------------------------------------------
# process, is the core function
def process(simname,component,time,verbose):
#print (simname, " " , time,file=sys.stderr)
# Create a UNSIO object
uns = CunsIn(simname,component,time,verbose)
find=False
bits="m"
while (uns.nextFrame(bits)): # loop while there is something to read
ok,timex = uns.getValueF("time")
ok,nbody = uns.getValueI("nsel")
ok,mass = uns.getArrayF(component,"mass")
if ok:
find=True
print ( simname, component, timex, nbody,mass[0], nbody*mass[0])
break;
if not find:
print ("none")
# -----------------------------------------------------
# main program
commandLine() # parse command line
......@@ -7,7 +7,7 @@ import argparse
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def commandLine():
dbname=""
dbname=None
# help
parser = argparse.ArgumentParser(description="UNS test python",
......@@ -26,8 +26,17 @@ def commandLine():
# -----------------------------------------------------
# process, is the core function
def process(simname,dbname):
test = UnsSimu(simname,dbname)
sql3 = UnsSimu(dbname)
sql3.printInfo(simname)
r = sql3.getInfo(simname)
snap_list = sql3.getSnapshotList(simname)
if (snap_list):
for i in snap_list:
print i
# -----------------------------------------------------
# main program
......
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