Plotting routines

a selection of plotting routines for easy access


In [ ]:
import file_processor as fp  #contains simple routines for sorting files and making directories
import processing_tools as pt #bulk of the processing
import int_plot as ip #allows for interactive plots

Plotting entire directories

As it is necessary to often plot many files, a script is included that will go through a directory, make a folder for each file (which ends in .h5, but you may specify other endings by the optional parameter 'file_ending' ) This plots all the defaults, both in pandas and bokeh and then moves them in said directory.


In [2]:
directory = './example'
fp.plot_defaults(directory, file_ending='.h5')

Interactive plots

To plot an interactive interface an ordered list of files which follows the path along the simulation must be provided. file_processor has some tools to ease this process. This can plot either any combination of standard distributions or the slice values over a slice.


In [3]:
list_of_files = fp.directory_list('./example') #returns a list of files that 
#can be sorted in your preferred method
fp.sort_nicely(list_of_files) # sorts in a nice way, but you ought to check
#in this case the files are too different to work, so I provide similar files 

list_of_files = ['./example/noise_10kSI_MASP.h5',
             './example/noise_10kSI_MASP.h5',
             './example/noise_10kSI_MASP.h5']

from bokeh.plotting import show
from bokeh.io import output_notebook  #To view on a notebook such as this
output_notebook()  # allows Bokeh to output to the notebook

int_plot = ip.interactive_plot(list_of_files,'z_pos','CoM_y',num_slices=100, undulator_period=0.0275,k_fact=1) 
#what to plot
show(int_plot)


Loading BokehJS ...

Quick plotting

To quickly plot any combination the pandas inbuit system can help


In [4]:
import matplotlib.pyplot as plt

test = pt.ProcessedData('./example/example.h5',undulator_period=0.00275,num_slices=100)
panda_data = test.StatsFrame()
ax = panda_data.plot(x='z_pos',y='CoM_y')
panda_data.plot(ax=ax, x='z_pos',y='std_y',c='b') #first option allows shared axes, one can even mix different runs
#by plotting another dataset on the same axis
plt.show()



In [ ]:


In [ ]:


In [ ]: