Coordinate Transforms Module#
The coordinates module provides functions for converting between various coordinate systems used in antenna and radar applications, including antenna coordinates, radar coordinates, cone/clock coordinates, and rotation matrices for pattern rotation.
Antenna and Radar Coordinates#
Functions for converting between antenna (theta/phi) and radar (az/el) coordinate systems.
- phased_array.antenna_to_radar(theta_ant, phi_ant)[source]#
Convert antenna coordinates (theta/phi) to radar coordinates (az/el).
- Antenna coordinates:
theta: angle from boresight (z-axis), 0 at boresight
phi: azimuthal angle in x-y plane, 0 along x-axis
- Radar coordinates:
az: azimuth in horizontal plane, 0 at boresight
el: elevation from horizon, 0 at horizon, positive up
- Parameters:
theta_ant (
array_like) – Theta angle in radians (from boresight)phi_ant (
array_like) – Phi angle in radians (azimuthal)
- Returns:
az (
ndarray) – Azimuth angle in radiansel (
ndarray) – Elevation angle in radians
- Return type:
Examples
Boresight in antenna coords is also boresight in radar:
>>> import numpy as np >>> import phased_array as pa >>> az, el = pa.antenna_to_radar(0.0, 0.0) >>> np.isclose(az, 0.0) and np.isclose(el, np.pi/2) True
Off-boresight conversion:
>>> az, el = pa.antenna_to_radar(np.pi/6, 0.0) # 30 deg in x-z plane >>> np.isclose(np.rad2deg(az), 0.0, atol=1e-10) True
- phased_array.radar_to_antenna(az, el)[source]#
Convert radar coordinates (az/el) to antenna coordinates (theta/phi).
- Parameters:
az (
array_like) – Azimuth angle in radiansel (
array_like) – Elevation angle in radians (from horizon)
- Returns:
theta (
ndarray) – Theta angle in radians (from boresight)phi (
ndarray) – Phi angle in radians (azimuthal)
- Return type:
Examples
>>> import numpy as np >>> import phased_array as pa >>> theta, phi = pa.radar_to_antenna(0.0, np.pi/2) # Boresight >>> np.isclose(theta, 0.0, atol=1e-10) True
Round-trip conversion:
>>> theta_orig, phi_orig = np.pi/4, np.pi/3 >>> az, el = pa.antenna_to_radar(theta_orig, phi_orig) >>> theta, phi = pa.radar_to_antenna(az, el) >>> np.isclose(theta, theta_orig, atol=1e-10) True
Cone/Clock Coordinates#
Cone/clock coordinates are useful for describing patterns on aircraft radomes or for visualizing scan limits.
- phased_array.antenna_to_cone(theta, phi)[source]#
Convert antenna coordinates (theta/phi) to cone/clock coordinates.
Cone/clock coordinates are useful for describing patterns on aircraft radomes or for visualizing scan limits.
- Parameters:
theta (
array_like) – Theta angle in radians (from boresight)phi (
array_like) – Phi angle in radians (azimuthal)
- Returns:
cone (
ndarray) – Cone angle in radians (distance from boresight, same as theta)clock (
ndarray) – Clock angle in radians (azimuthal position, same as phi)
- Return type:
Examples
>>> import numpy as np >>> import phased_array as pa >>> cone, clock = pa.antenna_to_cone(np.pi/6, np.pi/4) >>> np.isclose(cone, np.pi/6) and np.isclose(clock, np.pi/4) True
- phased_array.cone_to_antenna(cone, clock)[source]#
Convert cone/clock coordinates to antenna coordinates (theta/phi).
- Parameters:
cone (
array_like) – Cone angle in radiansclock (
array_like) – Clock angle in radians
- Returns:
theta (
ndarray) – Theta angle in radiansphi (
ndarray) – Phi angle in radians
- Return type:
Examples
>>> import numpy as np >>> import phased_array as pa >>> theta, phi = pa.cone_to_antenna(np.pi/6, np.pi/4) >>> np.isclose(theta, np.pi/6) and np.isclose(phi, np.pi/4) True
Rotation Matrices#
3x3 rotation matrices for transforming coordinate systems using aircraft-style roll, pitch, and yaw angles.
- phased_array.rotation_matrix_roll(angle)[source]#
Create 3x3 rotation matrix for roll (rotation about x-axis).
- Parameters:
angle (
float) – Roll angle in radians (positive = right wing down)- Returns:
R – 3x3 rotation matrix
- Return type:
ndarray
Examples
>>> import numpy as np >>> import phased_array as pa >>> R = pa.rotation_matrix_roll(0.0) >>> np.allclose(R, np.eye(3)) True
90 degree roll:
>>> R = pa.rotation_matrix_roll(np.pi/2) >>> v = np.array([0, 1, 0]) # y-axis >>> v_rot = R @ v >>> np.allclose(v_rot, [0, 0, 1], atol=1e-10) # Rotates to z-axis True
- phased_array.rotation_matrix_pitch(angle)[source]#
Create 3x3 rotation matrix for pitch (rotation about y-axis).
- Parameters:
angle (
float) – Pitch angle in radians (positive = nose up)- Returns:
R – 3x3 rotation matrix
- Return type:
ndarray
Examples
>>> import numpy as np >>> import phased_array as pa >>> R = pa.rotation_matrix_pitch(0.0) >>> np.allclose(R, np.eye(3)) True
90 degree pitch:
>>> R = pa.rotation_matrix_pitch(np.pi/2) >>> v = np.array([0, 0, 1]) # z-axis (boresight) >>> v_rot = R @ v >>> np.allclose(v_rot, [1, 0, 0], atol=1e-10) # Rotates to x-axis True
- phased_array.rotation_matrix_yaw(angle)[source]#
Create 3x3 rotation matrix for yaw (rotation about z-axis).
- Parameters:
angle (
float) – Yaw angle in radians (positive = nose left)- Returns:
R – 3x3 rotation matrix
- Return type:
ndarray
Examples
>>> import numpy as np >>> import phased_array as pa >>> R = pa.rotation_matrix_yaw(0.0) >>> np.allclose(R, np.eye(3)) True
90 degree yaw:
>>> R = pa.rotation_matrix_yaw(np.pi/2) >>> v = np.array([1, 0, 0]) # x-axis >>> v_rot = R @ v >>> np.allclose(v_rot, [0, 1, 0], atol=1e-10) # Rotates to y-axis True
Pattern Rotation#
Functions for rotating radiation patterns in 3D space.
- phased_array.rotate_pattern(theta, phi, pattern, roll_deg, pitch_deg, yaw_deg)[source]#
Rotate a radiation pattern by specified Euler angles.
The rotation order is: yaw -> pitch -> roll (intrinsic rotations), which corresponds to standard aerospace convention.
- Parameters:
theta (
ndarray) – Original theta angles in radians (1D or 2D grid)phi (
ndarray) – Original phi angles in radians (same shape as theta)pattern (
ndarray) – Pattern values (complex or magnitude, same shape as theta)roll_deg (
float) – Roll angle in degreespitch_deg (
float) – Pitch angle in degreesyaw_deg (
float) – Yaw angle in degrees
- Returns:
theta_new (
ndarray) – New theta coordinates after rotationphi_new (
ndarray) – New phi coordinates after rotationpattern_interp (
ndarray) – Pattern values interpolated onto the new grid
- Return type:
Examples
Rotate pattern by 30 degrees in yaw:
>>> import numpy as np >>> import phased_array as pa >>> theta = np.linspace(0, np.pi/2, 46) >>> phi = np.linspace(0, 2*np.pi, 73) >>> theta_grid, phi_grid = np.meshgrid(theta, phi, indexing='ij') >>> pattern = np.cos(theta_grid) # Simple cosine pattern >>> theta_r, phi_r, pattern_r = pa.rotate_pattern( ... theta_grid, phi_grid, pattern, ... roll_deg=0, pitch_deg=0, yaw_deg=30 ... ) >>> pattern_r.shape == pattern.shape True
Notes
For points that rotate outside the original grid, extrapolation may produce artifacts. Consider padding the original pattern.