4 Coordinate transformation functions for DISPATCH2 data. 10 def rtp_to_xyz(r, theta, phi, theta_rotate=0.0, phi_rotate=0.0):
12 Convert 1-D spherical (r, theta, phi) coords. to 3-D Cartesian coords. 13 (x, y, z) for plotting purposes. 15 theta_rotate: rotate the coordinate system in the theta-direction by 16 `theta_rotate`; the default gives a r-coord that overlies 17 the -z-coord when theta=0. 18 phi_rotate: rotate the coordinate system in the phi-direction by 19 `phi_rotate`; the default results in a r-coord that overlies 20 the x-coord when theta = pi/2. 25 rr, tt, pp = np.meshgrid(r, theta, phi, indexing=
'ij')
28 xx = rr * np.sin(tt + theta_rotate) * np.cos(pp + phi_rotate)
29 yy = -rr * np.sin(tt + theta_rotate) * np.sin(pp + phi_rotate)
30 zz = -rr * np.cos(tt + theta_rotate)
34 def zrp_to_xyz(z, r, phi, phi_rotate=0.0):
36 Convert 1-D cylindrical (Z, R, Phi) coords. to 3-D Cartesian coords. 37 (x, y, z) for plotting purposes. 39 phi_rotate: rotate the coordinate system in the phi-direction by 40 'phi_rotate'; the the default gives a R-coord. that overlies 41 the x-coord when phi = 0. 46 ZZ, RR, PP = np.meshgrid(z, r, phi, indexing=
'ij')
49 xx = RR * np.cos(PP + phi_rotate)
50 yy = RR * np.sin(PP + phi_rotate)
55 def rtp_to_zrp(r, theta, phi, theta_rotate=0.0, phi_rotate=0.0):
57 Convert 1-D spherical (r, theta, phi) coords. to 3-D cylindrical coords. 60 theta_rotate: rotate the coordinate system in the theta-direction by 61 `theta_rotate`; the default gives a r-coord that overlies 62 the -z-coord when theta=0. 63 phi_rotate: rotate the coordinate system in the phi-direction by 64 `phi_rotate`; the default results in a r-coord that overlies 65 the R-coord when theta = pi/2. 70 rr, tt, pp = np.meshgrid(r, theta, phi, indexing=
'ij')
73 ZZ = -rr * np.cos(tt + theta_rotate)
74 RR = rr * abs(np.sin(tt + theta_rotate))
79 def zrp_to_rtp(z, r, phi, phi_rotate=0.0):
81 Convert 1-D cylindrical (Z, R, Phi) coords. to 3-D spherical coords. 84 phi_rotate: rotate the coordinate system in the phi-direction by 85 'phi_rotate'; the default gives a R-coord which overlies 86 the r-coord when theta=pi/2. 91 ZZ, RR, PP = np.meshgrid(z, r, phi, indexing=
'ij')
94 rr = np.sqrt(RR**2 + ZZ**2)
95 tt = np.arctan2(RR, ZZ)
100 def xyz_to_zrp(x, y, z):
102 Convert 1-D Cartesian (x, y, z) coords. to 3-D cylindrical coords. 105 The z- and Z-coords. are assumed equivalent. 110 xx, yy, zz = np.meshgrid(x, y, z, indexing=
'ij')
114 RR = np.sqrt(xx**2 + yy**2)
115 PP = np.arctan2(yy, xx)
119 def xyz_to_rtp(x, y, z):
121 Convert 1-D Cartesian (x, y, z) coords. to 3-D spherical coords. 124 The z-coord. is assumed to be anti-parallel to the r-coord. when 130 xx, yy, zz = np.meshgrid(x, y, z, indexing=
'ij')
133 rr = np.sqrt(xx**2 + yy**2 + zz**2)
134 tt = np.arccos(zz / rr)
135 pp = np.arccos(xx / np.sqrt(xx**2 + yy**2))