Skip to content
Snippets Groups Projects
Commit f646ea75 authored by Vishal Johnson's avatar Vishal Johnson
Browse files

Update response.py, added tests and corrected the matrices

parent 60aba6d4
No related branches found
No related tags found
1 merge request!48Polarization response
Pipeline #205865 failed
...@@ -19,16 +19,20 @@ def get_binbounds(coordinates): ...@@ -19,16 +19,20 @@ def get_binbounds(coordinates):
def convert_polarization(inp, inp_pol, out_pol): def convert_polarization(inp, inp_pol, out_pol):
mat_stokes_to_circular = jnp.array( mat_stokes_to_circular = jnp.array([[1,0,0,1],
[[1, 0, 0, 1], [0, 1, 1j, 0], [0, 1, -1j, 0], [1, 0, 0, -1]] [0,1,1,0],
) [0,1j,-1j,0],
mat_stokes_to_linear = jnp.array( [1,0,0,-1]])
[[1, 1, 0, 0], [1, -1, 0, 0], [0, 0, 1, 1j], [0, 0, 1, -1j]] mat_stokes_to_linear = jnp.array([[1,1,0,0],
) [1,-1,0,0],
if set(inp_pol) == {"I", "Q", "U", "V"}: [0,0,1,1],
if set(out_pol) == {"RR", "RL", "LR", "LL"}: [0,0,1j,-1j]])
if inp_pol == ('I', 'Q', 'U', 'V'):
if jnp.any(inp[0]**2 < inp[1]**2 + inp[2]**2 + inp[3]**2) or jnp.any(inp[0]) <= 0:
raise ValueError('Values for Stokes parameters are inconsistent.')
if out_pol == ('RR', 'RL', 'LR', 'LL'):
return jnp.tensordot(mat_stokes_to_circular, inp, axes=([0],[0])) return jnp.tensordot(mat_stokes_to_circular, inp, axes=([0],[0]))
elif set(out_pol) == {"XX", "XY", "YX", "YY"}: elif out_pol == ('XX', 'XY', 'YX', 'YY'):
return jnp.tensordot(mat_stokes_to_linear, inp, axes=([0],[0])) return jnp.tensordot(mat_stokes_to_linear, inp, axes=([0],[0]))
elif inp_pol == ("I",): elif inp_pol == ("I",):
if out_pol == ("LL", "RR") or out_pol == ("XX", "YY"): if out_pol == ("LL", "RR") or out_pol == ("XX", "YY"):
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment