Commit 5e55b47c authored by LAMBERT Jean-charles's avatar LAMBERT Jean-charles

python3 compatible fixes

parent 1697048f
# ANALYSIS
ANALYSIS
#cmake
*build*/
......
......@@ -14,7 +14,9 @@
cmake_minimum_required(VERSION 2.6)
cmake_policy(SET CMP0054 NEW)
if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
# project name
project (uns_projects)
......
......@@ -24,7 +24,7 @@ if (NOT UNSIO_SETUP)
if ( UNSIOPATH ) # user configure cmake with variable -DUNSIO_INSTALLPATH="/unsio/path"
find_library(UNSIOLIB NAMES unsio PATHS ${UNSIOPATH}/lib64)
find_library(UNSIOLIB NAMES unsio PATHS ${UNSIOPATH}/lib ${UNSIOPATH}/lib64)
MESSAGE (STATUS "UNSIOLIB = " ${UNSIOLIB})
if (NOT ${UNSIOLIB} STREQUAL UNSIOLIB-NOTFOUND)
MESSAGE(STATUS "Found UNSIOLIB =" ${UNSIOLIB})
......
......@@ -410,7 +410,7 @@ class C2dplot:
def fullProcess(self,uns,out="",component=None,xrange=20.,sigma=6.0,mergers="",cmap="jet",
cpt=0,noxz=False,contour=False,nc=20,center_cod=None,nopart=False,
rect_sim=None, rect_comp="stars-stars",rect_dir="rectify2",rect_suffix="ev",
circle=0.0):
circle=""):
t0=time.clock()
sigma_ori=sigma
xrange_ori=xrange
......@@ -803,7 +803,8 @@ def commandLine():
Syntax is \"component1:cmap1,component2:cmap2\"\
example: stars:rainbow,halo:Purples\n \
(to display all colormap available use \"show\" as keyword)",
default="gas:jet,stars:rainbow,halo:PuOr")
default="gas:jet,stars:Paired,halo:Accent")
#other cmap="gas:jet,stars:rainbow,halo:PuOr"
parser.add_argument('--mergers', help="use results from mergers analysis to re-center (ex; @mdf648) to get file automatically from simulation ",default="",type=str)
parser.add_argument('--cod', help="use COD file to re-center, or @sim (ex; @mdf648) to get file automatically from simulation ",default=None)
parser.add_argument('--rect_sim', help="give a simname or a rectify file name to activate rectify",default=None)
......
......@@ -7,7 +7,15 @@ from .ctree import *
from multiprocessing import Process, Lock,Pool
import multiprocessing
import Queue # necessary to raise Queue.Empty signal
try:
# python3
import queue as Queue
pyver=3
except ImportError:
# python2
import Queue
pyver=2
import time
import os
import signal
......
......@@ -13,6 +13,7 @@ from multiprocessing import Lock
import time
import os
import glob
#from IPython import embed
#
# ----
......@@ -184,16 +185,16 @@ class CRectify:
#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))
print("Rectifing time (%f) select <%s> cod[%s]\n"%(time,select,cod_file))
try:
print(self.__use_rho,self.__dmin, self.__dmax)
ok,eigen_v=c.computeEigenVectors(pos,vel,mass,rho,16,time.item(),self.__use_rho,False,str(cod_file),rcut,self.__dmin, self.__dmax)
ok,eigen_v=c.computeEigenVectors(pos,vel,mass,rho,16,time,self.__use_rho,False,str(cod_file),rcut,self.__dmin, self.__dmax)
print("Time [%f] eigen:\n"%(time),eigen_v)
data.lock[data.lock_id].acquire()
self.__saveEigenVectors(pre_rect_file,eigen_v)
data.lock[data.lock_id].release()
except:
print("UNABLE TO COMPUTE EIGENVECTORS for time (%f) select <%s> cod[%s]\n"%(time.item(),select,cod_file))
print("UNABLE TO COMPUTE EIGENVECTORS for time (%f) select <%s> cod[%s]\n"%(time,select,cod_file))
......
......@@ -6,10 +6,12 @@ from multiprocessing import Process, Lock,Pool
import multiprocessing
try:
# python3
import queue
import queue as Queue
pyver=3
except ImportError:
# python2
import Queue
pyver=2
import matplotlib
matplotlib.use('Agg')
......@@ -56,7 +58,7 @@ class CUnsAnalysis:
self.simname = simname
self.__sql3 = UnsSimu(simname,dbname=self.__dbname,verbose=self.__verbose)
self.__r = self.__sql3.getInfo() # return None if does not exist
if self.__vdebug:
self.__sql3.printInfo(simname)
self.__slist = self.__sql3.getSnapshotList()
......@@ -89,19 +91,18 @@ class CUnsAnalysis:
components are presents
"""
# get half of list of snapshot to check if all components exist
half_snap=self.__slist[len(self.__slist)/2]
half_snap=self.__slist[int(len(self.__slist)/2)]
if self.__vdebug:
print("Half snapshot =",half_snap)
#sys.exit()
test_snap=CSnapshot(half_snap, "all" )
ok=test_snap.nextFrame()
ok=test_snap.unsin.nextFrame()
# rebuild select string with existing components
self.__new_select=""
whole_select="halo:disk:gas:stars:bndry"
for colon_s in whole_select.split(":"):
ok,data=test_snap.getData(colon_s,"pos")
ok,data=test_snap.unsin.getData(colon_s,"pos")
if ok:
if len(self.__new_select)==0:
sep=""
......@@ -110,7 +111,7 @@ class CUnsAnalysis:
self.__new_select += sep+ colon_s
if self.__vdebug:
print("new select :",self.__new_select)
test_snap.close()
test_snap.unsin.close()
#
# ----
......@@ -194,10 +195,13 @@ class CUnsAnalysis:
#my_snap=queue_list.get() # do not use this, could block if nothing to get
#time.sleep(0.01)
data.uns_snap=CSnapshot(my_snap,self.__select,verbose_debug=self.__vdebug)
ok=data.uns_snap.nextFrame("") # load in memory
ok=data.uns_snap.unsin.nextFrame("") # load in memory
if ok:
# start analysis script
execfile(self.__analysis_script)
if pyver==2:
execfile(self.__analysis_script)
else : # python3 ?
exec(open(self.__analysis_script).read())
cpt+=1
print ("Core [",n,"] got snap : ",my_snap,cpt)
......
......@@ -82,7 +82,7 @@ class build_py(_build_py, object):
#
MAJOR = '0'
MINOR = '0'
MICRO = '6'
MICRO = '7'
VERSION = '%s.%s.%s' % (MAJOR, MINOR, MICRO)
#
......
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