First, setup the environment so that we have graphics

In [1]:
%matplotlib notebook
from pylab import rcParams
rcParams['figure.figsize'] = (12, 8)  # Figure size for inline display

Import 'runner' classes from pynx to analyze data from a CXI file

In [2]:
from pynx.ptycho.runner.cxi import PtychoRunnerScanCXI
from pynx.ptycho.runner.runner import params_generic as params
print('Import OK')
gpyfft version: 0.7.0
Import OK

First, make sure all results will be saved in your sub-directory, so that all results don't collide !

In [3]:
params['saveprefix']='vincent/ResultsScan%04d/Run%04d'

Set the parameters for the optimization:

In [4]:
params['cxifile']='/home/pynx/UM2017/201606id01-FZP-S0013.cxi'
params['loadprobe']='/home/pynx/UM2017/201606id01-FZP-S0013-result.npz'  # Use existing probe with 3 modes
params['algorithm'] = '20DM'
params['object'] = 'random,0.8,1,0,0.5'
params['verbose'] = 10          # Print progress every 10 cycles
params['loadmask'] = 'maxipix'  # This masks the maxipix gaps
#params['moduloframe'] = 2,0  # Use every over frame to go faster, and use less GPU memory
params['liveplot'] = True  # Liveplot updated at the end of each cell.
In [5]:
ws = PtychoRunnerScanCXI(params, 0)
In [6]:
ws.load_data()  # Load 1025 frames from a maxipix detector using CXI/HDF5 data
Reading frames from CXI-HDF5 file
Reading frames: 
Time to read all frames:  4.5s [60.21 Mpixel/s]
In [7]:
ws.center_crop_data()  # Auto-crop the data
ws.prepare()  # This will prepare the initialobject
Loaded MASK from:  maxipix
Initialized mask with 6156 ( 2.312%) bad pixels
Center of diffraction: X=206.65 Y=209.09
Largest prime number acceptable for FFT size: 13
/usr/local/lib/python3.4/dist-packages/matplotlib/backend_bases.py:2437: MatplotlibDeprecationWarning: Using default event loop until function specific to this GUI is implemented
  warnings.warn(str, mplDeprecation)
E= 8.000keV, zdetector= 1.386m, pixel size= 55.00um, pixel size(object)=   9.8nm
Using random object type with amplitude range:  0.80- 1.00 and phase range:  0.00- 0.50
1 9.76374e-09 9.76374e-09 True
Computing FFT speed for all available GPU:
                           Tesla K80 [platform: NVIDIA CUDA]: GPU mem: 11439.88Mb [max alloc.:  2859.97Mb],  106.38 Gflop/s (FFT shape: (16, 400, 400) )
No GPU given, or listed ones not available. Auto-selecting:  ['Tesla K80']
In [8]:
ws.run()  # Run the optimization,as defined in params['algorithm']
 #################################################################################################### 
# 
#         Run: 18
#
 ####################################################################################################
Using double precision for simulation.
Updating defaults values for object.
Simulating object: random
Making obj: (760, 768) 760 768
Using OpenCL device(s):
   Device: Tesla K80 [platform=NVIDIA CUDA] [frame range: 0-1025] [FFT speed:   121.15Gflop/s]
Number of frames is not a multiple of 16, adding 15 null frames
Pure FFT performance[nz=16x3, ny=400, nx=400]: dt=0.008501s (2fft => 0.181533s/cycle for 3x3 frames),  156.18 Gflop/s

 #################################################################################################### 
# 
#         Run: 18 , Algorithm: 20DM
#
 ####################################################################################################

## Beginning Difference Map optimisation of:  object

Number of frames is not a multiple of 16, adding 15 null frames
DM/o, cycle=    1/20: LLK= 5.4708e+02 [dt/cycle =  2.275s]