workflows/arlexecute/simulation/simulation_arlexecute.py
def calculate_residual_from_gaintables_arlexecute_workflow(sub_bvis_list, sub_components, sub_model_list,
                                                           no_error_gt_list, error_gt_list):
    """Calculate residual image corresponding to a set of gaintables

    The visibility difference for a set of components for error and no error gaintables
    are calculated and the residual images constructed

    :param sub_bvis_list:
    :param sub_components:
    :param sub_model_list:
    :param no_error_gt_list:
    :param error_gt_list:
    :return:
    """
    error_sm_list = [[
        arlexecute.execute(SkyModel, nout=1)(components=[sub_components[i]], gaintable=error_gt_list[ibv][i])
        for i, _ in enumerate(sub_components)] for ibv, bv in enumerate(sub_bvis_list)]
    
    no_error_sm_list = [[
        arlexecute.execute(SkyModel, nout=1)(components=[sub_components[i]], gaintable=no_error_gt_list[ibv][i])
        for i, _ in enumerate(sub_components)] for ibv, bv in enumerate(sub_bvis_list)]
    
    # Predict each visibility for each skymodel. We keep all the visibilities separate
    # and add up dirty images at the end of processing. We calibrate which applies the voltage pattern
    no_error_bvis_list = [arlexecute.execute(copy_visibility, nout=1)(bvis, zero=True) for bvis in sub_bvis_list]
    no_error_bvis_list = [
        predict_skymodel_list_compsonly_arlexecute_workflow(no_error_bvis_list[ibv], no_error_sm_list[ibv],
                                                            context='2d', docal=True)
        for ibv, bvis in enumerate(no_error_bvis_list)]
    
    error_bvis_list = [arlexecute.execute(copy_visibility, nout=1)(bvis, zero=True) for bvis in sub_bvis_list]
    error_bvis_list = [predict_skymodel_list_compsonly_arlexecute_workflow(error_bvis_list[ibv], error_sm_list[ibv],
                                                                           context='2d', docal=True)
                       for ibv, bvis in enumerate(error_bvis_list)]
    
    # Inner nest is bvis per skymodels, outer is over vis's. Calculate residual visibility
    def subtract_vis_convert(error_bvis, no_error_bvis):
        error_bvis.data['vis'] = error_bvis.data['vis'] - no_error_bvis.data['vis']
        error_vis = convert_blockvisibility_to_visibility(error_bvis)
        return error_vis
    
    error_vis_list = [[arlexecute.execute(subtract_vis_convert)(error_bvis_list[ibvis][icomp],
                                                                no_error_bvis_list[ibvis][icomp])
                       for icomp, _ in enumerate(sub_components)]
                      for ibvis, _ in enumerate(error_bvis_list)]
    
    # Now for each visibility/component, we make the component dirty images. We just add these
    # component dirty images since the weights should be the same
    def sum_images(images):
        sum_image = create_empty_image_like(images[0][0])
        for im in images:
            sum_image.data += im[0].data
        return sum_image, images[0][1]
    
    dirty_list = list()
    for vis in error_vis_list:
        result = invert_list_arlexecute_workflow(vis, sub_model_list, '2d')
        dirty_list.append(arlexecute.execute(sum_images)(result))
    
    return dirty_list
Calculate residual image corresponding to a set of gaintables

    The visibility difference for a set of components for error and no error gaintables
    are calculated and the residual images constructed

    :param sub_bvis_list:
    :param sub_components:
    :param sub_model_list:
    :param no_error_gt_list:
    :param error_gt_list:
    :return:
    
Calculate residual image corresponding to a set of gaintables
The visibility difference for a set of components for error and no error gaintables
are calculated and the residual images constructed
Calculate residual image corresponding to a set of gaintables The visibility difference for a set of components for error and no error gaintables are calculated and the residual images constructed
def calculate_residual_from_gaintables_arlexecute_workflow(sub_bvis_list, sub_components, sub_model_list,
                                                           no_error_gt_list, error_gt_list):
    error_sm_list = [[
        arlexecute.execute(SkyModel, nout=1)(components=[sub_components[i]], gaintable=error_gt_list[ibv][i])
        for i, _ in enumerate(sub_components)] for ibv, bv in enumerate(sub_bvis_list)]
    no_error_sm_list = [[
        arlexecute.execute(SkyModel, nout=1)(components=[sub_components[i]], gaintable=no_error_gt_list[ibv][i])
        for i, _ in enumerate(sub_components)] for ibv, bv in enumerate(sub_bvis_list)]
    no_error_bvis_list = [arlexecute.execute(copy_visibility, nout=1)(bvis, zero=True) for bvis in sub_bvis_list]
    no_error_bvis_list = [
        predict_skymodel_list_compsonly_arlexecute_workflow(no_error_bvis_list[ibv], no_error_sm_list[ibv],
                                                            context='2d', docal=True)
        for ibv, bvis in enumerate(no_error_bvis_list)]
    error_bvis_list = [arlexecute.execute(copy_visibility, nout=1)(bvis, zero=True) for bvis in sub_bvis_list]
    error_bvis_list = [predict_skymodel_list_compsonly_arlexecute_workflow(error_bvis_list[ibv], error_sm_list[ibv],
                                                                           context='2d', docal=True)
                       for ibv, bvis in enumerate(error_bvis_list)]
    def subtract_vis_convert(error_bvis, no_error_bvis):
        error_bvis.data['vis'] = error_bvis.data['vis'] - no_error_bvis.data['vis']
        error_vis = convert_blockvisibility_to_visibility(error_bvis)
        return error_vis
    error_vis_list = [[arlexecute.execute(subtract_vis_convert)(error_bvis_list[ibvis][icomp],
                                                                no_error_bvis_list[ibvis][icomp])
                       for icomp, _ in enumerate(sub_components)]
                      for ibvis, _ in enumerate(error_bvis_list)]
    def sum_images(images):
        sum_image = create_empty_image_like(images[0][0])
        for im in images:
            sum_image.data += im[0].data
        return sum_image, images[0][1]
    dirty_list = list()
    for vis in error_vis_list:
        result = invert_list_arlexecute_workflow(vis, sub_model_list, '2d')
        dirty_list.append(arlexecute.execute(sum_images)(result))
    return dirty_list
