deprecated_code/workflows/mpi/imaging/imaging_mpi.py
def deconvolve_list_channel_mpi_workflow(dirty_list, psf_list, model_imagelist,
                                         subimages, comm=MPI.COMM_WORLD,**kwargs):
    """Create a graph for deconvolution by channels, adding to the model

    Does deconvolution channel by channel.
    :param subimages: MONTSE: number of subimages (= freqchannels?)
    :param dirty_list: in rank=0
    :param psf_list: Must be the size of a facet in rank=0
    :param model_imagelist: Current model in rank=0
    :param kwargs: Parameters for functions in components
    :return:
    """
    
    def deconvolve_subimage(dirty, psf):
        assert isinstance(dirty, Image)
        assert isinstance(psf, Image)
        comp = deconvolve_cube(dirty, psf, **kwargs)
        return comp[0]
    
    def add_model(sum_model, model):
        assert isinstance(output, Image)
        assert isinstance(model, Image)
        sum_model.data += model.data
        return sum_model
    
    rank = comm.Get_rank()
    size = comm.Get_size()
    if rank==0:
        output = create_empty_image_like(model_imagelist)
    dirty_lists = image_scatter_channels(dirty_list[0], subimages=subimages)
    sub_dirty_lists = numpy.array_split(dirty_lists,size)
    sub_dirty_lists = comm.scatter(sub_dirty_lists, root=0)
    psf_list_im=comm.Bcast(psf_list[0],root=0)
    
    sub_results = [deconvolve_subimage(dirty_list, psf_list_im)
               for dirty_list in sub_dirty_lists]
    results=comm.gather(sub_results,root=0)
    # NOTE: This is same as in invert, not scalable, we should use a reduction
    # instead but I don't understand image_gather_channels ...
    if rank==0:
        results=numpy.concatenate(results)
        result = image_gather_channels(results, output, subimages=subimages)
        result = add_model(result, model_imagelist)
    else:
        result=None
    return result
Create a graph for deconvolution by channels, adding to the model

    Does deconvolution channel by channel.
    :param subimages: MONTSE: number of subimages (= freqchannels?)
    :param dirty_list: in rank=0
    :param psf_list: Must be the size of a facet in rank=0
    :param model_imagelist: Current model in rank=0
    :param kwargs: Parameters for functions in components
    :return:
    
Create a graph for deconvolution by channels, adding to the model
Does deconvolution channel by channel.
Create a graph for deconvolution by channels adding to the model Does deconvolution channel by channel .
def deconvolve_list_channel_mpi_workflow(dirty_list, psf_list, model_imagelist,
                                         subimages, comm=MPI.COMM_WORLD,**kwargs):
    def deconvolve_subimage(dirty, psf):
        assert isinstance(dirty, Image)
        assert isinstance(psf, Image)
        comp = deconvolve_cube(dirty, psf, **kwargs)
        return comp[0]
    def add_model(sum_model, model):
        assert isinstance(output, Image)
        assert isinstance(model, Image)
        sum_model.data += model.data
        return sum_model
    rank = comm.Get_rank()
    size = comm.Get_size()
    if rank==0:
        output = create_empty_image_like(model_imagelist)
    dirty_lists = image_scatter_channels(dirty_list[0], subimages=subimages)
    sub_dirty_lists = numpy.array_split(dirty_lists,size)
    sub_dirty_lists = comm.scatter(sub_dirty_lists, root=0)
    psf_list_im=comm.Bcast(psf_list[0],root=0)
    sub_results = [deconvolve_subimage(dirty_list, psf_list_im)
               for dirty_list in sub_dirty_lists]
    results=comm.gather(sub_results,root=0)
    if rank==0:
        results=numpy.concatenate(results)
        result = image_gather_channels(results, output, subimages=subimages)
        result = add_model(result, model_imagelist)
    else:
        result=None
    return result
def deconvolve_list_channel_mpi_workflow ( dirty_list , psf_list , model_imagelist , subimages , comm = MPI . COMM_WORLD , ** kwargs ) : def deconvolve_subimage ( dirty , psf ) : assert isinstance ( dirty , Image ) assert isinstance ( psf , Image ) comp = deconvolve_cube ( dirty , psf , ** kwargs ) return comp [ 0 ] def add_model ( sum_model , model ) : assert isinstance ( output , Image ) assert isinstance ( model , Image ) sum_model . data += model . data return sum_model rank = comm . Get_rank ( ) size = comm . Get_size ( ) if rank == 0 : output = create_empty_image_like ( model_imagelist ) dirty_lists = image_scatter_channels ( dirty_list [ 0 ] , subimages = subimages ) sub_dirty_lists = numpy . array_split ( dirty_lists , size ) sub_dirty_lists = comm . scatter ( sub_dirty_lists , root = 0 ) psf_list_im = comm . Bcast ( psf_list [ 0 ] , root = 0 ) sub_results = [ deconvolve_subimage ( dirty_list , psf_list_im ) for dirty_list in sub_dirty_lists ] results = comm . gather ( sub_results , root = 0 ) if rank == 0 : results = numpy . concatenate ( results ) result = image_gather_channels ( results , output , subimages = subimages ) result = add_model ( result , model_imagelist ) else : result = None return result
Create a graph for deconvolution by channels, adding to the model
Does deconvolution channel by channel.
Create a graph for deconvolution by channels adding to the model Does deconvolution channel by channel .
"""Create a graph for deconvolution by channels, adding to the model

    Does deconvolution channel by channel.
    :param subimages: MONTSE: number of subimages (= freqchannels?)
    :param dirty_list: in rank=0
    :param psf_list: Must be the size of a facet in rank=0
    :param model_imagelist: Current model in rank=0
    :param kwargs: Parameters for functions in components
    :return:
    """ # NOTE: This is same as in invert, not scalable, we should use a reduction # instead but I don't understand image_gather_channels ...
None
dirty_list
None
psf_list
Must be the size of a facet in rank=0
Must be the size of a facet in rank = 0
model_imagelist
Current model in rank=0
Current model in rank = 0
subimages
number of subimages (= freqchannels?)
number of subimages ( = freqchannels? )
comm
kwargs
Parameters for functions in components
Parameters for functions in components