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]
189 variable smooth_method
190 variable smooth_factor
193 if (ParamIsDefault(smooth_method))
196 if (ParamIsDefault(smooth_factor))
197 switch(smooth_method)
205 if (ParamIsDefault(check))
213 extract /free /indx raw_dist, clean_index, numtype(raw_dist) == 0
214 duplicate /free raw_dist, dist, dist_x
215 redimension /n=(numpnts(clean_index)) dist, dist_x
216 dist = raw_dist[clean_index[p]]
217 dist_x = pnt2x(raw_dist, clean_index[p])
218 variable div = mean(dist)
222 duplicate /o raw_dist, check_dist
223 check_dist = numtype(raw_dist) == 0 ? interp(x, dist_x, dist) : nan
227 switch(smooth_method)
229 Smooth /B /E=3 smooth_factor, dist
232 Smooth /E=3 smooth_factor, dist
235 make /n=1 /d /free fit_params
236 fit_scienta_ang_transm(raw_dist, fit_params)
237 duplicate /free raw_dist, dist, dist_x
239 dist = scienta_ang_transm(fit_params, x)
242 loess /smth=(smooth_factor) srcWave=dist, factors={dist_x}
247 duplicate /o raw_dist, check_smoo
248 check_smoo = interp(x, dist_x, dist)
253 strip /= interp(x, dist_x, dist)
287 variable theta_offset
291 if (ParamIsDefault(check))
294 if (ParamIsDefault(theta_offset))
297 if (ParamIsDefault(theta_range))
305 duplicate /free dist, dist_smoo
306 duplicate /free theta, theta_int
307 theta_int = theta - theta_offset
308 duplicate /free phi, phi_int
309 setscale /p x phi_int[0], phi_int[1] - phi_int[0], waveunits(phi, -1), dist, dist_smoo
311 extract /free /indx dist, red_idx, theta_int < theta_range
312 duplicate /free red_idx, red_dist, red_phi
313 red_dist = dist[red_idx]
314 red_phi = phi_int[red_idx]
316 variable wavg = mean(red_dist)
317 make /n=4 /d /free coef
318 coef[0] = {wavg, wavg/100, pi/180, 0}
319 CurveFit /q /h=
"0010" /g /w=2 sin, kwcWave=coef, red_dist /x=red_phi
320 dist_smoo = coef[0] + coef[1] * sin(coef[2] * phi_int[p] + coef[3])
324 strip = strip / dist_smoo[q] * coef[0]
329 duplicate /o dist, check_dist
330 duplicate /o dist_smoo, check_smoo
331 setscale /p x dimoffset(dist,0), dimdelta(dist,0), waveunits(dist,0), check_dist, check_smoo
369 variable theta_offset
370 variable smooth_method
371 variable smooth_factor
374 if (ParamIsDefault(check))
377 if (ParamIsDefault(theta_offset))
380 if (ParamIsDefault(smooth_method))
383 if (ParamIsDefault(smooth_factor))
391 duplicate /free dist, dist_smoo
392 duplicate /free theta, theta_int
393 theta_int = theta - theta_offset
394 setscale /p x theta_int[0], theta_int[1] - theta_int[0], waveunits(theta,-1), dist, dist_smoo
395 variable nx = dimsize(strip, 0)
398 switch(smooth_method)
400 Smooth /B /E=3 smooth_factor, dist_smoo
403 Smooth /E=3 smooth_factor, dist_smoo
406 loess /dest=dist_smoo /smth=(smooth_factor) srcWave=dist, factors={theta_int}
409 for (ix = 0; ix < nx; ix += 1)
411 if (smooth_factor > 1)
412 CurveFit /nthr=0 /q /w=2 poly smooth_factor+1, dist /x=theta_int /d=dist_smoo
414 CurveFit /nthr=0 /q /w=2 line, dist /x=theta_int /d=dist_smoo
416 strip[ix,ix][] /= dist_smoo[q]
424 strip /= dist_smoo[q]
429 duplicate /o dist, check_dist
430 duplicate /o dist_smoo, check_smoo
431 setscale /p x dimoffset(dist,0), dimdelta(dist,0), waveunits(dist,0), check_dist, check_smoo
468 variable theta_offset
469 variable smooth_method
470 variable smooth_factor
473 if (ParamIsDefault(check))
476 if (ParamIsDefault(theta_offset))
479 if (ParamIsDefault(smooth_method))
482 if (ParamIsDefault(smooth_factor))
490 duplicate /free dist, dist_smoo
491 duplicate /free theta, theta_int
492 theta_int = theta - theta_offset
493 setscale /p x theta_int[0], theta_int[1] - theta_int[0], waveunits(theta,-1), dist, dist_smoo
494 variable nx = dimsize(strip, 0)
497 switch(smooth_method)
499 loess /dest=dist_smoo /smth=(smooth_factor) srcWave=dist, factors={theta_int, phi}
502 abort
"smooth method not supported" 507 strip /= dist_smoo[q]
512 duplicate /o dist, check_dist
513 duplicate /o dist_smoo, check_smoo
514 setscale /p x dimoffset(dist,0), dimdelta(dist,0), waveunits(dist,0), check_dist, check_smoo
534 variable theta_offset
535 variable smooth_method
536 variable smooth_factor
539 if (ParamIsDefault(check))
542 if (ParamIsDefault(theta_offset))
545 if (ParamIsDefault(smooth_method))
548 if (ParamIsDefault(smooth_factor))
552 variable nx = dimsize(strip, 0)
553 variable ny = dimsize(strip, 1)
555 duplicate /free strip, dist, alpha_int, theta_int
556 theta_int = theta[q] - theta_offset
557 alpha_int = dimoffset(strip, 0) + p * dimdelta(strip, 0)
558 redimension /n=(nx * ny) dist, alpha_int, theta_int
560 switch(smooth_method)
562 loess /dest=dist_smoo /smth=(smooth_factor) srcWave=dist, factors={alpha_int, theta_int}
563 redimension /n=(nx, ny) dist_smoo
566 Abort
"undefined smooth method" 578 duplicate /o dist_smoo, check_smoo
596 variable plo = round((xlo - dimoffset(strip, 0)) / dimdelta(strip, 0))
597 variable phi = round((xhi - dimoffset(strip, 0)) / dimdelta(strip, 0))
598 xlo = plo * dimdelta(strip, 0) + dimoffset(strip, 0)
599 xhi = phi * dimdelta(strip, 0) + dimoffset(strip, 0)
600 variable nx = phi - plo + 1
601 variable ny = dimsize(strip, 1)
603 duplicate /free strip, strip_copy
604 redimension /n=(nx,ny) strip
605 strip = strip_copy[p + plo][q]
606 setscale /i x xlo, xhi, waveunits(strip, 0), strip
651 function
pizza_service(data, nickname, theta_offset, tilt_offset, phi_offset, [npolar, nograph, folding, xpdplot])
654 variable theta_offset
662 if (ParamIsDefault(npolar))
665 if (ParamIsDefault(nograph))
668 if (ParamIsDefault(folding))
671 if (ParamIsDefault(xpdplot))
676 dfref saveDF = GetDataFolderDFR()
677 dfref dataDF = GetWavesDataFolderDFR(data)
679 if (DataFolderExists(":attr"))
682 dfref attrDF = GetDataFolderDFR()
684 wave /sdfr=attrDF ManipulatorTheta
685 wave /sdfr=attrDF ManipulatorTilt
686 wave /sdfr=attrDF ManipulatorPhi
688 if ((dimsize(ManipulatorTheta, 0) != dimsize(data, 1)) || (dimsize(ManipulatorTilt, 0) != dimsize(data, 1)) || (dimsize(ManipulatorPhi, 0) != dimsize(data, 1)))
689 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."
692 duplicate /free ManipulatorTheta, m_theta
693 duplicate /free ManipulatorTilt, m_tilt
694 duplicate /free ManipulatorPhi, m_phi
696 m_theta -= theta_offset
697 m_tilt -= tilt_offset
700 pizza_service_2(data, nickname, m_theta, m_tilt, m_phi, npolar=npolar, nograph=nograph, folding=folding, xpdplot=xpdplot)
744 function
pizza_service_2(data, nickname, m_theta, m_tilt, m_phi, [npolar, nograph, folding, xpdplot])
755 if (ParamIsDefault(npolar))
758 if (ParamIsDefault(nograph))
761 if (ParamIsDefault(folding))
764 if (ParamIsDefault(xpdplot))
768 if ((dimsize(m_theta, 0) != dimsize(data, 1)) || (dimsize(m_tilt, 0) != dimsize(data, 1)) || (dimsize(m_phi, 0) != dimsize(data, 1)))
769 Abort "Warning: The dimension size of the manipulator waves does not match the Y dimension of the data wave!"
772 string graphname = "graph_" + nickname
773 string outprefix = nickname
776 dfref saveDF = GetDataFolderDFR()
777 dfref dataDF = GetWavesDataFolderDFR(data)
785 newdatafolder /s/o $nickname
788 dfref destDF = GetDataFolderDFR()
792 variable /g pol_perf_secs
793 timerRefNum = startMSTimer
795 duplicate /free m_tilt, corr_tilt
796 duplicate /free m_phi, corr_phi
800 make /n=1/d/free d_polar, d_azi
806 for (ifold = 0; ifold < folding; ifold += 1)
807 d_azi = d_azi >= 360 ? d_azi - 360 : d_azi
809 d_azi += 360 / folding
813 if (strlen(outprefix))
814 string s_prefix = outprefix + "_"
815 string s_int = s_prefix + "i"
829 if (timerRefNum >= 0)
830 pol_perf_secs = stopMSTimer(timerRefNum) / 1e6
861 function
show_analyser_line(theta, tilt, phi, theta_offset, tilt_offset, phi_offset, [npolar, nograph, xpdplot])
865 variable theta_offset
872 string nickname = "analyser"
874 if (ParamIsDefault(npolar))
877 if (ParamIsDefault(nograph))
880 if (ParamIsDefault(xpdplot))
883 string graphname = "graph_" + nickname
884 string outprefix = nickname
887 dfref saveDF = GetDataFolderDFR()
888 dfref dataDF = saveDF
894 newdatafolder /s/o $nickname
897 dfref destDF = GetDataFolderDFR()
899 make /n=1 /free m_theta
900 make /n=1 /free m_tilt
901 make /n=1 /free m_phi
902 m_theta = theta - theta_offset
903 m_tilt = tilt - tilt_offset
905 m_phi = phi - phi_offset
908 make /n=60 /free data
909 setscale /i x -30, 30, data
911 make /n=1/d/free d_polar, d_azi
915 d_azi = d_azi >= 360 ? d_azi - 360 : d_azi
932 wave theta, tilt, phi
937 make /n=(dimsize(data, 0)) /d /free ana
938 setscale /p x dimoffset(data, 0), dimdelta(data, 0), waveunits(data, 0), ana
977 variable nn = numpnts(theta)
978 variable na = numpnts(analyser)
979 redimension /n=(na, nn) polar, azi
986 make /n=(3,na) /d /free w_orig_polar, w_orig_cart, w_rot_cart, w_rot_polar
987 w_orig_polar[0][] = radius
988 w_orig_polar[1][] = analyser[q]
989 w_orig_polar[2][] = 0
995 for (ii = 0; ii < nn; ii += 1)
1001 w_rot_cart = w_orig_cart
1008 polar[][ii] = w_rot_polar[1][p]
1009 azi[][ii] = w_rot_polar[2][p]
1019 variable nn = dimsize(source, 1)
1020 make /n=(dimsize(source, 0))/d/free line
1021 for (ii = 0; ii < nn; ii += 1)
1022 line = source[p][ii]
1024 dest[][ii] = line[p] / v_max
1031 static function
calc_nth(Theta_st, Theta_in, th, Phi_ran, Phi_ref, Holomode)
1032 Variable Theta_st, Theta_in, th, Phi_ran, Phi_ref
1035 Variable deg2rad=0.01745329
1037 if ( cmpstr(Holomode, "Stereographic") == 0)
1038 The_step =trunc( Phi_ran*sin(th*deg2rad)*Phi_ref/Theta_st )
1040 The_step =trunc( Phi_ran*sin(th*pi/180)*Phi_ref/Theta_st )
1043 if (cmpstr(Holomode, "Parallel") == 0)
1044 The_step=trunc( Phi_ran*tan(th*deg2rad)*Phi_ref/Theta_st )
1046 if ( cmpstr(Holomode, "h") == 0)
1047 The_step=trunc( th/Theta_in*Phi_ran/Theta_st )
1060 static function
calc_phi_step(Theta_in, th, Theta_st, Phi_ran, Phi_ref, Holomode)
1061 Variable Theta_in, th, Theta_st, Phi_ran, Phi_ref
1065 Variable deg2rad=0.01745329
1067 if ( cmpstr(Holomode, "Stereographic") == 0 )
1068 if ((th < 0.5) || (trunc(Phi_ran*sin(th*deg2rad)*Phi_ref/Theta_st) == 0))
1071 Phi_st=Phi_ran/(trunc(Phi_ran*sin(th*deg2rad)*Phi_ref/Theta_st))
1078 if ( cmpstr(Holomode, "Parallel") == 0 )
1079 if((th < 0.5) || (trunc(Phi_ran*tan(th*deg2rad)*Phi_ref/Theta_st) == 0))
1082 Phi_st=Phi_ran/(trunc(Phi_ran*tan(th*deg2rad)*Phi_ref/Theta_st))
1086 if ( cmpstr(Holomode, "h") == 0 )
1087 if((th < 0.5) || (trunc(Phi_ran*sin(th*deg2rad)*Phi_ref/Theta_st) == 0))
1090 Phi_st=Phi_ran/trunc(th/Theta_in*Phi_ran/Theta_st)
1106 Variable th, Theta_st
1108 Variable deg2rad=0.01745329, dt_loc,The_step
1110 if ( (cmpstr(Holomode, "Stereographic")) ==0 )
1114 if ( (cmpstr(Holomode, "h")) ==0 )
1118 if ( cmpstr(Holomode, "Parallel") == 0 )
1120 dt_loc = Theta_st/cos(th*deg2rad)
1137 Variable Theta_in,Theta_ran,Theta_st
1138 Variable n_theta, aux, aux1,ii
1141 aux1= Theta_in - Theta_ran
1145 if(aux<=Theta_in-Theta_ran)
1146 aux=Theta_in-Theta_ran
1149 while((aux>aux1)%&(Theta_in-aux<=Theta_ran))
1178 if (ParamIsDefault(xpdplot))
1182 string HoloMode = "h"
1183 variable Theta_in = 90
1184 variable Theta_ran = 90
1185 variable Theta_st = 90 / (npol - 1)
1186 variable Phi_ran = 360
1187 variable Phi_ref = 1
1190 variable n_theta =
CalcN_Theta(HoloMode, Theta_in, Theta_ran, Theta_st)
1193 if (strlen(nickname))
1194 string s_prefix = nickname + "_"
1195 string s_int = s_prefix + "i"
1200 string s_polar = s_prefix + "pol"
1201 string s_azim = s_prefix + "az"
1203 string s_index = s_prefix + "index"
1204 string s_theta = s_prefix + "th"
1205 string s_dphi = s_prefix + "dphi"
1206 string s_nphis = s_prefix + "nphis"
1208 string s_HoloData = s_prefix + "data"
1209 string s_HoloInfo = s_prefix + "info"
1212 string s_tot = s_prefix + "tot"
1213 string s_weight = s_prefix + "wt"
1215 make /O/D/n=(n_theta) $s_index /wave=index
1216 make /O/D/n=(n_theta) $s_theta /wave=theta
1217 make /O/D/n=(n_theta) $s_dphi /wave=dphi
1218 make /O/D/n=(n_theta) $s_nphis /wave=nphis
1222 dphi[0] =
calc_phi_step(Theta_in, Theta_in, aux, Phi_ran, Phi_ref, HoloMode)
1224 nphis[0] =
calc_nth(aux, Theta_in, Theta_in, Phi_ran, Phi_ref, HoloMode)
1230 Theta[ii] = Theta[ii-1] - aux
1231 if(Theta[ii] <= Theta_in-Theta_ran)
1232 Theta[ii] = Theta_in-Theta_ran
1235 dphi[ii] =
calc_phi_step(Theta_in, Theta[ii], aux, Phi_ran, Phi_ref, HoloMode)
1236 nphis[ii] =
calc_nth(aux, Theta_in, Theta[ii], Phi_ran, Phi_ref, HoloMode)
1237 Index[ii] = Index[ii-1] + nphis[ii]
1241 if (Index[n_theta-1]==Index[n_theta-2])
1242 Index[n_theta-1]=Index[n_theta-2]+1
1246 variable NumPoints = sum(nphis, 0, numpnts(nphis))
1249 make /O/D/N=(NumPoints) $s_polar /wave=polar, $s_azim /wave=azim
1253 variable StartIndex = 0
1257 Polar[StartIndex, EndIndex-1]=Theta[ii]
1258 Azim[StartIndex, EndIndex-1]= mod(Phi_ran+(x-StartIndex)*dphi[ii]+Phi_in,Phi_ran)
1260 StartIndex = EndIndex
1263 duplicate /o azim, $s_int /wave=values
1264 duplicate /o azim, $s_tot /wave=totals
1265 duplicate /o azim, $s_weight /wave=weights
1272 string s_FileName = ""
1273 string s_Comment = "created by pearl-anglescan-process.ipf"
1274 string s_HoloMode = "Stereographic"
1275 variable /g gb_SpectraFile = 0
1277 Make/O/D/n=22 $s_HoloData /wave=HoloData
1280 HoloData[6] = NumPoints
1281 HoloData[7] = Theta_in
1282 HoloData[8] = Theta_ran
1283 HoloData[9] = Theta_st
1284 HoloData[11] = Phi_in
1285 HoloData[12] = Phi_ran
1286 HoloData[13] = Theta_st
1287 HoloData[15] = Phi_ref
1288 HoloData[16] = Phi_ran
1291 Make/O/T/n=22 $s_HoloInfo /wave=HoloInfo
1292 HoloInfo[0] = s_FileName
1293 HoloInfo[1] = s_Comment
1294 HoloInfo[10] = s_HoloMode
1298 if (WinType(NickName) == 5)
1299 Notebook $NickName selection={startOfFile, endOfFile}
1300 Notebook $NickName text=
"" 1302 NewNotebook /F=0 /K=1 /N=$NickName /W=(5,40,341,260)
1303 Notebook $NickName defaultTab=140
1304 Notebook $NickName statusWidth=300
1305 Notebook $NickName backRGB=(56797,56797,56797)
1306 Notebook $NickName pageMargins={80,80,80,80}
1307 Notebook $NickName fSize=10
1308 Notebook $NickName fStyle=0,textRGB=(65535,0,26214)
1309 Notebook $NickName textRGB=(65535,0,26214)
1311 Notebook $NickName text =
"File:\t" + s_FileName +
"\r" 1312 Notebook $NickName text =
"*** " + s_Comment +
" ***\r\r" 1313 Notebook $NickName text =
"Angle-Mode:\t" + s_HoloMode +
"\r" 1314 Notebook $NickName text =
"XPDplot Nickname:\t" + NickName +
"\r" 1328 string wname = nameofwave(w)
1334 string s_wave_df = GetWavesDataFolder(w, 1)
1335 dfref parent_df = $(s_wave_df + "::")
1336 nickname = GetDataFolder(0, parent_df)
1352 string wname = nameofwave(w)
1354 if (ItemsInList(wname, "_") >= 2)
1355 prefix = StringFromList(0, wname, "_")
1388 if (strlen(nickname))
1389 if (DataFolderExists(nickname))
1392 datadf = getdatafolderdfr()
1393 prefix = nickname + "_"
1394 intwave = prefix + "i"
1395 if (exists(intwave) != 1)
1400 datadf = getdatafolderdfr()
1422 string s_totals = s_prefix + "tot"
1423 string s_weights = s_prefix + "wt"
1425 wave /sdfr=datadf /z w_values = $s_int
1426 wave /sdfr=datadf /z w_totals = $s_totals
1427 wave /sdfr=datadf /z w_weights = $s_weights
1429 if (waveexists(w_totals))
1432 if (waveexists(w_weights))
1435 if (waveexists(w_values))
1462 string source_nickname
1464 string dest_nickname
1467 if (ParamIsDefault(xpdplot))
1471 dfref savedf = getdatafolderdfr()
1474 string s_prefix = ""
1475 string s_int = "values"
1476 dfref source_df =
find_hemi_data(source_nickname, s_prefix, s_int)
1477 string s_polar = s_prefix + "pol"
1478 string s_azim = s_prefix + "az"
1479 string s_theta = s_prefix + "th"
1480 string s_tot = s_prefix + "tot"
1481 string s_weight = s_prefix + "wt"
1482 string s_matrix = s_prefix + "matrix"
1484 wave /sdfr=source_df theta1 = $s_theta
1485 wave /sdfr=source_df polar1 = $s_polar
1486 wave /sdfr=source_df azim1 = $s_azim
1487 wave /sdfr=source_df tot1 = $s_tot
1488 wave /sdfr=source_df weight1 = $s_weight
1489 wave /sdfr=source_df values1 = $s_int
1490 wave /sdfr=source_df /z matrix1 = $s_matrix
1492 variable npol = numpnts(theta1)
1494 setdatafolder dest_folder
1499 s_polar = s_prefix + "pol"
1500 s_azim = s_prefix + "az"
1501 s_theta = s_prefix + "th"
1502 s_tot = s_prefix + "tot"
1503 s_weight = s_prefix + "wt"
1504 s_matrix = s_prefix + "matrix"
1506 wave /sdfr=dest_df theta2 = $s_theta
1507 wave /sdfr=dest_df polar2 = $s_polar
1508 wave /sdfr=dest_df azim2 = $s_azim
1509 wave /sdfr=dest_df tot2 = $s_tot
1510 wave /sdfr=dest_df weight2 = $s_weight
1511 wave /sdfr=dest_df values2 = $s_int
1516 if (waveexists(matrix1))
1517 setdatafolder dest_df
1518 duplicate /o matrix1, $s_matrix
1521 if (!(NumberByKey("
version", note(azim1), "=", "\r") >= 1.6))
1523 azim2 = azim2 >= 360 ? azim2 - 360 : azim2
1526 setdatafolder saveDF
1540 dfref savedf = getdatafolderdfr()
1542 string s_prefix = ""
1543 string s_int = "values"
1546 string s_polar = s_prefix + "pol"
1547 string s_azim = s_prefix + "az"
1548 string s_tot = s_prefix + "tot"
1549 string s_weight = s_prefix + "wt"
1551 wave /sdfr=df polar = $s_polar
1552 wave /sdfr=df azim = $s_azim
1553 wave /sdfr=df tot = $s_tot
1554 wave /sdfr=df weight = $s_weight
1555 wave /sdfr=df values = $s_int
1558 azim = azim < 0 ? azim + 360 : azim
1559 azim = azim >= 360 ? azim - 360 : azim
1561 duplicate /free polar, neg_polar
1563 sort {neg_polar, azim}, polar, azim, tot, weight, values
1565 setdatafolder saveDF
1588 dfref savedf = getdatafolderdfr()
1590 if (ParamIsDefault(projection))
1595 string s_prefix = ""
1596 string s_int = "values"
1599 string s_polar = s_prefix + "pol"
1600 string s_azim = s_prefix + "az"
1602 wave /sdfr=df /z values = $s_int
1603 wave /sdfr=df /z azim = $s_azim
1604 wave /sdfr=df /z polar = $s_polar
1607 string s_ster_rad = s_prefix + "ster_rad"
1608 duplicate /o polar, $s_ster_rad /wave=ster_rad
1611 string s_ster_x = s_prefix + "ster_x"
1612 string s_ster_y = s_prefix + "ster_y"
1613 duplicate /o azim, $s_ster_x /wave=ster_x, $s_ster_y /wave=ster_y
1614 ster_x = ster_rad * cos(azim * pi / 180)
1615 ster_y = ster_rad * sin(azim * pi / 180)
1617 setdatafolder savedf
1674 dfref savedf = getdatafolderdfr()
1676 if (ParamIsDefault(projection))
1679 if (ParamIsDefault(graphtype))
1682 if (ParamIsDefault(do_ticks))
1685 if (ParamIsDefault(do_grids))
1688 if (ParamIsDefault(graphname))
1689 if (strlen(nickname) > 0)
1690 graphname = nickname
1692 graphname = GetDataFolder(0)
1699 string s_prefix = ""
1700 string s_int = "values"
1703 string s_polar = s_prefix + "pol"
1704 string s_azim = s_prefix + "az"
1705 string s_matrix = s_prefix + "matrix"
1706 string s_ster_rad = s_prefix + "ster_rad"
1708 wave /sdfr=df /z values = $s_int
1709 wave /sdfr=df /z azim = $s_azim
1710 wave /sdfr=df /z polar = $s_polar
1711 wave /sdfr=df /z ster_rad = $s_ster_rad
1712 wave /sdfr=df /z matrix = $s_matrix
1715 variable azim_offset = 0
1716 if (!(NumberByKey("
version", note(azim), "=", "\r") >= 1.6))
1717 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!"
1724 if (str2num(GetUserData(graphname, "", "graphtype")) == graphtype)
1729 killwindow $graphname
1737 s_trace = WMPolarAppendTrace(graphname, ster_rad, azim, 360)
1738 ModifyGraph /W=$graphname mode($s_trace)=2, lsize($s_trace)=2
1739 ModifyGraph /W=$graphname zColor($s_trace)={values,*,*,BlueGreenOrange,0}
1741 ColorScale /W=$graphname /C /N=text0 /E=2 /F=0 /B=1 /A=RB /X=0.00 /Y=0.00 trace=polarY0
1742 ColorScale /W=$graphname /C /N=text0 side=2, width=5, heightPct=40, frame=0.50, lblMargin=0
1743 ColorScale /W=$graphname /C /N=text0 nticks=2, minor=1, tickLen=4.00, tickThick=0.50
1745 SetWindow $graphname, userdata(projection)=num2str(projection)
1746 SetWindow $graphname, userdata(graphtype)=num2str(graphtype)
1752 s_trace = WMPolarAppendTrace(graphname, ster_rad, azim, 360)
1753 ModifyGraph /W=$graphname mode($s_trace)=0, lsize($s_trace)=0
1754 AppendImage /L=VertCrossing /B=HorizCrossing matrix
1756 ColorScale /W=$graphname /C /N=text0 /E=2 /F=0 /B=1 /A=RB /X=0.00 /Y=0.00 image=$s_matrix
1757 ColorScale /W=$graphname /C /N=text0 side=2, width=5, heightPct=40, frame=0.50, lblMargin=0
1758 ColorScale /W=$graphname /C /N=text0 nticks=2, minor=1, tickLen=4.00, tickThick=0.50
1760 SetWindow $graphname, userdata(projection)=num2str(projection)
1761 SetWindow $graphname, userdata(graphtype)=num2str(graphtype)
1766 setdatafolder savedf
1814 variable angle_offset
1817 dfref savedf = GetDataFolderDFR()
1819 if (ParamIsDefault(angle_offset))
1822 if (ParamIsDefault(do_ticks))
1826 if ((strlen(graphname) == 0) || (wintype(graphname) == 0))
1827 Display /k=1 /W=(10,45,360,345)
1828 DoWindow /C $graphname
1829 graphname = WMNewPolarGraph("", graphname)
1830 WMPolarGraphSetVar(graphname, "zeroAngleWhere", angle_offset)
1832 WMPolarGraphSetVar(graphname, "angleAxisThick", 0.5)
1833 WMPolarGraphSetStr(graphname, "doMajorAngleTicks", "manual")
1834 WMPolarGraphSetVar(graphname, "majorAngleInc", 30)
1835 WMPolarGraphSetVar(graphname, "minorAngleTicks", 2)
1836 WMPolarGraphSetStr(graphname, "angleTicksLocation", "Outside")
1837 WMPolarGraphSetVar(graphname, "doAngleTickLabelSubRange", 1)
1838 WMPolarGraphSetVar(graphname, "angleTickLabelRangeStart", 0)
1839 WMPolarGraphSetVar(graphname, "angleTickLabelRangeExtent", 90)
1840 WMPolarGraphSetStr(graphname, "angleTickLabelNotation", "%g°")
1842 WMPolarGraphSetVar(graphname, "doPolarGrids", 0)
1843 WMPolarGraphSetVar(graphname, "doRadiusTickLabels", 0)
1844 WMPolarGraphSetStr(graphname, "radiusAxesWhere", " Off")
1845 WMPolarGraphSetStr(graphname, "radiusTicksLocation", "Off")
1847 WMPolarGraphSetVar(graphname, "majorTickLength", 2)
1848 WMPolarGraphSetVar(graphname, "majorTickThick", 0.5)
1849 WMPolarGraphSetVar(graphname, "minorTickLength", 1)
1850 WMPolarGraphSetVar(graphname, "minorTickThick", 0.5)
1851 WMPolarGraphSetVar(graphname, "tickLabelOpaque", 0)
1852 WMPolarGraphSetVar(graphname, "tickLabelFontSize", 7)
1856 WMPolarGraphSetStr(graphname, "angleTicksLocation", "Outside")
1858 WMPolarGraphSetStr(graphname, "angleTicksLocation", "Off")
1861 WMPolarGraphSetVar(graphname, "doMinorAngleTicks", 1)
1863 WMPolarGraphSetVar(graphname, "doMinorAngleTicks", 0)
1866 DoWindow /T $graphname, graphname
1869 string graphdf = "root:packages:WMPolarGraphs:" + graphname
1870 setdatafolder graphdf
1872 variable /g csrA_theta
1873 variable /g csrA_phi
1874 variable /g csrB_theta
1875 variable /g csrB_phi
1879 tb = tb + "\
"A = (%.1f, %.1f)\"," 1880 tb = tb + graphdf +
":csrA_theta," 1881 tb = tb + graphdf +
":csrA_phi" 1883 TextBox /W=$graphname /A=LT /B=1 /E=2 /F=0 /N=tb_angles /X=1 /Y=1 /V=0 tb
1885 tb = tb +
"\"B = (%.1f, %.1f)\"," 1886 tb = tb + graphdf +
":csrB_theta," 1887 tb = tb + graphdf +
":csrB_phi" 1889 AppendText /W=$graphname /N=tb_angles tb
1894 DoWindow /F $graphname
1897 setdatafolder savedf
1930 if (ParamIsDefault(do_grids))
1934 dfref savedf = GetDataFolderDFR()
1936 string sproj = GetUserData(graphname, "", "projection")
1937 variable projection = str2num("0" + sproj)
1939 SetDrawLayer /W=$graphname ProgFront
1942 SetDrawEnv /W=$graphname xcoord=HorizCrossing, ycoord=VertCrossing
1943 SetDrawEnv /W=$graphname linethick= 0.5
1944 SetDrawEnv /W=$graphname dash=2
1945 SetDrawEnv /W=$graphname fillpat=0
1946 SetDrawEnv /W=$graphname fname="default", fsize=7
1947 SetDrawEnv /W=$graphname textxjust=1, textyjust=1
1949 SetDrawEnv /W=$graphname save
1952 DrawLine /W=$graphname 0, -2, 0, 2
1953 DrawLine /W=$graphname -2, 0, 2, 0
1959 DrawOval /W=$graphname -radi, radi, radi, -radi
1960 radi = calc_graph_radius(30, projection=projection)
1961 DrawOval /W=$graphname -radi, radi, radi, -radi
1962 radi = calc_graph_radius(60, projection=projection)
1963 DrawOval /W=$graphname -radi, radi, radi, -radi
1965 SetDrawEnv /W=$graphname textxjust= 1,textyjust= 2
1966 SetDrawEnv /W=$graphname save
1967 radi = calc_graph_radius(30, projection=projection)
1968 DrawText /W=$graphname radi, -0.1, "30°"
1969 radi = calc_graph_radius(60, projection=projection)
1970 DrawText /W=$graphname radi, -0.1, "60°"
1973 setdatafolder savedf
2003 variable theta_inner
2006 variable r_axis = calc_graph_radius(theta_axis)
2007 variable r_inner = calc_graph_radius(theta_inner)
2008 variable r_outer = calc_graph_radius(2 * theta_axis - theta_inner)
2011 SetDrawLayer UserFront
2012 DrawAction getgroup=$groupname, delete
2013 SetDrawEnv gstart, gname=$groupname
2014 variable xc, yc, xr, yr
2017 variable r_center = (r_outer + r_inner) / 2
2018 variable r_radius = (r_outer - r_inner) / 2
2019 xc = r_center * cos(phi * pi / 180)
2020 yc = r_center * sin(phi * pi / 180)
2023 SetDrawEnv xcoord=HorizCrossing, ycoord=VertCrossing
2024 SetDrawEnv dash=11, fillpat=0
2025 DrawOval xc - xr, yc - yr, xc + xr, yc + yr
2028 xc = r_axis * cos(phi * pi / 180)
2029 yc = r_axis * sin(phi * pi / 180)
2030 r_radius = calc_graph_radius(2)
2033 SetDrawEnv xcoord=HorizCrossing, ycoord=VertCrossing
2034 SetDrawEnv fillfgc=(0,0,0)
2035 DrawOval xc - xr, yc - yr, xc + xr, yc + yr
2062 function /s
display_scanlines(nickname, alpha_lo, alpha_hi, m_theta, m_tilt, m_phi, [folding, projection])
2072 if (ParamIsDefault(folding))
2075 if (ParamIsDefault(projection))
2080 dfref saveDF = GetDataFolderDFR()
2081 newdatafolder /s/o $nickname
2082 string graphname = "graph_" + nickname
2084 duplicate /free m_tilt, loc_m_tilt
2085 loc_m_tilt = -m_tilt
2087 make /n=1 /d /free d_polar, d_azi
2088 variable n_alpha = round(alpha_hi - alpha_lo) + 1
2089 make /n=(n_alpha) /d /free analyser
2090 setscale /i x alpha_lo, alpha_hi, "°", analyser
2094 duplicate /free d_polar, d_radius
2095 d_radius = calc_graph_radius(d_polar, projection=projection)
2099 SetWindow $graphname, userdata(projection)=num2str(projection)
2103 variable nang = numpnts(m_theta)
2107 for (ifold = 0; ifold < folding; ifold += 1)
2108 d_azi = d_azi >= 360 ? d_azi - 360 : d_azi
2109 for (iang = 0; iang < nang; iang += 1)
2110 sprintf s_rad, "rad_%d_%d", ifold, iang
2111 duplicate /o analyser, $s_rad
2113 w_rad = d_radius[p][iang]
2115 sprintf s_azi, "azi_%d_%d", ifold, iang
2116 duplicate /o analyser, $s_azi
2118 w_azi = d_azi[p][iang]
2120 if (numtype(sum(w_rad)) == 0)
2121 s_trace = WMPolarAppendTrace(graphname, w_rad, w_azi, 360)
2122 ModifyGraph /w=$graphname mode($s_trace)=0, lsize($s_trace)=0.5
2125 d_azi += 360 / folding
2130 setdatafolder saveDF
2177 threadsafe function calc_graph_radius(polar, [projection])
2181 if (ParamIsDefault(projection))
2194 radius = polar < 90 ?
kProjScaleGnom * tan(polar * pi / 180) : inf
2227 if (ParamIsDefault(projection))
2234 radius = sqrt(x^2 + y^2)
2281 if (ParamIsDefault(projection))
2284 if (ParamIsDefault(zeroAngle))
2290 azi = atan(y / x) * 180 / pi
2292 azi = atan(y / x) * 180 / pi + 180
2302 if (numtype(azi) != 0)
2323 dfref savedf = GetDataFolderDFR()
2325 string graphdf = "root:packages:WMPolarGraphs:" + graphname
2326 setdatafolder graphdf
2333 string sproj = GetUserData(graphname, "", "projection")
2334 variable projection = str2num("0" + sproj)
2337 variable x = hcsr(A, graphname)
2338 variable y = vcsr(A, graphname)
2340 csrA_phi =
calc_graph_azi(x, y, projection=projection, zeroAngle=zeroAngleWhere)
2342 x = hcsr(B, graphname)
2343 y = vcsr(B, graphname)
2345 csrB_phi =
calc_graph_azi(x, y, projection=projection, zeroAngle=zeroAngleWhere)
2347 setdatafolder savedf
2356 STRUCT WMWinHookStruct &s
2358 Variable hookResult = 0
2365 TextBox /W=$s.winname /N=tb_angles /C /V=1
2368 TextBox /W=$s.winname /N=tb_angles /C /V=0
2378 variable polar_angle
2382 if (ParamIsDefault(graphname))
2383 if (strlen(nickname) > 0)
2384 graphname = nickname
2386 graphname = GetDataFolder(0)
2390 string s_prefix = ""
2391 string s_int = "values"
2394 string s_polar = s_prefix + "pol"
2395 string s_azim = s_prefix + "az"
2396 wave /sdfr=df /z azim = $s_azim
2397 wave /sdfr=df /z polar = $s_polar
2399 FindLevel /P /Q polar, polar_angle
2401 variable polar_level = floor(v_levelx)
2402 FindLevel /P /Q /R=[polar_level] azim, azim_angle
2404 variable azim_level = round(v_levelx)
2405 string tracename = "polarY0"
2406 Cursor /W=$graphname /P $cursorname $traceName azim_level
2432 if (ParamIsDefault(weights))
2433 duplicate /free values, weights
2438 string s_prefix = ""
2439 string s_int = "values"
2442 string s_polar = s_prefix + "pol"
2443 string s_azim = s_prefix + "az"
2444 string s_theta = s_prefix + "th"
2446 wave /sdfr=df /z w_values = $s_int
2447 wave /sdfr=df /z w_azim = $s_azim
2448 wave /sdfr=df /z w_polar = $s_polar
2449 wave /sdfr=df /z w_theta = $s_theta
2450 if (!waveexists(w_values) || !waveexists(w_azim) || !waveexists(w_polar))
2451 abort "Missing hemispherical scan grid. Please call
make_hemi_grid() first."
2455 duplicate /free values, values_copy
2456 duplicate /free polar, polar_copy
2457 duplicate /free azi, azi_copy
2458 duplicate /free weights, weights_copy
2459 variable nn = dimsize(values, 0) * max(dimsize(values, 1), 1)
2460 redimension /n=(nn) values_copy, polar_copy, azi_copy, weights_copy
2461 sort /r polar_copy, polar_copy, azi_copy, values_copy, weights_copy
2464 variable pol_st = abs(w_theta[1] - w_theta[0])
2467 duplicate /free azi_copy, azi_slice
2468 duplicate /free values_copy, values_slice
2469 duplicate /free weights_copy, weights_slice
2470 for (pol = 90; pol >= 0; pol -= pol_st)
2471 pol1 = pol - pol_st / 2
2472 pol2 = pol + pol_st / 2
2473 extract /free /indx polar_copy, sel, (pol1 < polar_copy) && (polar_copy <= pol2)
2474 if (numpnts(sel) > 0)
2475 redimension /n=(numpnts(sel)) azi_slice, values_slice, weights_slice
2476 azi_slice = azi_copy[sel]
2477 values_slice = values_copy[sel]
2478 weights_slice = weights_copy[sel]
2479 hemi_add_aziscan(nickname, values_slice, pol, azi_slice, weights=weights_slice)
2500 if (ParamIsDefault(weights))
2501 duplicate /free values, weights
2506 string s_prefix = ""
2507 string s_int = "values"
2510 string s_totals = s_prefix + "tot"
2511 string s_weights = s_prefix + "wt"
2512 string s_polar = s_prefix + "pol"
2513 string s_azim = s_prefix + "az"
2514 string s_index = s_prefix + "index"
2515 string s_theta = s_prefix + "th"
2516 string s_dphi = s_prefix + "dphi"
2517 string s_nphis = s_prefix + "nphis"
2519 wave /sdfr=df w_polar = $s_polar
2520 wave /sdfr=df w_azim = $s_azim
2521 wave /sdfr=df w_values = $s_int
2522 wave /sdfr=df w_totals = $s_totals
2523 wave /sdfr=df w_weights = $s_weights
2524 wave /sdfr=df w_index = $s_index
2525 wave /sdfr=df w_theta = $s_theta
2526 wave /sdfr=df w_dphi = $s_dphi
2527 wave /sdfr=df w_nphis = $s_nphis
2532 variable ipol = BinarySearch(w_theta, polar)
2534 abort "assertion failed in
hemi_add_aziscan(): polar angle not found in grid."
2539 d1 = w_index[ipol - 1]
2543 d2 = w_index[ipol] - 1
2544 variable nd = d2 - d1 + 1
2545 variable dphi = w_dphi[ipol]
2550 azi = azi < 0 ? azi + 360 : azi
2551 azi = azi >= 360 - dphi/2 ? azi - 360 : azi
2552 duplicate /free values, sel_values
2553 duplicate /free weights, sel_weights
2557 variable v1, v2, w1, w2
2558 for (
id = 0;
id < nd;
id += 1)
2559 az1 = (
id - 0.5) * dphi
2560 az2 = (
id + 0.5) * dphi
2561 extract /free /indx azi, sel, (az1 <= azi) && (azi < az2)
2562 if (numpnts(sel) > 0)
2563 redimension /n=(numpnts(sel)) sel_values, sel_weights
2564 sel_values = values[sel]
2565 sel_weights = weights[sel]
2566 v1 = w_totals[d1 +
id]
2567 w1 = w_weights[d1 +
id]
2568 if ((numtype(v1) == 2) || (w1 <= 0))
2572 v2 = sum(sel_values)
2573 w2 = sum(sel_weights)
2574 w_totals[d1 +
id] = v1 + v2
2575 w_weights[d1 +
id] = w1 + w2
2578 w_values[d1, d1 + nd - 1] = w_totals[p] / w_weights[p]
2612 dfref savedf = GetDataFolderDFR()
2614 if (ParamIsDefault(projection))
2618 string s_prefix = ""
2619 string s_int = "values"
2623 string s_polar = s_prefix + "pol"
2624 string s_azim = s_prefix + "az"
2625 string s_matrix = s_prefix + "matrix"
2626 string s_ster_rad = s_prefix + "ster_rad"
2627 string s_ster_x = s_prefix + "ster_x"
2628 string s_ster_y = s_prefix + "ster_y"
2630 wave /sdfr=df /z values = $s_int
2631 wave /sdfr=df /z azim = $s_azim
2632 wave /sdfr=df /z polar = $s_polar
2633 wave /sdfr=df /z ster_rad = $s_ster_rad
2634 wave /sdfr=df /z ster_x = $s_ster_x
2635 wave /sdfr=df /z ster_y = $s_ster_y
2637 variable min_ster_x = wavemin(ster_x)
2638 variable max_ster_x = wavemax(ster_x)
2639 variable x0 = min_ster_x
2641 variable dx = (max_ster_x - min_ster_x) / (xn - 1)
2642 make /n=(numpnts(ster_x), 3) /free triplet
2643 triplet[][0] = ster_x[p]
2644 triplet[][1] = ster_y[p]
2645 triplet[][2] = values[p]
2649 make /n=(size, size) /d /o $(s_prefix + "matrix") /wave=matrix
2650 make /n=(size, size) /free mnorm
2651 ImageFromXYZ /as {ster_x, ster_y, values}, matrix, mnorm
2653 matrixfilter NanZapMedian, matrix
2654 matrixfilter gauss, matrix
2656 duplicate /free values, ster_finite
2657 ster_finite = (numtype(values) == 0) * (ster_x^2 + ster_y^2)
2658 variable ster_max = wavemax(ster_finite)
2659 matrix = (x^2 + y^2) <= ster_max ? matrix : nan
2661 setdatafolder savedf
2674 function quick_pizza_image(data, nickname, theta_offset, tilt_offset, phi_offset, [npolar, nograph, folding])
2679 variable theta_offset
2680 variable tilt_offset
2688 if (ParamIsDefault(npolar))
2691 if (ParamIsDefault(nograph))
2694 if (ParamIsDefault(folding))
2697 string graphname =
"graph_" + nickname
2698 string s_prefix =
"" 2701 dfref saveDF = GetDataFolderDFR()
2702 dfref dataDF = GetWavesDataFolderDFR(data)
2703 setdatafolder dataDF
2704 if (DataFolderExists(
":attr"))
2707 dfref attrDF = GetDataFolderDFR()
2708 setdatafolder dataDF
2709 newdatafolder /s/o $nickname
2710 dfref destDF = GetDataFolderDFR()
2713 variable timerRefNum
2714 variable /g xyz_perf_secs
2715 timerRefNum = startMSTimer
2717 wave /sdfr=attrDF ManipulatorTheta
2718 wave /sdfr=attrDF ManipulatorTilt
2719 wave /sdfr=attrDF ManipulatorPhi
2720 duplicate /free ManipulatorTheta, m_theta
2721 duplicate /free ManipulatorTilt, m_tilt
2722 duplicate /free ManipulatorPhi, m_phi
2723 m_theta -= theta_offset
2724 m_tilt -= tilt_offset
2729 make /n=1/d/free d_polar, d_azi
2732 d_azi = d_azi >= 360 ? d_azi - 360 : d_azi
2734 duplicate /free data, values
2735 variable nn = dimsize(values, 0) * max(dimsize(values, 1), 1)
2736 redimension /n=(nn) values, d_polar, d_azi
2737 duplicate /o d_polar, ster_rad, ster_x, ster_y
2739 variable projection = 1
2742 ster_rad = 2 * tan(d_polar / 2 * pi / 180)
2745 ster_rad = 2 * cos((180 - d_polar) / 2 * pi / 180)
2748 string s_ster_x = s_prefix + "ster_x"
2749 string s_ster_y = s_prefix + "ster_y"
2752 make /n=(nn, nn) /d /o matrix
2753 make /n=(nn, nn) /free mnorm
2754 setscale /i x -2, +2, matrix, mnorm
2755 setscale /i y -2, +2, matrix, mnorm
2760 for (ifold = 0; ifold < folding; ifold += 1)
2761 ster_x = ster_rad * cos(d_azi * pi / 180)
2762 ster_y = ster_rad * sin(d_azi * pi / 180)
2763 ImageFromXYZ {ster_x, ster_y, values}, matrix, mnorm
2764 d_azi = d_azi >= 180 ? d_azi + 360 / folding - 180 : d_azi + 360 / folding
2768 matrixfilter /n=5 NanZapMedian matrix
2769 matrixfilter /n=3 gauss matrix
2774 modifygraph width={Plan,1,bottom,left}
2777 if (timerRefNum >= 0)
2778 xyz_perf_secs = stopMSTimer(timerRefNum) / 1e6
2781 setdatafolder saveDF
2790 dfref savedf = getdatafolderdfr()
2793 string s_prefix = ""
2794 string s_int = "values"
2797 string s_polar = s_prefix + "pol"
2798 string s_azim = s_prefix + "az"
2799 string s_theta = s_prefix + "th"
2800 string s_tot = s_prefix + "tot"
2801 string s_weight = s_prefix + "wt"
2803 wave /sdfr=df theta1 = $s_theta
2804 wave /sdfr=df polar1 = $s_polar
2805 wave /sdfr=df azim1 = $s_azim
2806 wave /sdfr=df tot1 = $s_tot
2807 wave /sdfr=df weight1 = $s_weight
2808 wave /sdfr=df values1 = $s_int
2810 save /m="\r\n" /o /p=$pathname /t theta1, polar1, azim1, tot1, weight1, values1 as filename
2812 setdatafolder saveDF
2823 dfref savedf = getdatafolderdfr()
2832 setdatafolder saveDF
2867 function
import_tpi_scan(nickname, theta, phi, intensity, [folding, npolar, nograph, xpdplot])
2878 if (ParamIsDefault(npolar))
2881 if (ParamIsDefault(nograph))
2884 if (ParamIsDefault(folding))
2887 if (ParamIsDefault(xpdplot))
2894 duplicate /free phi, fold_phi
2895 for (ifold = 0; ifold < folding; ifold += 1)
2897 fold_phi = fold_phi >= 180 ? fold_phi + 360 / folding - fold_phi : fold_phi + 360 / folding
2920 string s_prefix = ""
2921 string s_int = "values"
2924 string s_totals = s_prefix + "tot"
2925 string s_weights = s_prefix + "wt"
2926 string s_polar = s_prefix + "pol"
2928 wave /sdfr=df w_polar = $s_polar
2929 wave /sdfr=df w_values = $s_int
2930 wave /sdfr=df w_totals = $s_totals
2931 wave /sdfr=df w_weights = $s_weights
2933 w_values = w_polar <= theta_max ? w_totals / w_weights : nan
2959 dfref savedf = getdatafolderdfr()
2960 string s_prefix = ""
2961 string s_int = "values"
2964 string s_totals = s_prefix + "tot"
2965 string s_weights = s_prefix + "wt"
2966 string s_polar = s_prefix + "pol"
2967 string s_azim = s_prefix + "az"
2968 string s_index = s_prefix + "index"
2969 string s_theta = s_prefix + "th"
2970 string s_dphi = s_prefix + "dphi"
2971 string s_nphis = s_prefix + "nphis"
2973 sprintf s_cut, "%s_azi%03u", s_int, round(azim)
2975 wave /sdfr=df w_polar = $s_polar
2976 wave /sdfr=df w_azim = $s_azim
2977 wave /sdfr=df w_values = $s_int
2978 wave /sdfr=df w_totals = $s_totals
2979 wave /sdfr=df w_weights = $s_weights
2980 wave /sdfr=df w_index = $s_index
2981 wave /sdfr=df w_theta = $s_theta
2982 wave /sdfr=df w_dphi = $s_dphi
2983 wave /sdfr=df w_nphis = $s_nphis
2985 variable npol = numpnts(w_theta)
2987 variable pol_st = abs(w_theta[1] - w_theta[0])
2993 make /n=(npol) /o $s_cut
2995 setscale /i x w_theta[0], w_theta[numpnts(w_theta)-1], "deg", w_cut
2996 make /n=1 /free azi_slice
2997 make /n=1 /free values_slice
2999 for (ipol = 0; ipol < npol; ipol += 1)
3001 pol1 = pol - pol_st / 2
3002 pol2 = pol + pol_st / 2
3003 extract /free /indx w_polar, sel, (pol1 < w_polar) && (w_polar <= pol2)
3006 redimension /n=(nsel+2) azi_slice, values_slice
3007 azi_slice[1, nsel] = w_azim[sel[p-1]]
3008 azi_slice[0] = azi_slice[nsel] - 360
3009 azi_slice[nsel+1] = azi_slice[1] + 360
3010 values_slice[1, nsel] = w_values[sel[p-1]]
3011 values_slice[0] = values_slice[nsel]
3012 values_slice[nsel+1] = values_slice[1]
3013 w_cut[ipol] = interp(azim, azi_slice, values_slice)
3019 setdatafolder savedf
3045 dfref savedf = getdatafolderdfr()
3046 string s_prefix = ""
3047 string s_int = "values"
3050 string s_totals = s_prefix + "tot"
3051 string s_weights = s_prefix + "wt"
3052 string s_polar = s_prefix + "pol"
3053 string s_azim = s_prefix + "az"
3054 string s_index = s_prefix + "index"
3055 string s_theta = s_prefix + "th"
3056 string s_dphi = s_prefix + "dphi"
3057 string s_nphis = s_prefix + "nphis"
3059 sprintf s_cut, "%s_pol%03u", s_int, round(pol)
3061 wave /sdfr=df w_polar = $s_polar
3062 wave /sdfr=df w_azim = $s_azim
3063 wave /sdfr=df w_values = $s_int
3064 wave /sdfr=df w_totals = $s_totals
3065 wave /sdfr=df w_weights = $s_weights
3066 wave /sdfr=df w_index = $s_index
3067 wave /sdfr=df w_theta = $s_theta
3068 wave /sdfr=df w_dphi = $s_dphi
3069 wave /sdfr=df w_nphis = $s_nphis
3071 variable pol_st = abs(w_theta[1] - w_theta[0])
3075 pol1 = pol - pol_st / 2
3076 pol2 = pol + pol_st / 2
3077 extract /free /indx w_polar, sel, (pol1 < w_polar) && (w_polar <= pol2)
3081 make /n=(nsel) /o $s_cut
3083 w_cut = w_values[sel]
3084 setscale /i x w_azim[sel[0]], w_azim[sel[nsel-1]], "°", w_cut
3085 setdatafolder savedf
3088 setdatafolder savedf
3091 setdatafolder savedf
3101 dfref save_df = GetDataFolderDFR()
3102 dfref dfr = NewFreeDataFolder()
3104 StatsQuantiles /inan /iw /q /z values
3105 wave index = w_quantilesindex
3106 variable imin = round(numpnts(index) * pcmin / 100)
3107 variable imax = round(numpnts(index) * (100 - pcmax) / 100)
3108 vmin = values[index[imin]]
3109 vmax = values[index[imax]]
3110 setdatafolder save_df
3135 if (ParamIsDefault(graphname))
3138 if (ParamIsDefault(colortable))
3142 dfref save_df = GetDataFolderDFR()
3154 string traces = TraceNameList(graphname, ";", 1+4)
3155 n = ItemsInList(traces, ";")
3156 for (i = 0; i < n; i += 1)
3157 objname = StringFromList(i, traces, ";")
3158 info = TraceInfo(graphname, objname, 0)
3159 if (strlen(info) > 0)
3160 info = StringByKey("RECREATION", info, ":", ";")
3161 info = StringByKey("zColor(x)", info, "=", ";")
3162 if (strlen(info) > 2)
3163 info = info[1,strlen(info)-2]
3164 wname = StringFromList(0, info, ",")
3166 ctab = StringFromList(3, info, ",")
3167 rev = str2num("0" + StringFromList(4, info, ","))
3168 if (strlen(colortable) > 0)
3172 ModifyGraph /w=$graphname zColor($objname)={w, vmin, vmax, $ctab, rev}
3177 string images = ImageNameList(graphname,
";")
3178 n = ItemsInList(images,
";")
3179 for (i = 0; i < n; i += 1)
3180 objname = StringFromList(i, images,
";")
3181 wave w = ImageNameToWaveRef(graphname, objname)
3182 info = ImageInfo(graphname, objname, 0)
3183 if (strlen(info) > 0)
3184 info = StringByKey(
"RECREATION", info,
":",
";")
3185 info = StringByKey(
"ctab", info,
"=",
";")
3186 if (strlen(info) > 2)
3187 info = info[1,strlen(info)-2]
3188 ctab = StringFromList(2, info,
",")
3189 rev = str2num(
"0" + StringFromList(3, info,
","))
3190 if (strlen(colortable) > 0)
3194 ModifyImage /w=$graphname $objname ctab={vmin, vmax, $ctab, rev}
3199 setdatafolder save_df
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
string prepare_hemi_scan_display(string nickname, variable projection=defaultValue)
create waves for plotting a hemispherical angle scan.
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
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 check_contrast(wave values, variable pcmin, variable pcmax, variable *vmin, variable *vmax)
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
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 interpolate_hemi_scan(string nickname, variable projection=defaultValue)
interpolate a hemispherical scan onto a rectangular grid
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
variable normalize_strip_phi(wave strip, wave theta, wave phi, variable theta_offset=defaultValue, variable theta_range=defaultValue, variable check=defaultValue)
divide the strip by a sine function in phi (wobble correction).
variable normalize_strip_thetaphi(wave strip, wave theta, wave phi, variable theta_offset=defaultValue, variable smooth_method=defaultValue, variable smooth_factor=defaultValue, variable check=defaultValue)
divide the strip by a smooth polar-azimuthal distribution.
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 set_contrast(variable pcmin, variable pcmax, string graphname=defaultValue, string colortable=defaultValue)
set the pseudocolor contrast by percentile.
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.