# This dataset was taken on 26ID at the APS in the Bragg geometry on a single Au nano-crystal

# 0) Set the GPU number in the PYNX_PU if not already done (replace '1' by your trainee number):
export PYNX_PU=.1

# 1) Look at the raw data file and the mask:

silx view summed.cxi

# 2) perform a quick analysis. The initial support will be calculated using
# auto-correlation, so no need to supply one.

pynx-cdi-id01 data=summed.cxi support_threshold=0.2 liveplot


# 3) Look at the result using silx:

silx view *.cxi


# You can tune the threshold if you want to improve the solution
#
# All the solutions feature some variations in the electronic density which are
# not physical, and could be due to partial coherence, so:

# 4) try with partial coherence correction using the 'psf' keyword. 

pynx-cdi-id01 data=summed.cxi support_threshold=0.2 psf=gaussian,0.5,10 liveplot

# 5) perform 10 runs and combine the 5 best ones (takes a little longer, liveplot is disabled)

rm -f *LLK*.cxi  # remove previous results
pynx-cdi-id01 data=summed.cxi support_threshold=0.2 psf=gaussian,0.5,10 nb_run=10 nb_run_keep=5 verbose=100
pynx-cdi-analysis *LLK*.cxi modes movie   # mode analysis
silx view *modes*.h5		                 # look at modes analysis
vlc *.mp4                    # movie of 3D object slices
