Commit b2542a24 by LAMBERT Jean-charles

### still fighting py2 vs py3

parent 7cb1bf79
 ... @@ -15,7 +15,7 @@ for i in np.arange(30): ... @@ -15,7 +15,7 @@ for i in np.arange(30): q.put(i) q.put(i) def f(x): def f(x): global zz global zz try: try: a=q.get() # get one more element a=q.get() # get one more element zz = zz+1 zz = zz+1 ... @@ -26,8 +26,7 @@ def f(x): ... @@ -26,8 +26,7 @@ def f(x): if __name__ == '__main__': if __name__ == '__main__': p = Pool(5) p = Pool(5) a=p.map(f,np.arange(30) ) a=list(p.map(f,np.arange(30) )) print ">>>",a print ">>>",a print "zz=",zz print "zz=",zz
 ... @@ -57,7 +57,7 @@ def process(args): ... @@ -57,7 +57,7 @@ def process(args): sys.exit() sys.exit() for i in range(data.size/3): for i in range(data.size/3): print (' '.join(map(str,data[:,i]))) print (' '.join(list(map(str,data[:,i])))) # ----------------------------------------------------- # ----------------------------------------------------- ... ...
 ... @@ -193,7 +193,7 @@ class C2dplot: ... @@ -193,7 +193,7 @@ class C2dplot: try: try: f=open(t_file,"r") f=open(t_file,"r") while True: while True: atime=map(np.float,(f.readline().split())) atime=list(map(np.float,(f.readline().split()))) if (len(atime)>0): if (len(atime)>0): if (atime[0]-0.001)
 ... @@ -20,7 +20,6 @@ import signal ... @@ -20,7 +20,6 @@ import signal import matplotlib.pyplot as plt import matplotlib.pyplot as plt # # # ---- # ---- # # ... @@ -35,7 +34,7 @@ class CCod: ... @@ -35,7 +34,7 @@ class CCod: __cod_file_base=None __cod_file_base=None __ctree_threshold=10000 __ctree_threshold=10000 __fastcod=True __fastcod=True __halo_part=np.zeros(10) __halo_part=np.zeros(10,dtype=int) __is_multiple_halo=False __is_multiple_halo=False __ok_halo_N=False __ok_halo_N=False __halo_comp=None __halo_comp=None ... @@ -357,6 +356,12 @@ class CCod: ... @@ -357,6 +356,12 @@ class CCod: # # # ---- # ---- # # def getExtractHalo(self,id,mass,pos,vel, halo_id): self.__halo_N=halo_id return self.__extractHalo(id,mass,pos,vel) # # ---- # def __extractHalo(self,id,mass,pos,vel): def __extractHalo(self,id,mass,pos,vel): id_sort=np.argsort(id) # sort according to ID order id_sort=np.argsort(id) # sort according to ID order offset=0 offset=0 ... @@ -368,7 +373,6 @@ class CCod: ... @@ -368,7 +373,6 @@ class CCod: mylast=self.__halo_part[1] mylast=self.__halo_part[1] offset = self.__halo_part[0]+mylast offset = self.__halo_part[0]+mylast myidsort = id_sort[self.__halo_part[0]:offset] myidsort = id_sort[self.__halo_part[0]:offset] #print("myidsort : ",myidsort,mylast,self.__halo_part) pos = np.reshape(pos,(-1,3)) # reshape pos to nbody,3 pos = np.reshape(pos,(-1,3)) # reshape pos to nbody,3 pos = np.reshape(pos[myidsort],-1) # select ids pos = np.reshape(pos[myidsort],-1) # select ids vel = np.reshape(vel,(-1,3)) # reshape vel to nbody,3 vel = np.reshape(vel,(-1,3)) # reshape vel to nbody,3 ... @@ -417,11 +421,8 @@ class CCod: ... @@ -417,11 +421,8 @@ class CCod: print("\n\n!!! File [%s] does not exist !!!!\n\n"%(model_param),file=sys.stderr) print("\n\n!!! File [%s] does not exist !!!!\n\n"%(model_param),file=sys.stderr) self.__halo_part=self.__halo_part[np.where(self.__halo_part>0)] self.__halo_part=self.__halo_part[np.where(self.__halo_part>0)] if self.__vdebug: if self.__vdebug: print (self.__halo_part,self.__halo_part.size,file=sys.stderr) print (">>> ",self.__halo_part,self.__halo_part.size,file=sys.stderr) return ok return ok # # # ---- # ---- # Compute mering time between two halos galaxy # Compute mering time between two halos galaxy ... @@ -581,9 +582,9 @@ class CCod: ... @@ -581,9 +582,9 @@ class CCod: f=open(cod_file,"r") f=open(cod_file,"r") try: try: while True: while True: tcxv=map(np.float64,(f.readline().split())) tcxv=list(map(np.float64,(f.readline().split()))) #print ("TCXV =",n,tcxv,len(tcxv)) #print ("TCXV =",n,tcxv,len(tcxv)) if (len(tcxv)>0): if (len(tcxv)>0): atime=tcxv[0] atime=tcxv[0] if (atime-0.001)
 ... @@ -3,7 +3,7 @@ from __future__ import print_function ... @@ -3,7 +3,7 @@ from __future__ import print_function from ..uns_simu import * from ..uns_simu import * from .csnapshot import * from .csnapshot import * from .cfalcon import * from .cfalcon import * from .ctree import * from .ctree import * from multiprocessing import Process, Lock,Pool from multiprocessing import Process, Lock,Pool import multiprocessing import multiprocessing ... @@ -209,7 +209,7 @@ class CCom: ... @@ -209,7 +209,7 @@ class CCom: xx=f.readline() xx=f.readline() if (len(xx)>0): if (len(xx)>0): tcxv.append( np.float64(xx)) tcxv.append( np.float64(xx)) tcxv.append(map(np.float64,(f.readline().split()))) tcxv.append(list(map(np.float64,(f.readline().split())))) if (len(tcxv)>0): if (len(tcxv)>0): atime=tcxv[0] atime=tcxv[0] read_index=tcxv[1][0] read_index=tcxv[1][0] ... ...
 ... @@ -517,7 +517,7 @@ class CInert: ... @@ -517,7 +517,7 @@ class CInert: try: try: f=open(t_file,"r") f=open(t_file,"r") while True: while True: atime=map(np.float,(f.readline().split())) atime=list(map(np.float,(f.readline().split()))) if (len(atime)>0): if (len(atime)>0): if (atime[0]-0.001)
 ... @@ -151,7 +151,7 @@ class CMovie: ... @@ -151,7 +151,7 @@ class CMovie: try: try: f=open(t_file,"r") f=open(t_file,"r") while True: while True: atime=map(np.float,(f.readline().split())) atime=list(map(np.float,(f.readline().split()))) if (len(atime)>0): if (len(atime)>0): if (atime[0]-0.001)
 #!/usr/bin/python #!/usr/bin/env python from __future__ import print_function from __future__ import print_function from ..uns_simu import * from ..uns_simu import * ... @@ -76,7 +76,7 @@ class CPlotInert: ... @@ -76,7 +76,7 @@ class CPlotInert: f.readline() #skip time f.readline() #skip time icut=0 icut=0 #try: #try: myline=map(np.float,(f.readline().split())) myline=list(map(np.float,(f.readline().split()))) #print(myline) #print(myline) lambda1=myline[10] lambda1=myline[10] lambda2=myline[11] lambda2=myline[11] ... @@ -117,13 +117,20 @@ class CPlotInert: ... @@ -117,13 +117,20 @@ class CPlotInert: #!!gs = gridspec.GridSpec(1, 2,wspace=0,hspace=0,width_ratios=[2,2],height_ratios=[1,1])#height_ratios=h,width_ratios=w) #!!gs = gridspec.GridSpec(1, 2,wspace=0,hspace=0,width_ratios=[2,2],height_ratios=[1,1])#height_ratios=h,width_ratios=w) #print(gs.get_width_ratios(),gs.get_height_ratios(),gs.get_grid_positions(fig)) #print(gs.get_width_ratios(),gs.get_height_ratios(),gs.get_grid_positions(fig)) #!!fig.suptitle("%s %s"%(self.__simname,self.__component)) #!!fig.suptitle("%s %s"%(self.__simname,self.__component)) import os allres=sorted(glob.glob(self.__dir_moi+"/inertia_*")) allres=sorted(glob.glob(self.__dir_moi+"/inertia_*")) # keep only directories allresdir=[] for d in allres: if os.path.isdir(d): allresdir.append(d) fig,axes = plt.subplots(ncols=len(allres),sharey=False,figsize=(12, 6))#gridspec_kw={'width_ratios': [2, 2]}) fig,axes = plt.subplots(ncols=len(allresdir),sharey=False,figsize=(12, 6))#gridspec_kw={'width_ratios': [2, 2]}) fig.suptitle("%s %s"%(self.__simname,self.__component)) fig.suptitle("%s %s"%(self.__simname,self.__component)) n=0 n=0 for res in allres: for res in allresdir: #ax = plt.subplot(gs[0,n]) #ax = plt.subplot(gs[0,n]) ax= axes[n] ax= axes[n] ax.set_xlabel("Gyears") ax.set_xlabel("Gyears") ... ...
 ... @@ -219,7 +219,7 @@ class CRectify: ... @@ -219,7 +219,7 @@ class CRectify: try: try: f=open(eigen_file,"r") f=open(eigen_file,"r") while True: while True: tce=map(np.float64,(f.readline().split())) tce=list(map(np.float64,(f.readline().split()))) if (len(tce)>0): if (len(tce)>0): atime=tce[0] atime=tce[0] if (atime-0.001)
 ... @@ -152,10 +152,10 @@ class CSnapshot: ... @@ -152,10 +152,10 @@ class CSnapshot: if type==2: # array if type==2: # array ret_data = np.append(ret_data,data) ret_data = np.append(ret_data,data) else: else: ret_data = data[0] ret_data = data else: else: status=0 # one component missing status=0 # one component missing if self.__vdebug: if self.__vdebug and type==2: print ("ok=",ok," data=",data.size," ret_data=",ret_data.size) print ("ok=",ok," data=",data.size," ret_data=",ret_data.size) return status,ret_data return status,ret_data # # ... @@ -173,13 +173,15 @@ class CSnapshot: ... @@ -173,13 +173,15 @@ class CSnapshot: # proceed __uns.getValue() # proceed __uns.getValue() if tab_value_F.count(comp_value) > 0: if tab_value_F.count(comp_value) > 0: ok,ret_data[0]=self.__uns.getValueF(comp_value) ok,ret_data[0]=self.__uns.getValueF(comp_value) data=float(ret_data[0]) else: else: if tab_value_I.count(comp_value) > 0: if tab_value_I.count(comp_value) > 0: ok,ret_data[0]=self.__uns.getValueI(comp_value) ok,ret_data[0]=self.__uns.getValueI(comp_value) data=int(ret_data[0]) #ret_data[0]=data #ret_data[0]=data if self.__vdebug: if self.__vdebug: print ("ok,data",ok,data) print ("ok,data",ok,data) return ok,1,ret_data return ok,1,data else: else: if tag != "id": if tag != "id": ok,data=self.__uns.getArrayF(comp_value,tag) ok,data=self.__uns.getArrayF(comp_value,tag) ... @@ -216,7 +218,7 @@ class CSnapshot: ... @@ -216,7 +218,7 @@ class CSnapshot: if com: # resquest com if com: # resquest com ok,mass=self.getData(select,"mass") # get mass ok,mass=self.getData(select,"mass") # get mass if not ok: # no mass if not ok: # no mass mass=np.ones(pos.size/3) # fake mass mass=np.ones(int(pos.size/3)) # fake mass cxv=self.center(pos,None,mass,True) # centering cxv=self.center(pos,None,mass,True) # centering # reshape pos 1d array to 2d array [nbody,3] # reshape pos 1d array to 2d array [nbody,3] pos2d=np.reshape(pos,(-1,3)) pos2d=np.reshape(pos,(-1,3)) ... ...
 ... @@ -138,7 +138,7 @@ def setup_package(): ... @@ -138,7 +138,7 @@ def setup_package(): platforms=["Linux", "Mac OS-X", "Unix"], platforms=["Linux", "Mac OS-X", "Unix"], python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*', python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*', package_dir={'':'py'}, # all packages are under 'py' directory package_dir={'':'py'}, # all packages are under 'py' directory packages=['unsiotools', 'unsiotools/simulations'], packages=['unsiotools', 'unsiotools/simulations','unsiotools/general'], cmdclass={'build_py': build_py}, cmdclass={'build_py': build_py}, py_modules=['unsiotools/py_unstools'], py_modules=['unsiotools/py_unstools'], ext_modules = [ ext_modules = [ ... @@ -175,6 +175,9 @@ def setup_package(): ... @@ -175,6 +175,9 @@ def setup_package(): os.environ['NEMO']+'/usr/dehnen/falcON/lib' ] os.environ['NEMO']+'/usr/dehnen/falcON/lib' ] ) ) ], ], scripts=[ 'py/mains/uns_extract_halo.py', ], entry_points={ entry_points={ "console_scripts": [ "console_scripts": [ "uns_2dplot.py = unsiotools.simulations.c2dplot:commandLine", "uns_2dplot.py = unsiotools.simulations.c2dplot:commandLine", ... @@ -187,8 +190,8 @@ def setup_package(): ... @@ -187,8 +190,8 @@ def setup_package(): "processing_analysis.py = unsiotools.simulations.cuns_analysis:commandLine", "processing_analysis.py = unsiotools.simulations.cuns_analysis:commandLine", ], ], }, }, #install_requires=['numpy'], install_requires=['python-unsio','matplotlib','scipy','numpy'], #setup_requires=['numpy'] setup_requires=['numpy'] ) ) setup(**metadata) setup(**metadata) # # ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!