def calculate_residual_from_gaintables_arlexecute_workflow ( sub_bvis_list , sub_components , sub_model_list , no_error_gt_list , error_gt_list ) : error_sm_list = [ [ arlexecute . execute ( SkyModel , nout = 1 ) ( components = [ sub_components [ i ] ] , gaintable = error_gt_list [ ibv ] [ i ] ) for i , _ in enumerate ( sub_components ) ] for ibv , bv in enumerate ( sub_bvis_list ) ] no_error_sm_list = [ [ arlexecute . execute ( SkyModel , nout = 1 ) ( components = [ sub_components [ i ] ] , gaintable = no_error_gt_list [ ibv ] [ i ] ) for i , _ in enumerate ( sub_components ) ] for ibv , bv in enumerate ( sub_bvis_list ) ] no_error_bvis_list = [ arlexecute . execute ( copy_visibility , nout = 1 ) ( bvis , zero = True ) for bvis in sub_bvis_list ] no_error_bvis_list = [ predict_skymodel_list_compsonly_arlexecute_workflow ( no_error_bvis_list [ ibv ] , no_error_sm_list [ ibv ] , context = '2d' , docal = True ) for ibv , bvis in enumerate ( no_error_bvis_list ) ] error_bvis_list = [ arlexecute . execute ( copy_visibility , nout = 1 ) ( bvis , zero = True ) for bvis in sub_bvis_list ] error_bvis_list = [ predict_skymodel_list_compsonly_arlexecute_workflow ( error_bvis_list [ ibv ] , error_sm_list [ ibv ] , context = '2d' , docal = True ) for ibv , bvis in enumerate ( error_bvis_list ) ] def subtract_vis_convert ( error_bvis , no_error_bvis ) : error_bvis . data [ 'vis' ] = error_bvis . data [ 'vis' ] - no_error_bvis . data [ 'vis' ] error_vis = convert_blockvisibility_to_visibility ( error_bvis ) return error_vis error_vis_list = [ [ arlexecute . execute ( subtract_vis_convert ) ( error_bvis_list [ ibvis ] [ icomp ] , no_error_bvis_list [ ibvis ] [ icomp ] ) for icomp , _ in enumerate ( sub_components ) ] for ibvis , _ in enumerate ( error_bvis_list ) ] def sum_images ( images ) : sum_image = create_empty_image_like ( images [ 0 ] [ 0 ] ) for im in images : sum_image . data += im [ 0 ] . data return sum_image , images [ 0 ] [ 1 ] dirty_list = list ( ) for vis in error_vis_list : result = invert_list_arlexecute_workflow ( vis , sub_model_list , '2d' ) dirty_list . append ( arlexecute . execute ( sum_images ) ( result ) ) return dirty_list
Calculate residual image corresponding to a set of gaintables
The visibility difference for a set of components for error and no error gaintables
are calculated and the residual images constructed
Calculate residual image corresponding to a set of gaintables The visibility difference for a set of components for error and no error gaintables are calculated and the residual images constructed
"""Calculate residual image corresponding to a set of gaintables

    The visibility difference for a set of components for error and no error gaintables
    are calculated and the residual images constructed

    :param sub_bvis_list:
    :param sub_components:
    :param sub_model_list:
    :param no_error_gt_list:
    :param error_gt_list:
    :return:
    """ # Predict each visibility for each skymodel. We keep all the visibilities separate # and add up dirty images at the end of processing. We calibrate which applies the voltage pattern # Inner nest is bvis per skymodels, outer is over vis's. Calculate residual visibility # Now for each visibility/component, we make the component dirty images. We just add these # component dirty images since the weights should be the same
None
sub_bvis_list
None
sub_components
None
sub_model_list
None
no_error_gt_list
None
error_gt_list
None