Skip to content

Commit 7a507b9

Browse files
committed
wip
1 parent 3462b71 commit 7a507b9

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/mokka/channels/torch.py

+25
Original file line numberDiff line numberDiff line change
@@ -1530,9 +1530,15 @@ def __init__(
15301530
theta=True,
15311531
phi=True,
15321532
psi=True,
1533+
pmd_sigma=None,
15331534
):
15341535
super(PMDAngleElement, self).__init__()
15351536
# angles are theta, phi, psi
1537+
if pmd_sigma is None:
1538+
self.pmd_sigma = 0.0
1539+
else:
1540+
self.pmd_sigma = pmd_sigma
1541+
self.theta, self.phi, self.psi = theta, phi, psi
15361542
if angles is None:
15371543
angles = torch.zeros((3,), dtype=torch.float)
15381544
# torch.nn.init.uniform_(angles, -torch.pi, torch.pi)
@@ -1586,6 +1592,25 @@ def J_k1(self):
15861592
def forward(self, signal):
15871593
return torch.matmul(self.J_k1, signal)
15881594

1595+
def step(self):
1596+
if self.pmd_sigma == 0.0:
1597+
return self.J_k1
1598+
if self.theta:
1599+
self.angles[0] = (
1600+
self.angles[0]
1601+
+ torch.zeros((), dtype=torch.float32).normal_() * self.pmd_sigma
1602+
)
1603+
if self.phi:
1604+
self.angles[1] = (
1605+
self.angles[1]
1606+
+ torch.zeros((), dtype=torch.float32).normal_() * self.pmd_sigma
1607+
)
1608+
if self.psi:
1609+
self.angles[2] = (
1610+
self.angles[2]
1611+
+ torch.zeros((), dtype=torch.float32).normal_() * self.pmd_sigma
1612+
)
1613+
15891614

15901615
class FixedChannelDP(torch.nn.Module):
15911616
"""Apply a fixed channel impulse response on both polarization separately."""

0 commit comments

Comments
 (0)