C ODE
E.2 Code to determine optical path length change in P ip and P pp
E.2 Code to determine optical path length change in Pipand Ppp 165
sparam = dictionary containing surface absorption data such as : angle of incidence , temperature
distribution , OPLTE all data values are normalised by absorption
x,y = position coordinates corresponding to dis
"""
from scipy . linalg import norm
from scipy . optimize import minimize
return norm( fit_funcxs ( ypos[0],coeff[0],coeff[1],0,dic ,param ,sp )- ydata[0])**2+ norm( fit_funcys ( ypos [1],coeff[0], coeff[1],0,dic ,param ,sp) -ydata[1])**2
E.2 Code to determine optical path length change in P
ipOUTPUT : coordinate vector and OPL_TR for IP slice
"""
# loading in required sample parameters rad=parameters['a']
length= parameters['h']
dndt = parameters['dndt '] n= parameters['n_ref ']
angle_t=np. arcsin (1/n*np.sin( angle )) # calculating transmitted angle
x=np.linspace(-rad ,rad ,len( data[0,:])) # creating a vector of xin
z = np.linspace(0, length , len( data[:,0]) # creating a vector of zin
X,Z= np.array(np. meshgrid (x,z)) # creating a mesh of coordinates for 2d array
xz = np.c_[X.flatten() ,Z.flatten()] # create x and z coordinates as list
T_vec=np. matrix .flatten( data ) # flatten temp distribution into 1d array
F = LinearNDInterpolator (xz , T_vec , fill_value=0) # Create function of temperature distribution
def ang (x0 , alpha ,no): # define integration
over beam path s=np.linspace(0,1,no)
x_ = x0 - s * length * np.tan( alpha ) z_ = s * length
integrand=F(x_ , z_)
# find temperature dist
return integrate . trapz ( integrand , x=s*length/np.cos( angle_t ))
E.2 Code to determine optical path length change in Pipand Ppp 167
F_intT = np.vectorize(lambda x0: ang (x0 , angle_t ,no)) # create vector function
intT= np.array( F_intT (x)) intT =( intT-intT .max())*dndt
# defining output array with x shift due to angled propogation through the sample
x_vec = np.linspace(-rad -length * np.tan( angle_t )/2, rad- length * np .tan( angle_t )/2, r_len )
return x_vec*np.cos( angle ), intT
def OPL_TR_PP ( parameters ,TD_Y , angle ):
""" calculate the optical path length change in the OPLpp slice parameters = dictionary of sample parameters
data = 2D array of change temperature distribution in the PP plane , the Y slice rotated by the
specified theta_t around the Y axis
angle = angle of incidence
no = defines how many points along the Z axis the probe ebam path is evaluated at
OUTPUT : coordinate vector and OPL_TR for PP slice
"""
# loading glass parameters a = dic["ay"]
h = dic["h"]
n_ref= dic['n_ref ']
dndT = dic['dndt ']
angle_T=np. arcsin (1/n_ref*np.sin( angle )) # find transmitted angle
x_new=np.linspace(-a,a,len( TD_Y[:,1])) # define radial vector
z_new=np.linspace(0,h/np.cos( angle_T ),len( TD_Y[1])) # define length vector
integr=sci . trapz (TD_Y ,z_new , axis=1)*dndT # integrate over path length anf multiply
#by thermo - optic coefficient return x_new , integr
def OPL_TE_slice ( parameters , x,y,dis ,angle , outx ,outy , xe=None,ye= None, dise = None):
""" calculate the optical path length change due to thermal expansion of rays starting at coordinates outx , outy
parameters = dictionary of sample parameters x,y = position coordinates corresponding to dis
dis = array of displacment of input face at position x,y, angle = angle of incidence
outx , outy = X and Y coordinates to evaluated OPL_TE at
xe ,ye = output face deformation position coordinates . If None assumes front andd back faces have the same deformation
dise = array of displacement of output face at position x,y. If None assumes front andd back faces have
the same deformation
OUTPUT : coordinate vector and OPL_TE for any set of coordinates
"""
E.2 Code to determine optical path length change in Pipand Ppp 169
a=0 # determine if output face
data inputted
if( dise is None): #if no output face data
set input = output dise=dis
xe=x ye=y a=1
angle_t=np. arcsin (1/parameters['n_ref ']*np.sin( angle )) # calculate transmission angle
# Interpolate the additional distance passed through the endface deformation for rays at given coordinates . The front face is shifted by the distance translated
over the sample
front =( griddata ((x*1e-3+parameters['h']*np.tan( angle_o ),y*1e-3),dis*
1e-3/np.cos( angle ) ,(outx , outy ), method ='linear ', fill_value=np. nan ))
back = ( griddata (( xe*1e-3,ye*1e-3),dise*1e-3/np.cos( angle ) ,(outx , outy ), method ='linear ', fill_value=np.
nan )) if a ==0: # invert output face data if given back= -1*( nonan ( back )-nonan ( back ).max())
tot= nonan (( front+back ))*( parameters[" n_ref "]-1) # Add addditional distances travelled by each ray and convert to OPL
if tot[-1]> tot[ int(len( tot )/2)]: # ensure OPL is positive tot=-1*( tot-tot .max())
return ( outx-parameters['h']*np.tan( angle_o )/2)*np.cos( angle ),outy ,(
tot ) # Output OPLTe translated to plane conjugate to HES
def TE_IP_PP ( parameters , x,y,dis ,angle , xe=None,ye=None, dise = None) :
""" calculate the optical path length change due to thermal expansion of rays in the ip and pp plane parameters = dictionary of sample parameters
x,y = position coordinates corresponding to dis
dis = array of displacment of input face at position x,y, angle = angle of incidence
xe ,ye = output face deformation position coordinates . If None assumes front andd back faces have the same deformation
dise = array of displacement of output face at position x,y. If None assumes front andd back faces have
the same deformation OUTPUT : coordinate vector and OPL_TE for IP and PP slices
"""
angle_t=np. arcsin (1/dic['n_ref ']*np.sin( angle )) # find angle of transmission
surf_pos = dic['h']/2 *np.tan( angle_t ) # find position probe beam is incidence on the surface in the x axis
x_new = np.linspace(( y_te ).min() , ( y_te ).max() ,500 ) #x coord for IP
y_new = np.zeros( 500 ) # Y coord for IP
x1 ,_, xted = TEdata (y_te ,x_te , dis_vec ,x_new ,y_new ,angle , dic ) # determine OPL for IP
y_newy = np.linspace(( x_te ).min() , ( x_te ).max() ,500 ) #y coord for PP
x_newy=np.linspace( surf_pos , surf_pos , 500 ) # x coord for PP
E.2 Code to determine optical path length change in Pipand Ppp 171
_,y1 , yted = TEdata (y_te ,x_te , dis_vec , x_newy , y_newy ,angle , dic ) # determine OPL for PP
return x1 ,xted ,y1 , yted # output IP coord , IP:OPLTE , output PP coord , PP:OPLTE ,
\ end{pyverbatim}
\ begin{pyverbatim}
def fit_funcIP (pos ,ab ,beta ,a, parameter , bparam , sparam= None):
""" calculate the optical path length in IP slice pos = coordinate vector in the x_h plane [mm]
ab = bulk absorption coefficient [m-1]
beta = surface absorption coefficient a = dc offset for fitting
parameters = dictionary of sample parameters
bparam = dictionary containing bulk absorption data such as : angle of incidence , temperature
distribution , OPLTE all data values are normalised by absorption
sparam = dictionary containing surface absorption data such as : angle of incidence , temperature distribution , OPLTE all data values are normalised by absorption
x,y = position coordinates corresponding to dis
OUTPUT : position vector in x_h , OPL_ip due to bulk and surface absorption