Utilities
vectorwaves.utils
Utility Functions
Miscellaneous helper functions for calculating optical properties, polarization ellipses, and basis transformations.
decompose_in_basis(E1, E2, u)
Decomposes a 2-component complex field (E1, E2) into an orthonormal
polarization basis defined by the reference vector u.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
E1
|
ndarray
|
Complex arrays representing the field in the original basis. |
required |
E2
|
ndarray
|
Complex arrays representing the field in the original basis. |
required |
u
|
tuple or ndarray
|
Reference vector (2,) defining the first new basis vector (in the same plane). |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Contains the new basis vectors and the projected field components: {'u_hat': array, 'v_hat': array, 'E_u': array, 'E_v': array} |
Source code in src\vectorwaves\utils.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
get_pol_ellipse_params(E1, E2)
Calculates the geometric properties of the polarization ellipse formed by two orthogonal electric field components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
E1
|
ndarray
|
Complex electric field components of the same shape. |
required |
E2
|
ndarray
|
Complex electric field components of the same shape. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary containing arrays of the same shape as inputs: - 'psi': Orientation angle in[-pi/2, pi/2] - 'chi': Ellipticity angle in [-pi/4, pi/4] - 'delta': Phase difference (phi_2 - phi_1) in range [-pi, pi] - 'a': Semi-major axis length (normalized to local intensity) - 'b': Semi-minor axis length (normalized to local intensity) - 'handedness': +1 for LCP/CCW, -1 for RCP/CW (based on S3 sign) |
Source code in src\vectorwaves\utils.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
get_stokes_params(E1, E2, normalize=False)
Computes Stokes parameters from two orthogonal electric field components.
For a beam propagating along the Z-axis, you can pass FieldResult.E[0] (Ex)
and FieldResult.E[1] (Ey) to calculate the transverse Stokes parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
E1
|
ndarray
|
Complex electric field components of the same shape. |
required |
E2
|
ndarray
|
Complex electric field components of the same shape. |
required |
normalize
|
bool
|
If True, returns the normalized Stokes parameters (s1, s2, s3) where s_i = S_i / S0. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
|
Source code in src\vectorwaves\utils.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |