workflows/serial/imaging/imaging_serial.py
def predict_list_serial_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
   """
    
    assert len(vis_list) == len(model_imagelist), "Model must be the same length as the vis_list"
    
    # Predict_2d does not clear the vis so we have to do it here.
    vis_list = zero_list_serial_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 = [create_pswf_convolutionfunction(m) for m in model_imagelist]
    
    # Loop over all frequency windows
    if facets == 1:
        image_results_list = list()
        for ivis, sub_vis_list in enumerate(vis_list):
            if len(gcfcf) > 1:
                g = gcfcf[ivis]
            else:
                g = gcfcf[0]
            # Loop over sub visibility
            vis_predicted = copy_visibility(sub_vis_list, zero=True)
            for rows in vis_iter(sub_vis_list, vis_slices):
                row_vis = create_visibility_from_rows(sub_vis_list, rows)
                row_vis_predicted = predict_ignore_none(row_vis, model_imagelist[ivis], g)
                if row_vis_predicted is not None:
                    vis_predicted.data['vis'][rows, ...] = row_vis_predicted.data['vis']
            image_results_list.append(vis_predicted)
        
        return image_results_list
    else:
        image_results_list = list()
        for ivis, sub_vis_list in enumerate(vis_list):
            # Create the graph to divide an image into facets. This is by reference.
            facet_lists = image_scatter_facets(model_imagelist[ivis], facets=facets)
            facet_vis_lists = list()
            sub_vis_lists = visibility_scatter(sub_vis_list, vis_iter, vis_slices)
            
            # 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 = predict_ignore_none(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(sum_predict_results(facet_vis_results))
            # Sum all sub-visibilties
            image_results_list.append(visibility_gather(facet_vis_lists, sub_vis_list, vis_iter))
        return image_results_list
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_serial_workflow(vis_list, model_imagelist, context, vis_slices=1, facets=1,
                                 gcfcf=None, **kwargs):
    assert len(vis_list) == len(model_imagelist), "Model must be the same length as the vis_list"
    vis_list = zero_list_serial_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 = [create_pswf_convolutionfunction(m) for m in model_imagelist]
    if facets == 1:
        image_results_list = list()
        for ivis, sub_vis_list in enumerate(vis_list):
            if len(gcfcf) > 1:
                g = gcfcf[ivis]
            else:
                g = gcfcf[0]
            vis_predicted = copy_visibility(sub_vis_list, zero=True)
            for rows in vis_iter(sub_vis_list, vis_slices):
                row_vis = create_visibility_from_rows(sub_vis_list, rows)
                row_vis_predicted = predict_ignore_none(row_vis, model_imagelist[ivis], g)
                if row_vis_predicted is not None:
                    vis_predicted.data['vis'][rows, ...] = row_vis_predicted.data['vis']
            image_results_list.append(vis_predicted)
        return image_results_list
    else:
        image_results_list = list()
        for ivis, sub_vis_list in enumerate(vis_list):
            facet_lists = image_scatter_facets(model_imagelist[ivis], facets=facets)
            facet_vis_lists = list()
            sub_vis_lists = visibility_scatter(sub_vis_list, vis_iter, vis_slices)
            for sub_vis_list in sub_vis_lists:
                facet_vis_results = list()
                for facet_list in facet_lists:
                    facet_vis_list = predict_ignore_none(sub_vis_list, facet_list,
                                                         None)
                    facet_vis_results.append(facet_vis_list)
                facet_vis_lists.append(sum_predict_results(facet_vis_results))
            image_results_list.append(visibility_gather(facet_vis_lists, sub_vis_list, vis_iter))
        return image_results_list
def predict_list_serial_workflow ( vis_list , model_imagelist , context , vis_slices = 1 , facets = 1 , gcfcf = None , ** kwargs ) : assert len ( vis_list ) == len ( model_imagelist ) , "Model must be the same length as the vis_list" vis_list = zero_list_serial_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 = [ create_pswf_convolutionfunction ( m ) for m in model_imagelist ] if facets == 1 : image_results_list = list ( ) for ivis , sub_vis_list in enumerate ( vis_list ) : if len ( gcfcf ) > 1 : g = gcfcf [ ivis ] else : g = gcfcf [ 0 ] vis_predicted = copy_visibility ( sub_vis_list , zero = True ) for rows in vis_iter ( sub_vis_list , vis_slices ) : row_vis = create_visibility_from_rows ( sub_vis_list , rows ) row_vis_predicted = predict_ignore_none ( row_vis , model_imagelist [ ivis ] , g ) if row_vis_predicted is not None : vis_predicted . data [ 'vis' ] [ rows , ... ] = row_vis_predicted . data [ 'vis' ] image_results_list . append ( vis_predicted ) return image_results_list else : image_results_list = list ( ) for ivis , sub_vis_list in enumerate ( vis_list ) : facet_lists = image_scatter_facets ( model_imagelist [ ivis ] , facets = facets ) facet_vis_lists = list ( ) sub_vis_lists = visibility_scatter ( sub_vis_list , vis_iter , vis_slices ) for sub_vis_list in sub_vis_lists : facet_vis_results = list ( ) for facet_list in facet_lists : facet_vis_list = predict_ignore_none ( sub_vis_list , facet_list , None ) facet_vis_results . append ( facet_vis_list ) facet_vis_lists . append ( sum_predict_results ( facet_vis_results ) ) image_results_list . append ( visibility_gather ( facet_vis_lists , sub_vis_list , vis_iter ) ) return image_results_list
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 # Loop over sub visibility # Create the graph to divide an image into facets. This is by reference. # 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-visibilties
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