############################################################################# # This script runs the sweep and plots the bandstructure for # bandstructure_1D.fsp and bandstucture_1D_fixed.fsp ############################################################################# # User Defined properties: tolerance = 0.01; #tolerance for finding peaks and accepting bands # setting this too low will result in noisy data where sidelobes of # peaks are interpreted as new bands # setting it too high will mean that some bands are not found num_band = 1; #number of bands to search for in the bandstructure # ############################################################################# runsweep; # run the sweep # get the bandstructure data from the sweep sweepname="kx"; kx=getsweepdata(sweepname,"kx"); spectrum=getsweepresult(sweepname,"spectrum"); f=c/spectrum.lambda; bandstructure=matrix(num_band,length(kx)); for (i=1:length(kx)) { #use findpeaks to find the maximum peaks fs=(pinch(spectrum.fs,2,i)); temp = findpeaks(fs,num_band); #collect data for any peaks that are more than 'tolerance' of the maximum peak (to avoid minor peaks like sielobes) minvalue = fs(temp(1))*tolerance; f_band=matrix(num_band); for(bandcount = 1:num_band) { if( fs(temp(bandcount)) > minvalue) { f_band(bandcount) = f(temp(bandcount)); } } bandstructure(1:num_band,i)=f_band; } # plot the bandstructure results bandstructure=transpose(bandstructure); kd=linspace(0,0.5,10); plot(kx*2*pi,bandstructure*2*pi/5.42e15,"kd","f/f0","bandstructure","plot points");