Commit 11ac9ebe authored by LAMBERT Jean-charles's avatar LAMBERT Jean-charles
Browse files

rsync new pipeline engine

parent 8c7a5cba
......@@ -6,7 +6,7 @@ import Queue
import multiprocessing
import numpy as np
import argparse
sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
#sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
from simulations.cuns_analysis import *
......
......@@ -5,10 +5,16 @@ This script is called by external python script through execfile() call
from simulations.ccod import *
from simulations.ccom import *
from simulations.crectify import *
from simulations.cmovie import *
run_cod=0
run_com=0
run_rectify=0
run_movie=1
##
## COD
##
if 1:
if run_cod:
data.lock_id=0 # lock file ID for COD analysis
data.cod_dir="ANALYSIS/"+data.simname+"/cod"
data.cod_select="halo: disk: stars: gas: bndry: bulge: halo_1: halo_2: halo,disk: halo,stars: disk,stars: halo,disk,stars"
......@@ -20,7 +26,7 @@ if 1:
##
## COM
##
if 1:
if run_com:
data.lock_id=1
data.com_dir="ANALYSIS/"+data.simname+"/com"
data.com_select="halo: disk: stars: gas: disk,stars: halo,disk,stars"
......@@ -32,7 +38,7 @@ if 1:
##
## RECTIFY
##
if 1:
if run_rectify:
data.lock_id=2
data.rectify_dir="ANALYSIS/"+data.simname+"/rectify"
data.rectify_select="stars#halo,disk,stars: stars#stars: gas#stars@10.0 " # syntax: "component#cod@rcut"
......@@ -42,6 +48,21 @@ if 1:
rectify.smartAnalysis()
##
## MOVIE
##
if run_movie:
data.lock_id=3
data.movie_dir="ANALYSIS/"+data.simname+"/movie"
#data.movie_select syntax: component # propertie # percen # newradius # extdir
data.movie_select="gas#none#99#1#whole : stars#none#99#1#whole : disk#none#99#1#whole:"+ \
"gas#none#-30#1#center : stars#none#-30#1#center : disk#none#-30#1#center:"+ \
"stars#age#99#1#age "
if data.first:
movie=CMovie(analysis=data,verbose_debug=True) # initialyze MOVIE analysis
movie.smartAnalysis()
data.first=False #MANDATORY
......
......@@ -72,6 +72,7 @@ class C2dplot:
# try to load positions
ok,pos=uns_snap.getData(select,"pos")
print("pos=",pos)
if ok:
# load time
ok,time=uns_snap.getData("time")
......@@ -120,6 +121,7 @@ class C2dplot:
if mass.size<1:
mass=np.ones(pos.size/3)
uns_snap.center(pos,None,mass,center=True)
print("center pos=",pos)
# print file name ?
if pfname:
filename=uns_snap.getFileName()
......@@ -137,6 +139,7 @@ class C2dplot:
print(pos.size,outdev,no,weight)
self.__c.compute_image(outdev,no,pos,nrange,title,comp_prop,filename,time.item(),xy,xz,zy,\
True,weight,psort,hsml,itf,cb,legend,cmap)
else:
print("There is no position in snapshot...")
......
......@@ -61,7 +61,7 @@ class CRectify:
print("RECTIFY DIR = ", self.__rectify_dir, data.sim_info['name'])
self.simname=data.sim_info['name']
self.__com_file_base=self.__rectify_dir
#self.__com_file_base=self.__rectify_dir
# lock process
data.lock[data.lock_id].acquire()
......
......@@ -15,6 +15,7 @@ class CSnapshot:
__uns=None
__verbose=False
__float32=True
__loaded=False
simname=None
select=None
......@@ -61,7 +62,10 @@ class CSnapshot:
if not self.__uns.isValid():
raise RuntimeError("UNS not valid")
else:
return self.__uns.nextFrame(bits)
ok=self.__uns.nextFrame(bits)
if ok:
self.__loaded=True
return ok
#
# close
#
......@@ -127,6 +131,8 @@ class CSnapshot:
if not self.__uns.isValid():
raise RuntimeError("UNS not valid")
if not self.__loaded:
raise RuntimeError("Snapshot not loaded")
status=1
ret_data=np.zeros(0,dtype=data_type) # initalyse an empty array
......@@ -172,7 +178,59 @@ class CSnapshot:
else:
ok,data=self.__uns.getArrayI(comp_value,tag)
return ok,2,data
#
# getMaxRadius
#
def getMaxRadius(self,select,percen=100.,x=True,y=True,z=True,com=True,bins=10000):
"""
Compute radius where percen% of the particles belong
Return :
status,radius (status=0 if something goes wrong)
Arguments:
select : selected component
percen : keep percen% particles
x : 1st dimension ?
y : 2nd dimension ?
z : 3rd dimension ?
com : center on mass ?
bins : number of bins to build histogram
"""
if not self.__uns.isValid():
raise RuntimeError("UNS not valid")
radius=-1
ok,pos=self.getData(select,"pos") # get pos
if pos.size>0:
if com: # resquest com
ok,mass=self.getData(select,"mass") # get mass
if not ok: # no mass
mass=np.ones(pos.size/3) # fake mass
cxv=self.center(pos,None,mass,True) # centering
# reshape pos 1d array to 2d array [nbody,3]
pos2d=np.reshape(pos,(-1,3))
xx=0.
if x:
xx=pos2d[:,0]
yy=0.
if y:
yy=pos2d[:,1]
zz=0.
if z:
zz=pos2d[:,2]
#compute radius
r2=np.sqrt(xx**2+yy**2+zz**2)
# compute histogram
hist,bin_edges=np.histogram(r2,bins=bins)
status=1
radius=bin_edges[(hist.cumsum()*100./r2.size)<=percen][-1]
else:
status=0
return status,radius
#
# center
#
......
......@@ -64,6 +64,7 @@ class CUnsAnalysis:
self.__data.list_components=self.__new_select
self.__data.simname=self.simname
self.__data.slist=self.__slist
self.__data.sim_info=self.__r # unsio simulation info
self.__data.lock=[] # locking mechanism
for i in range(self.__nb_lock):
......
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