deprecated_code/workflows/mpi/imaging/imaging_mpi.py
def restore_list_mpi_workflow(model_imagelist, psf_imagelist,
                              residual_imagelist,comm=MPI.COMM_WORLD, **kwargs):
    """ Create a graph to calculate the restored image

    :param model_imagelist: Model list (rank0)
    :param psf_imagelist: PSF list (rank0)
    :param residual_imagelist: Residual list (rank0)
    :param kwargs: Parameters for functions in components
    :return:
    """
    from workflows.serial.imaging.imaging_serial import restore_list_serial_workflow_nosumwt
    rank = comm.Get_rank()
    size = comm.Get_size()
    #TODO Parallelize! and check the dask version, it removes sumwt component
    # to reduce communication
    if residual_imagelist is None:
        residual_imagelist = []
    
    if rank==0:
        psf_list = remove_sumwt(psf_imagelist)
        if len(residual_imagelist) > 0:
            residual_list = remove_sumwt(residual_imagelist)
        else:
            residual_list = residual_imagelist
    else:
        psf_list=list()
        residual_list=list()

    sub_model_imagelist=numpy.array_split(model_imagelist,size)
    sub_model_imagelist=comm.scatter(sub_model_imagelist,root=0)
    sub_psf_list=numpy.array_split(psf_list,size)
    sub_psf_list=comm.scatter(sub_psf_list,root=0)
    sub_residual_list=numpy.array_split(residual_list,size)
    sub_residual_list=comm.scatter(sub_residual_list,root=0)

    sub_result_list=restore_list_serial_workflow_nosumwt(sub_model_imagelist,
                                         sub_psf_list,
                                         sub_residual_list)
    #sub_result_list=[restore_cube(sub_model_imagelist[i], sub_psf_list[i],
    #                     sub_residual_list[i], **kwargs)
    #            for i, _ in enumerate(sub_model_imagelist)]
    result_list=comm.gather(sub_result_list,root=0)
    if rank==0:
        # this is a list of tuples too, we may need to call my function
        result_list=numpy.concatenate(result_list)
    else:
        result_list=list()
    return result_list
 Create a graph to calculate the restored image

    :param model_imagelist: Model list (rank0)
    :param psf_imagelist: PSF list (rank0)
    :param residual_imagelist: Residual list (rank0)
    :param kwargs: Parameters for functions in components
    :return:
    
Create a graph to calculate the restored image
Create a graph to calculate the restored image
def restore_list_mpi_workflow(model_imagelist, psf_imagelist,
                              residual_imagelist,comm=MPI.COMM_WORLD, **kwargs):
    from workflows.serial.imaging.imaging_serial import restore_list_serial_workflow_nosumwt
    rank = comm.Get_rank()
    size = comm.Get_size()
    if residual_imagelist is None:
        residual_imagelist = []
    if rank==0:
        psf_list = remove_sumwt(psf_imagelist)
        if len(residual_imagelist) > 0:
            residual_list = remove_sumwt(residual_imagelist)
        else:
            residual_list = residual_imagelist
    else:
        psf_list=list()
        residual_list=list()
    sub_model_imagelist=numpy.array_split(model_imagelist,size)
    sub_model_imagelist=comm.scatter(sub_model_imagelist,root=0)
    sub_psf_list=numpy.array_split(psf_list,size)
    sub_psf_list=comm.scatter(sub_psf_list,root=0)
    sub_residual_list=numpy.array_split(residual_list,size)
    sub_residual_list=comm.scatter(sub_residual_list,root=0)
    sub_result_list=restore_list_serial_workflow_nosumwt(sub_model_imagelist,
                                         sub_psf_list,
                                         sub_residual_list)
    result_list=comm.gather(sub_result_list,root=0)
    if rank==0:
        result_list=numpy.concatenate(result_list)
    else:
        result_list=list()
    return result_list
def restore_list_mpi_workflow ( model_imagelist , psf_imagelist , residual_imagelist , comm = MPI . COMM_WORLD , ** kwargs ) : from workflows . serial . imaging . imaging_serial import restore_list_serial_workflow_nosumwt rank = comm . Get_rank ( ) size = comm . Get_size ( ) if residual_imagelist is None : residual_imagelist = [ ] if rank == 0 : psf_list = remove_sumwt ( psf_imagelist ) if len ( residual_imagelist ) > 0 : residual_list = remove_sumwt ( residual_imagelist ) else : residual_list = residual_imagelist else : psf_list = list ( ) residual_list = list ( ) sub_model_imagelist = numpy . array_split ( model_imagelist , size ) sub_model_imagelist = comm . scatter ( sub_model_imagelist , root = 0 ) sub_psf_list = numpy . array_split ( psf_list , size ) sub_psf_list = comm . scatter ( sub_psf_list , root = 0 ) sub_residual_list = numpy . array_split ( residual_list , size ) sub_residual_list = comm . scatter ( sub_residual_list , root = 0 ) sub_result_list = restore_list_serial_workflow_nosumwt ( sub_model_imagelist , sub_psf_list , sub_residual_list ) result_list = comm . gather ( sub_result_list , root = 0 ) if rank == 0 : result_list = numpy . concatenate ( result_list ) else : result_list = list ( ) return result_list
Create a graph to calculate the restored image
Create a graph to calculate the restored image
""" Create a graph to calculate the restored image

    :param model_imagelist: Model list (rank0)
    :param psf_imagelist: PSF list (rank0)
    :param residual_imagelist: Residual list (rank0)
    :param kwargs: Parameters for functions in components
    :return:
    """ #TODO Parallelize! and check the dask version, it removes sumwt component # to reduce communication #sub_result_list=[restore_cube(sub_model_imagelist[i], sub_psf_list[i], #                     sub_residual_list[i], **kwargs) #            for i, _ in enumerate(sub_model_imagelist)] # this is a list of tuples too, we may need to call my function
None
model_imagelist
Model list (rank0)
Model list ( rank0 )
psf_imagelist
PSF list (rank0)
PSF list ( rank0 )
residual_imagelist
Residual list (rank0)
Residual list ( rank0 )
comm
kwargs
Parameters for functions in components
Parameters for functions in components