Commit 7c6fda7d authored by LAMBERT Jean-charles's avatar LAMBERT Jean-charles
Browse files

refactoring...

parent 3944b8de
......@@ -8,7 +8,7 @@ import argparse,textwrap
#sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
import simulations.cplotinert as pmoi
import unsiotools.simulations.cplotinert as pmoi
#from IPython import embed
......
#!/usr/bin/python
from __future__ import print_function
from uns_simu import *
from csnapshot import *
from ..uns_simu import *
#from .csnapshot import *
import sys
try:
import py_unstools # rectify swig
from .. import py_unstools # rectify swig
except ImportError:
print("WARNING !!!, failed to import module [py_unstools]",file=sys.stderr)
print("WARNING !!!,c2dpgplot failed to import module [py_unstools]",file=sys.stderr)
from multiprocessing import Lock
import time
import os
import numpy as np
#
# ----
......@@ -146,6 +146,3 @@ class C2dpgplot:
else:
print("There is no position in snapshot...")
#!/usr/bin/python
from __future__ import print_function
from csnapshot import *
from uns_simu import *
from ccod import *
import simulations.crectify as crect
import sys
from ..uns_simu import *
from .ccod import *
from . import crectify as crect
from multiprocessing import Lock
import time
import os,sys
......@@ -772,5 +773,3 @@ class C2dplot:
#embed()
#plt.contour(zd, origin='lower',cmap='winter',norm = matplotlib.colors.LogNorm(), extent=[view_xmin, view_xmax, view_ymin, view_ymax])
#plt.contour(zd,norm = matplotlib.colors.LogNorm(), extent=[view_xmin, view_xmax, view_ymin, view_ymax])
#!/usr/bin/env python
from __future__ import print_function
import sys
from uns_simu import *
from csnapshot import *
from cfalcon import *
from ctree import *
from ..uns_simu import *
from .cfalcon import *
from . import ctree as CT
from multiprocessing import Process, Lock,Pool
import multiprocessing
......@@ -129,7 +129,7 @@ class CCod:
if < 0 use as percentage of particles
default (10000 particles)
"""
from . import csnapshot as cs
if self.__r is None:
print ("Simulation",self.simname," does not exist",file=sys.stderr)
return False
......@@ -170,7 +170,7 @@ class CCod:
if self.__vdebug:
print("Half snapshot =",half_snap,file=sys.stderr)
#sys.exit()
test_snap=CSnapshot(half_snap, self.__best_select)
test_snap=cs.CSnapshot(half_snap, self.__best_select)
ok=test_snap.nextFrame()
# rebuild select string with existing components
......@@ -249,6 +249,7 @@ class CCod:
"""
Compute COD on core
"""
from . import csnapshot as cs
my_snap=self.__findLastSnapshotWithNoCod(queue_list,n,lock)
stop=False
......@@ -265,7 +266,7 @@ class CCod:
# if nothing, then get raise Queue.Empty exception
#my_snap=queue_list.get() # do not use this, could block if nothing to get
#time.sleep(0.01)
uns_snap=CSnapshot(my_snap,self.__best_select)
uns_snap=cs.CSnapshot(my_snap,self.__best_select)
ok=uns_snap.nextFrame("mxvI")
okt,time=uns_snap.getData("time")
......@@ -315,7 +316,7 @@ class CCod:
cxv=uns_snap.center(pos,vel,rho*mass)
else : # fastcod
ctree=CTree(pos,vel,mass) # instantiate a ctree object
ctree=CT.CTree(pos,vel,mass) # instantiate a ctree object
cxv=ctree.fastCod3(self.__ctree_threshold)
# compute COM
comxv=uns_snap.center(pos,vel,mass)
......@@ -600,6 +601,8 @@ class CCod:
"""
find out last snapshot with computed COD
"""
from . import csnapshot as cs
stop=False
cpt=0
my_snap=None
......@@ -610,7 +613,7 @@ class CCod:
# if nothing, then get raise Queue.Empty exception
#my_snap=queue_list.get() # do not use this, could block if nothing to get
#time.sleep(0.01)
uns_snap=CSnapshot(my_snap,self.__best_select)
uns_snap=cs.CSnapshot(my_snap,self.__best_select)
ok=uns_snap.nextFrame("none")
okt,time=uns_snap.getData("time")
uns_snap.close()
......@@ -823,7 +826,7 @@ class CCod:
cxv=uns_snap.center(pos,vel,rho*mass)
else : # fastcod
ctree=CTree(pos,vel,mass) # instantiate a ctree object
ctree=CT.CTree(pos,vel,mass) # instantiate a ctree object
cxv=ctree.fastCod3(self.__ctree_threshold)
# compute COM
comxv=uns_snap.center(pos,vel,mass)
......@@ -845,4 +848,3 @@ class CCod:
out.write("%e %e %e %e %e %e %e\n"%(time,cxv[0],cxv[1],cxv[2],cxv[3],cxv[4],cxv[5]))
out.close()
data.lock[data.lock_id].release()
#!/usr/bin/python
from __future__ import print_function
from uns_simu import *
from csnapshot import *
from cfalcon import *
from ctree import *
from ..uns_simu import *
from .csnapshot import *
from .cfalcon import *
from .ctree import *
from multiprocessing import Process, Lock,Pool
import multiprocessing
......@@ -225,6 +225,3 @@ class CCom:
pass
return ok,tcxv
......@@ -4,9 +4,9 @@ from __future__ import print_function
import numpy as np
import sys
try:
import py_unstools
from .. import py_unstools
except ImportError:
print("WARNING !!!, failed to import module [py_unstools]",file=sys.stderr)
print("WARNING !!!, falcon failed to import module [py_unstools]",file=sys.stderr)
......@@ -37,7 +37,3 @@ class CFalcon:
falcon=py_unstools.cfalcon()
ok=falcon.compute_density(pos,mass,rho,hsml,method,K,N,ncrit)
return ok,rho,hsml
#!/usr/bin/python
from __future__ import print_function
from ctree import *
from csnapshot import *
from uns_simu import *
from ccod import *
from cfalcon import *
from .ctree import *
from .csnapshot import *
from ..uns_simu import *
from .ccod import *
from .cfalcon import *
import time
import os,sys
......
#!/usr/bin/python
from __future__ import print_function
from uns_simu import *
from csnapshot import *
from c2dpgplot import *
from ..uns_simu import *
from .csnapshot import *
from .c2dpgplot import *
import sys
try:
import py_unstools # rectify swig
except ImportError:
print("WARNING !!!, failed to import module [py_unstools]",file=sys.stderr)
print("WARNING !!!,cmovie failed to import module [py_unstools]",file=sys.stderr)
import subprocess
......
#!/usr/bin/python
from __future__ import print_function
from ctree import *
from csnapshot import *
from uns_simu import *
import ccod as cod
from .ctree import *
from .csnapshot import *
from ..uns_simu import *
from . import ccod as cod
import time
import os,sys
......@@ -71,5 +71,3 @@ class COrbits:
pass
else :
print("snap.nextFrame() failed....\n",file=sys.stderr)
#!/usr/bin/python
from __future__ import print_function
from uns_simu import *
from ..uns_simu import *
import time
import os,sys
......@@ -142,6 +142,3 @@ class CPlotInert:
plt.savefig(self.__outfile)
else :
plt.show()
#!/usr/bin/python
from __future__ import print_function
from uns_simu import *
from csnapshot import *
from ..uns_simu import *
from .csnapshot import *
import sys
try:
import py_unstools # rectify swig
from .. import py_unstools # rectify swig
except ImportError:
print("WARNING !!!, failed to import module [py_unstools]",file=sys.stderr)
print("WARNING crectify failed to import module [py_unstools]",file=sys.stderr)
from multiprocessing import Lock
import time
......@@ -415,12 +415,3 @@ class CRectify:
print("%e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e"\
%(a[id,0],cx[0],cx[1],cx[2],cv[0],cv[1],cv[2],ev0[0],\
ev0[1],ev0[2],ev1[0],ev1[1],ev1[2],ev2[0],ev2[1],ev2[2]))
#!/usr/bin/env python
from __future__ import print_function
from uns_simu import *
from ..uns_simu import *
import os,sys,subprocess
#
......@@ -91,4 +91,3 @@ class CReducesim:
subprocess.call(["uns2uns",snap,newsnap,"select="+select,"type=gadget3"])
cpt+=1
#!/usr/bin/python
from __future__ import print_function
#from py_unstools import * # import py_unstools package
import unsio
from uns_simu import *
from cfalcon import *
from ccod import *
from ..py_unstools import * # import py_unstools package
from ..uns_simu import *
from .cfalcon import *
import numpy as np
import unsio
#
# class CSsnapshot
......@@ -358,7 +359,7 @@ class CSnapshot:
print(" __getCenterFromFile [%s]"%(center_cod),file=sys.stderr)
if os.path.isfile(center_cod) : # it's a file
ok,time=self.getData("time")
return CCod(None).getCodFromFile(center_cod,time)
return ccod.CCod(None).getCodFromFile(center_cod,time)
else:
tmp=center_cod.split('@')
if (len(tmp)>1): # it's simulation name
......@@ -366,7 +367,7 @@ class CSnapshot:
if self.__vdebug:
print("Simulation name from COD [%s] comp <%s>\n"%(simname,comp))
print("SELF.__ANALYSIS = <%s>"%(self.__analysis))
cod=CCod(simname,verbose_debug=self.__vdebug)
cod=ccod.CCod(simname,verbose_debug=self.__vdebug)
ok,time=self.getData("time")
cod_base=None
if self.__analysis is not None:
......@@ -398,3 +399,4 @@ class CSnapshot:
c=CFalcon() # new falcon object
return c.getDensity(pos,mass) # compute density
from . import ccod
#!/usr/bin/python
from __future__ import print_function
import sys
import csnapshot as cs
try:
import py_unstools as ut # import py_unstools package
from .. import py_unstools as ut # import py_unstools package
except ImportError:
print("WARNING !!!, failed to import module [py_unstools]",file=sys.stderr)
print("WARNING !!!, ctree failed to import module [py_unstools]",file=sys.stderr)
import numpy as np
import cfalcon as cf
import unsio as unsio
from . import cfalcon as cf
import unsio
# -----------------------------------------------------
#
......@@ -70,6 +71,7 @@ class CTree:
Return:
"""
from . import csnapshot as cs
if threshold<0: # it's percentage of nbodies
threshold = (abs(threshold)*self.__tree.getNbody())/100
......@@ -125,6 +127,7 @@ class CTree:
Return:
"""
from . import csnapshot as cs
if threshold<0: # it's percentage of nbodies
threshold = (abs(threshold)*self.__tree.getNbody())/100
......@@ -184,6 +187,7 @@ class CTree:
cxv : COD, 1D numpy array of size 6
rpos : positions of particles used to compute cod 1D num array
"""
from . import csnapshot as cs
if threshold<0: # it's percentage of nbodies
threshold = (abs(threshold)*self.__tree.getNbody())/100
......
......@@ -9,8 +9,8 @@ import time
import os
import signal
from uns_simu import *
from csnapshot import *
from ..uns_simu import *
from .csnapshot import *
class CUnsAnalysis:
......@@ -201,6 +201,3 @@ class CUnsAnalysis:
print ("Core [",n,"] DONE !",cpt)
#print "Core [",n,"] got snap : ",queue_list.get()
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