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

uns_2dplot.py improvements

parent 29c4038d
......@@ -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
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
......
......@@ -580,7 +580,7 @@ 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",file=syst.stderr)
print("Failed to __getCenterCod, aborting...\n",file=sys.stderr)
sys.exit()
else:
print("tcxv=",tcxv[1:4],file=sys.stderr)
......@@ -598,22 +598,75 @@ class C2dplot:
y -= ycom
# proceed on rectify
if self.__rect_sim is not None:
x0 = pos * self.__data_rect[6:9]
x1 = pos * self.__data_rect[9:12]
x2 = pos * self.__data_rect[12:15]
if row==0:
x = np.sum(x0,axis=1)
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)
fix_pos=crect.CRectify.fixRotation(self.__data_rect[6:9],
self.__data_rect[9:12],
self.__data_rect[12:15])
print("\n\n FIX POS=",fix_pos)
x0 = pos * self.__data_rect[6:9]
x1 = pos * self.__data_rect[9:12]
x2 = pos * self.__data_rect[12:15]
if row==0:
x = np.sum(x0,axis=1)
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)
if fix_pos == 1:
x = x*-1
if fix_pos == 2:
y = y*-1
if fix_pos == 3:
sel=(x>0)&(y<0)
sel2=(x<0)&(y>0)
sel3=(x>0)&(y>0)
sel4=(x<0)&(y<0)
x[sel]=x[sel]*-1
y[sel]=y[sel]*-1
x[sel2]=x[sel2]*-1
y[sel2]=y[sel2]*-1
x_copy= np.copy(x[sel3])
y_copy= np.copy(y[sel3])
x[sel3] = y_copy
y[sel3] = x_copy
x2_copy= np.copy(x[sel4])
y2_copy= np.copy(y[sel4])
x[sel4] = y2_copy
y[sel4] = x2_copy
if fix_pos == 4:
sel=(x>0)&(y>0)
sel2=(x<0)&(y<0)
sel3=(x>0)&(y<0)
sel4=(x<0)&(y>0)
x[sel]=x[sel]*-1
y[sel]=y[sel]*-1
x[sel2]=x[sel2]*-1
y[sel2]=y[sel2]*-1
x_copy= np.copy(x[sel3])
y_copy= np.copy(y[sel3])
x[sel3] = y_copy
y[sel3] = x_copy
x2_copy= np.copy(x[sel4])
y2_copy= np.copy(y[sel4])
x[sel4] = y2_copy
y[sel4] = x2_copy
#x = x*fix_pos[0]
#y = y*fix_pos[1]
else:
pass
pass
else : # there are no particles
x=np.empty(0)
......
......@@ -281,7 +281,48 @@ class CRectify:
else :
self.__convertEv2Rect(ev_in,rect_out)
#
# fixRotation
#
@staticmethod
def fixRotation(ev1,ev2,ev3):
"""
correct rotation matrix
return values :
0 : nothing
1 : x*-1
2 : y*-1
3 : (x>0,y<0)*(-1,-1) (x<0,y>0)*(-1,-1) (x>0,y>0)*(y,x) (x<0,y<0)*(y,x)
4 : (x>0,y>0)*(-1,-1) (x<0,y<0)*(-1,-1) (x>0,y<0)*(y,x) (x<0,y>0)*(y,x)
"""
A=np.array([-10, 10, 0])
B=np.array([ 10, 10, 0])
C=np.array([-10,-10, 0])
D=np.array([ 10,-10, 0])
A1=np.array([np.dot(A,ev1), np.dot(A,ev2), np.dot(A,ev3)])
B1=np.array([np.dot(B,ev1), np.dot(B,ev2), np.dot(B,ev3)])
C1=np.array([np.dot(C,ev1), np.dot(C,ev2), np.dot(C,ev3)])
D1=np.array([np.dot(D,ev1), np.dot(D,ev2), np.dot(D,ev3)])
ret = 0
if A1[0]>0 and C1[0]>0:
ret = 1
if A1[1]<0 and B1[1]<0:
ret = 2
if A1[0]>0 and A1[1]<0:
ret = 3
if C1[0]>0 and C1[1]>0:
ret =4
return ret
#
# infoTimeSimu
#
......
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