mirror of
https://github.com/cdtools-developers/cdtools.git
synced 2026-09-10 05:22:41 +02:00
29 lines
728 B
Python
29 lines
728 B
Python
import numpy as numpy
|
|
import torch as t
|
|
|
|
def polarize_probe_linear(probe, polar_angle):
|
|
"""
|
|
Applies a linear polarizer to the probe
|
|
|
|
Parameters:
|
|
----------
|
|
probe: t.Tensor
|
|
A (...)x2x1xMxL tensor representing the probe
|
|
polar_angle: float
|
|
The angle between the fast-axis of the linear polarizer and the x-axis
|
|
"""
|
|
|
|
polarizer = t.tensor([[(math.cos(theta)) ** 2, math.sin(2 * theta) / 2], [math.sin(2 * theta) / 2, (math.sin(theta)) ** 2]])
|
|
return t.tensordot(polarizer, probe, dims=([-3], [-4]))
|
|
|
|
def apply_jones_matrix(probe, jones_matrix):
|
|
"""
|
|
Applies the given Jones matrix to the probe
|
|
|
|
Parameters:
|
|
----------
|
|
probe: t.Tensor
|
|
A (...)x2x1xMxL tensor representing the probe
|
|
jones_matrix: t.tensor
|
|
2x2
|
|
""" |