Commit adfd491b authored by David Vincent's avatar David Vincent
Browse files

The transformation matrix is now also used in 2D (instead of computing the angle)

parent d45d4bed
......@@ -230,14 +230,6 @@ class Coordinate_system :
xyz = region.coordinates
if mesh_proj :
self.coordinates = dgpy.pjTransform(_mesh_proj, _data_proj, xyz)
epsVect = np.zeros(xyz.shape)
coord = self.coordinates.copy()
epsVect[:,0] = np.hypot(coord[1,0]-coord[0,0],coord[1,1]-coord[0,1]) / 1000.
xyz0 = dgpy.pjTransform(_data_proj, _mesh_proj, coord-epsVect)
xyz1 = dgpy.pjTransform(_data_proj, _mesh_proj, coord+epsVect)
if dgpy.pj_is_latlong(_data_proj) :
xyz1[:,0] = np.where( xyz1[:,0]<xyz0[:,0], xyz1[:,0]+2*np.pi, xyz1[:,0])
self._angle = np.arctan2(xyz1[:,1]-xyz0[:,1], xyz1[:,0]-xyz0[:,0])
else :
lonlat = np.zeros(xyz.shape)
lonlat[:,0] = np.arctan2(xyz[:,1], xyz[:,0])
......@@ -290,14 +282,12 @@ class Coordinate_system :
* v
second component of the vector (in the data coordinate system)
"""
#u2 = u * np.cos(self._angle) - v * np.sin(self._angle)
#v2 = u * np.sin(self._angle) + v * np.cos(self._angle)
u2 = self._alpha[:,0,0]*u + self._alpha[:,0,1]*v
v2 = self._alpha[:,1,0]*u + self._alpha[:,1,1]*v
u2 = self._alpha[:,0,0]*u + self._alpha[:,0,1]*v
v2 = self._alpha[:,1,0]*u + self._alpha[:,1,1]*v
return (u2, v2)
def rotateSphere(self, F_lon, F_colat, F_r):
"""Return the vector in the carthesian field of coordinates
"""Return the vector in the cartesian field of coordinates
keyword arguments:
......@@ -316,7 +306,7 @@ class Coordinate_system :
return (Fx,Fy,Fz)
def rotate3D(self, u, v, w):
"""Return the rotated vector data array (u,v). Returned vector will be oriented in the carthesian system
"""Return the rotated vector data array (u,v). Returned vector will be oriented in the cartesian system
keyword arguments:
......
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