예제 #1
0
def convertcirculartostokes(vis):
    """Convert circular polarisations (RR, RL, LR, LL) into Stokes parameters.
        
    Args:
    vis (obj): ARL visibility data.
    
    Returns:
    vis: Converted visibility data.
    """
    vis.data['vis'] = convert_circular_to_stokes(vis.data['vis'], polaxis=1)
    vis.polarisation_frame = PolarisationFrame('stokesIQUV')
    return vis
def convert_polimage_to_stokes(im: Image):
    """Convert a polarisation image to stokes (complex)
    
    """
    assert isinstance(im, Image)
    assert im.data.dtype == 'complex'
    
    if im.polarisation_frame == PolarisationFrame('linear'):
        cimarr = convert_linear_to_stokes(im.data)
        return create_image_from_array(cimarr, im.wcs, PolarisationFrame('stokesIQUV'))
    elif im.polarisation_frame == PolarisationFrame('circular'):
        cimarr = convert_circular_to_stokes(im.data)
        return create_image_from_array(cimarr, im.wcs, PolarisationFrame('stokesIQUV'))
    else:
        raise ValueError("Cannot convert %s to stokes" % (im.polarisation_frame.type))
예제 #3
0
def convert_visibility_to_stokes(vis):
    """Convert the polarisation frame data into Stokes parameters.

    Args:
    vis (obj): ARL visibility data.

    Returns:
    vis: Converted visibility data.
    """
    poldef = vis.polarisation_frame
    if poldef == PolarisationFrame('linear'):
        vis.data['vis'] = convert_linear_to_stokes(vis.data['vis'], polaxis=1)
        vis.polarisation_frame = PolarisationFrame('stokesIQUV')
    elif poldef == PolarisationFrame('circular'):
        vis.data['vis'] = convert_circular_to_stokes(vis.data['vis'],
                                                     polaxis=1)
        vis.polarisation_frame = PolarisationFrame('stokesIQUV')
    return vis
예제 #4
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)
예제 #5
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)
예제 #6
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)