workflows/arlexecute/imaging/imaging_arlexecute.py
def predict_list_arlexecute_workflow(vis_list, model_imagelist, context, vis_slices=1, facets=1,
                                     gcfcf=None, **kwargs):
    """Predict, iterating over both the scattered vis_list and image
    
    The visibility and image are scattered, the visibility is predicted on each part, and then the
    parts are assembled.

    :param vis_list:
    :param model_imagelist: Model used to determine image parameters
    :param vis_slices: Number of vis slices (w stack or timeslice)
    :param facets: Number of facets (per axis)
    :param context: Type of processing e.g. 2d, wstack, timeslice or facets
    :param gcfcg: tuple containing grid correction and convolution function
    :param kwargs: Parameters for functions in components
    :return: List of vis_lists
   """
    if get_parameter(kwargs, "use_serial_predict", False):
        from workflows.serial.imaging.imaging_serial import predict_list_serial_workflow
        return [arlexecute.execute(predict_list_serial_workflow, nout=1) \
                    (vis_list=[vis_list[i]],
                     model_imagelist=[model_imagelist[i]], vis_slices=vis_slices,
                     facets=facets, context=context, gcfcf=gcfcf, **kwargs)[0]
                for i, _ in enumerate(vis_list)]
    
    # Predict_2d does not clear the vis so we have to do it here.
    vis_list = zero_list_arlexecute_workflow(vis_list)
    
    c = imaging_context(context)
    vis_iter = c['vis_iterator']
    predict = c['predict']
    
    if facets % 2 == 0 or facets == 1:
        actual_number_facets = facets
    else:
        actual_number_facets = facets - 1
    
    def predict_ignore_none(vis, model, g):
        if vis is not None:
            assert isinstance(vis, Visibility) or isinstance(vis, BlockVisibility), vis
            assert isinstance(model, Image), model
            return predict(vis, model, context=context, gcfcf=g, **kwargs)
        else:
            return None
    
    if gcfcf is None:
        gcfcf = [arlexecute.execute(create_pswf_convolutionfunction)(m) for m in model_imagelist]
    
    # Loop over all frequency windows
    if facets == 1:
        image_results_list = list()
        for ivis, subvis in enumerate(vis_list):
            if len(gcfcf) > 1:
                g = gcfcf[ivis]
            else:
                g = gcfcf[0]
            # Create the graph to divide the visibility into slices. This is by copy.
            sub_vis_lists = arlexecute.execute(visibility_scatter, nout=vis_slices)(subvis,
                                                                                    vis_iter, vis_slices)
            
            image_vis_lists = list()
            # Loop over sub visibility
            for sub_vis_list in sub_vis_lists:
                # Predict visibility for this sub-visibility from this image
                image_vis_list = arlexecute.execute(predict_ignore_none, pure=True, nout=1) \
                    (sub_vis_list, model_imagelist[ivis], g)
                # Sum all sub-visibilities
                image_vis_lists.append(image_vis_list)
            image_results_list.append(arlexecute.execute(visibility_gather, nout=1)
                                      (image_vis_lists, subvis, vis_iter))
        
        result = image_results_list
    else:
        image_results_list_list = list()
        for ivis, subvis in enumerate(vis_list):
            # Create the graph to divide an image into facets. This is by reference.
            facet_lists = arlexecute.execute(image_scatter_facets, nout=actual_number_facets ** 2)(
                model_imagelist[ivis],
                facets=facets)
            # Create the graph to divide the visibility into slices. This is by copy.
            sub_vis_lists = arlexecute.execute(visibility_scatter, nout=vis_slices)\
                (subvis, vis_iter, vis_slices)
            
            facet_vis_lists = list()
            # Loop over sub visibility
            for sub_vis_list in sub_vis_lists:
                facet_vis_results = list()
                # Loop over facets
                for facet_list in facet_lists:
                    # Predict visibility for this subvisibility from this facet
                    facet_vis_list = arlexecute.execute(predict_ignore_none, pure=True, nout=1)\
                        (sub_vis_list, facet_list, None)
                    facet_vis_results.append(facet_vis_list)
                # Sum the current sub-visibility over all facets
                facet_vis_lists.append(arlexecute.execute(sum_predict_results)(facet_vis_results))
            # Sum all sub-visibilities
            image_results_list_list.append(
                arlexecute.execute(visibility_gather, nout=1)(facet_vis_lists, subvis, vis_iter))
        
        result = image_results_list_list
    return arlexecute.optimize(result)
