From 03fb4a81abada0d0c7cf143ffbc01d64b08b7992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Tich=C3=A1=C4=8Dek?= Date: Fri, 21 Jul 2017 14:45:57 +0200 Subject: [PATCH 1/3] Options to select data to plot Added parameter -w --wavelength to select data to plot. Plots all data if left empty. Multiple data rows can be selected as e.g. -w 215nm -w 280nm. --- examplescripts/pycorn-bin.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/examplescripts/pycorn-bin.py b/examplescripts/pycorn-bin.py index 0b0b56f..ebcf5df 100644 --- a/examplescripts/pycorn-bin.py +++ b/examplescripts/pycorn-bin.py @@ -81,6 +81,8 @@ help="Data for 2nd y-axis (Default=Cond), to disable 2nd y-axis, use --par1 None") group1.add_argument("--par2", type = str, default=None, help="Data for 3rd y-axis (Default=None)") +parser.add_argument("-w", "--wavelength", action='append', default=None, + help="Data to plot (Default=None)") group1.add_argument('-f', '--format', type = str, choices=['svg','svgz','tif','tiff','jpg','jpeg', 'png','ps','eps','raw','rgba','pdf','pgf'], @@ -144,7 +146,17 @@ def smartscale(inp): checks user input/fractions to determine scaling of x/y-axis returns min/max for x/y ''' - UV_blocks = [i for i in inp.keys() if i.startswith('UV') and not i.endswith('_0nm')] + #UV_blocks = [i for i in inp.keys() if i.startswith('UV') and not i.endswith('_0nm')] + UV_blocks = [] + for i in inp.keys(): + if i.startswith('UV') and not i.endswith('_0nm'): + plot_this_data = True + if args.wavelength: + plot_this_data = any([w in i for w in args.wavelength]) + + if plot_this_data: + UV_blocks.append(i) + uv1_data = inp[UV_blocks[0]]['data'] uv1_x, uv1_y = xy_data(uv1_data) try: @@ -210,11 +222,17 @@ def plotterX(inp,fname): host.set_ylim(plot_y_min, plot_y_max) for i in inp.keys(): if i.startswith('UV') and not i.endswith('_0nm'): - x_dat, y_dat = xy_data(inp[i]['data']) - print("Plotting: " + inp[i]['data_name']) - stl = styles[i[:4]] - p0, = host.plot(x_dat, y_dat, label=inp[i]['data_name'], color=stl['color'], - ls=stl['ls'], lw=stl['lw'],alpha=stl['alpha']) + + plot_this_data = True + if args.wavelength: + plot_this_data = any([w in i for w in args.wavelength]) + + if plot_this_data: + x_dat, y_dat = xy_data(inp[i]['data']) + print("Plotting: " + inp[i]['data_name']) + stl = styles[i[:4]] + p0, = host.plot(x_dat, y_dat, label=inp[i]['data_name'], color=stl['color'], + ls=stl['ls'], lw=stl['lw'],alpha=stl['alpha']) if args.par1 == 'None': args.par1 = None if args.par1: From 7b7d10eba2ef54f414f66217c986b6f4ef085868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Tich=C3=A1=C4=8Dek?= Date: Sat, 22 Jul 2017 12:09:31 +0200 Subject: [PATCH 2/3] Allow to change output file name Add parameter -o --output to specify output file name (default still works) --- examplescripts/pycorn-bin.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examplescripts/pycorn-bin.py b/examplescripts/pycorn-bin.py index ebcf5df..70916b6 100644 --- a/examplescripts/pycorn-bin.py +++ b/examplescripts/pycorn-bin.py @@ -297,7 +297,10 @@ def plotterX(inp,fname): host.yaxis.set_minor_locator(AutoMinorLocator()) if not args.no_title: plt.title(fname, loc='left', size=9) - plot_file = fname[:-4] + "_" + inp.run_name + "_plot." + args.format + if not args.output: + plot_file = fname[:-4] + "_" + inp.run_name + "_plot." + args.format + else: + plot_file = args.output plt.savefig(plot_file, bbox_inches='tight', dpi=args.dpi) print("Plot saved to: " + plot_file) plt.clf() From 27cdf9e6d7e95d1d999bf5a7aabdbe9785e6583a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Tich=C3=A1=C4=8Dek?= Date: Sat, 22 Jul 2017 12:09:31 +0200 Subject: [PATCH 3/3] Revert "Allow to change output file name" This reverts commit 7b7d10eba2ef54f414f66217c986b6f4ef085868. --- examplescripts/pycorn-bin.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/examplescripts/pycorn-bin.py b/examplescripts/pycorn-bin.py index 70916b6..ebcf5df 100644 --- a/examplescripts/pycorn-bin.py +++ b/examplescripts/pycorn-bin.py @@ -297,10 +297,7 @@ def plotterX(inp,fname): host.yaxis.set_minor_locator(AutoMinorLocator()) if not args.no_title: plt.title(fname, loc='left', size=9) - if not args.output: - plot_file = fname[:-4] + "_" + inp.run_name + "_plot." + args.format - else: - plot_file = args.output + plot_file = fname[:-4] + "_" + inp.run_name + "_plot." + args.format plt.savefig(plot_file, bbox_inches='tight', dpi=args.dpi) print("Plot saved to: " + plot_file) plt.clf()