Example #1
0
    def test_stokes_circular_conversion(self):
        stokes = numpy.array([1.0, 0.0, 0.0, 0.0])
        circular = convert_stokes_to_circular(stokes)
        assert_array_almost_equal(
            circular, numpy.array([1.0 + 0j, 0.0 + 0j, 0.0 + 0j, 1.0 + 0j]))

        stokes = numpy.array([0.0, 1.0, 0.0, 0.0])
        circular = convert_stokes_to_circular(stokes)
        assert_array_almost_equal(circular,
                                  numpy.array([0.0 + 0j, -1j, -1j, 0.0 + 0j]))

        stokes = numpy.array([0.0, 0.0, 1.0, 0.0])
        circular = convert_stokes_to_circular(stokes)
        assert_array_almost_equal(
            circular, numpy.array([0.0 + 0j, 1.0 + 0j, -1.0 + 0j, 0.0 + 0j]))

        stokes = numpy.array([0.0, 0.0, 0.0, 1.0])
        circular = convert_stokes_to_circular(stokes)
        assert_array_almost_equal(
            circular, numpy.array([1.0 + 0j, +0.0j, 0.0j, -1.0 + 0j]))
def convert_stokes_to_polimage(im: Image, polarisation_frame: PolarisationFrame):
    """Convert a stokes image to polarisation_frame

    """
    
    assert isinstance(im, Image)
    assert isinstance(polarisation_frame, PolarisationFrame)
    
    if polarisation_frame == PolarisationFrame('linear'):
        cimarr = convert_stokes_to_linear(im.data)
        return create_image_from_array(cimarr, im.wcs, polarisation_frame)
    elif polarisation_frame == PolarisationFrame('circular'):
        cimarr = convert_stokes_to_circular(im.data)
        return create_image_from_array(cimarr, im.wcs, polarisation_frame)
    else:
        raise ValueError("Cannot convert stokes to %s" % (polarisation_frame.type))
Example #3
0
 def test_vis_conversion(self):
     stokes = numpy.array(random.uniform(-1.0, 1.0, [1000, 3, 4]))
     cir = convert_stokes_to_circular(stokes, polaxis=2)
     st = convert_circular_to_stokes(cir, polaxis=2)
     assert_array_almost_equal(st.real, stokes, 15)
Example #4
0
 def test_image_conversion(self):
     stokes = numpy.array(random.uniform(-1.0, 1.0, [3, 4, 128, 128]))
     cir = convert_stokes_to_circular(stokes)
     st = convert_circular_to_stokes(cir)
     assert_array_almost_equal(st.real, stokes, 15)
Example #5
0
 def test_stokes_circular_stokes_conversion(self):
     stokes = numpy.array([1, 0.5, 0.2, -0.1])
     circular = convert_stokes_to_circular(stokes)
     assert_array_almost_equal(
         convert_circular_to_stokes(circular).real, stokes, 15)