Plot examples¶
In [1]:
Copied!
# Useful for debugging
%load_ext autoreload
%autoreload 2
# Useful for debugging
%load_ext autoreload
%autoreload 2
In [2]:
Copied!
from astra import Astra, run_astra_with_distgen
from astra.plot import plot_fieldmaps, plot_stats, plot_stats_with_layout
import matplotlib
import matplotlib.pyplot as plt
matplotlib.rcParams['figure.figsize'] = (16,4)
%config InlineBackend.figure_format = 'retina'
%matplotlib inline
import os
from astra import Astra, run_astra_with_distgen
from astra.plot import plot_fieldmaps, plot_stats, plot_stats_with_layout
import matplotlib
import matplotlib.pyplot as plt
matplotlib.rcParams['figure.figsize'] = (16,4)
%config InlineBackend.figure_format = 'retina'
%matplotlib inline
import os
In [3]:
Copied!
# Input template file
ASTRA_IN = 'templates/dcgun/astra.in'
# Make an Astra object
A = Astra(input_file=ASTRA_IN)
# Input template file
ASTRA_IN = 'templates/dcgun/astra.in'
# Make an Astra object
A = Astra(input_file=ASTRA_IN)
Fieldmap plot from A.input¶
In [4]:
Copied!
A.plot_fieldmaps()
A.plot_fieldmaps()
Stat plots from completed run¶
In [5]:
Copied!
# Run Astra with Distgen
DISTGEN_IN = 'templates/dcgun/distgen.yaml'
settings = {'zstop':1, 'zemit':200, 'zphase':1, 'phases':True}
settings['distgen:n_particle'] = 2000
A2 = run_astra_with_distgen(settings=settings, astra_input_file=ASTRA_IN,
distgen_input_file=DISTGEN_IN)
# Run Astra with Distgen
DISTGEN_IN = 'templates/dcgun/distgen.yaml'
settings = {'zstop':1, 'zemit':200, 'zphase':1, 'phases':True}
settings['distgen:n_particle'] = 2000
A2 = run_astra_with_distgen(settings=settings, astra_input_file=ASTRA_IN,
distgen_input_file=DISTGEN_IN)
In [6]:
Copied!
matplotlib.rcParams['figure.figsize'] = (16,10)
# Modify limits
plot_stats(A2)
matplotlib.rcParams['figure.figsize'] = (16,10)
# Modify limits
plot_stats(A2)
Compact summary plot¶
In [7]:
Copied!
?plot_stats_with_layout
?plot_stats_with_layout
In [8]:
Copied!
kwargs = {'figsize':(10,5)}
plot_stats_with_layout(A2, ykeys=['sigma_x', 'sigma_y'], ykeys2=['sigma_z'],
xkey='mean_z', xlim=(0, 1.3),
nice=True,
include_layout=False,
include_labels=True,
include_particles=True,
include_legend=True, **kwargs)
kwargs = {'figsize':(10,5)}
plot_stats_with_layout(A2, ykeys=['sigma_x', 'sigma_y'], ykeys2=['sigma_z'],
xkey='mean_z', xlim=(0, 1.3),
nice=True,
include_layout=False,
include_labels=True,
include_particles=True,
include_legend=True, **kwargs)
In [9]:
Copied!
# The convenience plottings slightly changes the keys
A2.plot( y=['sigma_x', 'sigma_y'], y2=['sigma_z'], x='mean_z', xlim=(0,1.3), figsize=(10,5))
# The convenience plottings slightly changes the keys
A2.plot( y=['sigma_x', 'sigma_y'], y2=['sigma_z'], x='mean_z', xlim=(0,1.3), figsize=(10,5))