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

2dplot updates

parent 5e4f7716
......@@ -5,7 +5,7 @@ import numpy as np
import os,time
import sys
import argparse,textwrap
#sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/']+sys.path
sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/']+sys.path
#from IPython import embed
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
......
......@@ -128,7 +128,8 @@ class C2dplot:
uns_snap=data.uns_snap # link to UNS object
ok,time=uns_snap.getData("time")
print("Core [%d] time <%f>"%(data.core_id,time))
if self.__vdebug:
print("Core [%d] time <%f>"%(data.core_id,time))
if not contour:
my_dir=self.__movie_dir_std
else:
......@@ -220,7 +221,8 @@ class C2dplot:
for my_dir in (self.__movie_dir_std, self.__movie_dir_contour):
if (not os.path.isdir(my_dir)) :
try:
print("Core ID ",data.core_id," create directory [%s]\n"%(my_dir))
if self.__vdebug:
print("Core ID ",data.core_id," create directory [%s]\n"%(my_dir))
os.makedirs(my_dir)
except OSError:
......@@ -283,7 +285,7 @@ class C2dplot:
print("myix[maskglob]=",myix[maskglob].size,myix[maskglob].max(),file=sys.stderr)
print("myiy[maskglob]=",myiy[maskglob].size,myiy[maskglob].max(),file=sys.stderr)
#img[myix[maskglob]][myiy[maskglob]]=np.random.random_integers(1024)
print("IMG:",img.size,img.shape)
print("IMG:",img.size,img.shape)
for a,b,rr in zip(myiy[maskglob],myix[maskglob],rho[maskglob]): #myix[maskglob],myiy[maskglob]):
img[a][b] += 1.#*rr
#sys.exit()
......@@ -431,7 +433,8 @@ class C2dplot:
newcy2=math.fabs(cx2[1]-center_xy[1])
best_winsize=max(max(newcx1,newcy1),max(newcx2,newcy2))
print("BEST =", best_winsize,newcx1,newcy1,newcx2,newcy2)
if self.__vdebug:
print("BEST =", best_winsize,newcx1,newcy1,newcx2,newcy2)
if best_winsize > xrange_ori:
xrange=best_winsize+0.2*xrange_ori # add 20% of rmax to best_winsize
else:
......@@ -455,13 +458,14 @@ class C2dplot:
inches = 1080./mydpi
w=inches*ncols/nrows
h=inches
print("w/h=",w,h,w*mydpi,h*mydpi,file=sys.stderr)
if self.__vdebug:
print("w/h=",w,h,w*mydpi,h*mydpi,file=sys.stderr)
# specify figure dimensions
fig=plt.figure(figsize=(w,h),dpi=mydpi)
#fig=plt.figure(figsize=(w,h))
print ("FIG DPI =",fig.dpi)
if self.__vdebug:
print ("FIG DPI =",fig.dpi)
# create grid
gs = gridspec.GridSpec(nrows, ncols,wspace=0,hspace=0)#height_ratios=h,width_ratios=w)
#print(gs.get_width_ratios(),gs.get_height_ratios(),gs.get_grid_positions(fig))
......@@ -484,7 +488,8 @@ class C2dplot:
ok_center, center_xy,center_xz,ax,fig,r,contour=contour,nc=nc,
center_cod=center_cod,nopart=nopart)
fig.subplots_adjust(hspace=0.,wspace=0.)
print("Overall time [%.3f] sec"%(time.clock()-t0),file=sys.stderr)
if self.__vdebug:
print("Overall time [%.3f] sec"%(time.clock()-t0),file=sys.stderr)
if (out==''):
plt.show()
else:
......@@ -535,8 +540,8 @@ class C2dplot:
y = pos[:,2] # z coordinates
nbody = x.size
print("Ok_center [%d] center_cod <%s>"%(ok_center,center_cod))
if self.__vdebug:
print("Ok_center [%d] center_cod <%s>"%(ok_center,center_cod))
if ok_center:# it's a merger requested which exist
x -= center_xy[0]
if row==0:
......@@ -621,7 +626,8 @@ class C2dplot:
if self.__vdebug:
print("Sigma re-computed=",sigma)
zd = self.__grid_density_gaussian_filter(view_xmin, view_ymin, view_xmax, view_ymax, width,height, x, y, sigma,rho)
print("Gaussian filtering : [%.3f] sec"%(time.clock()-t1),file=sys.stderr)
if self.__vdebug:
print("Gaussian filtering : [%.3f] sec"%(time.clock()-t1),file=sys.stderr)
# plot time text
xtext=(view_xmin+0.05*(view_xmax-view_xmin))
ytext=(view_ymin+0.90*(view_ymax-view_ymin))
......@@ -650,7 +656,8 @@ class C2dplot:
if contour:
tc = time.clock()
plt.contour(zd, origin='lower',levels=np.logspace(np.log(zd.min()),np.log(zd.max()),nc),cmap='winter', norm = matplotlib.colors.LogNorm(),extent=[view_xmin, view_xmax, view_ymin, view_ymax] )
print("Contour : [%.3f] sec"%(time.clock()-tc),file=sys.stderr)
if self.__vdebug:
print("Contour : [%.3f] sec"%(time.clock()-tc),file=sys.stderr)
#plt.contour(zd, origin='lower',levels=np.linspace(np.log(zd.min()),np.log(zd.max()),50),cmap='winter', norm = matplotlib.colors.LogNorm() )
......
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