Ejemplo n.º 1
0
def test_dpc_end_to_end():
    """
    Integrated test for DPC based on dpc_runner.
    
    """
    
    start_point = [1, 0]
    pixel_size = (55, 55)
    focus_to_det = 1.46e6
    scan_rows = 2
    scan_cols = 2
    scan_xstep = 0.1
    scan_ystep = 0.1
    energy = 19.5
    roi = None
    padding = 0
    weighting = 1
    bad_pixels = None
    solver = 'Nelder-Mead'
    img_size = (40, 40)
    scale = True
    negate = True

    ref_image = np.ones(img_size)
    image_sequence = np.ones((scan_rows * scan_cols, img_size[0], img_size[1]))

    phi, a = dpc.dpc_runner(ref_image, image_sequence, start_point, pixel_size, 
                            focus_to_det, scan_rows, scan_cols, scan_xstep, 
                            scan_ystep, energy, padding, weighting, solver, 
                            roi, bad_pixels, negate, scale)

    assert_array_almost_equal(phi, np.zeros((scan_rows, scan_cols)))
    assert_array_almost_equal(a, np.ones((scan_rows, scan_cols)))
Ejemplo n.º 2
0
def run():
    # download to this folder
    current_folder = os.sep.join(__file__.split(os.sep)[:-1])
    dpc_demo_data_path = os.path.join(current_folder, 'SOFC')

    if not os.path.exists(dpc_demo_data_path):
        sofc_file = os.path.join(current_folder, 'SOFC.zip')
        print('The required test data directory was not found.'
              '\nDownloading the test data to %s' % dpc_demo_data_path)
        # todo make this not print every fraction of a second
        call(('wget https://www.dropbox.com/s/963c4ymfmbjg5dm/SOFC.zip -P %s' %
              current_folder),
             shell=True)
        # unzip it into this directory
        unzip(sofc_file)


    # 1. Set parameters
    start_point = [1, 0]
    first_image = 1
    pixel_size = (55, 55)
    focus_to_det = 1.46e6
    scan_xstep = 0.1
    scan_ystep = 0.1
    scan_rows = 121
    scan_cols = 121
    energy = 19.5
    roi = None
    padding = 0
    weighting = 1.
    bad_pixels = None
    solver = 'Nelder-Mead'
    images = ImageSequence(dpc_demo_data_path + "/*.tif")
    img_size = images[0].shape
    ref_image = np.ones(img_size)
    scale = True
    negate = True

    print('running dpc')
    # 2. Use dpc.dpc_runner
    phase, amplitude = dpc.dpc_runner(
        ref_image, images, start_point, pixel_size, focus_to_det, scan_rows,
        scan_cols, scan_xstep, scan_ystep, energy, padding, weighting, solver,
        roi, bad_pixels, negate, scale)

    # 3. Save intermediate and final results
    scipy.misc.imsave(os.path.join(current_folder, 'phase.jpg'), phase)
    np.savetxt(os.path.join(current_folder, 'phase.txt'), phase)
    scipy.misc.imsave(os.path.join(current_folder, 'amplitude.jpg'), amplitude)
    np.savetxt(os.path.join(current_folder, 'amplitude.txt'), amplitude)
Ejemplo n.º 3
0
def run():
    # download to this folder
    current_folder = os.sep.join(__file__.split(os.sep)[:-1])
    dpc_demo_data_path = os.path.join(current_folder, 'SOFC')

    if not os.path.exists(dpc_demo_data_path):
        sofc_file = os.path.join(current_folder, 'SOFC.zip')
        print('The required test data directory was not found.'
              '\nDownloading the test data to %s' % dpc_demo_data_path)
        # todo make this not print every fraction of a second
        call(('wget https://www.dropbox.com/s/963c4ymfmbjg5dm/SOFC.zip -P %s' %
              current_folder),
             shell=True)
        # unzip it into this directory
        unzip(sofc_file)

    # 1. Set parameters
    start_point = [1, 0]
    first_image = 1
    pixel_size = (55, 55)
    focus_to_det = 1.46e6
    scan_xstep = 0.1
    scan_ystep = 0.1
    scan_rows = 121
    scan_cols = 121
    energy = 19.5
    roi = None
    padding = 0
    weighting = 1.
    bad_pixels = None
    solver = 'Nelder-Mead'
    images = ImageSequence(dpc_demo_data_path + "/*.tif")
    img_size = images[0].shape
    ref_image = np.ones(img_size)
    scale = True
    negate = True

    print('running dpc')
    # 2. Use dpc.dpc_runner
    phase, amplitude = dpc.dpc_runner(ref_image, images, start_point,
                                      pixel_size, focus_to_det, scan_rows,
                                      scan_cols, scan_xstep, scan_ystep,
                                      energy, padding, weighting, solver, roi,
                                      bad_pixels, negate, scale)

    # 3. Save intermediate and final results
    scipy.misc.imsave(os.path.join(current_folder, 'phase.jpg'), phase)
    np.savetxt(os.path.join(current_folder, 'phase.txt'), phase)
    scipy.misc.imsave(os.path.join(current_folder, 'amplitude.jpg'), amplitude)
    np.savetxt(os.path.join(current_folder, 'amplitude.txt'), amplitude)
