Commit 04203c03 authored by (no author)'s avatar (no author)
Browse files

add mass multiplier option

git-svn-id: http://svn.oamp.fr/repos/uns_projects/trunk@124 f264a43e-d52d-4b82-913b-c2bd5215a18a
parent ae8c662c
# -----------------------------------------------------------------------
#!/usr/bin/python
# -----------------------------------------------------------------------
# For more information about how to use UNSIO, visit:
......@@ -27,7 +26,7 @@ import sys, getopt
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# compute
def compute(file,out,comp,take,bits):
def compute(file,out,comp,take,bits,mmult):
compchk="gas,halo,disk,bulge,stars,bndry"
uns=CunsIn(file,"all","all")
......@@ -40,7 +39,7 @@ def compute(file,out,comp,take,bits):
# loop on all components stored in comp variable
for onecomp in (compchk.split(",")):
printAndSaveProp(uns,unso,onecomp,take) # print properties for the component
printAndSaveProp(uns,unso,onecomp,take,mmult) # print properties for the component
unso.save()
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
......@@ -64,7 +63,7 @@ def keepEveryTake(array,dim,take):
# print properties for the component comp given as argument
# keep one particle over tale
# and save them in gadget2 file
def printAndSaveProp(uns,unso,comp,take):
def printAndSaveProp(uns,unso,comp,take,mmult):
info="""\
----------------------------------------------
Component : [%s]
......@@ -76,7 +75,8 @@ def printAndSaveProp(uns,unso,comp,take):
if ok:
print "mass =",mass.size,mass
mass=keepEveryTake(mass,1,take)
mass=mass*take # multiply mass by take
if mmult==1:
mass=mass*take # multiply mass by take
print "mass =",mass.size,mass
unso.setArrayF(comp,"mass",mass) # save mass
......@@ -155,9 +155,10 @@ def main(argv):
comp='all'
times='all'
bits=''
mmult=1
try:
opts,args=getopt.getopt(argv,"hi:o:k:c:b:",["in=","out=","take=","comp=","bits="])
opts,args=getopt.getopt(argv,"hi:o:k:c:b:m:",["in=","out=","take=","comp=","bits=","mmult="])
except getopt.GetoptError:
print "\nUnknown parameters, please check ....\n\n"
......@@ -177,10 +178,12 @@ def main(argv):
take = int(arg)
elif opt in ("-b", "--bits"):
bits = arg
elif opt in ("-m", "--mmult"):
mmult = int(arg)
if (infile != '' and out != '' and take !=0):
compute(infile,out,comp,take,bits)
compute(infile,out,comp,take,bits,mmult)
else:
print "\nYou must provide input, output files and number of particles to take.....\n\n"
printHelp(prog)
......@@ -195,7 +198,7 @@ def printHelp(prog):
- multiply masses by "take" and save into a gadget2 file
--------------------------------------------------
Syntaxe : %s -i <inputfile> -o <outfile> -c <components> -k <taKe> -b <bits>
Syntaxe : %s -i <inputfile> -o <outfile> -c <components> -k <taKe> -b <bits> -m <mmult>
Example : %s -i gtr118_1912 -o myfile.g2 -c all -k 10
Notes :
......@@ -212,7 +215,8 @@ def printHelp(prog):
bits : you specify which array you want to process
example:
bits="mxvIU" (pos,mass,vel,id,internal energy)
bits="" (every array, default)
bits="" (every array, default)
mmult : multiply mass by take (default 1 - yes, else 0 - no)
"""
print help % (prog,prog)
......
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