#Script for re-plotting drift-measurement data measured from stacks in GMS # as a trajectory. #Requires Matplotlib #To install packages like scipy, see instructions in GMS Help:Python:Installation and Configuration:Additional Packages #Code written by Ben Miller. Last Updated 2020-06 import numpy as np import sys if (DM.IsScriptOnMainThread() == False): print(' MatplotLib and scipy scripts require to be run on the main thread.', '\n Uncheck the "Execute on Background Thread"', 'checkbox at the bottom of the Script Window' ) exit() sys.argv.extend(['-a', ' ']) import matplotlib.pyplot as plt def plot_drift_data(data,title): def axes_setup(): fig, ax = plt.subplots() ax.axvline(0,color='0.75') ax.axhline(0,color='0.75') ax.axis('scaled') plt.xlabel('Drift (nm)',fontsize=14) plt.ylabel('Drift (nm)',fontsize=14) return ax drift_plot = axes_setup() plt.title(title,fontsize=12) ax_lim = 1.1*max(np.linalg.norm(data,axis=0)) drift_plot.axis([-ax_lim, ax_lim, -ax_lim, ax_lim]) drift_plot.plot(data[1,:],data[0,:]) plt.show() image_0 = DM.GetFrontImage() im_name = image_0.GetName() numpy_array = image_0.GetNumArray()*image_0.GetIntensityScale() plot_drift_data(numpy_array,im_name) del image_0