Ejemplo n.º 4
0
def run():
    # download to this folder
    current_folder = os.sep.join(__file__.split(os.sep)[:-1])
    dpc_demo_data_path = os.path.join(current_folder, 'SOFC')
    if not os.path.exists(dpc_demo_data_path):
        zip_file_url = 'https://www.dropbox.com/s/963c4ymfmbjg5dm/SOFC.zip?dl=1'
        import download
        download.run()
        # download_zip(zip_file_url, current_folder)

    # 1. Set parameters
    start_point = [1, 0]
    first_image = 1
    pixel_size = (55, 55)
    focus_to_det = 1.46e6
    scan_xstep = 0.1
    scan_ystep = 0.1
    scan_rows = 121
    scan_cols = 121
    energy = 19.5
    roi = None
    padding = 0
    weighting = 1.
    bad_pixels = None
    solver = 'Nelder-Mead'
    images = ImageSequence(dpc_demo_data_path + "/*.tif")
    img_size = images[0].shape
    ref_image = np.ones(img_size)
    scale = True
    negate = True

    print('running dpc')
    # 2. Use dpc.dpc_runner
    phase, amplitude = dpc.dpc_runner(ref_image, images, start_point,
                                      pixel_size, focus_to_det, scan_rows,
                                      scan_cols, scan_xstep, scan_ystep,
                                      energy, padding, weighting, solver, roi,
                                      bad_pixels, negate, scale)

    # 3. Save intermediate and final results
    print('saving dpc output to disk in --> %s' % current_folder)
    scipy.misc.imsave(os.path.join(current_folder, 'phase.jpg'), phase)
    np.savetxt(os.path.join(current_folder, 'phase.txt'), phase)
    scipy.misc.imsave(os.path.join(current_folder, 'amplitude.jpg'), amplitude)
    np.savetxt(os.path.join(current_folder, 'amplitude.txt'), amplitude)
Ejemplo n.º 5
0
def run():
    # download to this folder
    current_folder = os.sep.join(__file__.split(os.sep)[:-1])
    dpc_demo_data_path = os.path.join(current_folder, 'SOFC')
    if not os.path.exists(dpc_demo_data_path):
        zip_file_url = 'https://www.dropbox.com/s/963c4ymfmbjg5dm/SOFC.zip?dl=1'
        import download
        download.run()
        # download_zip(zip_file_url, current_folder)

    # 1. Set parameters
    start_point = [1, 0]
    first_image = 1
    pixel_size = (55, 55)
    focus_to_det = 1.46e6
    scan_xstep = 0.1
    scan_ystep = 0.1
    scan_rows = 121
    scan_cols = 121
    energy = 19.5
    roi = None
    padding = 0
    weighting = 1.
    bad_pixels = None
    solver = 'Nelder-Mead'
    images = ImageSequence(dpc_demo_data_path + "/*.tif")
    img_size = images[0].shape
    ref_image = np.ones(img_size)
    scale = True
    negate = True

    print('running dpc')
    # 2. Use dpc.dpc_runner
    phase, amplitude = dpc.dpc_runner(
        ref_image, images, start_point, pixel_size, focus_to_det, scan_rows,
        scan_cols, scan_xstep, scan_ystep, energy, padding, weighting, solver,
        roi, bad_pixels, negate, scale)

    # 3. Save intermediate and final results
    print('saving dpc output to disk in --> %s' % current_folder)
    scipy.misc.imsave(os.path.join(current_folder, 'phase.jpg'), phase)
    np.savetxt(os.path.join(current_folder, 'phase.txt'), phase)
    scipy.misc.imsave(os.path.join(current_folder, 'amplitude.jpg'), amplitude)
    np.savetxt(os.path.join(current_folder, 'amplitude.txt'), amplitude)