1 #pragma rtGlobals=3// Use modern global access method and strict wave access. 3 #pragma IgorVersion = 6.2 4 #pragma ModuleName = PearlAnglescanProcess 5 #include "pearl-vector-operations" 6 #include "pearl-polar-coordinates" 7 #include <New Polar Graphs> 118 variable snx = dimsize(strip, 0)
119 variable sny = dimsize(strip, 1)
121 variable sq1hi = max(qlo-1, 0)
122 variable sq2lo = min(qhi+1, sny - 1)
123 variable sq2hi = dimsize(strip, 1) - 1
127 variable dny = sny - (sq2lo - sq1hi + 1)
129 variable dq1hi = sq1hi
130 variable dq2lo = dq1hi + 1
131 variable dq2hi = dny - 1
132 variable q1ofs = sq1lo - dq1lo
133 variable q2ofs = sq2lo - dq2lo
135 duplicate /free strip, strip_copy
136 redimension /n=(dnx,dny) strip
137 strip[][dq1lo,dq1hi] = strip_copy[p][q + q1ofs]
138 strip[][dq2lo,dq2hi] = strip_copy[p][q + q2ofs]
140 duplicate /free theta, theta_copy
141 redimension /n=(dny) theta
142 theta[dq1lo,dq1hi] = theta_copy[p + q1ofs]
143 theta[dq2lo,dq2hi] = theta_copy[p + q2ofs]
145 duplicate /free tilt, tilt_copy
146 redimension /n=(dny) tilt
147 tilt[dq1lo,dq1hi] = tilt_copy[p + q1ofs]
148 tilt[dq2lo,dq2hi] = tilt_copy[p + q2ofs]
150 duplicate /free phi, phi_copy
151 redimension /n=(dny) phi
152 phi[dq1lo,dq1hi] = phi_copy[p + q1ofs]
153 phi[dq2lo,dq2hi] = phi_copy[p + q2ofs]
185 variable
normalize_strip_x(wave strip, variable smooth_method = defaultValue, variable smooth_factor = defaultValue, variable check = defaultValue){
187 variable smooth_method
188 variable smooth_factor
191 if (ParamIsDefault(smooth_method))
194 if (ParamIsDefault(smooth_factor))
195 switch(smooth_method)
203 if (ParamIsDefault(check))
209 variable div = mean(dist)
213 duplicate /o dist, check_dist
217 switch(smooth_method)
219 Smooth /B /E=3 smooth_factor, dist
222 Smooth /E=3 smooth_factor, dist
225 make /n=1 /d /free fit_params
230 loess /smth=(smooth_factor) srcWave=dist
235 duplicate /o dist, check_smoo
275 variable
normalize_strip_theta(wave strip, wave theta, variable theta_offset = defaultValue, variable smooth_method = defaultValue, variable smooth_factor = defaultValue, variable check = defaultValue){
278 variable theta_offset
279 variable smooth_method
280 variable smooth_factor
283 if (ParamIsDefault(check))
286 if (ParamIsDefault(theta_offset))
289 if (ParamIsDefault(smooth_method))
292 if (ParamIsDefault(smooth_factor))
300 duplicate /free dist, dist_smoo
301 duplicate /free theta, theta_int
302 theta_int = theta - theta_offset
303 setscale /p x theta_int[0], theta_int[1] - theta_int[0], waveunits(theta,-1), dist, dist_smoo
304 variable nx = dimsize(strip, 0)
307 switch(smooth_method)
309 Smooth /B /E=3 smooth_factor, dist_smoo
312 Smooth /E=3 smooth_factor, dist_smoo
315 loess /dest=dist_smoo /smth=(smooth_factor) srcWave=dist, factors={theta_int}
318 for (ix = 0; ix < nx; ix += 1)
320 if (smooth_factor > 1)
321 CurveFit /nthr=0 /q /w=2 poly smooth_factor+1, dist /x=theta_int /d=dist_smoo
323 CurveFit /nthr=0 /q /w=2 line, dist /x=theta_int /d=dist_smoo
325 strip[ix,ix][] /= dist_smoo[q]
333 strip /= dist_smoo[q]
338 duplicate /o dist, check_dist
339 duplicate /o dist_smoo, check_smoo
340 setscale /p x dimoffset(dist,0), dimdelta(dist,0), waveunits(dist,0), check_dist, check_smoo
357 variable
normalize_strip_2d(wave strip, wave theta, variable theta_offset = defaultValue, variable smooth_method = defaultValue, variable smooth_factor = defaultValue, variable check = defaultValue){
360 variable theta_offset
361 variable smooth_method
362 variable smooth_factor
365 if (ParamIsDefault(check))
368 if (ParamIsDefault(theta_offset))
371 if (ParamIsDefault(smooth_method))
374 if (ParamIsDefault(smooth_factor))
378 variable nx = dimsize(strip, 0)
379 variable ny = dimsize(strip, 1)
381 duplicate /free strip, dist, alpha_int, theta_int
382 theta_int = theta[q] - theta_offset
383 alpha_int = dimoffset(strip, 0) + p * dimdelta(strip, 0)
384 redimension /n=(nx * ny) dist, alpha_int, theta_int
386 switch(smooth_method)
388 loess /dest=dist_smoo /smth=(smooth_factor) srcWave=dist, factors={alpha_int, theta_int}
389 redimension /n=(nx, ny) dist_smoo
392 Abort
"undefined smooth method" 404 duplicate /o dist_smoo, check_smoo
422 variable plo = round((xlo - dimoffset(strip, 0)) / dimdelta(strip, 0))
423 variable phi = round((xhi - dimoffset(strip, 0)) / dimdelta(strip, 0))
424 xlo = plo * dimdelta(strip, 0) + dimoffset(strip, 0)
425 xhi = phi * dimdelta(strip, 0) + dimoffset(strip, 0)
426 variable nx = phi - plo + 1
427 variable ny = dimsize(strip, 1)
429 duplicate /free strip, strip_copy
430 redimension /n=(nx,ny) strip
431 strip = strip_copy[p + plo][q]
432 setscale /i x xlo, xhi, waveunits(strip, 0), strip
477 variable
pizza_service(wave data,
string nickname, variable theta_offset, variable tilt_offset, variable phi_offset, variable npolar = defaultValue, variable nograph = defaultValue, variable folding = defaultValue, variable xpdplot = defaultValue){
480 variable theta_offset
488 if (ParamIsDefault(npolar))
491 if (ParamIsDefault(nograph))
494 if (ParamIsDefault(folding))
497 if (ParamIsDefault(xpdplot))
502 dfref saveDF = GetDataFolderDFR()
503 dfref dataDF = GetWavesDataFolderDFR(data)
505 if (DataFolderExists(
":attr"))
508 dfref attrDF = GetDataFolderDFR()
510 wave /sdfr=attrDF ManipulatorTheta
511 wave /sdfr=attrDF ManipulatorTilt
512 wave /sdfr=attrDF ManipulatorPhi
514 if ((dimsize(ManipulatorTheta, 0) != dimsize(data, 1)) || (dimsize(ManipulatorTilt, 0) != dimsize(data, 1)) || (dimsize(ManipulatorPhi, 0) != dimsize(data, 1)))
515 Abort
"Warning: The dimension size of the manipulator waves does not match the Y dimension of the data wave!\rIf you restructured the data wave, please use pizza_service_2 with properly scaled manipulator waves." 518 duplicate /free ManipulatorTheta, m_theta
519 duplicate /free ManipulatorTilt, m_tilt
520 duplicate /free ManipulatorPhi, m_phi
522 m_theta -= theta_offset
523 m_tilt -= tilt_offset
526 pizza_service_2(data, nickname, m_theta, m_tilt, m_phi, npolar=npolar, nograph=nograph, folding=folding, xpdplot=xpdplot)
570 variable
pizza_service_2(wave data,
string nickname, wave m_theta, wave m_tilt, wave m_phi, variable npolar = defaultValue, variable nograph = defaultValue, variable folding = defaultValue, variable xpdplot = defaultValue){
581 if (ParamIsDefault(npolar))
584 if (ParamIsDefault(nograph))
587 if (ParamIsDefault(folding))
590 if (ParamIsDefault(xpdplot))
594 if ((dimsize(m_theta, 0) != dimsize(data, 1)) || (dimsize(m_tilt, 0) != dimsize(data, 1)) || (dimsize(m_phi, 0) != dimsize(data, 1)))
595 Abort
"Warning: The dimension size of the manipulator waves does not match the Y dimension of the data wave!" 598 string graphname =
"graph_" + nickname
599 string outprefix = nickname
602 dfref saveDF = GetDataFolderDFR()
603 dfref dataDF = GetWavesDataFolderDFR(data)
611 newdatafolder /s/o $nickname
614 dfref destDF = GetDataFolderDFR()
618 variable /g pol_perf_secs
619 timerRefNum = startMSTimer
621 duplicate /free m_tilt, corr_tilt
622 duplicate /free m_phi, corr_phi
626 make /n=1/d/free d_polar, d_azi
632 for (ifold = 0; ifold < folding; ifold += 1)
633 d_azi = d_azi >= 360 ? d_azi - 360 : d_azi
635 d_azi += 360 / folding
639 if (strlen(outprefix))
640 string s_prefix = outprefix +
"_" 641 string s_int = s_prefix +
"i" 655 if (timerRefNum >= 0)
656 pol_perf_secs = stopMSTimer(timerRefNum) / 1e6
687 variable
show_analyser_line(variable theta, variable tilt, variable phi, variable theta_offset, variable tilt_offset, variable phi_offset, variable npolar = defaultValue, variable nograph = defaultValue, variable xpdplot = defaultValue){
691 variable theta_offset
698 string nickname =
"analyser" 700 if (ParamIsDefault(npolar))
703 if (ParamIsDefault(nograph))
706 if (ParamIsDefault(xpdplot))
709 string graphname =
"graph_" + nickname
710 string outprefix = nickname
713 dfref saveDF = GetDataFolderDFR()
714 dfref dataDF = saveDF
720 newdatafolder /s/o $nickname
723 dfref destDF = GetDataFolderDFR()
725 make /n=1 /free m_theta
726 make /n=1 /free m_tilt
727 make /n=1 /free m_phi
728 m_theta = theta - theta_offset
729 m_tilt = tilt - tilt_offset
731 m_phi = phi - phi_offset
734 make /n=60 /free data
735 setscale /i x -30, 30, data
737 make /n=1/d/free d_polar, d_azi
741 d_azi = d_azi >= 360 ? d_azi - 360 : d_azi
758 wave theta, tilt, phi
763 make /n=(dimsize(data, 0)) /d /free ana
764 setscale /p x dimoffset(data, 0), dimdelta(data, 0), waveunits(data, 0), ana
803 variable nn = numpnts(theta)
804 variable na = numpnts(analyser)
805 redimension /n=(na, nn) polar, azi
812 make /n=(3,na) /d /free w_orig_polar, w_orig_cart, w_rot_cart, w_rot_polar
813 w_orig_polar[0][] = radius
814 w_orig_polar[1][] = analyser[q]
815 w_orig_polar[2][] = 0
821 for (ii = 0; ii < nn; ii += 1)
827 w_rot_cart = w_orig_cart
834 polar[][ii] = w_rot_polar[1][p]
835 azi[][ii] = w_rot_polar[2][p]
845 variable nn = dimsize(source, 1)
846 make /n=(dimsize(source, 0))/d/free line
847 for (ii = 0; ii < nn; ii += 1)
850 dest[][ii] = line[p] / v_max
857 static variable
calc_nth(variable Theta_st, variable Theta_in, variable th, variable Phi_ran, variable Phi_ref,
string Holomode){
858 Variable Theta_st, Theta_in, th, Phi_ran, Phi_ref
861 Variable deg2rad=0.01745329
863 if ( cmpstr(Holomode,
"Stereographic") == 0)
864 The_step =trunc( Phi_ran*sin(th*deg2rad)*Phi_ref/Theta_st )
866 The_step =trunc( Phi_ran*sin(th*pi/180)*Phi_ref/Theta_st )
869 if (cmpstr(Holomode,
"Parallel") == 0)
870 The_step=trunc( Phi_ran*tan(th*deg2rad)*Phi_ref/Theta_st )
872 if ( cmpstr(Holomode,
"h") == 0)
873 The_step=trunc( th/Theta_in*Phi_ran/Theta_st )
886 static variable
calc_phi_step(variable Theta_in, variable th, variable Theta_st, variable Phi_ran, variable Phi_ref,
string Holomode){
887 Variable Theta_in, th, Theta_st, Phi_ran, Phi_ref
891 Variable deg2rad=0.01745329
893 if ( cmpstr(Holomode,
"Stereographic") == 0 )
894 if ((th < 0.5) || (trunc(Phi_ran*sin(th*deg2rad)*Phi_ref/Theta_st) == 0))
897 Phi_st=Phi_ran/(trunc(Phi_ran*sin(th*deg2rad)*Phi_ref/Theta_st))
904 if ( cmpstr(Holomode,
"Parallel") == 0 )
905 if((th < 0.5) || (trunc(Phi_ran*tan(th*deg2rad)*Phi_ref/Theta_st) == 0))
908 Phi_st=Phi_ran/(trunc(Phi_ran*tan(th*deg2rad)*Phi_ref/Theta_st))
912 if ( cmpstr(Holomode,
"h") == 0 )
913 if((th < 0.5) || (trunc(Phi_ran*sin(th*deg2rad)*Phi_ref/Theta_st) == 0))
916 Phi_st=Phi_ran/trunc(th/Theta_in*Phi_ran/Theta_st)
930 static variable
Calc_The_step(variable th, variable Theta_st,
string Holomode){
932 Variable th, Theta_st
934 Variable deg2rad=0.01745329, dt_loc,The_step
936 if ( (cmpstr(Holomode,
"Stereographic")) ==0 )
940 if ( (cmpstr(Holomode,
"h")) ==0 )
944 if ( cmpstr(Holomode,
"Parallel") == 0 )
946 dt_loc = Theta_st/cos(th*deg2rad)
961 static variable
CalcN_Theta(
string HoloMode, variable Theta_in, variable Theta_ran, variable Theta_st){
963 Variable Theta_in,Theta_ran,Theta_st
964 Variable n_theta, aux, aux1,ii
967 aux1= Theta_in - Theta_ran
971 if(aux<=Theta_in-Theta_ran)
972 aux=Theta_in-Theta_ran
975 while((aux>aux1)%&(Theta_in-aux<=Theta_ran))
999 variable
make_hemi_grid(variable npol,
string nickname, variable xpdplot = defaultValue){
1004 if (ParamIsDefault(xpdplot))
1008 string HoloMode =
"h" 1009 variable Theta_in = 90
1010 variable Theta_ran = 90
1011 variable Theta_st = 90 / (npol - 1)
1012 variable Phi_ran = 360
1013 variable Phi_ref = 1
1016 variable n_theta =
CalcN_Theta(HoloMode, Theta_in, Theta_ran, Theta_st)
1019 if (strlen(nickname))
1020 string s_prefix = nickname +
"_" 1021 string s_int = s_prefix +
"i" 1026 string s_polar = s_prefix +
"pol" 1027 string s_azim = s_prefix +
"az" 1029 string s_index = s_prefix +
"index" 1030 string s_theta = s_prefix +
"th" 1031 string s_dphi = s_prefix +
"dphi" 1032 string s_nphis = s_prefix +
"nphis" 1034 string s_HoloData = s_prefix +
"data" 1035 string s_HoloInfo = s_prefix +
"info" 1038 string s_tot = s_prefix +
"tot" 1039 string s_weight = s_prefix +
"wt" 1041 make /O/D/n=(n_theta) $s_index /wave=index
1042 make /O/D/n=(n_theta) $s_theta /wave=theta
1043 make /O/D/n=(n_theta) $s_dphi /wave=dphi
1044 make /O/D/n=(n_theta) $s_nphis /wave=nphis
1048 dphi[0] =
calc_phi_step(Theta_in, Theta_in, aux, Phi_ran, Phi_ref, HoloMode)
1050 nphis[0] =
calc_nth(aux, Theta_in, Theta_in, Phi_ran, Phi_ref, HoloMode)
1056 Theta[ii] = Theta[ii-1] - aux
1057 if(Theta[ii] <= Theta_in-Theta_ran)
1058 Theta[ii] = Theta_in-Theta_ran
1061 dphi[ii] =
calc_phi_step(Theta_in, Theta[ii], aux, Phi_ran, Phi_ref, HoloMode)
1062 nphis[ii] =
calc_nth(aux, Theta_in, Theta[ii], Phi_ran, Phi_ref, HoloMode)
1063 Index[ii] = Index[ii-1] + nphis[ii]
1067 if (Index[n_theta-1]==Index[n_theta-2])
1068 Index[n_theta-1]=Index[n_theta-2]+1
1072 variable NumPoints = sum(nphis, 0, numpnts(nphis))
1075 make /O/D/N=(NumPoints) $s_polar /wave=polar, $s_azim /wave=azim
1076 note azim,
"version=1.6" 1079 variable StartIndex = 0
1083 Polar[StartIndex, EndIndex-1]=Theta[ii]
1084 Azim[StartIndex, EndIndex-1]= mod(Phi_ran+(x-StartIndex)*dphi[ii]+Phi_in,Phi_ran)
1086 StartIndex = EndIndex
1089 duplicate /o azim, $s_int /wave=values
1090 duplicate /o azim, $s_tot /wave=totals
1091 duplicate /o azim, $s_weight /wave=weights
1098 string s_FileName =
"" 1099 string s_Comment =
"created by pearl-anglescan-process.ipf" 1100 string s_HoloMode =
"Stereographic" 1101 variable /g gb_SpectraFile = 0
1103 Make/O/D/n=22 $s_HoloData /wave=HoloData
1106 HoloData[6] = NumPoints
1107 HoloData[7] = Theta_in
1108 HoloData[8] = Theta_ran
1109 HoloData[9] = Theta_st
1110 HoloData[11] = Phi_in
1111 HoloData[12] = Phi_ran
1112 HoloData[13] = Theta_st
1113 HoloData[15] = Phi_ref
1114 HoloData[16] = Phi_ran
1117 Make/O/T/n=22 $s_HoloInfo /wave=HoloInfo
1118 HoloInfo[0] = s_FileName
1119 HoloInfo[1] = s_Comment
1120 HoloInfo[10] = s_HoloMode
1124 if (WinType(NickName) == 5)
1125 Notebook $NickName selection={startOfFile, endOfFile}
1126 Notebook $NickName text=
"" 1128 NewNotebook /F=0 /K=1 /N=$NickName /W=(5,40,341,260)
1129 Notebook $NickName defaultTab=140
1130 Notebook $NickName statusWidth=300
1131 Notebook $NickName backRGB=(56797,56797,56797)
1132 Notebook $NickName pageMargins={80,80,80,80}
1133 Notebook $NickName fSize=10
1134 Notebook $NickName fStyle=0,textRGB=(65535,0,26214)
1135 Notebook $NickName textRGB=(65535,0,26214)
1137 Notebook $NickName text =
"File:\t" + s_FileName +
"\r" 1138 Notebook $NickName text =
"*** " + s_Comment +
" ***\r\r" 1139 Notebook $NickName text =
"Angle-Mode:\t" + s_HoloMode +
"\r" 1140 Notebook $NickName text =
"XPDplot Nickname:\t" + NickName +
"\r" 1154 string wname = nameofwave(w)
1160 string s_wave_df = GetWavesDataFolder(w, 1)
1161 dfref parent_df = $(s_wave_df +
"::")
1162 nickname = GetDataFolder(0, parent_df)
1178 string wname = nameofwave(w)
1180 if (ItemsInList(wname,
"_") >= 2)
1181 prefix = StringFromList(0, wname,
"_")
1214 if (strlen(nickname))
1215 if (DataFolderExists(nickname))
1218 datadf = getdatafolderdfr()
1219 prefix = nickname +
"_" 1220 intwave = prefix +
"i" 1221 if (exists(intwave) != 1)
1226 datadf = getdatafolderdfr()
1248 string s_totals = s_prefix +
"tot" 1249 string s_weights = s_prefix +
"wt" 1251 wave /sdfr=datadf /z w_values = $s_int
1252 wave /sdfr=datadf /z w_totals = $s_totals
1253 wave /sdfr=datadf /z w_weights = $s_weights
1255 if (waveexists(w_totals))
1258 if (waveexists(w_weights))
1261 if (waveexists(w_values))
1287 variable
duplicate_hemi_scan(
string source_nickname, dfref dest_folder,
string dest_nickname, variable xpdplot = defaultValue){
1288 string source_nickname
1290 string dest_nickname
1293 if (ParamIsDefault(xpdplot))
1297 dfref savedf = getdatafolderdfr()
1300 if (strlen(source_nickname))
1301 string s_prefix = source_nickname +
"_" 1302 string s_int = s_prefix +
"i" 1307 string s_polar = s_prefix +
"pol" 1308 string s_azim = s_prefix +
"az" 1309 string s_theta = s_prefix +
"th" 1310 string s_tot = s_prefix +
"tot" 1311 string s_weight = s_prefix +
"wt" 1312 string s_matrix = s_prefix +
"matrix" 1314 wave theta1 = $s_theta
1315 wave polar1 = $s_polar
1316 wave azim1 = $s_azim
1318 wave weight1 = $s_weight
1319 wave values1 = $s_int
1320 wave /z matrix1 = $s_matrix
1322 variable npol = numpnts(theta1)
1324 setdatafolder dest_folder
1328 if (strlen(dest_nickname))
1329 s_prefix = dest_nickname +
"_" 1330 s_int = s_prefix +
"i" 1335 s_polar = s_prefix +
"pol" 1336 s_azim = s_prefix +
"az" 1337 s_theta = s_prefix +
"th" 1338 s_tot = s_prefix +
"tot" 1339 s_weight = s_prefix +
"wt" 1340 s_matrix = s_prefix +
"matrix" 1342 wave theta2 = $s_theta
1343 wave polar2 = $s_polar
1344 wave azim2 = $s_azim
1346 wave weight2 = $s_weight
1347 wave values2 = $s_int
1352 if (waveexists(matrix1))
1353 duplicate /o matrix1, $s_matrix
1356 if (!(NumberByKey(
"version", note(azim1),
"=",
"\r") >= 1.6))
1358 azim2 = azim2 >= 360 ? azim2 - 360 : azim2
1361 setdatafolder saveDF
1375 dfref savedf = getdatafolderdfr()
1377 if (strlen(nickname))
1378 string s_prefix = nickname +
"_" 1379 string s_int = s_prefix +
"i" 1384 string s_polar = s_prefix +
"pol" 1385 string s_azim = s_prefix +
"az" 1386 string s_tot = s_prefix +
"tot" 1387 string s_weight = s_prefix +
"wt" 1389 wave polar = $s_polar
1392 wave weight = $s_weight
1393 wave values = $s_int
1396 azim = azim < 0 ? azim + 360 : azim
1397 azim = azim >= 360 ? azim - 360 : azim
1399 duplicate /free polar, neg_polar
1401 sort {neg_polar, azim}, polar, azim, tot, weight, values
1403 setdatafolder saveDF
1450 string display_hemi_scan(
string nickname, variable projection = defaultValue, variable graphtype = defaultValue, variable do_ticks = defaultValue, variable do_grids = defaultValue,
string graphname = defaultValue){
1458 if (ParamIsDefault(projection))
1461 if (ParamIsDefault(graphtype))
1464 if (ParamIsDefault(do_ticks))
1467 if (ParamIsDefault(do_grids))
1470 if (ParamIsDefault(graphname))
1471 if (strlen(nickname) > 0)
1472 graphname = nickname
1474 graphname = GetDataFolder(0)
1479 if (strlen(nickname))
1480 string s_prefix = nickname +
"_" 1481 string s_int = s_prefix +
"i" 1486 string s_polar = s_prefix +
"pol" 1487 string s_azim = s_prefix +
"az" 1488 string s_matrix = s_prefix +
"matrix" 1490 wave /z values = $s_int
1491 wave /z azim = $s_azim
1492 wave /z polar = $s_polar
1493 wave /z matrix = $s_matrix
1495 string s_ster_rad = s_prefix +
"ster_rad" 1496 duplicate /o polar, $s_ster_rad /wave=ster_rad
1499 string s_ster_x = s_prefix +
"ster_x" 1500 string s_ster_y = s_prefix +
"ster_y" 1501 duplicate /o azim, $s_ster_x /wave=ster_x, $s_ster_y /wave=ster_y
1502 ster_x = ster_rad * cos(azim * pi / 180)
1503 ster_y = ster_rad * sin(azim * pi / 180)
1505 variable azim_offset = 0
1506 if (!(NumberByKey(
"version", note(azim),
"=",
"\r") >= 1.6))
1507 DoAlert /T=
"display hemi scan" 0,
"your dataset doesn't include the version 1.6 flag. if it was created with an earlier version that might be okay. please check that the orientation is correct!" 1516 s_trace = WMPolarAppendTrace(graphname, ster_rad, azim, 360)
1517 ModifyGraph /W=$graphname mode($s_trace)=2, lsize($s_trace)=2
1518 ModifyGraph /W=$graphname zColor($s_trace)={values,*,*,BlueGreenOrange,0}
1520 ColorScale /W=$graphname /C /N=text0 /E=2 /F=0 /B=1 /A=RB /X=0.00 /Y=0.00 trace=polarY0
1521 ColorScale /W=$graphname /C /N=text0 side=2, width=5, heightPct=40, frame=0.50, lblMargin=0
1522 ColorScale /W=$graphname /C /N=text0 nticks=2, minor=1, tickLen=4.00, tickThick=0.50
1524 SetWindow $graphname, userdata(projection)=num2str(projection)
1530 s_trace = WMPolarAppendTrace(graphname, ster_rad, azim, 360)
1531 ModifyGraph /W=$graphname mode($s_trace)=0, lsize($s_trace)=0
1532 AppendImage /L=VertCrossing /B=HorizCrossing matrix
1534 ColorScale /W=$graphname /C /N=text0 /E=2 /F=0 /B=1 /A=RB /X=0.00 /Y=0.00 image=$s_matrix
1535 ColorScale /W=$graphname /C /N=text0 side=2, width=5, heightPct=40, frame=0.50, lblMargin=0
1536 ColorScale /W=$graphname /C /N=text0 nticks=2, minor=1, tickLen=4.00, tickThick=0.50
1538 SetWindow $graphname, userdata(projection)=num2str(projection)
1587 static string display_polar_graph(
string graphname, variable angle_offset = defaultValue, variable do_ticks = defaultValue){
1590 variable angle_offset
1593 dfref savedf = GetDataFolderDFR()
1595 if (ParamIsDefault(angle_offset))
1598 if (ParamIsDefault(do_ticks))
1602 if ((strlen(graphname) == 0) || (wintype(graphname) == 0))
1603 Display /k=1 /W=(10,45,360,345)
1604 DoWindow /C $graphname
1605 graphname = WMNewPolarGraph(
"", graphname)
1606 WMPolarGraphSetVar(graphname,
"zeroAngleWhere", angle_offset)
1608 WMPolarGraphSetVar(graphname,
"angleAxisThick", 0.5)
1609 WMPolarGraphSetStr(graphname,
"doMajorAngleTicks",
"manual")
1610 WMPolarGraphSetVar(graphname,
"majorAngleInc", 30)
1611 WMPolarGraphSetVar(graphname,
"minorAngleTicks", 2)
1612 WMPolarGraphSetStr(graphname,
"angleTicksLocation",
"Outside")
1613 WMPolarGraphSetVar(graphname,
"doAngleTickLabelSubRange", 1)
1614 WMPolarGraphSetVar(graphname,
"angleTickLabelRangeStart", 0)
1615 WMPolarGraphSetVar(graphname,
"angleTickLabelRangeExtent", 90)
1616 WMPolarGraphSetStr(graphname,
"angleTickLabelNotation",
"%g")
1618 WMPolarGraphSetVar(graphname,
"doPolarGrids", 0)
1619 WMPolarGraphSetVar(graphname,
"doRadiusTickLabels", 0)
1620 WMPolarGraphSetStr(graphname,
"radiusAxesWhere",
" Off")
1621 WMPolarGraphSetStr(graphname,
"radiusTicksLocation",
"Off")
1623 WMPolarGraphSetVar(graphname,
"majorTickLength", 2)
1624 WMPolarGraphSetVar(graphname,
"majorTickThick", 0.5)
1625 WMPolarGraphSetVar(graphname,
"minorTickLength", 1)
1626 WMPolarGraphSetVar(graphname,
"minorTickThick", 0.5)
1627 WMPolarGraphSetVar(graphname,
"tickLabelOpaque", 0)
1628 WMPolarGraphSetVar(graphname,
"tickLabelFontSize", 7)
1632 WMPolarGraphSetStr(graphname,
"angleTicksLocation",
"Outside")
1634 WMPolarGraphSetStr(graphname,
"angleTicksLocation",
"Off")
1637 WMPolarGraphSetVar(graphname,
"doMinorAngleTicks", 1)
1639 WMPolarGraphSetVar(graphname,
"doMinorAngleTicks", 0)
1642 DoWindow /T $graphname, graphname
1645 string graphdf =
"root:packages:WMPolarGraphs:" + graphname
1646 setdatafolder graphdf
1648 variable /g csrA_theta
1649 variable /g csrA_phi
1650 variable /g csrB_theta
1651 variable /g csrB_phi
1655 tb = tb +
"\"A = (%.1f, %.1f)\"," 1656 tb = tb + graphdf +
":csrA_theta," 1657 tb = tb + graphdf +
":csrA_phi" 1659 TextBox /W=$graphname /A=LT /B=1 /E=2 /F=0 /N=tb_angles /X=1 /Y=1 /V=0 tb
1661 tb = tb +
"\"B = (%.1f, %.1f)\"," 1662 tb = tb + graphdf +
":csrB_theta," 1663 tb = tb + graphdf +
":csrB_phi" 1665 AppendText /W=$graphname /N=tb_angles tb
1670 DoWindow /F $graphname
1673 setdatafolder savedf
1706 if (ParamIsDefault(do_grids))
1710 dfref savedf = GetDataFolderDFR()
1712 string sproj = GetUserData(graphname,
"",
"projection")
1713 variable projection = str2num(
"0" + sproj)
1715 SetDrawLayer /W=$graphname ProgFront
1718 SetDrawEnv /W=$graphname xcoord=HorizCrossing, ycoord=VertCrossing
1719 SetDrawEnv /W=$graphname linethick= 0.5
1720 SetDrawEnv /W=$graphname dash=2
1721 SetDrawEnv /W=$graphname fillpat=0
1722 SetDrawEnv /W=$graphname fname=
"default", fsize=7
1723 SetDrawEnv /W=$graphname textxjust=1, textyjust=1
1725 SetDrawEnv /W=$graphname save
1728 DrawLine /W=$graphname 0, -2, 0, 2
1729 DrawLine /W=$graphname -2, 0, 2, 0
1735 DrawOval /W=$graphname -radi, radi, radi, -radi
1737 DrawOval /W=$graphname -radi, radi, radi, -radi
1739 DrawOval /W=$graphname -radi, radi, radi, -radi
1741 SetDrawEnv /W=$graphname textxjust= 1,textyjust= 2
1742 SetDrawEnv /W=$graphname save
1744 DrawText /W=$graphname radi, -0.1,
"30" 1746 DrawText /W=$graphname radi, -0.1,
"60" 1749 setdatafolder savedf
1774 variable
draw_diffraction_cone(
string graphname,
string groupname, variable theta_axis, variable theta_inner, variable phi){
1779 variable theta_inner
1787 SetDrawLayer UserFront
1788 DrawAction getgroup=$groupname,
delete 1789 SetDrawEnv gstart, gname=$groupname
1790 variable xc, yc, xr, yr
1793 variable r_center = (r_outer + r_inner) / 2
1794 variable r_radius = (r_outer - r_inner) / 2
1795 xc = r_center * cos(phi * pi / 180)
1796 yc = r_center * sin(phi * pi / 180)
1799 SetDrawEnv xcoord=HorizCrossing, ycoord=VertCrossing
1800 SetDrawEnv dash=11, fillpat=0
1801 DrawOval xc - xr, yc - yr, xc + xr, yc + yr
1804 xc = r_axis * cos(phi * pi / 180)
1805 yc = r_axis * sin(phi * pi / 180)
1809 SetDrawEnv xcoord=HorizCrossing, ycoord=VertCrossing
1810 SetDrawEnv fillfgc=(0,0,0)
1811 DrawOval xc - xr, yc - yr, xc + xr, yc + yr
1838 string display_scanlines(
string nickname, variable alpha_lo, variable alpha_hi, wave m_theta, wave m_tilt, wave m_phi, variable folding = defaultValue, variable projection = defaultValue){
1848 if (ParamIsDefault(folding))
1851 if (ParamIsDefault(projection))
1856 dfref saveDF = GetDataFolderDFR()
1857 newdatafolder /s/o $nickname
1858 string graphname =
"graph_" + nickname
1860 duplicate /free m_tilt, loc_m_tilt
1861 loc_m_tilt = -m_tilt
1863 make /n=1 /d /free d_polar, d_azi
1864 variable n_alpha = round(alpha_hi - alpha_lo) + 1
1865 make /n=(n_alpha) /d /free analyser
1866 setscale /i x alpha_lo, alpha_hi,
"", analyser
1870 duplicate /free d_polar, d_radius
1875 SetWindow $graphname, userdata(projection)=num2str(projection)
1879 variable nang = numpnts(m_theta)
1883 for (ifold = 0; ifold < folding; ifold += 1)
1884 d_azi = d_azi >= 360 ? d_azi - 360 : d_azi
1885 for (iang = 0; iang < nang; iang += 1)
1886 sprintf s_rad,
"rad_%d_%d", ifold, iang
1887 duplicate /o analyser, $s_rad
1889 w_rad = d_radius[p][iang]
1891 sprintf s_azi,
"azi_%d_%d", ifold, iang
1892 duplicate /o analyser, $s_azi
1894 w_azi = d_azi[p][iang]
1896 if (numtype(sum(w_rad)) == 0)
1897 s_trace = WMPolarAppendTrace(graphname, w_rad, w_azi, 360)
1898 ModifyGraph /w=$graphname mode($s_trace)=0, lsize($s_trace)=0.5
1901 d_azi += 360 / folding
1906 setdatafolder saveDF
1957 if (ParamIsDefault(projection))
1970 radius = polar < 90 ?
kProjScaleGnom * tan(polar * pi / 180) : inf
1998 threadsafe variable
calc_graph_polar(variable x, variable y, variable projection = defaultValue){
2003 if (ParamIsDefault(projection))
2010 radius = sqrt(x^2 + y^2)
2051 threadsafe variable
calc_graph_azi(variable x, variable y, variable projection = defaultValue, variable zeroAngle = defaultValue){
2057 if (ParamIsDefault(projection))
2060 if (ParamIsDefault(zeroAngle))
2066 azi = atan(y / x) * 180 / pi
2068 azi = atan(y / x) * 180 / pi + 180
2078 if (numtype(azi) != 0)
2099 dfref savedf = GetDataFolderDFR()
2101 string graphdf =
"root:packages:WMPolarGraphs:" + graphname
2102 setdatafolder graphdf
2109 string sproj = GetUserData(graphname,
"",
"projection")
2110 variable projection = str2num(
"0" + sproj)
2113 variable x = hcsr(A, graphname)
2114 variable y = vcsr(A, graphname)
2116 csrA_phi =
calc_graph_azi(x, y, projection=projection, zeroAngle=zeroAngleWhere)
2118 x = hcsr(B, graphname)
2119 y = vcsr(B, graphname)
2121 csrB_phi =
calc_graph_azi(x, y, projection=projection, zeroAngle=zeroAngleWhere)
2123 setdatafolder savedf
2132 STRUCT WMWinHookStruct &s
2134 Variable hookResult = 0
2141 TextBox /W=$s.winname /N=tb_angles /C /V=1
2144 TextBox /W=$s.winname /N=tb_angles /C /V=0
2151 variable
set_polar_graph_cursor(
string nickname,
string cursorname, variable polar_angle, variable azim_angle,
string graphname = defaultValue){
2154 variable polar_angle
2158 if (ParamIsDefault(graphname))
2159 if (strlen(nickname) > 0)
2160 graphname = nickname
2162 graphname = GetDataFolder(0)
2166 if (strlen(nickname))
2167 string s_prefix = nickname +
"_" 2171 string s_polar = s_prefix +
"pol" 2172 string s_azim = s_prefix +
"az" 2173 wave /z azim = $s_azim
2174 wave /z polar = $s_polar
2176 FindLevel /P /Q polar, polar_angle
2178 variable polar_level = floor(v_levelx)
2179 FindLevel /P /Q /R=[polar_level] azim, azim_angle
2181 variable azim_level = round(v_levelx)
2182 string tracename =
"polarY0" 2183 Cursor /W=$graphname /P $cursorname $traceName azim_level
2197 variable
hemi_add_anglescan(
string nickname, wave values, wave polar, wave azi, wave weights = defaultValue){
2209 if (ParamIsDefault(weights))
2210 duplicate /free values, weights
2215 if (strlen(nickname))
2216 string s_prefix = nickname +
"_" 2217 string s_int = s_prefix +
"i" 2222 string s_polar = s_prefix +
"pol" 2223 string s_azim = s_prefix +
"az" 2224 string s_theta = s_prefix +
"th" 2226 wave /z w_values = $s_int
2227 wave /z w_azim = $s_azim
2228 wave /z w_polar = $s_polar
2229 wave /z w_theta = $s_theta
2230 if (!waveexists(w_values) || !waveexists(w_azim) || !waveexists(w_polar))
2231 abort
"Missing hemispherical scan grid. Please call make_hemi_grid() first." 2235 duplicate /free values, values_copy
2236 duplicate /free polar, polar_copy
2237 duplicate /free azi, azi_copy
2238 duplicate /free weights, weights_copy
2239 variable nn = dimsize(values, 0) * max(dimsize(values, 1), 1)
2240 redimension /n=(nn) values_copy, polar_copy, azi_copy, weights_copy
2241 sort /r polar_copy, polar_copy, azi_copy, values_copy, weights_copy
2244 variable pol_st = abs(w_theta[1] - w_theta[0])
2247 duplicate /free azi_copy, azi_slice
2248 duplicate /free values_copy, values_slice
2249 duplicate /free weights_copy, weights_slice
2250 for (pol = 90; pol >= 0; pol -= pol_st)
2251 pol1 = pol - pol_st / 2
2252 pol2 = pol + pol_st / 2
2253 extract /free /indx polar_copy, sel, (pol1 < polar_copy) && (polar_copy <= pol2)
2254 if (numpnts(sel) > 0)
2255 redimension /n=(numpnts(sel)) azi_slice, values_slice, weights_slice
2256 azi_slice = azi_copy[sel]
2257 values_slice = values_copy[sel]
2258 weights_slice = weights_copy[sel]
2259 hemi_add_aziscan(nickname, values_slice, pol, azi_slice, weights=weights_slice)
2270 variable
hemi_add_aziscan(
string nickname, wave values, variable polar, wave azi, wave weights = defaultValue){
2280 if (ParamIsDefault(weights))
2281 duplicate /free values, weights
2286 if (strlen(nickname))
2287 string s_prefix = nickname +
"_" 2288 string s_int = s_prefix +
"i" 2293 string s_totals = s_prefix +
"tot" 2294 string s_weights = s_prefix +
"wt" 2295 string s_polar = s_prefix +
"pol" 2296 string s_azim = s_prefix +
"az" 2297 string s_index = s_prefix +
"index" 2298 string s_theta = s_prefix +
"th" 2299 string s_dphi = s_prefix +
"dphi" 2300 string s_nphis = s_prefix +
"nphis" 2302 wave w_polar = $s_polar
2303 wave w_azim = $s_azim
2304 wave w_values = $s_int
2305 wave w_totals = $s_totals
2306 wave w_weights = $s_weights
2307 wave w_index = $s_index
2308 wave w_theta = $s_theta
2309 wave w_dphi = $s_dphi
2310 wave w_nphis = $s_nphis
2315 variable ipol = BinarySearch(w_theta, polar)
2317 abort
"assertion failed in hemi_add_aziscan(): polar angle not found in grid." 2322 d1 = w_index[ipol - 1]
2326 d2 = w_index[ipol] - 1
2327 variable nd = d2 - d1 + 1
2328 variable dphi = w_dphi[ipol]
2333 azi = azi < 0 ? azi + 360 : azi
2334 azi = azi >= 360 - dphi/2 ? azi - 360 : azi
2335 duplicate /free values, sel_values
2336 duplicate /free weights, sel_weights
2340 variable v1, v2, w1, w2
2341 for (
id = 0;
id < nd;
id += 1)
2342 az1 = (
id - 0.5) * dphi
2343 az2 = (
id + 0.5) * dphi
2344 extract /free /indx azi, sel, (az1 <= azi) && (azi < az2)
2345 if (numpnts(sel) > 0)
2346 redimension /n=(numpnts(sel)) sel_values, sel_weights
2347 sel_values = values[sel]
2348 sel_weights = weights[sel]
2349 v1 = w_totals[d1 +
id]
2350 w1 = w_weights[d1 +
id]
2351 if ((numtype(v1) == 2) || (w1 <= 0))
2355 v2 = sum(sel_values)
2356 w2 = sum(sel_weights)
2357 w_totals[d1 + id] = v1 + v2
2358 w_weights[d1 + id] = w1 + w2
2361 w_values[d1, d1 + nd - 1] = w_totals[p] / w_weights[p]
2374 if (strlen(nickname))
2375 string s_prefix = nickname +
"_" 2376 string s_int = s_prefix +
"i" 2382 string s_polar = s_prefix +
"pol" 2383 string s_azim = s_prefix +
"az" 2384 string s_ster_x = s_prefix +
"ster_x" 2385 string s_ster_y = s_prefix +
"ster_y" 2387 wave values = $s_int
2389 wave polar = $s_polar
2390 wave ster_x = $s_ster_x
2391 wave ster_y = $s_ster_y
2393 variable min_ster_x = wavemin(ster_x)
2394 variable max_ster_x = wavemax(ster_x)
2395 variable x0 = min_ster_x
2397 variable dx = (max_ster_x - min_ster_x) / (xn - 1)
2398 make /n=(numpnts(ster_x), 3) /free triplet
2399 triplet[][0] = ster_x[p]
2400 triplet[][1] = ster_y[p]
2401 triplet[][2] = values[p]
2405 make /n=(size, size) /d /o $(s_prefix +
"matrix") /wave=matrix
2406 make /n=(size, size) /free mnorm
2407 ImageFromXYZ /as {ster_x, ster_y, values}, matrix, mnorm
2409 matrixfilter NanZapMedian, matrix
2410 matrixfilter gauss, matrix
2412 matrix = (x^2 + y^2) < 4 ? matrix : nan
2425 variable
quick_pizza_image(wave data,
string nickname, variable theta_offset, variable tilt_offset, variable phi_offset, variable npolar = defaultValue, variable nograph = defaultValue, variable folding = defaultValue){
2430 variable theta_offset
2431 variable tilt_offset
2439 if (ParamIsDefault(npolar))
2442 if (ParamIsDefault(nograph))
2445 if (ParamIsDefault(folding))
2448 string graphname =
"graph_" + nickname
2449 string s_prefix =
"" 2452 dfref saveDF = GetDataFolderDFR()
2453 dfref dataDF = GetWavesDataFolderDFR(data)
2454 setdatafolder dataDF
2455 if (DataFolderExists(
":attr"))
2458 dfref attrDF = GetDataFolderDFR()
2459 setdatafolder dataDF
2460 newdatafolder /s/o $nickname
2461 dfref destDF = GetDataFolderDFR()
2464 variable timerRefNum
2465 variable /g xyz_perf_secs
2466 timerRefNum = startMSTimer
2468 wave /sdfr=attrDF ManipulatorTheta
2469 wave /sdfr=attrDF ManipulatorTilt
2470 wave /sdfr=attrDF ManipulatorPhi
2471 duplicate /free ManipulatorTheta, m_theta
2472 duplicate /free ManipulatorTilt, m_tilt
2473 duplicate /free ManipulatorPhi, m_phi
2474 m_theta -= theta_offset
2475 m_tilt -= tilt_offset
2480 make /n=1/d/free d_polar, d_azi
2483 d_azi = d_azi >= 360 ? d_azi - 360 : d_azi
2485 duplicate /free data, values
2486 variable nn = dimsize(values, 0) * max(dimsize(values, 1), 1)
2487 redimension /n=(nn) values, d_polar, d_azi
2488 duplicate /o d_polar, ster_rad, ster_x, ster_y
2490 variable projection = 1
2493 ster_rad = 2 * tan(d_polar / 2 * pi / 180)
2496 ster_rad = 2 * cos((180 - d_polar) / 2 * pi / 180)
2499 string s_ster_x = s_prefix +
"ster_x" 2500 string s_ster_y = s_prefix +
"ster_y" 2503 make /n=(nn, nn) /d /o matrix
2504 make /n=(nn, nn) /free mnorm
2505 setscale /i x -2, +2, matrix, mnorm
2506 setscale /i y -2, +2, matrix, mnorm
2511 for (ifold = 0; ifold < folding; ifold += 1)
2512 ster_x = ster_rad * cos(d_azi * pi / 180)
2513 ster_y = ster_rad * sin(d_azi * pi / 180)
2514 ImageFromXYZ {ster_x, ster_y, values}, matrix, mnorm
2515 d_azi = d_azi >= 180 ? d_azi + 360 / folding - 180 : d_azi + 360 / folding
2519 matrixfilter /n=5 NanZapMedian matrix
2520 matrixfilter /n=3 gauss matrix
2525 modifygraph width={Plan,1,bottom,left}
2528 if (timerRefNum >= 0)
2529 xyz_perf_secs = stopMSTimer(timerRefNum) / 1e6
2532 setdatafolder saveDF
2541 dfref savedf = getdatafolderdfr()
2544 if (strlen(nickname))
2545 string s_prefix = nickname +
"_" 2546 string s_int = s_prefix +
"i" 2551 string s_polar = s_prefix +
"pol" 2552 string s_azim = s_prefix +
"az" 2553 string s_theta = s_prefix +
"th" 2554 string s_tot = s_prefix +
"tot" 2555 string s_weight = s_prefix +
"wt" 2557 wave theta1 = $s_theta
2558 wave polar1 = $s_polar
2559 wave azim1 = $s_azim
2561 wave weight1 = $s_weight
2562 wave values1 = $s_int
2564 save /m=
"\r\n" /o /p=$pathname /t theta1, polar1, azim1, tot1, weight1, values1 as filename
2566 setdatafolder saveDF
2577 dfref savedf = getdatafolderdfr()
2586 setdatafolder saveDF
2621 variable
import_tpi_scan(
string nickname, wave theta, wave phi, wave intensity, variable folding = defaultValue, variable npolar = defaultValue, variable nograph = defaultValue, variable xpdplot = defaultValue){
2632 if (ParamIsDefault(npolar))
2635 if (ParamIsDefault(nograph))
2638 if (ParamIsDefault(folding))
2641 if (ParamIsDefault(xpdplot))
2648 duplicate /free phi, fold_phi
2649 for (ifold = 0; ifold < folding; ifold += 1)
2651 fold_phi = fold_phi >= 180 ? fold_phi + 360 / folding - fold_phi : fold_phi + 360 / folding
2674 if (strlen(nickname))
2675 string s_prefix = nickname +
"_" 2676 string s_int = s_prefix +
"i" 2681 string s_totals = s_prefix +
"tot" 2682 string s_weights = s_prefix +
"wt" 2683 string s_polar = s_prefix +
"pol" 2685 wave w_polar = $s_polar
2686 wave w_values = $s_int
2687 wave w_totals = $s_totals
2688 wave w_weights = $s_weights
2690 w_values = w_polar <= theta_max ? w_totals / w_weights : nan
2716 if (strlen(nickname))
2717 string s_prefix = nickname +
"_" 2718 string s_int = s_prefix +
"i" 2723 string s_totals = s_prefix +
"tot" 2724 string s_weights = s_prefix +
"wt" 2725 string s_polar = s_prefix +
"pol" 2726 string s_azim = s_prefix +
"az" 2727 string s_index = s_prefix +
"index" 2728 string s_theta = s_prefix +
"th" 2729 string s_dphi = s_prefix +
"dphi" 2730 string s_nphis = s_prefix +
"nphis" 2732 sprintf s_cut,
"%s_azi%03u", s_int, round(azim)
2734 wave w_polar = $s_polar
2735 wave w_azim = $s_azim
2736 wave w_values = $s_int
2737 wave w_totals = $s_totals
2738 wave w_weights = $s_weights
2739 wave w_index = $s_index
2740 wave w_theta = $s_theta
2741 wave w_dphi = $s_dphi
2742 wave w_nphis = $s_nphis
2744 variable npol = numpnts(w_theta)
2746 variable pol_st = abs(w_theta[1] - w_theta[0])
2750 make /n=(npol) /o $s_cut
2752 setscale /i x w_theta[0], w_theta[numpnts(w_theta)-1],
"deg", w_cut
2753 make /n=1 /free azi_slice
2754 make /n=1 /free values_slice
2756 for (ipol = 0; ipol < npol; ipol += 1)
2758 pol1 = pol - pol_st / 2
2759 pol2 = pol + pol_st / 2
2760 extract /free /indx w_polar, sel, (pol1 < w_polar) && (w_polar <= pol2)
2763 redimension /n=(nsel+2) azi_slice, values_slice
2764 azi_slice[1, nsel] = w_azim[sel[p-1]]
2765 azi_slice[0] = azi_slice[nsel] - 360
2766 azi_slice[nsel+1] = azi_slice[1] + 360
2767 values_slice[1, nsel] = w_values[sel[p-1]]
2768 values_slice[0] = values_slice[nsel]
2769 values_slice[nsel+1] = values_slice[1]
2770 w_cut[ipol] = interp(azim, azi_slice, values_slice)
2800 if (strlen(nickname))
2801 string s_prefix = nickname +
"_" 2802 string s_int = s_prefix +
"i" 2807 string s_totals = s_prefix +
"tot" 2808 string s_weights = s_prefix +
"wt" 2809 string s_polar = s_prefix +
"pol" 2810 string s_azim = s_prefix +
"az" 2811 string s_index = s_prefix +
"index" 2812 string s_theta = s_prefix +
"th" 2813 string s_dphi = s_prefix +
"dphi" 2814 string s_nphis = s_prefix +
"nphis" 2816 sprintf s_cut,
"%s_pol%03u", s_int, round(pol)
2818 wave w_polar = $s_polar
2819 wave w_azim = $s_azim
2820 wave w_values = $s_int
2821 wave w_totals = $s_totals
2822 wave w_weights = $s_weights
2823 wave w_index = $s_index
2824 wave w_theta = $s_theta
2825 wave w_dphi = $s_dphi
2826 wave w_nphis = $s_nphis
2828 variable pol_st = abs(w_theta[1] - w_theta[0])
2832 pol1 = pol - pol_st / 2
2833 pol2 = pol + pol_st / 2
2834 extract /free /indx w_polar, sel, (pol1 < w_polar) && (w_polar <= pol2)
2837 make /n=(nsel) /o $s_cut
2839 w_cut = w_values[sel]
2840 setscale /i x w_azim[sel[0]], w_azim[sel[nsel-1]],
"", w_cut
wave fit_scienta_ang_transm(wave data, wave params)
wave hemi_polar_cut(string nickname, variable azim)
extract a polar cut from a hemispherical scan.
variable trim_hemi_scan(string nickname, variable theta_max)
trim a hemispherical scan at grazing angle
variable pizza_service_2(wave data, string nickname, wave m_theta, wave m_tilt, wave m_phi, variable npolar=defaultValue, variable nograph=defaultValue, variable folding=defaultValue, variable xpdplot=defaultValue)
create a pizza plot from a measured (energy-integrated) data strip
static const variable kProjScaleOrtho
variable polar2cart_wave(wave in, wave out)
variable normalize_strip_theta(wave strip, wave theta, variable theta_offset=defaultValue, variable smooth_method=defaultValue, variable smooth_factor=defaultValue, variable check=defaultValue)
divide the strip by the average polar distribution.
variable normalize_strip_2d(wave strip, wave theta, variable theta_offset=defaultValue, variable smooth_method=defaultValue, variable smooth_factor=defaultValue, variable check=defaultValue)
divide the strip by a two-dimensional normalization function.
variable crop_strip(wave strip, variable xlo, variable xhi)
crop a strip at the sides.
threadsafe wave ad_profile_y(wave dataset, variable p1, variable p2, string destname, variable noavg=defaultValue)
1D cut through 2D dataset along Y dimension, new destination wave.
variable make_hemi_grid(variable npol, string nickname, variable xpdplot=defaultValue)
create a hemispherical, constant solid angle grid
variable hemi_add_anglescan(string nickname, wave values, wave polar, wave azi, wave weights=defaultValue)
add an arbitrary angle scan to a hemispherical scan grid.
string get_hemi_nickname(wave w)
finds the nick name given any hemi wave
variable interpolate_hemi_scan(string nickname)
interpolate a hemispherical scan onto a rectangular grid
string get_hemi_prefix(wave w)
finds the prefix given any hemi wave
string display_hemi_scan(string nickname, variable projection=defaultValue, variable graphtype=defaultValue, variable do_ticks=defaultValue, variable do_grids=defaultValue, string graphname=defaultValue)
display a plot of a hemispherical angle scan.
static variable CalcN_Theta(string HoloMode, variable Theta_in, variable Theta_ran, variable Theta_st)
calculate the number of thetas for a pattern
dfr find_hemi_data(string nickname, string *prefix, string *intwave)
finds the folder, prefix and name of holo waves given their nick name
variable convert_angles_ttpd2polar(wave theta, wave tilt, wave phi, wave data, wave polar, wave azi)
convert angles from TTPA (theta-tilt-phi-analyser) scheme to polar coordinates.
variable clear_hemi_grid(string nickname)
clear a hemispherical scan grid
static const variable kProjScaleDist
threadsafe variable calc_graph_polar(variable x, variable y, variable projection=defaultValue)
calculate polar angle from Cartesian coordinate
static variable Calc_The_step(variable th, variable Theta_st, string Holomode)
calculate delta-theta for a given theta
static variable line_average(wave source, wave dest)
threadsafe variable calc_graph_radius(variable polar, variable projection=defaultValue)
calculate the projected polar angle
threadsafe variable scienta_ang_transm(wave w, variable x)
variable pizza_service(wave data, string nickname, variable theta_offset, variable tilt_offset, variable phi_offset, variable npolar=defaultValue, variable nograph=defaultValue, variable folding=defaultValue, variable xpdplot=defaultValue)
create a pizza plot from a measured (energy-integrated) data strip
variable rotate_x_wave(wave inout, variable angle)
variable cart2polar_wave(wave in, wave out)
string display_scanlines(string nickname, variable alpha_lo, variable alpha_hi, wave m_theta, wave m_tilt, wave m_phi, variable folding=defaultValue, variable projection=defaultValue)
display a polar graph with lines indicating the angles covered by an angle scan.
wave hemi_azi_cut(string nickname, variable pol)
extract an azimuthal cut from a hemispherical scan
variable draw_diffraction_cone(string graphname, string groupname, variable theta_axis, variable theta_inner, variable phi)
draw the circle of a diffraction cone in a stereographic polar graph.
variable hemi_add_aziscan(string nickname, wave values, variable polar, wave azi, wave weights=defaultValue)
add an azimuthal scan to a hemispherical scan grid.
static const variable kProjScaleGnom
variable rotate_y_wave(wave inout, variable angle)
variable rotate_hemi_scan(string nickname, variable angle)
azimuthally rotate a hemispherical scan dataset.
static const variable kProjScaleStereo
processing and holographic mapping of angle scanned XPD data.
static string display_polar_graph(string graphname, variable angle_offset=defaultValue, variable do_ticks=defaultValue)
displays an empty polar graph
const variable kProjOrtho
variable save_hemi_scan(string nickname, string pathname, string filename)
save a hemispherical scan to an Igor text file
const variable kProjStereo
variable quick_pizza_image(wave data, string nickname, variable theta_offset, variable tilt_offset, variable phi_offset, variable npolar=defaultValue, variable nograph=defaultValue, variable folding=defaultValue)
map angle scan data onto a rectangular grid in stereographic projection
static variable polar_graph_hook(WMWinHookStruct *s)
polar graph window hook
threadsafe variable calc_graph_azi(variable x, variable y, variable projection=defaultValue, variable zeroAngle=defaultValue)
calculate azimuthal angle from Cartesian coordinate
variable strip_delete_frames(wave strip, variable qlo, variable qhi, wave theta, wave tilt, wave phi)
delete a contiguous range of frames from a strip.
variable rotate_z_wave(wave inout, variable angle)
static variable calc_nth(variable Theta_st, variable Theta_in, variable th, variable Phi_ran, variable Phi_ref, string Holomode)
calculate the number of phis for a given theta
static const variable kProjScaleArea
variable show_analyser_line(variable theta, variable tilt, variable phi, variable theta_offset, variable tilt_offset, variable phi_offset, variable npolar=defaultValue, variable nograph=defaultValue, variable xpdplot=defaultValue)
calculate and display the line seen by the analyser for a specific emission angle ...
variable convert_angles_ttpa2polar(wave theta, wave tilt, wave phi, wave analyser, wave polar, wave azi)
convert angles from TTPA (theta-tilt-phi-analyser) scheme to polar coordinates.
static string draw_hemi_axes(string graphname, variable do_grids=defaultValue)
draw polar and azimuthal grids in an existing polar graph.
variable duplicate_hemi_scan(string source_nickname, dfref dest_folder, string dest_nickname, variable xpdplot=defaultValue)
duplicate a hemispherical scan dataset.
variable set_polar_graph_cursor(string nickname, string cursorname, variable polar_angle, variable azim_angle, string graphname=defaultValue)
static variable update_polar_info(string graphname)
update the angles info based on cursors A and B of a given polar graph window
variable import_tpi_scan(string nickname, wave theta, wave phi, wave intensity, variable folding=defaultValue, variable npolar=defaultValue, variable nograph=defaultValue, variable xpdplot=defaultValue)
import a hemispherical scan from theta-phi-intensity waves and display it
variable load_hemi_scan(string nickname, string pathname, string filename)
load a hemispherical scan from an Igor text file
threadsafe wave ad_profile_x(wave dataset, variable q1, variable q2, string destname, variable noavg=defaultValue)
1D cut through 2D dataset along X dimension, new destination wave.
static variable calc_phi_step(variable Theta_in, variable th, variable Theta_st, variable Phi_ran, variable Phi_ref, string Holomode)
calculate delta-phi for a given theta
variable normalize_strip_x(wave strip, variable smooth_method=defaultValue, variable smooth_factor=defaultValue, variable check=defaultValue)
divide the strip by the average X distribution.