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
226 fit_scienta_ang_transm(dist, fit_params)
227 dist = scienta_ang_transm(fit_params, x)
230 loess /smth=(smooth_factor) srcWave=dist
235 duplicate /o dist, check_smoo
270 variable
normalize_strip_phi(wave strip, wave theta, wave phi, variable theta_offset = defaultValue, variable theta_range = defaultValue, variable check = defaultValue){
274 variable theta_offset
278 if (ParamIsDefault(check))
281 if (ParamIsDefault(theta_offset))
284 if (ParamIsDefault(theta_range))
292 duplicate /free dist, dist_smoo
293 duplicate /free theta, theta_int
294 theta_int = theta - theta_offset
295 duplicate /free phi, phi_int
296 setscale /p x phi_int[0], phi_int[1] - phi_int[0], waveunits(phi, -1), dist, dist_smoo
298 extract /free /indx dist, red_idx, theta_int < theta_range
299 duplicate /free red_idx, red_dist, red_phi
300 red_dist = dist[red_idx]
301 red_phi = phi_int[red_idx]
303 variable wavg = mean(red_dist)
304 make /n=4 /d /free coef
305 coef[0] = {wavg, wavg/100, pi/180, 0}
306 CurveFit /q /h=
"0010" /g /w=2 sin, kwcWave=coef, red_dist /x=red_phi
307 dist_smoo = coef[0] + coef[1] * sin(coef[2] * phi_int[p] + coef[3])
311 strip = strip / dist_smoo[q] * coef[0]
316 duplicate /o dist, check_dist
317 duplicate /o dist_smoo, check_smoo
318 setscale /p x dimoffset(dist,0), dimdelta(dist,0), waveunits(dist,0), check_dist, check_smoo
353 variable
normalize_strip_theta(wave strip, wave theta, variable theta_offset = defaultValue, variable smooth_method = defaultValue, variable smooth_factor = defaultValue, variable check = defaultValue){
356 variable theta_offset
357 variable smooth_method
358 variable smooth_factor
361 if (ParamIsDefault(check))
364 if (ParamIsDefault(theta_offset))
367 if (ParamIsDefault(smooth_method))
370 if (ParamIsDefault(smooth_factor))
378 duplicate /free dist, dist_smoo
379 duplicate /free theta, theta_int
380 theta_int = theta - theta_offset
381 setscale /p x theta_int[0], theta_int[1] - theta_int[0], waveunits(theta,-1), dist, dist_smoo
382 variable nx = dimsize(strip, 0)
385 switch(smooth_method)
387 Smooth /B /E=3 smooth_factor, dist_smoo
390 Smooth /E=3 smooth_factor, dist_smoo
393 loess /dest=dist_smoo /smth=(smooth_factor) srcWave=dist, factors={theta_int}
396 for (ix = 0; ix < nx; ix += 1)
398 if (smooth_factor > 1)
399 CurveFit /nthr=0 /q /w=2 poly smooth_factor+1, dist /x=theta_int /d=dist_smoo
401 CurveFit /nthr=0 /q /w=2 line, dist /x=theta_int /d=dist_smoo
403 strip[ix,ix][] /= dist_smoo[q]
411 strip /= dist_smoo[q]
416 duplicate /o dist, check_dist
417 duplicate /o dist_smoo, check_smoo
418 setscale /p x dimoffset(dist,0), dimdelta(dist,0), waveunits(dist,0), check_dist, check_smoo
451 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){
455 variable theta_offset
456 variable smooth_method
457 variable smooth_factor
460 if (ParamIsDefault(check))
463 if (ParamIsDefault(theta_offset))
466 if (ParamIsDefault(smooth_method))
469 if (ParamIsDefault(smooth_factor))
477 duplicate /free dist, dist_smoo
478 duplicate /free theta, theta_int
479 theta_int = theta - theta_offset
480 setscale /p x theta_int[0], theta_int[1] - theta_int[0], waveunits(theta,-1), dist, dist_smoo
481 variable nx = dimsize(strip, 0)
484 switch(smooth_method)
486 loess /dest=dist_smoo /smth=(smooth_factor) srcWave=dist, factors={theta_int, phi}
489 abort
"smooth method not supported" 494 strip /= dist_smoo[q]
499 duplicate /o dist, check_dist
500 duplicate /o dist_smoo, check_smoo
501 setscale /p x dimoffset(dist,0), dimdelta(dist,0), waveunits(dist,0), check_dist, check_smoo
518 variable
normalize_strip_2d(wave strip, wave theta, variable theta_offset = defaultValue, variable smooth_method = defaultValue, variable smooth_factor = defaultValue, variable check = defaultValue){
521 variable theta_offset
522 variable smooth_method
523 variable smooth_factor
526 if (ParamIsDefault(check))
529 if (ParamIsDefault(theta_offset))
532 if (ParamIsDefault(smooth_method))
535 if (ParamIsDefault(smooth_factor))
539 variable nx = dimsize(strip, 0)
540 variable ny = dimsize(strip, 1)
542 duplicate /free strip, dist, alpha_int, theta_int
543 theta_int = theta[q] - theta_offset
544 alpha_int = dimoffset(strip, 0) + p * dimdelta(strip, 0)
545 redimension /n=(nx * ny) dist, alpha_int, theta_int
547 switch(smooth_method)
549 loess /dest=dist_smoo /smth=(smooth_factor) srcWave=dist, factors={alpha_int, theta_int}
550 redimension /n=(nx, ny) dist_smoo
553 Abort
"undefined smooth method" 565 duplicate /o dist_smoo, check_smoo
583 variable plo = round((xlo - dimoffset(strip, 0)) / dimdelta(strip, 0))
584 variable phi = round((xhi - dimoffset(strip, 0)) / dimdelta(strip, 0))
585 xlo = plo * dimdelta(strip, 0) + dimoffset(strip, 0)
586 xhi = phi * dimdelta(strip, 0) + dimoffset(strip, 0)
587 variable nx = phi - plo + 1
588 variable ny = dimsize(strip, 1)
590 duplicate /free strip, strip_copy
591 redimension /n=(nx,ny) strip
592 strip = strip_copy[p + plo][q]
593 setscale /i x xlo, xhi, waveunits(strip, 0), strip
638 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){
641 variable theta_offset
649 if (ParamIsDefault(npolar))
652 if (ParamIsDefault(nograph))
655 if (ParamIsDefault(folding))
658 if (ParamIsDefault(xpdplot))
663 dfref saveDF = GetDataFolderDFR()
664 dfref dataDF = GetWavesDataFolderDFR(data)
666 if (DataFolderExists(
":attr"))
669 dfref attrDF = GetDataFolderDFR()
671 wave /sdfr=attrDF ManipulatorTheta
672 wave /sdfr=attrDF ManipulatorTilt
673 wave /sdfr=attrDF ManipulatorPhi
675 if ((dimsize(ManipulatorTheta, 0) != dimsize(data, 1)) || (dimsize(ManipulatorTilt, 0) != dimsize(data, 1)) || (dimsize(ManipulatorPhi, 0) != dimsize(data, 1)))
676 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." 679 duplicate /free ManipulatorTheta, m_theta
680 duplicate /free ManipulatorTilt, m_tilt
681 duplicate /free ManipulatorPhi, m_phi
683 m_theta -= theta_offset
684 m_tilt -= tilt_offset
687 pizza_service_2(data, nickname, m_theta, m_tilt, m_phi, npolar=npolar, nograph=nograph, folding=folding, xpdplot=xpdplot)
731 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){
742 if (ParamIsDefault(npolar))
745 if (ParamIsDefault(nograph))
748 if (ParamIsDefault(folding))
751 if (ParamIsDefault(xpdplot))
755 if ((dimsize(m_theta, 0) != dimsize(data, 1)) || (dimsize(m_tilt, 0) != dimsize(data, 1)) || (dimsize(m_phi, 0) != dimsize(data, 1)))
756 Abort
"Warning: The dimension size of the manipulator waves does not match the Y dimension of the data wave!" 759 string graphname =
"graph_" + nickname
760 string outprefix = nickname
763 dfref saveDF = GetDataFolderDFR()
764 dfref dataDF = GetWavesDataFolderDFR(data)
772 newdatafolder /s/o $nickname
775 dfref destDF = GetDataFolderDFR()
779 variable /g pol_perf_secs
780 timerRefNum = startMSTimer
782 duplicate /free m_tilt, corr_tilt
783 duplicate /free m_phi, corr_phi
787 make /n=1/d/free d_polar, d_azi
793 for (ifold = 0; ifold < folding; ifold += 1)
794 d_azi = d_azi >= 360 ? d_azi - 360 : d_azi
796 d_azi += 360 / folding
800 if (strlen(outprefix))
801 string s_prefix = outprefix +
"_" 802 string s_int = s_prefix +
"i" 816 if (timerRefNum >= 0)
817 pol_perf_secs = stopMSTimer(timerRefNum) / 1e6
848 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){
852 variable theta_offset
859 string nickname =
"analyser" 861 if (ParamIsDefault(npolar))
864 if (ParamIsDefault(nograph))
867 if (ParamIsDefault(xpdplot))
870 string graphname =
"graph_" + nickname
871 string outprefix = nickname
874 dfref saveDF = GetDataFolderDFR()
875 dfref dataDF = saveDF
881 newdatafolder /s/o $nickname
884 dfref destDF = GetDataFolderDFR()
886 make /n=1 /free m_theta
887 make /n=1 /free m_tilt
888 make /n=1 /free m_phi
889 m_theta = theta - theta_offset
890 m_tilt = tilt - tilt_offset
892 m_phi = phi - phi_offset
895 make /n=60 /free data
896 setscale /i x -30, 30, data
898 make /n=1/d/free d_polar, d_azi
902 d_azi = d_azi >= 360 ? d_azi - 360 : d_azi
919 wave theta, tilt, phi
924 make /n=(dimsize(data, 0)) /d /free ana
925 setscale /p x dimoffset(data, 0), dimdelta(data, 0), waveunits(data, 0), ana
964 variable nn = numpnts(theta)
965 variable na = numpnts(analyser)
966 redimension /n=(na, nn) polar, azi
973 make /n=(3,na) /d /free w_orig_polar, w_orig_cart, w_rot_cart, w_rot_polar
974 w_orig_polar[0][] = radius
975 w_orig_polar[1][] = analyser[q]
976 w_orig_polar[2][] = 0
982 for (ii = 0; ii < nn; ii += 1)
988 w_rot_cart = w_orig_cart
995 polar[][ii] = w_rot_polar[1][p]
996 azi[][ii] = w_rot_polar[2][p]
1006 variable nn = dimsize(source, 1)
1007 make /n=(dimsize(source, 0))/d/free line
1008 for (ii = 0; ii < nn; ii += 1)
1009 line = source[p][ii]
1011 dest[][ii] = line[p] / v_max
1018 static variable
calc_nth(variable Theta_st, variable Theta_in, variable th, variable Phi_ran, variable Phi_ref,
string Holomode){
1019 Variable Theta_st, Theta_in, th, Phi_ran, Phi_ref
1022 Variable deg2rad=0.01745329
1024 if ( cmpstr(Holomode,
"Stereographic") == 0)
1025 The_step =trunc( Phi_ran*sin(th*deg2rad)*Phi_ref/Theta_st )
1027 The_step =trunc( Phi_ran*sin(th*pi/180)*Phi_ref/Theta_st )
1030 if (cmpstr(Holomode,
"Parallel") == 0)
1031 The_step=trunc( Phi_ran*tan(th*deg2rad)*Phi_ref/Theta_st )
1033 if ( cmpstr(Holomode,
"h") == 0)
1034 The_step=trunc( th/Theta_in*Phi_ran/Theta_st )
1047 static variable
calc_phi_step(variable Theta_in, variable th, variable Theta_st, variable Phi_ran, variable Phi_ref,
string Holomode){
1048 Variable Theta_in, th, Theta_st, Phi_ran, Phi_ref
1052 Variable deg2rad=0.01745329
1054 if ( cmpstr(Holomode,
"Stereographic") == 0 )
1055 if ((th < 0.5) || (trunc(Phi_ran*sin(th*deg2rad)*Phi_ref/Theta_st) == 0))
1058 Phi_st=Phi_ran/(trunc(Phi_ran*sin(th*deg2rad)*Phi_ref/Theta_st))
1065 if ( cmpstr(Holomode,
"Parallel") == 0 )
1066 if((th < 0.5) || (trunc(Phi_ran*tan(th*deg2rad)*Phi_ref/Theta_st) == 0))
1069 Phi_st=Phi_ran/(trunc(Phi_ran*tan(th*deg2rad)*Phi_ref/Theta_st))
1073 if ( cmpstr(Holomode,
"h") == 0 )
1074 if((th < 0.5) || (trunc(Phi_ran*sin(th*deg2rad)*Phi_ref/Theta_st) == 0))
1077 Phi_st=Phi_ran/trunc(th/Theta_in*Phi_ran/Theta_st)
1093 Variable th, Theta_st
1095 Variable deg2rad=0.01745329, dt_loc,The_step
1097 if ( (cmpstr(Holomode,
"Stereographic")) ==0 )
1101 if ( (cmpstr(Holomode,
"h")) ==0 )
1105 if ( cmpstr(Holomode,
"Parallel") == 0 )
1107 dt_loc = Theta_st/cos(th*deg2rad)
1122 static variable
CalcN_Theta(
string HoloMode, variable Theta_in, variable Theta_ran, variable Theta_st){
1124 Variable Theta_in,Theta_ran,Theta_st
1125 Variable n_theta, aux, aux1,ii
1128 aux1= Theta_in - Theta_ran
1132 if(aux<=Theta_in-Theta_ran)
1133 aux=Theta_in-Theta_ran
1136 while((aux>aux1)%&(Theta_in-aux<=Theta_ran))
1160 variable
make_hemi_grid(variable npol,
string nickname, variable xpdplot = defaultValue){
1165 if (ParamIsDefault(xpdplot))
1169 string HoloMode =
"h" 1170 variable Theta_in = 90
1171 variable Theta_ran = 90
1172 variable Theta_st = 90 / (npol - 1)
1173 variable Phi_ran = 360
1174 variable Phi_ref = 1
1177 variable n_theta =
CalcN_Theta(HoloMode, Theta_in, Theta_ran, Theta_st)
1180 if (strlen(nickname))
1181 string s_prefix = nickname +
"_" 1182 string s_int = s_prefix +
"i" 1187 string s_polar = s_prefix +
"pol" 1188 string s_azim = s_prefix +
"az" 1190 string s_index = s_prefix +
"index" 1191 string s_theta = s_prefix +
"th" 1192 string s_dphi = s_prefix +
"dphi" 1193 string s_nphis = s_prefix +
"nphis" 1195 string s_HoloData = s_prefix +
"data" 1196 string s_HoloInfo = s_prefix +
"info" 1199 string s_tot = s_prefix +
"tot" 1200 string s_weight = s_prefix +
"wt" 1202 make /O/D/n=(n_theta) $s_index /wave=index
1203 make /O/D/n=(n_theta) $s_theta /wave=theta
1204 make /O/D/n=(n_theta) $s_dphi /wave=dphi
1205 make /O/D/n=(n_theta) $s_nphis /wave=nphis
1209 dphi[0] =
calc_phi_step(Theta_in, Theta_in, aux, Phi_ran, Phi_ref, HoloMode)
1211 nphis[0] =
calc_nth(aux, Theta_in, Theta_in, Phi_ran, Phi_ref, HoloMode)
1217 Theta[ii] = Theta[ii-1] - aux
1218 if(Theta[ii] <= Theta_in-Theta_ran)
1219 Theta[ii] = Theta_in-Theta_ran
1222 dphi[ii] =
calc_phi_step(Theta_in, Theta[ii], aux, Phi_ran, Phi_ref, HoloMode)
1223 nphis[ii] =
calc_nth(aux, Theta_in, Theta[ii], Phi_ran, Phi_ref, HoloMode)
1224 Index[ii] = Index[ii-1] + nphis[ii]
1228 if (Index[n_theta-1]==Index[n_theta-2])
1229 Index[n_theta-1]=Index[n_theta-2]+1
1233 variable NumPoints = sum(nphis, 0, numpnts(nphis))
1236 make /O/D/N=(NumPoints) $s_polar /wave=polar, $s_azim /wave=azim
1237 note azim,
"version=1.6" 1240 variable StartIndex = 0
1244 Polar[StartIndex, EndIndex-1]=Theta[ii]
1245 Azim[StartIndex, EndIndex-1]= mod(Phi_ran+(x-StartIndex)*dphi[ii]+Phi_in,Phi_ran)
1247 StartIndex = EndIndex
1250 duplicate /o azim, $s_int /wave=values
1251 duplicate /o azim, $s_tot /wave=totals
1252 duplicate /o azim, $s_weight /wave=weights
1259 string s_FileName =
"" 1260 string s_Comment =
"created by pearl-anglescan-process.ipf" 1261 string s_HoloMode =
"Stereographic" 1262 variable /g gb_SpectraFile = 0
1264 Make/O/D/n=22 $s_HoloData /wave=HoloData
1267 HoloData[6] = NumPoints
1268 HoloData[7] = Theta_in
1269 HoloData[8] = Theta_ran
1270 HoloData[9] = Theta_st
1271 HoloData[11] = Phi_in
1272 HoloData[12] = Phi_ran
1273 HoloData[13] = Theta_st
1274 HoloData[15] = Phi_ref
1275 HoloData[16] = Phi_ran
1278 Make/O/T/n=22 $s_HoloInfo /wave=HoloInfo
1279 HoloInfo[0] = s_FileName
1280 HoloInfo[1] = s_Comment
1281 HoloInfo[10] = s_HoloMode
1285 if (WinType(NickName) == 5)
1286 Notebook $NickName selection={startOfFile, endOfFile}
1287 Notebook $NickName text=
"" 1289 NewNotebook /F=0 /K=1 /N=$NickName /W=(5,40,341,260)
1290 Notebook $NickName defaultTab=140
1291 Notebook $NickName statusWidth=300
1292 Notebook $NickName backRGB=(56797,56797,56797)
1293 Notebook $NickName pageMargins={80,80,80,80}
1294 Notebook $NickName fSize=10
1295 Notebook $NickName fStyle=0,textRGB=(65535,0,26214)
1296 Notebook $NickName textRGB=(65535,0,26214)
1298 Notebook $NickName text =
"File:\t" + s_FileName +
"\r" 1299 Notebook $NickName text =
"*** " + s_Comment +
" ***\r\r" 1300 Notebook $NickName text =
"Angle-Mode:\t" + s_HoloMode +
"\r" 1301 Notebook $NickName text =
"XPDplot Nickname:\t" + NickName +
"\r" 1315 string wname = nameofwave(w)
1321 string s_wave_df = GetWavesDataFolder(w, 1)
1322 dfref parent_df = $(s_wave_df +
"::")
1323 nickname = GetDataFolder(0, parent_df)
1339 string wname = nameofwave(w)
1341 if (ItemsInList(wname,
"_") >= 2)
1342 prefix = StringFromList(0, wname,
"_")
1375 if (strlen(nickname))
1376 if (DataFolderExists(nickname))
1379 datadf = getdatafolderdfr()
1380 prefix = nickname +
"_" 1381 intwave = prefix +
"i" 1382 if (exists(intwave) != 1)
1387 datadf = getdatafolderdfr()
1409 string s_totals = s_prefix +
"tot" 1410 string s_weights = s_prefix +
"wt" 1412 wave /sdfr=datadf /z w_values = $s_int
1413 wave /sdfr=datadf /z w_totals = $s_totals
1414 wave /sdfr=datadf /z w_weights = $s_weights
1416 if (waveexists(w_totals))
1419 if (waveexists(w_weights))
1422 if (waveexists(w_values))
1448 variable
duplicate_hemi_scan(
string source_nickname, dfref dest_folder,
string dest_nickname, variable xpdplot = defaultValue){
1449 string source_nickname
1451 string dest_nickname
1454 if (ParamIsDefault(xpdplot))
1458 dfref savedf = getdatafolderdfr()
1461 string s_prefix =
"" 1462 string s_int =
"values" 1463 dfref source_df =
find_hemi_data(source_nickname, s_prefix, s_int)
1464 string s_polar = s_prefix +
"pol" 1465 string s_azim = s_prefix +
"az" 1466 string s_theta = s_prefix +
"th" 1467 string s_tot = s_prefix +
"tot" 1468 string s_weight = s_prefix +
"wt" 1469 string s_matrix = s_prefix +
"matrix" 1471 wave /sdfr=source_df theta1 = $s_theta
1472 wave /sdfr=source_df polar1 = $s_polar
1473 wave /sdfr=source_df azim1 = $s_azim
1474 wave /sdfr=source_df tot1 = $s_tot
1475 wave /sdfr=source_df weight1 = $s_weight
1476 wave /sdfr=source_df values1 = $s_int
1477 wave /sdfr=source_df /z matrix1 = $s_matrix
1479 variable npol = numpnts(theta1)
1481 setdatafolder dest_folder
1486 s_polar = s_prefix +
"pol" 1487 s_azim = s_prefix +
"az" 1488 s_theta = s_prefix +
"th" 1489 s_tot = s_prefix +
"tot" 1490 s_weight = s_prefix +
"wt" 1491 s_matrix = s_prefix +
"matrix" 1493 wave /sdfr=dest_df theta2 = $s_theta
1494 wave /sdfr=dest_df polar2 = $s_polar
1495 wave /sdfr=dest_df azim2 = $s_azim
1496 wave /sdfr=dest_df tot2 = $s_tot
1497 wave /sdfr=dest_df weight2 = $s_weight
1498 wave /sdfr=dest_df values2 = $s_int
1503 if (waveexists(matrix1))
1504 setdatafolder dest_df
1505 duplicate /o matrix1, $s_matrix
1508 if (!(NumberByKey(
"version", note(azim1),
"=",
"\r") >= 1.6))
1510 azim2 = azim2 >= 360 ? azim2 - 360 : azim2
1513 setdatafolder saveDF
1527 dfref savedf = getdatafolderdfr()
1529 string s_prefix =
"" 1530 string s_int =
"values" 1533 string s_polar = s_prefix +
"pol" 1534 string s_azim = s_prefix +
"az" 1535 string s_tot = s_prefix +
"tot" 1536 string s_weight = s_prefix +
"wt" 1538 wave /sdfr=df polar = $s_polar
1539 wave /sdfr=df azim = $s_azim
1540 wave /sdfr=df tot = $s_tot
1541 wave /sdfr=df weight = $s_weight
1542 wave /sdfr=df values = $s_int
1545 azim = azim < 0 ? azim + 360 : azim
1546 azim = azim >= 360 ? azim - 360 : azim
1548 duplicate /free polar, neg_polar
1550 sort {neg_polar, azim}, polar, azim, tot, weight, values
1552 setdatafolder saveDF
1601 string display_hemi_scan(
string nickname, variable projection = defaultValue, variable graphtype = defaultValue, variable do_ticks = defaultValue, variable do_grids = defaultValue,
string graphname = defaultValue){
1609 dfref savedf = getdatafolderdfr()
1611 if (ParamIsDefault(projection))
1614 if (ParamIsDefault(graphtype))
1617 if (ParamIsDefault(do_ticks))
1620 if (ParamIsDefault(do_grids))
1623 if (ParamIsDefault(graphname))
1624 if (strlen(nickname) > 0)
1625 graphname = nickname
1627 graphname = GetDataFolder(0)
1632 string s_prefix =
"" 1633 string s_int =
"values" 1636 string s_polar = s_prefix +
"pol" 1637 string s_azim = s_prefix +
"az" 1638 string s_matrix = s_prefix +
"matrix" 1640 wave /sdfr=df /z values = $s_int
1641 wave /sdfr=df /z azim = $s_azim
1642 wave /sdfr=df /z polar = $s_polar
1643 wave /sdfr=df /z matrix = $s_matrix
1646 string s_ster_rad = s_prefix +
"ster_rad" 1647 duplicate /o polar, $s_ster_rad /wave=ster_rad
1650 string s_ster_x = s_prefix +
"ster_x" 1651 string s_ster_y = s_prefix +
"ster_y" 1652 duplicate /o azim, $s_ster_x /wave=ster_x, $s_ster_y /wave=ster_y
1653 ster_x = ster_rad * cos(azim * pi / 180)
1654 ster_y = ster_rad * sin(azim * pi / 180)
1656 variable azim_offset = 0
1657 if (!(NumberByKey(
"version", note(azim),
"=",
"\r") >= 1.6))
1658 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!" 1667 s_trace = WMPolarAppendTrace(graphname, ster_rad, azim, 360)
1668 ModifyGraph /W=$graphname mode($s_trace)=2, lsize($s_trace)=2
1669 ModifyGraph /W=$graphname zColor($s_trace)={values,*,*,BlueGreenOrange,0}
1671 ColorScale /W=$graphname /C /N=text0 /E=2 /F=0 /B=1 /A=RB /X=0.00 /Y=0.00 trace=polarY0
1672 ColorScale /W=$graphname /C /N=text0 side=2, width=5, heightPct=40, frame=0.50, lblMargin=0
1673 ColorScale /W=$graphname /C /N=text0 nticks=2, minor=1, tickLen=4.00, tickThick=0.50
1675 SetWindow $graphname, userdata(projection)=num2str(projection)
1681 s_trace = WMPolarAppendTrace(graphname, ster_rad, azim, 360)
1682 ModifyGraph /W=$graphname mode($s_trace)=0, lsize($s_trace)=0
1683 AppendImage /L=VertCrossing /B=HorizCrossing matrix
1685 ColorScale /W=$graphname /C /N=text0 /E=2 /F=0 /B=1 /A=RB /X=0.00 /Y=0.00 image=$s_matrix
1686 ColorScale /W=$graphname /C /N=text0 side=2, width=5, heightPct=40, frame=0.50, lblMargin=0
1687 ColorScale /W=$graphname /C /N=text0 nticks=2, minor=1, tickLen=4.00, tickThick=0.50
1689 SetWindow $graphname, userdata(projection)=num2str(projection)
1694 setdatafolder savedf
1739 static string display_polar_graph(
string graphname, variable angle_offset = defaultValue, variable do_ticks = defaultValue){
1742 variable angle_offset
1745 dfref savedf = GetDataFolderDFR()
1747 if (ParamIsDefault(angle_offset))
1750 if (ParamIsDefault(do_ticks))
1754 if ((strlen(graphname) == 0) || (wintype(graphname) == 0))
1755 Display /k=1 /W=(10,45,360,345)
1756 DoWindow /C $graphname
1757 graphname = WMNewPolarGraph(
"", graphname)
1758 WMPolarGraphSetVar(graphname,
"zeroAngleWhere", angle_offset)
1760 WMPolarGraphSetVar(graphname,
"angleAxisThick", 0.5)
1761 WMPolarGraphSetStr(graphname,
"doMajorAngleTicks",
"manual")
1762 WMPolarGraphSetVar(graphname,
"majorAngleInc", 30)
1763 WMPolarGraphSetVar(graphname,
"minorAngleTicks", 2)
1764 WMPolarGraphSetStr(graphname,
"angleTicksLocation",
"Outside")
1765 WMPolarGraphSetVar(graphname,
"doAngleTickLabelSubRange", 1)
1766 WMPolarGraphSetVar(graphname,
"angleTickLabelRangeStart", 0)
1767 WMPolarGraphSetVar(graphname,
"angleTickLabelRangeExtent", 90)
1768 WMPolarGraphSetStr(graphname,
"angleTickLabelNotation",
"%g")
1770 WMPolarGraphSetVar(graphname,
"doPolarGrids", 0)
1771 WMPolarGraphSetVar(graphname,
"doRadiusTickLabels", 0)
1772 WMPolarGraphSetStr(graphname,
"radiusAxesWhere",
" Off")
1773 WMPolarGraphSetStr(graphname,
"radiusTicksLocation",
"Off")
1775 WMPolarGraphSetVar(graphname,
"majorTickLength", 2)
1776 WMPolarGraphSetVar(graphname,
"majorTickThick", 0.5)
1777 WMPolarGraphSetVar(graphname,
"minorTickLength", 1)
1778 WMPolarGraphSetVar(graphname,
"minorTickThick", 0.5)
1779 WMPolarGraphSetVar(graphname,
"tickLabelOpaque", 0)
1780 WMPolarGraphSetVar(graphname,
"tickLabelFontSize", 7)
1784 WMPolarGraphSetStr(graphname,
"angleTicksLocation",
"Outside")
1786 WMPolarGraphSetStr(graphname,
"angleTicksLocation",
"Off")
1789 WMPolarGraphSetVar(graphname,
"doMinorAngleTicks", 1)
1791 WMPolarGraphSetVar(graphname,
"doMinorAngleTicks", 0)
1794 DoWindow /T $graphname, graphname
1797 string graphdf =
"root:packages:WMPolarGraphs:" + graphname
1798 setdatafolder graphdf
1800 variable /g csrA_theta
1801 variable /g csrA_phi
1802 variable /g csrB_theta
1803 variable /g csrB_phi
1807 tb = tb +
"\"A = (%.1f, %.1f)\"," 1808 tb = tb + graphdf +
":csrA_theta," 1809 tb = tb + graphdf +
":csrA_phi" 1811 TextBox /W=$graphname /A=LT /B=1 /E=2 /F=0 /N=tb_angles /X=1 /Y=1 /V=0 tb
1813 tb = tb +
"\"B = (%.1f, %.1f)\"," 1814 tb = tb + graphdf +
":csrB_theta," 1815 tb = tb + graphdf +
":csrB_phi" 1817 AppendText /W=$graphname /N=tb_angles tb
1822 DoWindow /F $graphname
1825 setdatafolder savedf
1858 if (ParamIsDefault(do_grids))
1862 dfref savedf = GetDataFolderDFR()
1864 string sproj = GetUserData(graphname,
"",
"projection")
1865 variable projection = str2num(
"0" + sproj)
1867 SetDrawLayer /W=$graphname ProgFront
1870 SetDrawEnv /W=$graphname xcoord=HorizCrossing, ycoord=VertCrossing
1871 SetDrawEnv /W=$graphname linethick= 0.5
1872 SetDrawEnv /W=$graphname dash=2
1873 SetDrawEnv /W=$graphname fillpat=0
1874 SetDrawEnv /W=$graphname fname=
"default", fsize=7
1875 SetDrawEnv /W=$graphname textxjust=1, textyjust=1
1877 SetDrawEnv /W=$graphname save
1880 DrawLine /W=$graphname 0, -2, 0, 2
1881 DrawLine /W=$graphname -2, 0, 2, 0
1887 DrawOval /W=$graphname -radi, radi, radi, -radi
1889 DrawOval /W=$graphname -radi, radi, radi, -radi
1891 DrawOval /W=$graphname -radi, radi, radi, -radi
1893 SetDrawEnv /W=$graphname textxjust= 1,textyjust= 2
1894 SetDrawEnv /W=$graphname save
1896 DrawText /W=$graphname radi, -0.1,
"30" 1898 DrawText /W=$graphname radi, -0.1,
"60" 1901 setdatafolder savedf
1926 variable
draw_diffraction_cone(
string graphname,
string groupname, variable theta_axis, variable theta_inner, variable phi){
1931 variable theta_inner
1939 SetDrawLayer UserFront
1940 DrawAction getgroup=$groupname,
delete 1941 SetDrawEnv gstart, gname=$groupname
1942 variable xc, yc, xr, yr
1945 variable r_center = (r_outer + r_inner) / 2
1946 variable r_radius = (r_outer - r_inner) / 2
1947 xc = r_center * cos(phi * pi / 180)
1948 yc = r_center * sin(phi * pi / 180)
1951 SetDrawEnv xcoord=HorizCrossing, ycoord=VertCrossing
1952 SetDrawEnv dash=11, fillpat=0
1953 DrawOval xc - xr, yc - yr, xc + xr, yc + yr
1956 xc = r_axis * cos(phi * pi / 180)
1957 yc = r_axis * sin(phi * pi / 180)
1961 SetDrawEnv xcoord=HorizCrossing, ycoord=VertCrossing
1962 SetDrawEnv fillfgc=(0,0,0)
1963 DrawOval xc - xr, yc - yr, xc + xr, yc + yr
1990 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){
2000 if (ParamIsDefault(folding))
2003 if (ParamIsDefault(projection))
2008 dfref saveDF = GetDataFolderDFR()
2009 newdatafolder /s/o $nickname
2010 string graphname =
"graph_" + nickname
2012 duplicate /free m_tilt, loc_m_tilt
2013 loc_m_tilt = -m_tilt
2015 make /n=1 /d /free d_polar, d_azi
2016 variable n_alpha = round(alpha_hi - alpha_lo) + 1
2017 make /n=(n_alpha) /d /free analyser
2018 setscale /i x alpha_lo, alpha_hi,
"", analyser
2022 duplicate /free d_polar, d_radius
2027 SetWindow $graphname, userdata(projection)=num2str(projection)
2031 variable nang = numpnts(m_theta)
2035 for (ifold = 0; ifold < folding; ifold += 1)
2036 d_azi = d_azi >= 360 ? d_azi - 360 : d_azi
2037 for (iang = 0; iang < nang; iang += 1)
2038 sprintf s_rad,
"rad_%d_%d", ifold, iang
2039 duplicate /o analyser, $s_rad
2041 w_rad = d_radius[p][iang]
2043 sprintf s_azi,
"azi_%d_%d", ifold, iang
2044 duplicate /o analyser, $s_azi
2046 w_azi = d_azi[p][iang]
2048 if (numtype(sum(w_rad)) == 0)
2049 s_trace = WMPolarAppendTrace(graphname, w_rad, w_azi, 360)
2050 ModifyGraph /w=$graphname mode($s_trace)=0, lsize($s_trace)=0.5
2053 d_azi += 360 / folding
2058 setdatafolder saveDF
2109 if (ParamIsDefault(projection))
2122 radius = polar < 90 ?
kProjScaleGnom * tan(polar * pi / 180) : inf
2150 threadsafe variable
calc_graph_polar(variable x, variable y, variable projection = defaultValue){
2155 if (ParamIsDefault(projection))
2162 radius = sqrt(x^2 + y^2)
2203 threadsafe variable
calc_graph_azi(variable x, variable y, variable projection = defaultValue, variable zeroAngle = defaultValue){
2209 if (ParamIsDefault(projection))
2212 if (ParamIsDefault(zeroAngle))
2218 azi = atan(y / x) * 180 / pi
2220 azi = atan(y / x) * 180 / pi + 180
2230 if (numtype(azi) != 0)
2251 dfref savedf = GetDataFolderDFR()
2253 string graphdf =
"root:packages:WMPolarGraphs:" + graphname
2254 setdatafolder graphdf
2261 string sproj = GetUserData(graphname,
"",
"projection")
2262 variable projection = str2num(
"0" + sproj)
2265 variable x = hcsr(A, graphname)
2266 variable y = vcsr(A, graphname)
2268 csrA_phi =
calc_graph_azi(x, y, projection=projection, zeroAngle=zeroAngleWhere)
2270 x = hcsr(B, graphname)
2271 y = vcsr(B, graphname)
2273 csrB_phi =
calc_graph_azi(x, y, projection=projection, zeroAngle=zeroAngleWhere)
2275 setdatafolder savedf
2284 STRUCT WMWinHookStruct &s
2286 Variable hookResult = 0
2293 TextBox /W=$s.winname /N=tb_angles /C /V=1
2296 TextBox /W=$s.winname /N=tb_angles /C /V=0
2303 variable
set_polar_graph_cursor(
string nickname,
string cursorname, variable polar_angle, variable azim_angle,
string graphname = defaultValue){
2306 variable polar_angle
2310 if (ParamIsDefault(graphname))
2311 if (strlen(nickname) > 0)
2312 graphname = nickname
2314 graphname = GetDataFolder(0)
2318 string s_prefix =
"" 2319 string s_int =
"values" 2322 string s_polar = s_prefix +
"pol" 2323 string s_azim = s_prefix +
"az" 2324 wave /sdfr=df /z azim = $s_azim
2325 wave /sdfr=df /z polar = $s_polar
2327 FindLevel /P /Q polar, polar_angle
2329 variable polar_level = floor(v_levelx)
2330 FindLevel /P /Q /R=[polar_level] azim, azim_angle
2332 variable azim_level = round(v_levelx)
2333 string tracename =
"polarY0" 2334 Cursor /W=$graphname /P $cursorname $traceName azim_level
2348 variable
hemi_add_anglescan(
string nickname, wave values, wave polar, wave azi, wave weights = defaultValue){
2360 if (ParamIsDefault(weights))
2361 duplicate /free values, weights
2366 string s_prefix =
"" 2367 string s_int =
"values" 2370 string s_polar = s_prefix +
"pol" 2371 string s_azim = s_prefix +
"az" 2372 string s_theta = s_prefix +
"th" 2374 wave /sdfr=df /z w_values = $s_int
2375 wave /sdfr=df /z w_azim = $s_azim
2376 wave /sdfr=df /z w_polar = $s_polar
2377 wave /sdfr=df /z w_theta = $s_theta
2378 if (!waveexists(w_values) || !waveexists(w_azim) || !waveexists(w_polar))
2379 abort
"Missing hemispherical scan grid. Please call make_hemi_grid() first." 2383 duplicate /free values, values_copy
2384 duplicate /free polar, polar_copy
2385 duplicate /free azi, azi_copy
2386 duplicate /free weights, weights_copy
2387 variable nn = dimsize(values, 0) * max(dimsize(values, 1), 1)
2388 redimension /n=(nn) values_copy, polar_copy, azi_copy, weights_copy
2389 sort /r polar_copy, polar_copy, azi_copy, values_copy, weights_copy
2392 variable pol_st = abs(w_theta[1] - w_theta[0])
2395 duplicate /free azi_copy, azi_slice
2396 duplicate /free values_copy, values_slice
2397 duplicate /free weights_copy, weights_slice
2398 for (pol = 90; pol >= 0; pol -= pol_st)
2399 pol1 = pol - pol_st / 2
2400 pol2 = pol + pol_st / 2
2401 extract /free /indx polar_copy, sel, (pol1 < polar_copy) && (polar_copy <= pol2)
2402 if (numpnts(sel) > 0)
2403 redimension /n=(numpnts(sel)) azi_slice, values_slice, weights_slice
2404 azi_slice = azi_copy[sel]
2405 values_slice = values_copy[sel]
2406 weights_slice = weights_copy[sel]
2407 hemi_add_aziscan(nickname, values_slice, pol, azi_slice, weights=weights_slice)
2418 variable
hemi_add_aziscan(
string nickname, wave values, variable polar, wave azi, wave weights = defaultValue){
2428 if (ParamIsDefault(weights))
2429 duplicate /free values, weights
2434 string s_prefix =
"" 2435 string s_int =
"values" 2438 string s_totals = s_prefix +
"tot" 2439 string s_weights = s_prefix +
"wt" 2440 string s_polar = s_prefix +
"pol" 2441 string s_azim = s_prefix +
"az" 2442 string s_index = s_prefix +
"index" 2443 string s_theta = s_prefix +
"th" 2444 string s_dphi = s_prefix +
"dphi" 2445 string s_nphis = s_prefix +
"nphis" 2447 wave /sdfr=df w_polar = $s_polar
2448 wave /sdfr=df w_azim = $s_azim
2449 wave /sdfr=df w_values = $s_int
2450 wave /sdfr=df w_totals = $s_totals
2451 wave /sdfr=df w_weights = $s_weights
2452 wave /sdfr=df w_index = $s_index
2453 wave /sdfr=df w_theta = $s_theta
2454 wave /sdfr=df w_dphi = $s_dphi
2455 wave /sdfr=df w_nphis = $s_nphis
2460 variable ipol = BinarySearch(w_theta, polar)
2462 abort
"assertion failed in hemi_add_aziscan(): polar angle not found in grid." 2467 d1 = w_index[ipol - 1]
2471 d2 = w_index[ipol] - 1
2472 variable nd = d2 - d1 + 1
2473 variable dphi = w_dphi[ipol]
2478 azi = azi < 0 ? azi + 360 : azi
2479 azi = azi >= 360 - dphi/2 ? azi - 360 : azi
2480 duplicate /free values, sel_values
2481 duplicate /free weights, sel_weights
2485 variable v1, v2, w1, w2
2486 for (
id = 0;
id < nd;
id += 1)
2487 az1 = (
id - 0.5) * dphi
2488 az2 = (
id + 0.5) * dphi
2489 extract /free /indx azi, sel, (az1 <= azi) && (azi < az2)
2490 if (numpnts(sel) > 0)
2491 redimension /n=(numpnts(sel)) sel_values, sel_weights
2492 sel_values = values[sel]
2493 sel_weights = weights[sel]
2494 v1 = w_totals[d1 +
id]
2495 w1 = w_weights[d1 +
id]
2496 if ((numtype(v1) == 2) || (w1 <= 0))
2500 v2 = sum(sel_values)
2501 w2 = sum(sel_weights)
2502 w_totals[d1 + id] = v1 + v2
2503 w_weights[d1 + id] = w1 + w2
2506 w_values[d1, d1 + nd - 1] = w_totals[p] / w_weights[p]
2527 dfref savedf = GetDataFolderDFR()
2529 string s_prefix =
"" 2530 string s_int =
"values" 2533 string s_polar = s_prefix +
"pol" 2534 string s_azim = s_prefix +
"az" 2535 string s_ster_x = s_prefix +
"ster_x" 2536 string s_ster_y = s_prefix +
"ster_y" 2538 wave /sdfr=df values = $s_int
2539 wave /sdfr=df azim = $s_azim
2540 wave /sdfr=df polar = $s_polar
2541 wave /sdfr=df ster_x = $s_ster_x
2542 wave /sdfr=df ster_y = $s_ster_y
2544 variable min_ster_x = wavemin(ster_x)
2545 variable max_ster_x = wavemax(ster_x)
2546 variable x0 = min_ster_x
2548 variable dx = (max_ster_x - min_ster_x) / (xn - 1)
2549 make /n=(numpnts(ster_x), 3) /free triplet
2550 triplet[][0] = ster_x[p]
2551 triplet[][1] = ster_y[p]
2552 triplet[][2] = values[p]
2556 make /n=(size, size) /d /o $(s_prefix +
"matrix") /wave=matrix
2557 make /n=(size, size) /free mnorm
2558 ImageFromXYZ /as {ster_x, ster_y, values}, matrix, mnorm
2560 matrixfilter NanZapMedian, matrix
2561 matrixfilter gauss, matrix
2563 duplicate /free values, ster_finite
2564 ster_finite = (numtype(values) == 0) * (ster_x^2 + ster_y^2)
2565 variable ster_max = wavemax(ster_finite)
2566 matrix = (x^2 + y^2) <= ster_max ? matrix : nan
2568 setdatafolder savedf
2581 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){
2586 variable theta_offset
2587 variable tilt_offset
2595 if (ParamIsDefault(npolar))
2598 if (ParamIsDefault(nograph))
2601 if (ParamIsDefault(folding))
2604 string graphname =
"graph_" + nickname
2605 string s_prefix =
"" 2608 dfref saveDF = GetDataFolderDFR()
2609 dfref dataDF = GetWavesDataFolderDFR(data)
2610 setdatafolder dataDF
2611 if (DataFolderExists(
":attr"))
2614 dfref attrDF = GetDataFolderDFR()
2615 setdatafolder dataDF
2616 newdatafolder /s/o $nickname
2617 dfref destDF = GetDataFolderDFR()
2620 variable timerRefNum
2621 variable /g xyz_perf_secs
2622 timerRefNum = startMSTimer
2624 wave /sdfr=attrDF ManipulatorTheta
2625 wave /sdfr=attrDF ManipulatorTilt
2626 wave /sdfr=attrDF ManipulatorPhi
2627 duplicate /free ManipulatorTheta, m_theta
2628 duplicate /free ManipulatorTilt, m_tilt
2629 duplicate /free ManipulatorPhi, m_phi
2630 m_theta -= theta_offset
2631 m_tilt -= tilt_offset
2636 make /n=1/d/free d_polar, d_azi
2639 d_azi = d_azi >= 360 ? d_azi - 360 : d_azi
2641 duplicate /free data, values
2642 variable nn = dimsize(values, 0) * max(dimsize(values, 1), 1)
2643 redimension /n=(nn) values, d_polar, d_azi
2644 duplicate /o d_polar, ster_rad, ster_x, ster_y
2646 variable projection = 1
2649 ster_rad = 2 * tan(d_polar / 2 * pi / 180)
2652 ster_rad = 2 * cos((180 - d_polar) / 2 * pi / 180)
2655 string s_ster_x = s_prefix +
"ster_x" 2656 string s_ster_y = s_prefix +
"ster_y" 2659 make /n=(nn, nn) /d /o matrix
2660 make /n=(nn, nn) /free mnorm
2661 setscale /i x -2, +2, matrix, mnorm
2662 setscale /i y -2, +2, matrix, mnorm
2667 for (ifold = 0; ifold < folding; ifold += 1)
2668 ster_x = ster_rad * cos(d_azi * pi / 180)
2669 ster_y = ster_rad * sin(d_azi * pi / 180)
2670 ImageFromXYZ {ster_x, ster_y, values}, matrix, mnorm
2671 d_azi = d_azi >= 180 ? d_azi + 360 / folding - 180 : d_azi + 360 / folding
2675 matrixfilter /n=5 NanZapMedian matrix
2676 matrixfilter /n=3 gauss matrix
2681 modifygraph width={Plan,1,bottom,left}
2684 if (timerRefNum >= 0)
2685 xyz_perf_secs = stopMSTimer(timerRefNum) / 1e6
2688 setdatafolder saveDF
2697 dfref savedf = getdatafolderdfr()
2700 string s_prefix =
"" 2701 string s_int =
"values" 2704 string s_polar = s_prefix +
"pol" 2705 string s_azim = s_prefix +
"az" 2706 string s_theta = s_prefix +
"th" 2707 string s_tot = s_prefix +
"tot" 2708 string s_weight = s_prefix +
"wt" 2710 wave /sdfr=df theta1 = $s_theta
2711 wave /sdfr=df polar1 = $s_polar
2712 wave /sdfr=df azim1 = $s_azim
2713 wave /sdfr=df tot1 = $s_tot
2714 wave /sdfr=df weight1 = $s_weight
2715 wave /sdfr=df values1 = $s_int
2717 save /m=
"\r\n" /o /p=$pathname /t theta1, polar1, azim1, tot1, weight1, values1 as filename
2719 setdatafolder saveDF
2730 dfref savedf = getdatafolderdfr()
2739 setdatafolder saveDF
2774 variable
import_tpi_scan(
string nickname, wave theta, wave phi, wave intensity, variable folding = defaultValue, variable npolar = defaultValue, variable nograph = defaultValue, variable xpdplot = defaultValue){
2785 if (ParamIsDefault(npolar))
2788 if (ParamIsDefault(nograph))
2791 if (ParamIsDefault(folding))
2794 if (ParamIsDefault(xpdplot))
2801 duplicate /free phi, fold_phi
2802 for (ifold = 0; ifold < folding; ifold += 1)
2804 fold_phi = fold_phi >= 180 ? fold_phi + 360 / folding - fold_phi : fold_phi + 360 / folding
2827 string s_prefix =
"" 2828 string s_int =
"values" 2831 string s_totals = s_prefix +
"tot" 2832 string s_weights = s_prefix +
"wt" 2833 string s_polar = s_prefix +
"pol" 2835 wave /sdfr=df w_polar = $s_polar
2836 wave /sdfr=df w_values = $s_int
2837 wave /sdfr=df w_totals = $s_totals
2838 wave /sdfr=df w_weights = $s_weights
2840 w_values = w_polar <= theta_max ? w_totals / w_weights : nan
2866 dfref savedf = getdatafolderdfr()
2867 string s_prefix =
"" 2868 string s_int =
"values" 2871 string s_totals = s_prefix +
"tot" 2872 string s_weights = s_prefix +
"wt" 2873 string s_polar = s_prefix +
"pol" 2874 string s_azim = s_prefix +
"az" 2875 string s_index = s_prefix +
"index" 2876 string s_theta = s_prefix +
"th" 2877 string s_dphi = s_prefix +
"dphi" 2878 string s_nphis = s_prefix +
"nphis" 2880 sprintf s_cut,
"%s_azi%03u", s_int, round(azim)
2882 wave /sdfr=df w_polar = $s_polar
2883 wave /sdfr=df w_azim = $s_azim
2884 wave /sdfr=df w_values = $s_int
2885 wave /sdfr=df w_totals = $s_totals
2886 wave /sdfr=df w_weights = $s_weights
2887 wave /sdfr=df w_index = $s_index
2888 wave /sdfr=df w_theta = $s_theta
2889 wave /sdfr=df w_dphi = $s_dphi
2890 wave /sdfr=df w_nphis = $s_nphis
2892 variable npol = numpnts(w_theta)
2894 variable pol_st = abs(w_theta[1] - w_theta[0])
2900 make /n=(npol) /o $s_cut
2902 setscale /i x w_theta[0], w_theta[numpnts(w_theta)-1],
"deg", w_cut
2903 make /n=1 /free azi_slice
2904 make /n=1 /free values_slice
2906 for (ipol = 0; ipol < npol; ipol += 1)
2908 pol1 = pol - pol_st / 2
2909 pol2 = pol + pol_st / 2
2910 extract /free /indx w_polar, sel, (pol1 < w_polar) && (w_polar <= pol2)
2913 redimension /n=(nsel+2) azi_slice, values_slice
2914 azi_slice[1, nsel] = w_azim[sel[p-1]]
2915 azi_slice[0] = azi_slice[nsel] - 360
2916 azi_slice[nsel+1] = azi_slice[1] + 360
2917 values_slice[1, nsel] = w_values[sel[p-1]]
2918 values_slice[0] = values_slice[nsel]
2919 values_slice[nsel+1] = values_slice[1]
2920 w_cut[ipol] = interp(azim, azi_slice, values_slice)
2926 setdatafolder savedf
2952 dfref savedf = getdatafolderdfr()
2953 string s_prefix =
"" 2954 string s_int =
"values" 2957 string s_totals = s_prefix +
"tot" 2958 string s_weights = s_prefix +
"wt" 2959 string s_polar = s_prefix +
"pol" 2960 string s_azim = s_prefix +
"az" 2961 string s_index = s_prefix +
"index" 2962 string s_theta = s_prefix +
"th" 2963 string s_dphi = s_prefix +
"dphi" 2964 string s_nphis = s_prefix +
"nphis" 2966 sprintf s_cut,
"%s_pol%03u", s_int, round(pol)
2968 wave /sdfr=df w_polar = $s_polar
2969 wave /sdfr=df w_azim = $s_azim
2970 wave /sdfr=df w_values = $s_int
2971 wave /sdfr=df w_totals = $s_totals
2972 wave /sdfr=df w_weights = $s_weights
2973 wave /sdfr=df w_index = $s_index
2974 wave /sdfr=df w_theta = $s_theta
2975 wave /sdfr=df w_dphi = $s_dphi
2976 wave /sdfr=df w_nphis = $s_nphis
2978 variable pol_st = abs(w_theta[1] - w_theta[0])
2982 pol1 = pol - pol_st / 2
2983 pol2 = pol + pol_st / 2
2984 extract /free /indx w_polar, sel, (pol1 < w_polar) && (w_polar <= pol2)
2988 make /n=(nsel) /o $s_cut
2990 w_cut = w_values[sel]
2991 setscale /i x w_azim[sel[0]], w_azim[sel[nsel-1]],
"", w_cut
2992 setdatafolder savedf
2995 setdatafolder savedf
2998 setdatafolder savedf
3001 static variable
check_contrast(wave values, variable pcmin, variable pcmax, variable* vmin, variable* vmax){
3008 dfref save_df = GetDataFolderDFR()
3009 dfref dfr = NewFreeDataFolder()
3011 StatsQuantiles /inan /iw /q /z values
3012 wave index = w_quantilesindex
3013 variable imin = round(numpnts(index) * pcmin / 100)
3014 variable imax = round(numpnts(index) * (100 - pcmax) / 100)
3015 vmin = values[index[imin]]
3016 vmax = values[index[imax]]
3018 setdatafolder save_df
3037 variable
set_contrast(variable pcmin, variable pcmax,
string graphname = defaultValue,
string colortable = defaultValue){
3043 if (ParamIsDefault(graphname))
3046 if (ParamIsDefault(colortable))
3050 dfref save_df = GetDataFolderDFR()
3062 string traces = TraceNameList(graphname,
";", 1+4)
3063 n = ItemsInList(traces,
";")
3064 for (i = 0; i < n; i += 1)
3065 objname = StringFromList(i, traces,
";")
3066 info = TraceInfo(graphname, objname, 0)
3067 if (strlen(info) > 0)
3068 info = StringByKey(
"RECREATION", info,
":",
";")
3069 info = StringByKey(
"zColor(x)", info,
"=",
";")
3070 if (strlen(info) > 2)
3071 info = info[1,strlen(info)-2]
3072 wname = StringFromList(0, info,
",")
3074 ctab = StringFromList(3, info,
",")
3075 rev = str2num(
"0" + StringFromList(4, info,
","))
3076 if (strlen(colortable) > 0)
3080 ModifyGraph /w=$graphname zColor($objname)={w, vmin, vmax, $ctab, rev}
3085 string images = ImageNameList(graphname,
";")
3086 n = ItemsInList(images,
";")
3087 for (i = 0; i < n; i += 1)
3088 objname = StringFromList(i, images,
";")
3089 wave w = ImageNameToWaveRef(graphname, objname)
3090 info = ImageInfo(graphname, objname, 0)
3091 if (strlen(info) > 0)
3092 info = StringByKey(
"RECREATION", info,
":",
";")
3093 info = StringByKey(
"ctab", info,
"=",
";")
3094 if (strlen(info) > 2)
3095 info = info[1,strlen(info)-2]
3096 ctab = StringFromList(2, info,
",")
3097 rev = str2num(
"0" + StringFromList(3, info,
","))
3098 if (strlen(colortable) > 0)
3102 ModifyImage /w=$graphname $objname ctab={vmin, vmax, $ctab, rev}
3107 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
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 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 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.