Skip to content

Commit

Permalink
Merge pull request #423 from ReactionMechanismGenerator/2D_plotter
Browse files Browse the repository at this point in the history
BugFix: Corrected 2D scan plots
  • Loading branch information
alongd committed Sep 20, 2020
2 parents 845bc4f + 48cf3b0 commit 95d6d8f
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions arc/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ def plot_1d_rotor_scan(angles=None,
else:
fig_name = f'{pivots}.png'
fig_path = os.path.join(path, fig_name)
plt.savefig(fig_path, dpi=120, facecolor='w', edgecolor='w', orientation='portrait', papertype=None,
plt.savefig(fig_path, dpi=120, facecolor='w', edgecolor='w', orientation='portrait',
format='png', transparent=False, bbox_inches=None, pad_inches=0.1, metadata=None)
if is_notebook():
plt.show()
Expand Down Expand Up @@ -1146,22 +1146,26 @@ def plot_2d_rotor_scan(results, path=None, label='', cmap='Blues', resolution=90
if key in keys_list:
energies[i, j] = results['directed_scan'][key]['energy']
else:
key1 = tuple(f'{dihedral:.2f}' for dihedral in [360.0 - phi0, phi1])
key2 = tuple(f'{dihedral:.2f}' for dihedral in [phi0, 360.0 - phi1])
key3 = tuple(f'{dihedral:.2f}' for dihedral in [360.0 + phi0, phi1])
key4 = tuple(f'{dihedral:.2f}' for dihedral in [phi0, 360.0 + phi1])
key5 = tuple(f'{dihedral:.2f}' for dihedral in [360.0 + phi0, 360.0 + phi1])
key6 = tuple(f'{dihedral:.2f}' for dihedral in [360.0 - phi0, 360.0 - phi1])
key7 = tuple(f'{dihedral:.2f}' for dihedral in [-phi0, phi1])
key8 = tuple(f'{dihedral:.2f}' for dihedral in [phi0, -phi1])
key9 = tuple(f'{dihedral:.2f}' for dihedral in [-phi0, -phi1])
for key_ in [key1, key2, key3, key4, key5, key6, key7, key8, key9]:
keys = list()
keys.append(tuple(f'{dihedral:.2f}' for dihedral in [360.0 - phi0, phi1]))
keys.append(tuple(f'{dihedral:.2f}' for dihedral in [phi0, 360.0 - phi1]))
keys.append(tuple(f'{dihedral:.2f}' for dihedral in [360.0 + phi0, phi1]))
keys.append(tuple(f'{dihedral:.2f}' for dihedral in [phi0, 360.0 + phi1]))
keys.append(tuple(f'{dihedral:.2f}' for dihedral in [360.0 + phi0, 360.0 + phi1]))
keys.append(tuple(f'{dihedral:.2f}' for dihedral in [360.0 - phi0, 360.0 - phi1]))
keys.append(tuple(f'{dihedral:.2f}' for dihedral in [-phi0, phi1]))
keys.append(tuple(f'{dihedral:.2f}' for dihedral in [phi0, -phi1]))
keys.append(tuple(f'{dihedral:.2f}' for dihedral in [-phi0, -phi1]))
keys.append(tuple(f'{dihedral:.2f}' for dihedral in [phi0 - 360.0, phi1]))
keys.append(tuple(f'{dihedral:.2f}' for dihedral in [phi0, phi1 - 360.0]))
keys.append(tuple(f'{dihedral:.2f}' for dihedral in [phi0 - 360.0, phi1 - 360.0]))
for key_ in keys:
if key_ in keys_list:
energies[i, j] = results['directed_scan'][key_]['energy']
break
else:
logger.warning(f'Could not replace {key} when plotting 2D scan for {label} ({path}).\n'
f'Tried: {[key1, key2, key3, key4, key5, key6, key7, key8, key9]}.')
f'Tried: {keys}.')
if mark_lowest_conformations and energies[i, j] == 0:
zero_phi0.append(phi0)
zero_phi1.append(phi1)
Expand All @@ -1177,10 +1181,11 @@ def plot_2d_rotor_scan(results, path=None, label='', cmap='Blues', resolution=90
plt.ylabel(f'Dihedral 2 for {results["scans"][1]} (degrees)')
label = ' for ' + label if label else ''
plt.title(f'2D scan energies (kJ/mol){label}')
min_x = int(np.ceil(np.min(phis0) / 10.0)) * 10
# min_x = int(np.ceil(np.min(phis0) / 10.0)) * 10
min_x = min_y = -180
plt.xlim = (min_x, min_x + 360)
plt.xticks(np.arange(min_x, min_x + 361, step=60))
min_y = int(np.ceil(np.min(phis1) / 10.0)) * 10
# min_y = int(np.ceil(np.min(phis1) / 10.0)) * 10
plt.ylim = (min_y, min_y + 360)
plt.yticks(np.arange(min_y, min_y + 361, step=60))

Expand All @@ -1194,9 +1199,10 @@ def plot_2d_rotor_scan(results, path=None, label='', cmap='Blues', resolution=90
if path is not None:
fig_name = f'{results["directed_scan_type"]}_{results["scans"]}.png'
fig_path = os.path.join(path, fig_name)
plt.savefig(fig_path, dpi=resolution, facecolor='w', edgecolor='w', orientation='portrait', papertype=None,
plt.savefig(fig_path, dpi=resolution, facecolor='w', edgecolor='w', orientation='portrait',
format='png', transparent=False, bbox_inches=None, pad_inches=0.1, metadata=None)

plt.show()
plt.close(fig=fig)


Expand Down

0 comments on commit 95d6d8f

Please sign in to comment.