corgidrp.pol#
Functions#
|
Perform aperture photometry on both channels of a 2-channel polarimetric image. |
|
Compute uncalibrated Stokes parameters (I, Q/I, U/I) from unocculted L3 polarimetric datacubes. |
|
Calculates the Mueller Matrix calibration for a given dataset of polarimetric observations. |
|
Convert either the degree of polarization and polarization angle to normalized Stokes q (Q/I) and u (U/I), |
|
Measure the normalized difference for a single CorgiDRP pol Image. |
|
constructs a rotation matrix from a given angle |
|
constructs a linear polarizer matrix from a given angle |
Module Contents#
- corgidrp.pol.aper_phot_pol(image, phot_kwargs)[source]#
Perform aperture photometry on both channels of a 2-channel polarimetric image.
Each input image contains two orthogonally polarized beams (e.g., ordinary and extraordinary). This function measures the flux and its uncertainty in both channels using aperture photometry.
- Parameters:
image (Image) – Polarimetric Image object with shape (2, ny, nx). Must contain data, err, and dq attributes.
phot_kwargs (dict) – Keyword arguments passed to aper_phot, defining aperture radius, centering method, background subtraction, etc.
- Returns:
(flux, flux_err) lists of fluxes and uncertainties for both polarization channels.
- Return type:
tuple[list, list]
- corgidrp.pol.calc_stokes_unocculted(input_dataset, phot_kwargs=None, image_center_x=None, image_center_y=None, split_pa_states=True, pa_tolerance=0.1)[source]#
Compute uncalibrated Stokes parameters (I, Q/I, U/I) from unocculted L3 polarimetric datacubes.
Each element in dataset represents a single observation taken with a specific Wollaston prism (e.g., POL0 or POL45), which splits the incoming light into two orthogonally polarized beams. This function performs aperture photometry on each beam and computes the corresponding Stokes parameters in the instrument frame.
- Parameters:
input_dataset (corgidrp.data.Dataset) – A corgidrp dataset of L3 polarimetric images
phot_kwargs (dict, optional) – Keyword arguments passed to aper_phot. If not provided, a default aperture setup is used.
image_center_x (float, optional) – X-coordinate of the aperture center in pixels. Default is None. If None, assume the center of the array is a good guess.
image_center_y (float, optional) – Y-coordinate of the aperture center in pixels. Default is None. If None, assume the center of the array is a good guess.
split_pa_states (bool, optional) – If True, split the input dataset by both target and PA_APER. If False, split only by target. Default is True.
pa_tolerance (float, optional) – Maximum allowed difference in PA_APER (deg) to group frames together when split_pa_states is True. Default is 0.1.
- Returns:
A corgidrp.data.Image instance containing: - data (ndarray, shape=(3,)): [I, Q/I, U/I] - err (ndarray, shape=(3,)): propagated uncertainties - dq (ndarray, shape=(3,)): data quality flags (zeros) - FITS headers (pri_hdr, ext_hdr, err_hdr, dq_hdr) propagated from the first input image.
- Return type:
- Raises:
ValueError – If an input image contains an unrecognized prism name in ‘DPAMNAME’.
- corgidrp.pol.generate_mueller_matrix_cal(input_dataset, path_to_pol_ref_file=None, svd_threshold=1e-05)[source]#
Calculates the Mueller Matrix calibration for a given dataset of polarimetric observations. The expected input is a dataset of stokes vectors measured from known polarized standard stars, separated by target and PA_APER angle. The function reads in a polarization reference file containing the known polarization properties of the targets, and uses these to calculate the Mueller Matrix elements via SVD inversion.
The pol reference file should contain the known polarization properties of the targets in the dataset. It should be a csv file with the following columns: TARGET, P, P_err, PA, PA_err where TARGET is the name of the target, P is the degree of polarization in percent, P_err is the error in the degree of polarization in percent, PA is the polarization angle in degrees, and PA_err is the error in the polarization angle in degrees.
The error calculation propagates both the photometric measurement noise on the observed Stokes vectors and the uncertainties in the reference star polarization fraction and angle (P_err, PA_err from the reference file), combined in quadrature.
- Parameters:
input_dataset (corgidrp.data.Dataset) – A CorgiDRP dataset consisting of stokes vectors. This data should be either all ND datasets or all non-ND datasets.
path_to_pol_ref_file (str) – The path to the polarization reference file. Default is “./data/stellar_polarization_database.csv”.
svd_threshold (float, optional) – The threshold for singular values in the SVD inversion. Defaults to 1e-5 (semi-arbitrary).
- Returns:
The generated Mueller Matrix object.
- Return type:
mueller_matrix_obj (MuellerMatrix or NDMuellerMatrix)
- corgidrp.pol.get_qu_from_p_theta(p, theta)[source]#
Convert either the degree of polarization and polarization angle to normalized Stokes q (Q/I) and u (U/I), or the polarized intensity (P) and angle (PA) into Stokes Q and U intensities.
Convert polarization and angle into Stokes Q and U components.
This function can operate in two distinct modes depending on the nature of p:
Normalized Stokes: - p represents the degree of polarization (fractional, 0–1, not percent). - Returns the normalized Stokes parameters (q = Q/I, u = U/I), i.e. unitless ratios.
Absolute mode: - p represents the polarized intensity P (same units as total intensity I). - Returns the absolute Stokes intensities Q and U (in the same units as p).
- Parameters:
p (float) – Either the fractional degree of polarization (0–1) or polarized intensity P.
theta (float) – Polarization angle in degrees.
- Returns:
(Q, U) Stokes parameters, either normalized (q,u) or absolute (Q,U) depending on the meaning of p.
- Return type:
tuple
Example
>>> get_qu_from_p_theta(0.05, 30) # 5% polarization (as fraction) >>> get_qu_from_p_theta(5, 30) # polarized intensity = 5 (arbitrary intensity units)
- corgidrp.pol.measure_normalized_difference_L2b(input_pol_Image, image_center_x=512, image_center_y=512, separation_diameter_arcsec=7.5, alignment_angle=None, phot_kwargs=None)[source]#
Measure the normalized difference for a single CorgiDRP pol Image. The normalized difference is defined as (I0 - I90) / (I0 + I90) for Q, and (I45 - I135) / (I45 + I135) for U.
- Parameters:
input_pol_Image (CorgiDRP Image) – A CorgiDRP Image object that has been processed through the pol pipeline. It should have the FPAMNAME keyword in the header to identify the polarization angle.
image_center_x (int, optional) – The x-coordinate of the image center. Defaults to 512.
image_center_y (int, optional) – The y-coordinate of the image center. Defaults to 512.
separation_diameter_arcsec (float, optional) – The separation in arcseconds between the center of the two FOVs. Defaults to 7.5 arcseconds.
alignment_angle (float, optional) – The alignment angle of the Wollaston prism in degrees. This is used to determine which polarization state is being measured (e.g., 0 for POL0, 45 for POL45). If None, the function will attempt to determine the angle from the DPAMNAME keyword in the header.
phot_kwargs (dict) – A dictionary of keyword arguments to pass to the aperture photometry function. See the documentation for the fluxcal.calibrate_fluxcal_aper function for more details.
- Returns:
The measured normalized difference. error (float): The error in the normalized difference.
- Return type:
normalized_difference (float)