<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 *This notebook was created by Svitozar Serkez. Source and license info is on GitHub. August 2016. *
Tutorial N6.  Genesis postprocessor.
This example will cover the following topics
Step1:  Setting project directory
Step2:  Genesis Field file dfl
can be read with readRadiationFile function
Step3:  Statistical properties postprocessing
since the SASE FEL radiation  properties change shot-to-shot, one needs to visualize the averaged FEL radiation parameters
<ASSISTANT_TASK:>
Python Code:
# the output of plotting commands is displayed inline within frontends, 
# directly below the code cell that produced it
%matplotlib inline
from __future__ import print_function
# this python library provides generic shallow (copy) and deep copy (deepcopy) operations 
from copy import deepcopy
# import from Ocelot graphical modules
import sys, os
from ocelot import *
from ocelot.utils.xfel_utils import *
from ocelot.gui.accelerator import *
from ocelot.gui.genesis_plot import *
#from ocelot.optics.elements import Filter_freq
import numpy as np
from copy import copy
#import matplotlib.pyplot as plt
# load beam distribution
Explanation: *This notebook was created by Svitozar Serkez. Source and license info is on GitHub. August 2016. *
Tutorial N6.  Genesis postprocessor.
This example will cover the following topics:
* Analyze the single run results
* Analyze the statistical properties from many runs
Requirements
invtap_tdp\ - Folder with experimental results.
NB... there is software like xgenesis ....
1) also pyton-based (same language)
2) already included in OCELOT
why write again?
Import of modules
End of explanation
proj_dir = 'materials/invtap_tdp'
out_file = proj_dir + '/run_0' + '/run.0.s1.gout'
out = readGenesisOutput(out_file)
gen_outplot_e(out)
plt.show()
gen_outplot_ph(out)
plt.show()
gen_outplot_z(out,z=inf)
plt.show()
Explanation: Setting project directory
End of explanation
dfl=readRadiationFile(out_file+'.dfl', out.ncar)
gen_outplot_dfl(dfl, out)
plt.show()
gen_outplot_dfl(dfl, out, freq_domain=True,far_field=True)
plt.show()
dpa=read_particle_file(out_file+'.dpa',out('nbins'),out('npart'))
dist=dpa2dist(out,dpa)
plot_dist(dist, showfig=True)
Explanation: Genesis Field file dfl
can be read with readRadiationFile function
End of explanation
# this function plots the averaged properties of FEL radiation
gen_stat_plot(proj_dir,run_inp=[],stage_inp=[1],param_inp=[],s_param_inp=['p_int'],z_param_inp=['p_int','spec'],dfl_param_inp=[],s_inp=['max'],z_inp=['end'], savefig=0, saveval=0, showfig=1)
gen_corr_plot(proj_dir,run_inp=[],p1=('rad_t_size_weighted',1,inf,'max'),p2=('p_int',4,inf,'max'),saveval=1, showfig=True)
a=('ad',2,'ersre',5)
str(a)
b='_'.join(('1',2,'3'))
for i in a: i=str(i)
aa={}
aa['r']='gg'
aa
dir(out)
Explanation: Statistical properties postprocessing
since the SASE FEL radiation  properties change shot-to-shot, one needs to visualize the averaged FEL radiation parameters
End of explanation
<END_TASK>