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

improve rectify options

parent 133f8d2d
[Dolphin]
SortFoldersFirst=false
SortOrder=1
SortRole=date
Timestamp=2017,1,24,16,43,17
Version=3
SortRole=modificationtime
Timestamp=2018,8,16,11,29,15
Version=4
ViewMode=1
......@@ -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
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
......@@ -27,7 +27,7 @@ def commandLine():
default="gas:jet,stars:Paired,halo:Accent")
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="you must give a simname to activate rectify",default=None)
parser.add_argument('--rect_sim', help="give a simname or a rectify file name to activate rectify",default=None)
parser.add_argument('--rect_comp', help="used component based file, eg 'stars-stars' or 'gas-stars'",default="stars-stars")
parser.add_argument('--rect_dir', help="rectify directory name",default="rectify2")
parser.add_argument('--rect_suffix',help="rectify suffix file name",default="ev")
......
......@@ -429,12 +429,13 @@ class C2dplot:
# read data_rectify
if self.__rect_sim is not None:
print("Rectify is activated....\n",file=sys.stderr)
ok,self.__data_rect=crect.CRectify.infoTimeSimu(self.__rect_sim,timex,self.__rect_comp,
self.__rect_dir,self.__rect_suffix)
if not ok:
print("\nUnable to retreive RECTIFY information...aborting\n\n",file=sys.stderr)
sys.exit()
else:
print("Rectify, sim is None !!\n")
self.__uns=uns
#
......@@ -567,7 +568,6 @@ class C2dplot:
y = pos[:,2] # z coordinates
nbody = x.size
print("before center pos[100,:] =",pos[100,:])
if self.__vdebug:
print("Ok_center [%d] center_cod <%s>"%(ok_center,center_cod))
if ok_center:# it's a merger requested which exist
......@@ -580,10 +580,10 @@ class C2dplot:
if center_cod is not None: # center on COD requested
ok,tcxv=self.__getCenterCod(center_cod,comp)
if not ok :
print("Failed to __getCenterCod, aborting...\n")
print("Failed to __getCenterCod, aborting...\n",file=syst.stderr)
sys.exit()
else:
print("tcxv=",tcxv[1:4])
print("tcxv=",tcxv[1:4],file=sys.stderr)
x -= tcxv[1]
if row==0: # y = y
y -= tcxv[2]
......@@ -593,11 +593,10 @@ class C2dplot:
xcom=np.average(x.astype(np.float64),weights=mass*rho)
ycom=np.average(y.astype(np.float64),weights=mass*rho)
if self.__vdebug:
print ("COM = ",xcom,ycom)
print ("COM = ",xcom,ycom,file=sys.stderr)
x -= xcom
y -= ycom
# proceed on rectify
print("after center pos[100,:] =",pos[100,:])
if self.__rect_sim is not None:
x0 = pos * self.__data_rect[6:9]
x1 = pos * self.__data_rect[9:12]
......@@ -605,13 +604,14 @@ class C2dplot:
if row==0:
x = np.sum(x0,axis=1)
self.__x[component]=np.copy(x)
self.__x[component]=np.copy(x) # we copy the result of x0 the first time (row=0)
# otherwise x coordinates will not be centered
# at next row. It's because we we offset y coordinates
# either with center_xy (row 0) or center_xz (row>0)
y = np.sum(x1,axis=1)
else:
x = self.__x[component] # np.sum(x0,axis=1)
y = np.sum(x2,axis=1)
print("after rectify x[100] y[100] =",x[100],y[100])
else:
pass
......
......@@ -286,19 +286,28 @@ class CRectify:
# infoTimeSimu
#
@staticmethod
def infoTimeSimu(simname,time,component="gas-stars",rectify_dir_name='rectify2',verbose=False):
def infoTimeSimu(simname,time,component="gas-stars",rectify_dir_name='rectify2',rectify_suffix="ev",verbose=False):
"""
return info array at the corresponding time and simu rect file
arguments:
simname : input simname or rect file
time : requested time to retreive
component : component base name for rect file, in case of simulation
rectify_dir_name : dir name where is store rect files, in case of simulation
rectify_suffix : rect file suffox name , in case of simulation
"""
sql3 = UnsSimu(simname,verbose=verbose)
r = sql3.getInfo()
if (r is None) :
print("Simulation %s does not belong to UNS database...\n"%(simname))
sys.exit()
rectify_dir=r['dir']+"/ANALYSIS/"+rectify_dir_name
rect_file=rectify_dir+"/"+r['name']+"."+component+".ev"
print("Trying reading file [%s]\n"%(rect_file))
rect_file=None
if os.path.isfile(simname) :
rect_file=simname
else: # trying UNS database
sql3 = UnsSimu(simname,verbose=verbose)
r = sql3.getInfo()
if (r is None) :
print("\nSimulation %s does not belong to UNS database...\n"%(simname))
else:
rectify_dir=r['dir']+"/ANALYSIS/"+rectify_dir_name
rect_file=rectify_dir+"/"+r['name']+"."+component+"."+rectify_suffix
print("Trying reading file [%s]\n"%(rect_file),file=sys.stderr)
ok=False
data=[]
if os.path.isfile(rect_file):
......@@ -315,6 +324,8 @@ class CRectify:
return False,[]
except EOFError:
pass
else:
print("Unable to load RECT file [%s]"%(rect_file),file=sys.stderr)
return ok,[]
......
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