diff --git a/py/mains/decrease_nbody.py b/py/mains/decrease_nbody.py index c51cb1576ff8e7e8847218100caedf61724c16eb..e2cee90b1818d73feebefbd4d66c282dee9bc241 100755 --- a/py/mains/decrease_nbody.py +++ b/py/mains/decrease_nbody.py @@ -17,6 +17,7 @@ # unsio module loading # ==> do not forget to update PYTHONPATH environment variable with # unsio location path +from __future__ import print_function from unsio import * import numpy as np @@ -33,7 +34,7 @@ def compute(file,out,comp,take,bits,mmult): if uns.nextFrame(bits): unso=CunsOut(out,"gadget2") ok,tsnap=uns.getValueF("time") # return snasphot time - print "Snapshot time : ","%.03f"%tsnap + print ("Snapshot time : ","%.03f"%tsnap) unso.setValueF("time",tsnap) # save snapshot time # loop on all components stored in comp variable @@ -68,85 +69,85 @@ def printAndSaveProp(uns,unso,comp,take,mmult): Component : [%s] ---------------------------------------------- """ - print info % (comp) + print (info % (comp)) # return a 1D numpy data array with mass ok,mass=uns.getArrayF(comp,"mass") if ok: - print "mass =",mass.size,mass + print ("mass =",mass.size,mass) mass=keepEveryTake(mass,1,take) - if mmult==1: + if mmult==1: mass=mass*take # multiply mass by take - print "mass =",mass.size,mass + print ("mass =",mass.size,mass) unso.setArrayF(comp,"mass",mass) # save mass # return a 1D numpy data array with pos ok,pos=uns.getArrayF(comp,"pos") if ok: - print "pos =",pos + print ("pos =",pos) pos=keepEveryTake(pos,3,take) unso.setArrayF(comp,"pos",pos) # save pos # return a 1D numpy data array with vel ok,vel=uns.getArrayF(comp,"vel") if ok: - print "vel =",vel + print ("vel =",vel) vel=keepEveryTake(vel,3,take) unso.setArrayF(comp,"vel",vel) # save vel # return a 1D numpy data array with acc ok,acc=uns.getArrayF(comp,"acc") if ok: - print "acc =",acc + print ("acc =",acc) acc=keepEveryTake(acc,3,take) unso.setArrayF(comp,"acc",acc) # save vel # return a 1D numpy data array with rho ok,rho=uns.getArrayF(comp,"rho") if ok: - print "rho =",rho + print ("rho =",rho) rho=keepEveryTake(rho,1,take) unso.setArrayF(comp,"rho",rho) # save rho # return a 1D numpy data array with temperature ok,temp=uns.getArrayF(comp,"temp") if ok: - print "temp =",temp + print ("temp =",temp) temp=keepEveryTake(temp,1,take) unso.setArrayF(comp,"temp",temp) # save temperature # return a 1D numpy data array with internal energy (U) ok,u=uns.getArrayF(comp,"u") if ok: - print "u =",u.size,u.dtype,u + print ("u =",u.size,u.dtype,u) u=keepEveryTake(u,1,take) - print "u =",u.size,u.dtype,u + print ("u =",u.size,u.dtype,u) unso.setArrayF(comp,"u",u) # save internal energy # return a 1D numpy data array with hsml ok,hsml=uns.getArrayF(comp,"hsml") if ok: - print "hsml =",hsml + print ("hsml =",hsml) hsml=keepEveryTake(hsml,1,take) unso.setArrayF(comp,"hsml",hsml) # save hsml # return a 1D numpy data array with particles age ok,age=uns.getArrayF(comp,"age") if ok: - print "age =",age + print ("age =",age) age=keepEveryTake(age,1,take) unso.setArrayF(comp,"age",age) # save age # return a 1D numpy data array with mettalicity ok,metal=uns.getArrayF(comp,"metal") if ok: - print "metal =",metal + print ("metal =",metal) metal=keepEveryTake(metal,1,take) unso.setArrayF(comp,"metal",metal) # save mettalicity # return a 1D numpy data array with potential ok,pot=uns.getArrayF(comp,"pot") if ok: - print "pot =",pot + print ("pot =",pot) pot=keepEveryTake(pot,1,take) unso.setArrayF(comp,"pot",pot) # save mettalicity @@ -155,7 +156,7 @@ def printAndSaveProp(uns,unso,comp,take,mmult): # return a 1D numy data array with id ok,indexes=uns.getArrayI(comp,"id") if ok: - print "indexes =", indexes + print ("indexes =", indexes) indexes=keepEveryTake(indexes,1,take) unso.setArrayI(comp,"id",indexes) # save id @@ -175,7 +176,7 @@ def main(argv): 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" + print ("\nUnknown parameters, please check ....\n\n") printHelp(prog) sys.exit() for opt, arg in opts: @@ -192,14 +193,14 @@ def main(argv): take = int(arg) elif opt in ("-b", "--bits"): bits = arg - elif opt in ("-m", "--mmult"): + elif opt in ("-m", "--mmult"): mmult = int(arg) if (infile != '' and out != '' and take !=0): compute(infile,out,comp,take,bits,mmult) else: - print "\nYou must provide input, output files and number of particles to take.....\n\n" + print ("\nYou must provide input, output files and number of particles to take.....\n\n") printHelp(prog) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -233,7 +234,7 @@ def printHelp(prog): mmult : multiply mass by take (default 1 - yes, else 0 - no) """ - print help % (prog,prog) + print (help % (prog,prog)) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # main