-------------------
GENERAL INFORMATION
-------------------

Title of Dataset:The Raspberry Pi Auto-aligner: Machine Learning for Automated Alignment of Laser Beams

Author Information (Name, Institution, Address, Email)

	Principal Investigator: Ifan G. Hughes, Durham University, Science Site, South Road, Durham, DH1 3LE, U.K. ifan.g.hughes@durham.ac.uk
	Associate or Co-investigator: Danielle Pizzey, Durham University, Science Site, South Road, Durham, DH1 3LE, U.K. danielle.boddy@durham.ac.uk
	Alternate Contact(s): Renju S. Mathew, Durham University, Science Site, South Road, Durham, DH1 3LE, U.K. renju.s.mathew@durham.ac.uk

Date of data collection (single date, range, approximate date): 20190328-20190329

Geographic location of data collection: Durham University, U.K. 

Information about funding sources or sponsorship that supported the collection of the data: EPSRC Grant No. EP/R002061/1



--------------------
DATA & FILE OVERVIEW
--------------------

File list (filenames, directory structure (for zipped files) and brief description of all data files): figure 4(b):"controller_archive_2019-03-28_10-06"; figure 4(a):"controller_archive_2019-03-28_15-57"; figure 3(a): "controller_archive_2019-03-29_15-01"; figure 3(b):"learner_archive_2019-03-29_15-01"; "powers"; "x"; and "y"

Relationship between files, if important for context:  "powers", "x" and "y" enable a 3D plot to be produced (figure 2). "x" is changing the yaw knob on the kinematic mirror mount, and "y" is changing the pitch knob on the kinematic mirror mount. Both "x" and "y" are defined in motor steps. The "powers" data relates to the optical power out of a fiber and is in units of milliWatts.

--------------------------
METHODOLOGICAL INFORMATION
--------------------------
The methodological information can be found in the paper and Supplementary Materials. 

--------------------------
DATA-SPECIFIC INFORMATION 
--------------------------

Here is the python code to reproduce figure 2:

import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib import rc
import numpy as np
import matplotlib.colors as mcolors
from mpl_toolkits.mplot3d import axes3d, Axes3D #<-- Note the capitalization!
import math
import scipy.interpolate as interpolate
import matplotlib.font_manager as font_manager

# Durham colours old and new
durham_cs = {"red" : "#AA2B4A", "blue" : "#006388", "purple" : "#7E317B", "gold": '#E8E391',
"green": '#9FA161', "lightblue" : "#C4E5FA", "cyan": "#00AEEF",

from pylab import *
from numpy import *
from matplotlib.widgets import Button
from matplotlib import rc
import glob
import csv

## for Palatino and other serif fonts use:
rc('font',**{'family':'serif','serif':['Times New Roman']})
rc('text', usetex=True)
params={'axes.labelsize':14,'xtick.labelsize':11,'ytick.labelsize':11}
rcParams.update(params)

# Data for three-dimensional scattered points

Y = np.loadtxt('y.csv')
Z = np.loadtxt('powers.csv')

fig = plt.figure()
fig.set_size_inches(5,3.5)

# Sets the background colour for the mesh

ax = fig.add_subplot(111, projection='3d')
ax.w_xaxis.set_pane_color((1.0, 1.0, 1.0, 1.0))
ax.w_yaxis.set_pane_color((1.0, 1.0, 1.0, 1.0))
ax.w_zaxis.set_pane_color((1.0, 1.0, 1.0, 1.0))
ax.grid(False)
ax.view_init(45, 180+ (180/2)+ 45)
ax.plot_trisurf(X, Y, Z, color='lightblue', edgecolors='steelblue', alpha=0.25)
ax.scatter3D(X, Y, Z, c = "darkblue")


# Axes labels.

# labelpad moves the axes label with respect to the axes.
ax.set_xlabel('Mirror yaw (motor steps)',labelpad=10)
ax.set_ylabel('Mirror pitch (motor steps)',labelpad=10)
ax.set_zlabel('Power (mW)',labelpad=5)
plt.tight_layout()
plt.savefig('reproducibility.pdf')
ax.view_init(15,-49)

# Position the figure within the window

plt.subplots_adjust(left=0, bottom=0.1, right=0.95, top=0.95, wspace=None,hspace=None)
plt.show()

## Set the geometry of the window the figure is plotted in

plt.get_current_fig_manager().window.setGeometry(400,100,700,600)

=========================================================================

Here is the python code to reproduce figure 4:

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib import rc
import numpy as np
import matplotlib.colors as mcolors
from mpl_toolkits.mplot3d import axes3d, Axes3D #<-- Note the capitalization!
import math
import scipy.interpolate as interpolate
#from matplotlib.font_manager import FontProperties
import matplotlib.font_manager as font_manager
import os
from matplotlib.ticker import MultipleLocator
import matplotlib.ticker as tck
import scipy.io as sio
import pandas as pd

from pylab import *
from numpy import *
from matplotlib.widgets import Button
from matplotlib import rc
import glob
import csv

## for Palatino and other serif fonts use:
rc('font',**{'family':'serif','serif':['Times New Roman']})
rc('text', usetex=True)

params={'axes.labelsize':14,'xtick.labelsize':11,'ytick.labelsize':11}
rcParams.update(params)

# Data for scatter 
from os import listdir
from os.path import isfile, join

mypath = " " # state where the files are stored
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
#print onlyfiles
matfiles = []
matfiles = [f for f in onlyfiles if ('.mat' in f)]
print (matfiles)

mat_contents = sio.loadmat(mypath+'controller_archive_2019-03-28_15-57.mat')
mat_contents
y=np.squeeze(mat_contents['out_params']) ; x=range(len(y))
size = 5

fig, ax = plt.subplots()

# Set figure size width, height
fig.set_size_inches(5,3.5)
z = np.array(y[:,0])/max(abs(y[:,0]))
ax.scatter(x,z, s = size) ;
z = np.array(y[:,1])/max(abs(y[:,1]))
ax.scatter(x,z, s = size) ;
z = np.array(y[:,2])/max(abs(y[:,2]))

ax.scatter(x,z, s = size) ;
z = np.array(y[:,3])/max(abs(y[:,3]))
ax.scatter(x,z, s = size) ;
# Set axis limits
axlim = 80
ax.set_xlim((0, axlim+1))

ax.yaxis.set_minor_locator(tck.AutoMinorLocator(5))
ax.xaxis.set_minor_locator(tck.AutoMinorLocator(5))

plt.xticks(np.arange(0, axlim+1, 10.0))
plt.yticks(np.arange(-1, max(z)+0.1, 0.5))

plt.show()

plt.ylabel("Parameter value (arb. units)")
plt.xlabel("Run number")
plt.figtext(0.01, 0.945, "(a)", ha="left", fontsize=14)

plt.savefig("controller_archive_2019-03-28_15-57.png")
plt.savefig("controller_archive_2019-03-28_15-57.pdf")
plt.subplots_adjust(left=0.2, bottom=0.15, right=0.98, top=0.88, wspace=None,hspace=None)

## The same code is used for figure 4(b) except with a change of datafile name.