1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
# fmt: off
# Note:
# Try to avoid module level import statements here to reduce
# import time during CLI execution
class CLICommand:
"""Analyze NEB trajectories by making band plots.
One file:
ase nebplot neb.traj
Multiple files:
ase nebplot neb1.traj neb2.traj
Specify output:
ase nebplot neb1.traj neb2.traj myfile.pdf
"""
@staticmethod
def add_arguments(parser):
add = parser.add_argument
add('filenames', nargs='+',
help='one or more trajectory files to analyze')
add('output', nargs='?',
help='optional name of output file, default=nebplots.pdf')
add('--nimages', dest='n_images', type=int, default=None,
help='number of images per band, guessed if not supplied')
add('--share-x', dest='constant_x', action='store_true',
help='use a single x axis scale for all plots')
add('--share-y', dest='constant_y', action='store_true',
help='use a single y axis scale for all plots')
@staticmethod
def run(args, parser):
from ase.gui.images import Images
from ase.mep import NEBTools
# Nothing will ever be stored in args.output; need to manually find
# if its supplied by checking extensions.
if args.filenames[-1].endswith('.pdf'):
args.output = args.filenames.pop(-1)
else:
args.output = 'nebplots.pdf'
images = Images()
images.read(args.filenames)
nebtools = NEBTools(images=images)
nebtools.plot_bands(constant_x=args.constant_x,
constant_y=args.constant_y,
nimages=args.n_images,
label=args.output[:-4])
|