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

modifications for testing in production mode

parent 11ac9ebe
......@@ -3,7 +3,7 @@ import numpy as np
import os,time
import sys
import argparse,textwrap
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.crectify import *
......
......@@ -70,3 +70,4 @@ data.first=False #MANDATORY
#!/usr/bin/env python
#!/usr/bin/python
from __future__ import print_function
from uns_simu import *
from csnapshot import *
......@@ -30,7 +30,7 @@ class C2dplot:
def __init__(self,analysis=None,dimx=1024,dimy=1024,pixel=20,gp=5.0,verbose=False,verbose_debug=False):
"""
Constructor of CRectify class
Constructor of C2dplot class
- analysis : is a class object instantiate from CUnsAnalysis class
"""
......@@ -41,7 +41,7 @@ class C2dplot:
self.dimy = dimy
self.pixel = pixel
self.gp = gp
self.__c=C2dplotF(1,self.pixel,self.dimx,self.dimy,self.gp)
self.__c=py_unstools.C2dplotF(1,self.pixel,self.dimx,self.dimy,self.gp)
if analysis is not None:
......@@ -137,6 +137,8 @@ class C2dplot:
hsml=np.array([],dtype='f')
print(pos.size,outdev,no,weight)
print(outdev,no,pos,nrange,title,comp_prop,filename,time.item(),xy,xz,zy,\
True,weight,psort,hsml,itf,cb,legend,cmap)
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)
......
......@@ -562,7 +562,7 @@ class CCod:
pass
#
else: # default simdir simulation
data.cod_dir=data.sim_info['dir']+"/ANALYSIS"+self.__COD_DIR_NAME
data.cod_dir=data.sim_info['dir']+"/ANALYSIS/"+self.__COD_DIR_NAME
print("CoD DIR = ", data.cod_dir, data.sim_info['name'])
self.__cod_file_base=data.cod_dir
......
......@@ -93,6 +93,7 @@ class CCom:
f.close()
except:
print("Unable to create file [%s], aborting"%(self.__analysis.com_file))
self.__analysis.lock[self.__analysis.lock_id].release()
sys.exit()
# release process
......
#!/usr/bin/python
from py_unstools import * # import py_unstools package
from __future__ import print_function
import py_unstools
import numpy as np
class CFalcon:
"""methods imported from FalcON engine"""
#def __init__(self):
# print "simname = ", simname
def __init__(self):
#print ("simname = ", simname)
pass
def getGravity(self,pos,mass,eps,G=1.0,theta=0.6,kernel_type=1,ncrit=6):
# init returns array
acc = np.zeros(pos.size,'f') # acc is 3D !!
phi = np.zeros(mass.size,'f')
# compute gravity
falcon=cfalcon()
falcon=py_unstools.cfalcon()
ok=falcon.compute_gravity(pos,mass,acc,phi,eps,G,theta,kernel_type,ncrit)
return ok,acc,phi
......@@ -26,7 +27,7 @@ class CFalcon:
rho=np.zeros(mass.size,'f')
hsml=np.zeros(mass.size,'f')
# compute density
falcon=cfalcon()
falcon=py_unstools.cfalcon()
ok=falcon.compute_density(pos,mass,rho,hsml,method,K,N,ncrit)
return ok,rho,hsml
......
#!/usr/bin/env python
#!/usr/bin/python
from __future__ import print_function
from uns_simu import *
from csnapshot import *
......@@ -125,7 +125,7 @@ class CMovie:
else: # default simdir simulation
self.__movie_dir=data.sim_info['dir']+"/ANALYSIS/movie"
if self.__vdebug:
print("MOVIE DIR = ", self.__movie_dir, data.sim_info['name'])
print("MOVIE DIR = ", type(self.__movie_dir), data.sim_info['name'])
self.simname=data.sim_info['name']
self.__comp_data =[] # list to store compononent to proceed
......@@ -154,8 +154,9 @@ class CMovie:
print("CMovie#Warning : component <%s> from select <%s> does not exist...\n"\
%(comp,colon_s))
else: # comp exist
fdir=self.__movie_dir+"/work/rsnap_"+newradius+"_pcen_"+\
fdir=self.__movie_dir+"/work/rsnap_"+newradius+"_percen_"+\
percen+"_prop_"+prop+"/"+comp
self.__comp_data.append([comp,prop,float(percen),int(newradius),extdir,fdir])
......
#!/usr/bin/env python
#!/usr/bin/python
from __future__ import print_function
from uns_simu import *
from csnapshot import *
......@@ -8,7 +8,7 @@ import py_unstools # rectify swig
from multiprocessing import Lock
import time
import os
import glob
#
# ----
......@@ -17,18 +17,17 @@ class CRectify:
"""
compute Center Of Mass on UNS snapshots
"""
__analysis=None
#
# ----
#
# constructor
__analysis=None
def __init__(self,analysis=None,verbose=False,verbose_debug=False):
"""
Constructor of CRectify class
- analysis : is a class object instantiate from CUnsAnalysis class
"""
self.__vdebug=verbose_debug
self.__verbose=verbose
......@@ -85,7 +84,8 @@ class CRectify:
pass
#
else: # default simdir simulation
data.cod_dir=data.sim_info['dir']+"/ANALYSIS"+self.__COD_DIR_NAME
data.cod_dir=data.sim_info['dir']+"/ANALYSIS/cod"
#data.cod_dir=data.sim_info['dir']+"/ANALYSIS"+self.__COD_DIR_NAME
self.__cod_base_dir=data.cod_dir
......@@ -155,17 +155,22 @@ class CRectify:
cod_sel = comp_cod[1]
cod_file = comp_cod[2]
rcut = comp_cod[3]
print("select %s cod_sel %s cod_file %s rcut %s"%(select,cod_sel,cod_file,rcut))
# pre computed rectify file
pre_rect_file=self.__rectify_dir+"/"+self.simname+"."+select+"-"+cod_sel+".ev"
print("rect_file =",pre_rect_file)
# lock file
#data.lock[data.lock_id].acquire()
exist_time,e_vectors=self.__checkTimeInPreRect(time,pre_rect_file)
print("exist_time =",exist_time)
#data.lock[data.lock_id].release()
if not exist_time :
ok1,pos = uns_snap.getData(select,"pos" )
ok2,vel = uns_snap.getData(select,"vel" )
ok3,mass = uns_snap.getData(select,"mass")
print("ok1 ok2 ok3 ",ok1,ok2,ok3)
if pos.size>1 and vel.size>1 and mass.size>1 :
if self.__vdebug:
print("Rectifing time (%f) select <%s> cod[%s]\n"%(time.item(),select,cod_file))
......@@ -240,7 +245,7 @@ class CRectify:
if simname is not None:
self.simname = simname
self.__sql3 = UnsSimu(simname,dbname=self.__dbname,verbose=self.__verbose)
self.__sql3 = UnsSimu(simname,verbose=self.__verbose)
self.__r = self.__sql3.getInfo() # return None if does not exist
if self.__vdebug:
......@@ -250,7 +255,13 @@ class CRectify:
message="In CLASS <"+self.__class__.__name__+"> : Unknown simulation ["+simname+\
"] in UNS database..."
raise Exception(message)
if ev_in is None:
simdir=self.__r['dir']+"/ANALYSIS/rectify/"
for ev_in in glob.glob(simdir+"*.ev"):
rect_out=os.path.basename(ev_in)
rect_out=simdir+rect_out.split(".ev")[0]+".rect"
print(">> %s [%s]\n"%(ev_in,rect_out))
self.__convertEv2Rect(ev_in,rect_out)
else :
self.__convertEv2Rect(ev_in,rect_out)
......@@ -265,7 +276,7 @@ class CRectify:
try:
if rect_out is not None:
f=open(rect_out,"w")
except EOFError:
except (IOError,EOFError):
print("Unable to open file [%s] for writing, aborting....\n"%(rect_out))
sys.exit()
a=np.loadtxt(ev_in) # load file
......
#!/usr/bin/python
from __future__ import print_function
from py_unstools import * # import py_unstools package
#from py_unstools import * # import py_unstools package
from py_unsio import *
from uns_simu import *
from cfalcon import *
......
......@@ -9,7 +9,6 @@ import time
import os
import signal
from py_unstools import * # import py_unstools package
from uns_simu import *
from csnapshot import *
......
......@@ -81,6 +81,7 @@ class UnsSimu:
if name is None:
name=self.name
if ( self.__status) :
self.__conn.text_factory = bytes
c = self.__conn.cursor()
sql="select * from info where name=='"+name+"'"
cursor=c.execute(sql)
......
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