#NEWLINE# def generate_random_phase_field( diffracted_pattern ) : #NEWLINE# #INDENT# '\n    Initiate random phase.\n\n    Parameters\n    ----------\n    diffracted_pattern : array\n        diffraction pattern from experiments\n\n    Returns\n    -------\n    sample_obj : array\n        sample information with phase\n    ' #NEWLINE# pha_tmp = np . random . uniform ( 0 , ( 2 * np . pi ) , diffracted_pattern . shape ) #NEWLINE# sample_obj = ( np . fft . ifftn ( ( diffracted_pattern * np . exp ( ( 1j * pha_tmp ) ) ) ) * np . sqrt ( np . size ( diffracted_pattern ) ) ) #NEWLINE# return sample_obj