Predict, iterating over both the scattered vis_list and image
    
    The visibility and image are scattered, the visibility is predicted on each part, and then the
    parts are assembled.

    :param vis_list:
    :param model_imagelist: Model used to determine image parameters
    :param vis_slices: Number of vis slices (w stack or timeslice)
    :param facets: Number of facets (per axis)
    :param context: Type of processing e.g. 2d, wstack, timeslice or facets
    :param gcfcg: tuple containing grid correction and convolution function
    :param kwargs: Parameters for functions in components
    :return: List of vis_lists
   
Predict, iterating over both the scattered vis_list and image
The visibility and image are scattered, the visibility is predicted on each part, and then the
parts are assembled.
Predict iterating over both the scattered vis_list and image The visibility and image are scattered the visibility is predicted on each part and then the parts are assembled .
def predict_list_arlexecute_workflow(vis_list, model_imagelist, context, vis_slices=1, facets=1,
                                     gcfcf=None, **kwargs):
    if get_parameter(kwargs, "use_serial_predict", False):
        from workflows.serial.imaging.imaging_serial import predict_list_serial_workflow
        return [arlexecute.execute(predict_list_serial_workflow, nout=1) \
                    (vis_list=[vis_list[i]],
                     model_imagelist=[model_imagelist[i]], vis_slices=vis_slices,
                     facets=facets, context=context, gcfcf=gcfcf, **kwargs)[0]
                for i, _ in enumerate(vis_list)]
    vis_list = zero_list_arlexecute_workflow(vis_list)
    c = imaging_context(context)
    vis_iter = c['vis_iterator']
    predict = c['predict']
    if facets % 2 == 0 or facets == 1:
        actual_number_facets = facets
    else:
        actual_number_facets = facets - 1
    def predict_ignore_none(vis, model, g):
        if vis is not None:
            assert isinstance(vis, Visibility) or isinstance(vis, BlockVisibility), vis
            assert isinstance(model, Image), model
            return predict(vis, model, context=context, gcfcf=g, **kwargs)
        else:
            return None
    if gcfcf is None:
        gcfcf = [arlexecute.execute(create_pswf_convolutionfunction)(m) for m in model_imagelist]
    if facets == 1:
        image_results_list = list()
        for ivis, subvis in enumerate(vis_list):
            if len(gcfcf) > 1:
                g = gcfcf[ivis]
            else:
                g = gcfcf[0]
            sub_vis_lists = arlexecute.execute(visibility_scatter, nout=vis_slices)(subvis,
                                                                                    vis_iter, vis_slices)
            image_vis_lists = list()
            for sub_vis_list in sub_vis_lists:
                image_vis_list = arlexecute.execute(predict_ignore_none, pure=True, nout=1) \
                    (sub_vis_list, model_imagelist[ivis], g)
                image_vis_lists.append(image_vis_list)
            image_results_list.append(arlexecute.execute(visibility_gather, nout=1)
                                      (image_vis_lists, subvis, vis_iter))
        result = image_results_list
    else:
        image_results_list_list = list()
        for ivis, subvis in enumerate(vis_list):
            facet_lists = arlexecute.execute(image_scatter_facets, nout=actual_number_facets ** 2)(
                model_imagelist[ivis],
                facets=facets)
            sub_vis_lists = arlexecute.execute(visibility_scatter, nout=vis_slices)\
                (subvis, vis_iter, vis_slices)
            facet_vis_lists = list()
            for sub_vis_list in sub_vis_lists:
                facet_vis_results = list()
                for facet_list in facet_lists:
                    facet_vis_list = arlexecute.execute(predict_ignore_none, pure=True, nout=1)\
                        (sub_vis_list, facet_list, None)
                    facet_vis_results.append(facet_vis_list)
                facet_vis_lists.append(arlexecute.execute(sum_predict_results)(facet_vis_results))
            image_results_list_list.append(
                arlexecute.execute(visibility_gather, nout=1)(facet_vis_lists, subvis, vis_iter))
        result = image_results_list_list
    return arlexecute.optimize(result)
