Pynac/Pynplt demo¶
One of the most basic ways of working with Dynac is to feed the
executable an input file, and then to use plotit to look at the
output plots. Here we show how this simple workflow can be performed in
Pynac. We create an empty working directory, copy the relevant files
into it, and then move into that directory to work.
First we import some stuff we need.
In [1]:
from Pynac.Core import Pynac
from Pynac.Plotting import PynPlt
from bokeh.io import output_notebook
import os
import shutil
output_notebook()
Create and populate the working directory¶
In our case, the relevant files are in the ../tests directory, and
so we copy them from there.
In [2]:
newDir = 'workingDir'
if os.path.isdir(newDir):
shutil.rmtree(newDir)
os.mkdir(newDir)
filelist = [
'ESS_with_SC_ana.in',
'Spoke_F2F_field.txt',
'MBL_F2F_field.txt',
'HBL_F2F_field.txt',
'ESS_RFQ_out_70mA.dst',
]
for f in filelist:
shutil.copyfile('../tests/' + f, newDir + '/' + f)
os.chdir(newDir)
Run Pynac¶
Create a Pynac object from the Dynac input file, and then run it.
In [3]:
pynacObject = Pynac('ESS_with_SC_ana.in')
pynacObject.run()
Plotting¶
Create a plotting object. This will pick up the plotting data that Pynac
creates, and slice’n’dice it in preparation for plotting. Then call the
plotit() method.
In [4]:
plottingObject = PynPlt()
plottingObject.plotit()
os.chdir('..')
/Users/stephenmolloy/git/Pynac/venv/lib/python3.6/site-packages/bokeh/models/sources.py:81: BokehUserWarning: ColumnDataSource's columns must be of the same length
lambda: warnings.warn("ColumnDataSource's columns must be of the same length", BokehUserWarning))
/Users/stephenmolloy/git/Pynac/venv/lib/python3.6/site-packages/bokeh/models/sources.py:81: BokehUserWarning: ColumnDataSource's columns must be of the same length
lambda: warnings.warn("ColumnDataSource's columns must be of the same length", BokehUserWarning))
/Users/stephenmolloy/git/Pynac/venv/lib/python3.6/site-packages/bokeh/models/sources.py:81: BokehUserWarning: ColumnDataSource's columns must be of the same length
lambda: warnings.warn("ColumnDataSource's columns must be of the same length", BokehUserWarning))
/Users/stephenmolloy/git/Pynac/venv/lib/python3.6/site-packages/bokeh/models/sources.py:81: BokehUserWarning: ColumnDataSource's columns must be of the same length
lambda: warnings.warn("ColumnDataSource's columns must be of the same length", BokehUserWarning))