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