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

bunch of updates

parent 56222817
File mode changed from 100644 to 100755
......@@ -8,10 +8,11 @@ from simulations.ccod import *
from simulations.ccom import *
from simulations.crectify import *
from simulations.cmovie import *
from simulations.c2dplot import *
run_cod=0
run_cod=1
run_com=0
run_rectify=0
run_rectify=1
run_movie=0
run_2dplot=1
##
......@@ -19,9 +20,9 @@ run_2dplot=1
##
if run_cod:
data.lock_id=0 # lock file ID for COD analysis
data.cod_dir="ANALYSIS/"+data.simname+"/cod"
data.cod_dir="ANALYSIS/"+data.simname+"/xCODvCOM"
data.cod_select="halo: disk: stars: gas: bndry: bulge: halo_1: halo_2: halo,disk: halo,stars: disk,stars: halo,disk,stars"
print("DATA SIM INFO dir [%s]"%(data.sim_info['dir']))
if data.first:
cod=CCod("",analysis=data,verbose_debug=True) # initialyze COD analysis
......@@ -43,7 +44,7 @@ if run_com:
##
if run_rectify:
data.lock_id=2
data.rectify_dir="ANALYSIS/"+data.simname+"/rectify"
data.rectify_dir="ANALYSIS/"+data.simname+"/rectify2"
data.rectify_select="stars#halo,disk,stars: stars#stars: gas#stars@10.0 " # syntax: "component#cod@rcut"
if data.first:
......
......@@ -50,12 +50,16 @@ def process(args):
print("Unknown UNS date from file <%s>, aborting..."%(args.input),file=sys.stderr)
sys.exit()
nsave=0
if uns.nextFrame(args.bits):
unso=CunsOut(args.output,"gadget2")
cpt=0
while uns.nextFrame(args.bits):
outfile=args.output
if cpt==0 and args.tfirst or cpt>0:
outfile="%s_%05d"%(outfile,cpt)
unso=CunsOut(outfile,"gadget2")
ok,tsnap=uns.getValueF("time") # return snasphot time
#print "Snapshot time : ","%.03f"%tsnap
nsave=0
# loop on all components stored in select variable
for onecomp in (args.select.split(",")):
nsave += selectByIds(args,onecomp,id_list,uns,unso)
......@@ -63,6 +67,7 @@ def process(args):
if nsave > 0:
unso.setValueF("time",tsnap) # save snapshot time
unso.save()
cpt += 1
else:
print("Nothing to save for file <%s>."%(args.input),file=sys.stderr)
......@@ -211,12 +216,13 @@ def commandLine():
parser.add_argument('select', help='selected components separated by coma')
parser.add_argument('id_file', help='input file with particles\'s id (aka glnemo2 index file)')
parser.add_argument('--bits', help='specify which array you want to proces\nexample:\nbits=\"mxvIU\" (pos,mass,vel,id,internal energy)\nbits=\"\" (every array, default)',default="")
parser.add_argument('--tfirst ',help='add trailing number to the first snapshot', dest="tfirst", action="store_true", default=False)
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)
# parse
args = parser.parse_args()
print ("tfirst=",args.tfirst)
# start main funciton
process(args)
......
......@@ -35,7 +35,8 @@ class CCod:
__ok_halo_N=False
__halo_comp=None
__halo_N=None
__COD_DIR_NAME="codFAST"
#__COD_DIR_NAME="codFAST"
__COD_DIR_NAME="xCODvCOM"
#
# ----
#
......@@ -301,7 +302,14 @@ class CCod:
else : # fastcod
ctree=CTree(pos,vel,mass) # instantiate a ctree object
cxv=ctree.fastCod3(self.__ctree_threshold)
print ("TCXV : ", time,cxv,file=sys.stderr)
# compute COM
comxv=uns_snap.center(pos,vel,mass)
print ("COD TCXV : ", time,cxv,file=sys.stderr)
print ("COM TCXV : ", time,comxv,file=sys.stderr)
# copy vCOM to cCOD
cxv[3:]=comxv[3:]
print ("COD TxCODvCOM : ", time,cxv,file=sys.stderr)
else: # no data
pass
......@@ -522,11 +530,14 @@ class CCod:
#
# ----
#
def getCodFromComp(self, component, time,n=-1):
def getCodFromComp(self, component, time,cod_file_base=None,n=-1):
"""
check if current time exist in cod file build with componen
"""
cod_file=self.__cod_file_base+"/"+self.simname+"."+component+".cod"
if cod_file_base is None:
cod_file=self.__cod_file_base+"/"+self.simname+"."+component+".cod"
else:
cod_file=cod_file_base+"/"+self.simname+"."+component+".cod"
if self.__vdebug:
print("getCodFromComp file [%s]"%(cod_file),file=sys.stderr)
......@@ -791,6 +802,14 @@ class CCod:
else : # fastcod
ctree=CTree(pos,vel,mass) # instantiate a ctree object
cxv=ctree.fastCod3(self.__ctree_threshold)
# compute COM
comxv=uns_snap.center(pos,vel,mass)
if self.__vdebug:
print ("COD TCXV : ", time,cxv,file=sys.stderr)
print ("COM TCXV : ", time,comxv,file=sys.stderr)
# copy vCOM to cCOD
cxv[3:]=comxv[3:]
if self.__vdebug:
print ("TCXV : ", time,cxv,file=sys.stderr)
......
......@@ -264,54 +264,8 @@ class CMovie:
sys.exit()
data.lock[data.lock_id].release() # release process
#
#
#
def buildMovie(self,simname,overwrite):
"""
buildMovie, build movie created using process_analysis.py program
*IN*
simname : simulation name, must belong to unsio database
"""
sql3 = UnsSimu()
r = sql3.getInfo(simname)
if (r) : # simulation exist
dir_movie=r['dir']+'/ANALYSIS/movie' # movie directory
for d in glob.glob(dir_movie+"/w/*"): # loop on work "w" directory
base=os.path.basename(d) # get basename like r_1_p_99_pp_none
if (base[0:2]=='r_') :
q,radius,q,percen,q,property=base.split("_")
print("Radius [%f] Percen [%f] Property [%s]\n"%(float(radius),float(percen),property))
dir2_movie=dir_movie+"/center"
if float(percen)>0:
dir2_movie=dir_movie+"/whole"
if property!="none":
dir2_movie=dir_movie+"/"+property
if not os.path.isdir(dir2_movie) :
try:
os.makedirs(dir2_movie)
except OSError:
print("Unable to create directory [%s]\n"%(dir2_movie))
print ("Dir [%s]\n"%(d))
for c in glob.glob(d+"/*"): # loop on components
comp=os.path.basename(c)
movie_name=simname+"_"+comp+"_"+property+"_post.avi"
print ("comp <%s> filename [%s/%s]\n"%(comp,dir2_movie,movie_name))
if not os.path.isfile(myframe): # no frame created
subprocess.call(["convert","-size","850x680","xc:black",myframe]) # create a black frame
self.__saveNewTime(time,t_file) # save new time in ".time_completed" file
else:
if self.__vdebug:
print("MOVIE: skip time[%.3f] from <%s>\n"%(time,t_file))
#
# __checkTimeExist
# __saveNewTime
#
def __saveNewTime(self,time,t_file):
"""
......
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