Example #1
0
def PRTF(O, I, B=0, mask=None):
    """
    As defined in: High-resolution ab initio three-dimensional x-ray
    diffraction microscopy Vol. 23, No. 5 / May 2006 / J. Opt. Soc. Am. A
    """
    O = np.fft.fftn(O)
    M = np.sqrt(np.abs(O)**2 + B)
    amp = (np.sqrt(I) + 1.0e-10)
    if mask is not None:
        amp[~mask] = M[~mask]
    prtf = M / amp
    prtf = np.clip(prtf, 0.0, 3.0)
    rav_prtf = rad_av(prtf, is_fft_shifted=True)
    return prtf, rav_prtf
Example #2
0
def PSD(O, I):
    Oh = np.fft.fftn(O)
    rad_av_I = rad_av(I, is_fft_shifted=True)
    rad_av_intensity = rad_av(np.abs(Oh)**2, is_fft_shifted=True)
    rad_av_phase = rad_av(np.angle(Oh), is_fft_shifted=True)
    return rad_av_intensity, rad_av_I, rad_av_phase
Example #3
0
import sys, os

sys.path.append(os.path.abspath('.'))
from src import era

if __name__ == '__main__':
    fnam = sys.argv[1]

    # read the h5 file
    diff, diff_ret, support, support_ret, \
    good_pix, solid_unit, solid_units_ret, \
    emods, econs, efids, T, T_rav, B_rav     = io_utils.read_output_h5(fnam)

    pow = 1.0
    # display the radial average of the data
    diff_rav = noise.rad_av(diff * good_pix)
    plot = pg.plot(diff_rav**pow)

    # display the radial average of the retrieved diff
    diff_ret = np.abs(np.fft.fftn(solid_units_ret[0]))**2
    diff_ret_rav = noise.rad_av(diff_ret) + B_rav
    plot.plot(diff_rav**pow, pen=pg.mkPen('b'))

    # display the radial average of the background
    plot.plot(B_rav**pow, pen=pg.mkPen('g'))

    # display the radial average of the background
    plot.plot(noise.rad_av(diff_ret)**pow, pen=pg.mkPen('r'))

    ########### Make a large background filled with the radial average
    i = np.fft.fftfreq(diff.shape[0]) * diff.shape[0]
import sys, os

sys.path.append(os.path.abspath('.'))
from src import era

if __name__ == '__main__':
    fnam = sys.argv[1]
    
    # read the h5 file 
    diff, diff_ret, support, support_ret, \
    good_pix, solid_unit, solid_units_ret, \
    emods, econs, efids, T, T_rav, B_rav     = io_utils.read_output_h5(fnam)
    
    pow = 1.0
    # display the radial average of the data
    diff_rav = noise.rad_av(diff * good_pix)
    plot = pg.plot(diff_rav**pow)

    # display the radial average of the retrieved diff
    diff_ret = np.abs(np.fft.fftn(solid_units_ret[0]))**2
    diff_ret_rav = noise.rad_av(diff_ret) + B_rav
    plot.plot(diff_rav**pow, pen=pg.mkPen('b'))

    # display the radial average of the background
    plot.plot(B_rav**pow, pen=pg.mkPen('g'))

    # display the radial average of the background
    plot.plot(noise.rad_av(diff_ret)**pow, pen=pg.mkPen('r'))

    
    ########### Make a large background filled with the radial average