"""
Utility functions for Stokes parameter calculations.
This module provides functions to compute polarization properties
from Stokes Q and U parameters.
"""
import numpy
[docs]
def get_polarization_angle(q, u):
"""
Calculate the polarization angle from Stokes Q and U parameters.
The polarization angle is defined as:
PA = 0.5 * arctan2(U, Q)
Parameters
----------
q : float or array-like
Stokes Q parameter (normalized by I)
u : float or array-like
Stokes U parameter (normalized by I)
Returns
-------
float or numpy.ndarray
Polarization angle in degrees, ranging from -90 to +90 degrees
Notes
-----
The polarization angle is measured from north through east (IAU convention).
The factor of 0.5 comes from the fact that Stokes parameters are quadratic
in the electric field components.
Examples
--------
>>> get_polarization_angle(0.1, 0.0)
0.0
>>> get_polarization_angle(0.0, 0.1)
45.0
"""
return 0.5 * numpy.degrees(numpy.arctan2(u, q))
[docs]
def get_polarization_degree(q, u):
"""
Calculate the polarization degree from Stokes Q and U parameters.
The polarization degree is defined as:
PD = sqrt(Q^2 + U^2)
Parameters
----------
q : float or array-like
Stokes Q parameter (normalized by I)
u : float or array-like
Stokes U parameter (normalized by I)
Returns
-------
float or numpy.ndarray
Polarization degree (fractional), ranging from 0 to 1
Notes
-----
The polarization degree represents the fraction of polarized intensity
relative to the total intensity. For completely unpolarized radiation,
PD = 0, while for completely polarized radiation, PD = 1.
Examples
--------
>>> get_polarization_degree(0.3, 0.4)
0.5
>>> get_polarization_degree(0.0, 0.0)
0.0
"""
return numpy.sqrt(q**2 + u**2)