def predict_list_arlexecute_workflow ( vis_list , model_imagelist , context , vis_slices = 1 , facets = 1 , gcfcf = None , ** kwargs ) : if get_parameter ( kwargs , "use_serial_predict" , False ) : from workflows . serial . imaging . imaging_serial import predict_list_serial_workflow return [ arlexecute . execute ( predict_list_serial_workflow , nout = 1 ) ( vis_list = [ vis_list [ i ] ] , model_imagelist = [ model_imagelist [ i ] ] , vis_slices = vis_slices , facets = facets , context = context , gcfcf = gcfcf , ** kwargs ) [ 0 ] for i , _ in enumerate ( vis_list ) ] vis_list = zero_list_arlexecute_workflow ( vis_list ) c = imaging_context ( context ) vis_iter = c [ 'vis_iterator' ] predict = c [ 'predict' ] if facets % 2 == 0 or facets == 1 : actual_number_facets = facets else : actual_number_facets = facets - 1 def predict_ignore_none ( vis , model , g ) : if vis is not None : assert isinstance ( vis , Visibility ) or isinstance ( vis , BlockVisibility ) , vis assert isinstance ( model , Image ) , model return predict ( vis , model , context = context , gcfcf = g , ** kwargs ) else : return None if gcfcf is None : gcfcf = [ arlexecute . execute ( create_pswf_convolutionfunction ) ( m ) for m in model_imagelist ] if facets == 1 : image_results_list = list ( ) for ivis , subvis in enumerate ( vis_list ) : if len ( gcfcf ) > 1 : g = gcfcf [ ivis ] else : g = gcfcf [ 0 ] sub_vis_lists = arlexecute . execute ( visibility_scatter , nout = vis_slices ) ( subvis , vis_iter , vis_slices ) image_vis_lists = list ( ) for sub_vis_list in sub_vis_lists : image_vis_list = arlexecute . execute ( predict_ignore_none , pure = True , nout = 1 ) ( sub_vis_list , model_imagelist [ ivis ] , g ) image_vis_lists . append ( image_vis_list ) image_results_list . append ( arlexecute . execute ( visibility_gather , nout = 1 ) ( image_vis_lists , subvis , vis_iter ) ) result = image_results_list else : image_results_list_list = list ( ) for ivis , subvis in enumerate ( vis_list ) : facet_lists = arlexecute . execute ( image_scatter_facets , nout = actual_number_facets ** 2 ) ( model_imagelist [ ivis ] , facets = facets ) sub_vis_lists = arlexecute . execute ( visibility_scatter , nout = vis_slices ) ( subvis , vis_iter , vis_slices ) facet_vis_lists = list ( ) for sub_vis_list in sub_vis_lists : facet_vis_results = list ( ) for facet_list in facet_lists : facet_vis_list = arlexecute . execute ( predict_ignore_none , pure = True , nout = 1 ) ( sub_vis_list , facet_list , None ) facet_vis_results . append ( facet_vis_list ) facet_vis_lists . append ( arlexecute . execute ( sum_predict_results ) ( facet_vis_results ) ) image_results_list_list . append ( arlexecute . execute ( visibility_gather , nout = 1 ) ( facet_vis_lists , subvis , vis_iter ) ) result = image_results_list_list return arlexecute . optimize ( result )
Predict, iterating over both the scattered vis_list and image
The visibility and image are scattered, the visibility is predicted on each part, and then the
parts are assembled.
Predict iterating over both the scattered vis_list and image The visibility and image are scattered the visibility is predicted on each part and then the parts are assembled .
"""Predict, iterating over both the scattered vis_list and image
    
    The visibility and image are scattered, the visibility is predicted on each part, and then the
    parts are assembled.

    :param vis_list:
    :param model_imagelist: Model used to determine image parameters
    :param vis_slices: Number of vis slices (w stack or timeslice)
    :param facets: Number of facets (per axis)
    :param context: Type of processing e.g. 2d, wstack, timeslice or facets
    :param gcfcg: tuple containing grid correction and convolution function
    :param kwargs: Parameters for functions in components
    :return: List of vis_lists
   """ # Predict_2d does not clear the vis so we have to do it here. # Loop over all frequency windows # Create the graph to divide the visibility into slices. This is by copy. # Loop over sub visibility # Predict visibility for this sub-visibility from this image # Sum all sub-visibilities # Create the graph to divide an image into facets. This is by reference. # Create the graph to divide the visibility into slices. This is by copy. # Loop over sub visibility # Loop over facets # Predict visibility for this subvisibility from this facet # Sum the current sub-visibility over all facets # Sum all sub-visibilities
List of vis_lists
List of vis_lists
vis_list
None
model_imagelist
Model used to determine image parameters
Model used to determine image parameters
context
Type of processing e.g. 2d, wstack, timeslice or facets
Type of processing e . g . 2d wstack timeslice or facets
vis_slices
Number of vis slices (w stack or timeslice)
Number of vis slices ( w stack or timeslice )
facets
Number of facets (per axis)
Number of facets ( per axis )
gcfcf
gcfcg
tuple containing grid correction and convolution function
tuple containing grid correction and convolution function
kwargs
Parameters for functions in components
Parameters for functions in components