1 #pragma rtGlobals=3// Use modern global access method and strict wave access. 3 #pragma IgorVersion = 6.2 4 #pragma ModuleName = PearlAnglescanProcess 5 #include "pearl-vector-operations" 6 #include "pearl-polar-coordinates" 7 #include <New Polar Graphs> 118 variable snx = dimsize(strip, 0)
119 variable sny = dimsize(strip, 1)
121 variable sq1hi = max(qlo-1, 0)
122 variable sq2lo = min(qhi+1, sny - 1)
123 variable sq2hi = dimsize(strip, 1) - 1
127 variable dny = sny - (sq2lo - sq1hi + 1)
129 variable dq1hi = sq1hi
130 variable dq2lo = dq1hi + 1
131 variable dq2hi = dny - 1
132 variable q1ofs = sq1lo - dq1lo
133 variable q2ofs = sq2lo - dq2lo
135 duplicate /free strip, strip_copy
136 redimension /n=(dnx,dny) strip
137 strip[][dq1lo,dq1hi] = strip_copy[p][q + q1ofs]
138 strip[][dq2lo,dq2hi] = strip_copy[p][q + q2ofs]
140 duplicate /free theta, theta_copy
141 redimension /n=(dny) theta
142 theta[dq1lo,dq1hi] = theta_copy[p + q1ofs]
143 theta[dq2lo,dq2hi] = theta_copy[p + q2ofs]
145 duplicate /free tilt, tilt_copy
146 redimension /n=(dny) tilt
147 tilt[dq1lo,dq1hi] = tilt_copy[p + q1ofs]
148 tilt[dq2lo,dq2hi] = tilt_copy[p + q2ofs]
150 duplicate /free phi, phi_copy
151 redimension /n=(dny) phi
152 phi[dq1lo,dq1hi] = phi_copy[p + q1ofs]
153 phi[dq2lo,dq2hi] = phi_copy[p + q2ofs]
185 variable
normalize_strip_x(wave strip, variable smooth_method = defaultValue, variable smooth_factor = defaultValue, variable check = defaultValue){
187 variable smooth_method
188 variable smooth_factor
191 if (ParamIsDefault(smooth_method))
194 if (ParamIsDefault(smooth_factor))
195 switch(smooth_method)
203 if (ParamIsDefault(check))
209 variable div = mean(dist)
213 duplicate /o dist, check_dist
217 switch(smooth_method)
219 Smooth /B /E=3 smooth_factor, dist
222 Smooth /E=3 smooth_factor, dist
225 make /n=1 /d /free fit_params
230 loess /smth=(smooth_factor) srcWave=dist
235 duplicate /o dist, check_smoo
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
435 variable
normalize_strip_2d(wave strip, wave theta, variable theta_offset = defaultValue, variable smooth_method = defaultValue, variable smooth_factor = defaultValue, variable check = defaultValue){
438 variable theta_offset
439 variable smooth_method
440 variable smooth_factor
443 if (ParamIsDefault(check))
446 if (ParamIsDefault(theta_offset))
449 if (ParamIsDefault(smooth_method))
452 if (ParamIsDefault(smooth_factor))
456 variable nx = dimsize(strip, 0)
457 variable ny = dimsize(strip, 1)
459 duplicate /free strip, dist, alpha_int, theta_int
460 theta_int = theta[q] - theta_offset
461 alpha_int = dimoffset(strip, 0) + p * dimdelta(strip, 0)
462 redimension /n=(nx * ny) dist, alpha_int, theta_int
464 switch(smooth_method)
466 loess /dest=dist_smoo /smth=(smooth_factor) srcWave=dist, factors={alpha_int, theta_int}
467 redimension /n=(nx, ny) dist_smoo
470 Abort
"undefined smooth method" 482 duplicate /o dist_smoo, check_smoo
500 variable plo = round((xlo - dimoffset(strip, 0)) / dimdelta(strip, 0))
501 variable phi = round((xhi - dimoffset(strip, 0)) / dimdelta(strip, 0))
502 xlo = plo * dimdelta(strip, 0) + dimoffset(strip, 0)
503 xhi = phi * dimdelta(strip, 0) + dimoffset(strip, 0)
504 variable nx = phi - plo + 1
505 variable ny = dimsize(strip, 1)
507 duplicate /free strip, strip_copy
508 redimension /n=(nx,ny) strip
509 strip = strip_copy[p + plo][q]
510 setscale /i x xlo, xhi, waveunits(strip, 0), strip
555 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){
558 variable theta_offset
566 if (ParamIsDefault(npolar))
569 if (ParamIsDefault(nograph))
572 if (ParamIsDefault(folding))
575 if (ParamIsDefault(xpdplot))
580 dfref saveDF = GetDataFolderDFR()
581 dfref dataDF = GetWavesDataFolderDFR(data)
583 if (DataFolderExists(
":attr"))
586 dfref attrDF = GetDataFolderDFR()
588 wave /sdfr=attrDF ManipulatorTheta
589 wave /sdfr=attrDF ManipulatorTilt
590 wave /sdfr=attrDF ManipulatorPhi
592 if ((dimsize(ManipulatorTheta, 0) != dimsize(data, 1)) || (dimsize(ManipulatorTilt, 0) != dimsize(data, 1)) || (dimsize(ManipulatorPhi, 0) != dimsize(data, 1)))
593 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." 596 duplicate /free ManipulatorTheta, m_theta
597 duplicate /free ManipulatorTilt, m_tilt
598 duplicate /free ManipulatorPhi, m_phi
600 m_theta -= theta_offset
601 m_tilt -= tilt_offset
604 pizza_service_2(data, nickname, m_theta, m_tilt, m_phi, npolar=npolar, nograph=nograph, folding=folding, xpdplot=xpdplot)
648 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){
659 if (ParamIsDefault(npolar))
662 if (ParamIsDefault(nograph))
665 if (ParamIsDefault(folding))
668 if (ParamIsDefault(xpdplot))
672 if ((dimsize(m_theta, 0) != dimsize(data, 1)) || (dimsize(m_tilt, 0) != dimsize(data, 1)) || (dimsize(m_phi, 0) != dimsize(data, 1)))
673 Abort
"Warning: The dimension size of the manipulator waves does not match the Y dimension of the data wave!" 676 string graphname =
"graph_" + nickname
677 string outprefix = nickname
680 dfref saveDF = GetDataFolderDFR()
681 dfref dataDF = GetWavesDataFolderDFR(data)
689 newdatafolder /s/o $nickname
692 dfref destDF = GetDataFolderDFR()
696 variable /g pol_perf_secs
697 timerRefNum = startMSTimer
699 duplicate /free m_tilt, corr_tilt
700 duplicate /free m_phi, corr_phi
704 make /n=1/d/free d_polar, d_azi
710 for (ifold = 0; ifold < folding; ifold += 1)
711 d_azi = d_azi >= 360 ? d_azi - 360 : d_azi
713 d_azi += 360 / folding
717 if (strlen(outprefix))
718 string s_prefix = outprefix +
"_" 719 string s_int = s_prefix +
"i" 733 if (timerRefNum >= 0)
734 pol_perf_secs = stopMSTimer(timerRefNum) / 1e6
765 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){
769 variable theta_offset
776 string nickname =
"analyser" 778 if (ParamIsDefault(npolar))
781 if (ParamIsDefault(nograph))
784 if (ParamIsDefault(xpdplot))
787 string graphname =
"graph_" + nickname
788 string outprefix = nickname
791 dfref saveDF = GetDataFolderDFR()
792 dfref dataDF = saveDF
798 newdatafolder /s/o $nickname
801 dfref destDF = GetDataFolderDFR()
803 make /n=1 /free m_theta
804 make /n=1 /free m_tilt
805 make /n=1 /free m_phi
806 m_theta = theta - theta_offset
807 m_tilt = tilt - tilt_offset
809 m_phi = phi - phi_offset
812 make /n=60 /free data
813 setscale /i x -30, 30, data
815 make /n=1/d/free d_polar, d_azi
819 d_azi = d_azi >= 360 ? d_azi - 360 : d_azi
836 wave theta, tilt, phi
841 make /n=(dimsize(data, 0)) /d /free ana
842 setscale /p x dimoffset(data, 0), dimdelta(data, 0), waveunits(data, 0), ana
881 variable nn = numpnts(theta)
882 variable na = numpnts(analyser)
883 redimension /n=(na, nn) polar, azi
890 make /n=(3,na) /d /free w_orig_polar, w_orig_cart, w_rot_cart, w_rot_polar
891 w_orig_polar[0][] = radius
892 w_orig_polar[1][] = analyser[q]
893 w_orig_polar[2][] = 0
899 for (ii = 0; ii < nn; ii += 1)
905 w_rot_cart = w_orig_cart
912 polar[][ii] = w_rot_polar[1][p]
913 azi[][ii] = w_rot_polar[2][p]
923 variable nn = dimsize(source, 1)
924 make /n=(dimsize(source, 0))/d/free line
925 for (ii = 0; ii < nn; ii += 1)
928 dest[][ii] = line[p] / v_max
935 static variable
calc_nth(variable Theta_st, variable Theta_in, variable th, variable Phi_ran, variable Phi_ref,
string Holomode){
936 Variable Theta_st, Theta_in, th, Phi_ran, Phi_ref
939 Variable deg2rad=0.01745329
941 if ( cmpstr(Holomode,
"Stereographic") == 0)
942 The_step =trunc( Phi_ran*sin(th*deg2rad)*Phi_ref/Theta_st )
944 The_step =trunc( Phi_ran*sin(th*pi/180)*Phi_ref/Theta_st )
947 if (cmpstr(Holomode,
"Parallel") == 0)
948 The_step=trunc( Phi_ran*tan(th*deg2rad)*Phi_ref/Theta_st )
950 if ( cmpstr(Holomode,
"h") == 0)
951 The_step=trunc( th/Theta_in*Phi_ran/Theta_st )
964 static variable
calc_phi_step(variable Theta_in, variable th, variable Theta_st, variable Phi_ran, variable Phi_ref,
string Holomode){
965 Variable Theta_in, th, Theta_st, Phi_ran, Phi_ref
969 Variable deg2rad=0.01745329
971 if ( cmpstr(Holomode,
"Stereographic") == 0 )
972 if ((th < 0.5) || (trunc(Phi_ran*sin(th*deg2rad)*Phi_ref/Theta_st) == 0))
975 Phi_st=Phi_ran/(trunc(Phi_ran*sin(th*deg2rad)*Phi_ref/Theta_st))
982 if ( cmpstr(Holomode,
"Parallel") == 0 )
983 if((th < 0.5) || (trunc(Phi_ran*tan(th*deg2rad)*Phi_ref/Theta_st) == 0))
986 Phi_st=Phi_ran/(trunc(Phi_ran*tan(th*deg2rad)*Phi_ref/Theta_st))
990 if ( cmpstr(Holomode,
"h") == 0 )
991 if((th < 0.5) || (trunc(Phi_ran*sin(th*deg2rad)*Phi_ref/Theta_st) == 0))
994 Phi_st=Phi_ran/trunc(th/Theta_in*Phi_ran/Theta_st)
1010 Variable th, Theta_st
1012 Variable deg2rad=0.01745329, dt_loc,The_step
1014 if ( (cmpstr(Holomode,
"Stereographic")) ==0 )
1018 if ( (cmpstr(Holomode,
"h")) ==0 )
1022 if ( cmpstr(Holomode,
"Parallel") == 0 )
1024 dt_loc = Theta_st/cos(th*deg2rad)
1039 static variable
CalcN_Theta(
string HoloMode, variable Theta_in, variable Theta_ran, variable Theta_st){
1041 Variable Theta_in,Theta_ran,Theta_st
1042 Variable n_theta, aux, aux1,ii
1045 aux1= Theta_in - Theta_ran
1049 if(aux<=Theta_in-Theta_ran)
1050 aux=Theta_in-Theta_ran
1053 while((aux>aux1)%&(Theta_in-aux<=Theta_ran))
1077 variable
make_hemi_grid(variable npol,
string nickname, variable xpdplot = defaultValue){
1082 if (ParamIsDefault(xpdplot))
1086 string HoloMode =
"h" 1087 variable Theta_in = 90
1088 variable Theta_ran = 90
1089 variable Theta_st = 90 / (npol - 1)
1090 variable Phi_ran = 360
1091 variable Phi_ref = 1
1094 variable n_theta =
CalcN_Theta(HoloMode, Theta_in, Theta_ran, Theta_st)
1097 if (strlen(nickname))
1098 string s_prefix = nickname +
"_" 1099 string s_int = s_prefix +
"i" 1104 string s_polar = s_prefix +
"pol" 1105 string s_azim = s_prefix +
"az" 1107 string s_index = s_prefix +
"index" 1108 string s_theta = s_prefix +
"th" 1109 string s_dphi = s_prefix +
"dphi" 1110 string s_nphis = s_prefix +
"nphis" 1112 string s_HoloData = s_prefix +
"data" 1113 string s_HoloInfo = s_prefix +
"info" 1116 string s_tot = s_prefix +
"tot" 1117 string s_weight = s_prefix +
"wt" 1119 make /O/D/n=(n_theta) $s_index /wave=index
1120 make /O/D/n=(n_theta) $s_theta /wave=theta
1121 make /O/D/n=(n_theta) $s_dphi /wave=dphi
1122 make /O/D/n=(n_theta) $s_nphis /wave=nphis
1126 dphi[0] =
calc_phi_step(Theta_in, Theta_in, aux, Phi_ran, Phi_ref, HoloMode)
1128 nphis[0] =
calc_nth(aux, Theta_in, Theta_in, Phi_ran, Phi_ref, HoloMode)
1134 Theta[ii] = Theta[ii-1] - aux
1135 if(Theta[ii] <= Theta_in-Theta_ran)
1136 Theta[ii] = Theta_in-Theta_ran
1139 dphi[ii] =
calc_phi_step(Theta_in, Theta[ii], aux, Phi_ran, Phi_ref, HoloMode)
1140 nphis[ii] =
calc_nth(aux, Theta_in, Theta[ii], Phi_ran, Phi_ref, HoloMode)
1141 Index[ii] = Index[ii-1] + nphis[ii]
1145 if (Index[n_theta-1]==Index[n_theta-2])
1146 Index[n_theta-1]=Index[n_theta-2]+1
1150 variable NumPoints = sum(nphis, 0, numpnts(nphis))
1153 make /O/D/N=(NumPoints) $s_polar /wave=polar, $s_azim /wave=azim
1154 note azim,
"version=1.6" 1157 variable StartIndex = 0
1161 Polar[StartIndex, EndIndex-1]=Theta[ii]
1162 Azim[StartIndex, EndIndex-1]= mod(Phi_ran+(x-StartIndex)*dphi[ii]+Phi_in,Phi_ran)
1164 StartIndex = EndIndex
1167 duplicate /o azim, $s_int /wave=values
1168 duplicate /o azim, $s_tot /wave=totals
1169 duplicate /o azim, $s_weight /wave=weights
1176 string s_FileName =
"" 1177 string s_Comment =
"created by pearl-anglescan-process.ipf" 1178 string s_HoloMode =
"Stereographic" 1179 variable /g gb_SpectraFile = 0
1181 Make/O/D/n=22 $s_HoloData /wave=HoloData
1184 HoloData[6] = NumPoints
1185 HoloData[7] = Theta_in
1186 HoloData[8] = Theta_ran
1187 HoloData[9] = Theta_st
1188 HoloData[11] = Phi_in
1189 HoloData[12] = Phi_ran
1190 HoloData[13] = Theta_st
1191 HoloData[15] = Phi_ref
1192 HoloData[16] = Phi_ran
1195 Make/O/T/n=22 $s_HoloInfo /wave=HoloInfo
1196 HoloInfo[0] = s_FileName
1197 HoloInfo[1] = s_Comment
1198 HoloInfo[10] = s_HoloMode
1202 if (WinType(NickName) == 5)
1203 Notebook $NickName selection={startOfFile, endOfFile}
1204 Notebook $NickName text=
"" 1206 NewNotebook /F=0 /K=1 /N=$NickName /W=(5,40,341,260)
1207 Notebook $NickName defaultTab=140
1208 Notebook $NickName statusWidth=300
1209 Notebook $NickName backRGB=(56797,56797,56797)
1210 Notebook $NickName pageMargins={80,80,80,80}
1211 Notebook $NickName fSize=10
1212 Notebook $NickName fStyle=0,textRGB=(65535,0,26214)
1213 Notebook $NickName textRGB=(65535,0,26214)
1215 Notebook $NickName text =
"File:\t" + s_FileName +
"\r" 1216 Notebook $NickName text =
"*** " + s_Comment +
" ***\r\r" 1217 Notebook $NickName text =
"Angle-Mode:\t" + s_HoloMode +
"\r" 1218 Notebook $NickName text =
"XPDplot Nickname:\t" + NickName +
"\r" 1232 string wname = nameofwave(w)
1238 string s_wave_df = GetWavesDataFolder(w, 1)
1239 dfref parent_df = $(s_wave_df +
"::")
1240 nickname = GetDataFolder(0, parent_df)
1256 string wname = nameofwave(w)
1258 if (ItemsInList(wname,
"_") >= 2)
1259 prefix = StringFromList(0, wname,
"_")
1292 if (strlen(nickname))
1293 if (DataFolderExists(nickname))
1296 datadf = getdatafolderdfr()
1297 prefix = nickname +
"_" 1298 intwave = prefix +
"i" 1299 if (exists(intwave) != 1)
1304 datadf = getdatafolderdfr()
1326 string s_totals = s_prefix +
"tot" 1327 string s_weights = s_prefix +
"wt" 1329 wave /sdfr=datadf /z w_values = $s_int
1330 wave /sdfr=datadf /z w_totals = $s_totals
1331 wave /sdfr=datadf /z w_weights = $s_weights
1333 if (waveexists(w_totals))
1336 if (waveexists(w_weights))
1339 if (waveexists(w_values))
1365 variable
duplicate_hemi_scan(
string source_nickname, dfref dest_folder,
string dest_nickname, variable xpdplot = defaultValue){
1366 string source_nickname
1368 string dest_nickname
1371 if (ParamIsDefault(xpdplot))
1375 dfref savedf = getdatafolderdfr()
1378 if (strlen(source_nickname))
1379 string s_prefix = source_nickname +
"_" 1380 string s_int = s_prefix +
"i" 1385 string s_polar = s_prefix +
"pol" 1386 string s_azim = s_prefix +
"az" 1387 string s_theta = s_prefix +
"th" 1388 string s_tot = s_prefix +
"tot" 1389 string s_weight = s_prefix +
"wt" 1390 string s_matrix = s_prefix +
"matrix" 1392 wave theta1 = $s_theta
1393 wave polar1 = $s_polar
1394 wave azim1 = $s_azim
1396 wave weight1 = $s_weight
1397 wave values1 = $s_int
1398 wave /z matrix1 = $s_matrix
1400 variable npol = numpnts(theta1)
1402 setdatafolder dest_folder
1406 if (strlen(dest_nickname))
1407 s_prefix = dest_nickname +
"_" 1408 s_int = s_prefix +
"i" 1413 s_polar = s_prefix +
"pol" 1414 s_azim = s_prefix +
"az" 1415 s_theta = s_prefix +
"th" 1416 s_tot = s_prefix +
"tot" 1417 s_weight = s_prefix +
"wt" 1418 s_matrix = s_prefix +
"matrix" 1420 wave theta2 = $s_theta
1421 wave polar2 = $s_polar
1422 wave azim2 = $s_azim
1424 wave weight2 = $s_weight
1425 wave values2 = $s_int
1430 if (waveexists(matrix1))
1431 duplicate /o matrix1, $s_matrix
1434 if (!(NumberByKey(
"version", note(azim1),
"=",
"\r") >= 1.6))
1436 azim2 = azim2 >= 360 ? azim2 - 360 : azim2
1439 setdatafolder saveDF
1453 dfref savedf = getdatafolderdfr()
1455 if (strlen(nickname))
1456 string s_prefix = nickname +
"_" 1457 string s_int = s_prefix +
"i" 1462 string s_polar = s_prefix +
"pol" 1463 string s_azim = s_prefix +
"az" 1464 string s_tot = s_prefix +
"tot" 1465 string s_weight = s_prefix +
"wt" 1467 wave polar = $s_polar
1470 wave weight = $s_weight
1471 wave values = $s_int
1474 azim = azim < 0 ? azim + 360 : azim
1475 azim = azim >= 360 ? azim - 360 : azim
1477 duplicate /free polar, neg_polar
1479 sort {neg_polar, azim}, polar, azim, tot, weight, values
1481 setdatafolder saveDF
1528 string display_hemi_scan(
string nickname, variable projection = defaultValue, variable graphtype = defaultValue, variable do_ticks = defaultValue, variable do_grids = defaultValue,
string graphname = defaultValue){
1536 if (ParamIsDefault(projection))
1539 if (ParamIsDefault(graphtype))
1542 if (ParamIsDefault(do_ticks))
1545 if (ParamIsDefault(do_grids))
1548 if (ParamIsDefault(graphname))
1549 if (strlen(nickname) > 0)
1550 graphname = nickname
1552 graphname = GetDataFolder(0)
1557 if (strlen(nickname))
1558 string s_prefix = nickname +
"_" 1559 string s_int = s_prefix +
"i" 1564 string s_polar = s_prefix +
"pol" 1565 string s_azim = s_prefix +
"az" 1566 string s_matrix = s_prefix +
"matrix" 1568 wave /z values = $s_int
1569 wave /z azim = $s_azim
1570 wave /z polar = $s_polar
1571 wave /z matrix = $s_matrix
1573 string s_ster_rad = s_prefix +
"ster_rad" 1574 duplicate /o polar, $s_ster_rad /wave=ster_rad
1577 string s_ster_x = s_prefix +
"ster_x" 1578 string s_ster_y = s_prefix +
"ster_y" 1579 duplicate /o azim, $s_ster_x /wave=ster_x, $s_ster_y /wave=ster_y
1580 ster_x = ster_rad * cos(azim * pi / 180)
1581 ster_y = ster_rad * sin(azim * pi / 180)
1583 variable azim_offset = 0
1584 if (!(NumberByKey(
"version", note(azim),
"=",
"\r") >= 1.6))
1585 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!" 1594 s_trace = WMPolarAppendTrace(graphname, ster_rad, azim, 360)
1595 ModifyGraph /W=$graphname mode($s_trace)=2, lsize($s_trace)=2
1596 ModifyGraph /W=$graphname zColor($s_trace)={values,*,*,BlueGreenOrange,0}
1598 ColorScale /W=$graphname /C /N=text0 /E=2 /F=0 /B=1 /A=RB /X=0.00 /Y=0.00 trace=polarY0
1599 ColorScale /W=$graphname /C /N=text0 side=2, width=5, heightPct=40, frame=0.50, lblMargin=0
1600 ColorScale /W=$graphname /C /N=text0 nticks=2, minor=1, tickLen=4.00, tickThick=0.50
1602 SetWindow $graphname, userdata(projection)=num2str(projection)
1608 s_trace = WMPolarAppendTrace(graphname, ster_rad, azim, 360)
1609 ModifyGraph /W=$graphname mode($s_trace)=0, lsize($s_trace)=0
1610 AppendImage /L=VertCrossing /B=HorizCrossing matrix
1612 ColorScale /W=$graphname /C /N=text0 /E=2 /F=0 /B=1 /A=RB /X=0.00 /Y=0.00 image=$s_matrix
1613 ColorScale /W=$graphname /C /N=text0 side=2, width=5, heightPct=40, frame=0.50, lblMargin=0
1614 ColorScale /W=$graphname /C /N=text0 nticks=2, minor=1, tickLen=4.00, tickThick=0.50
1616 SetWindow $graphname, userdata(projection)=num2str(projection)
1665 static string display_polar_graph(
string graphname, variable angle_offset = defaultValue, variable do_ticks = defaultValue){
1668 variable angle_offset
1671 dfref savedf = GetDataFolderDFR()
1673 if (ParamIsDefault(angle_offset))
1676 if (ParamIsDefault(do_ticks))
1680 if ((strlen(graphname) == 0) || (wintype(graphname) == 0))
1681 Display /k=1 /W=(10,45,360,345)
1682 DoWindow /C $graphname
1683 graphname = WMNewPolarGraph(
"", graphname)
1684 WMPolarGraphSetVar(graphname,
"zeroAngleWhere", angle_offset)
1686 WMPolarGraphSetVar(graphname,
"angleAxisThick", 0.5)
1687 WMPolarGraphSetStr(graphname,
"doMajorAngleTicks",
"manual")
1688 WMPolarGraphSetVar(graphname,
"majorAngleInc", 30)
1689 WMPolarGraphSetVar(graphname,
"minorAngleTicks", 2)
1690 WMPolarGraphSetStr(graphname,
"angleTicksLocation",
"Outside")
1691 WMPolarGraphSetVar(graphname,
"doAngleTickLabelSubRange", 1)
1692 WMPolarGraphSetVar(graphname,
"angleTickLabelRangeStart", 0)
1693 WMPolarGraphSetVar(graphname,
"angleTickLabelRangeExtent", 90)
1694 WMPolarGraphSetStr(graphname,
"angleTickLabelNotation",
"%g")
1696 WMPolarGraphSetVar(graphname,
"doPolarGrids", 0)
1697 WMPolarGraphSetVar(graphname,
"doRadiusTickLabels", 0)
1698 WMPolarGraphSetStr(graphname,
"radiusAxesWhere",
" Off")
1699 WMPolarGraphSetStr(graphname,
"radiusTicksLocation",
"Off")
1701 WMPolarGraphSetVar(graphname,
"majorTickLength", 2)
1702 WMPolarGraphSetVar(graphname,
"majorTickThick", 0.5)
1703 WMPolarGraphSetVar(graphname,
"minorTickLength", 1)
1704 WMPolarGraphSetVar(graphname,
"minorTickThick", 0.5)
1705 WMPolarGraphSetVar(graphname,
"tickLabelOpaque", 0)
1706 WMPolarGraphSetVar(graphname,
"tickLabelFontSize", 7)
1710 WMPolarGraphSetStr(graphname,
"angleTicksLocation",
"Outside")
1712 WMPolarGraphSetStr(graphname,
"angleTicksLocation",
"Off")
1715 WMPolarGraphSetVar(graphname,
"doMinorAngleTicks", 1)
1717 WMPolarGraphSetVar(graphname,
"doMinorAngleTicks", 0)
1720 DoWindow /T $graphname, graphname
1723 string graphdf =
"root:packages:WMPolarGraphs:" + graphname
1724 setdatafolder graphdf
1726 variable /g csrA_theta
1727 variable /g csrA_phi
1728 variable /g csrB_theta
1729 variable /g csrB_phi
1733 tb = tb +
"\"A = (%.1f, %.1f)\"," 1734 tb = tb + graphdf +
":csrA_theta," 1735 tb = tb + graphdf +
":csrA_phi" 1737 TextBox /W=$graphname /A=LT /B=1 /E=2 /F=0 /N=tb_angles /X=1 /Y=1 /V=0 tb
1739 tb = tb +
"\"B = (%.1f, %.1f)\"," 1740 tb = tb + graphdf +
":csrB_theta," 1741 tb = tb + graphdf +
":csrB_phi" 1743 AppendText /W=$graphname /N=tb_angles tb
1748 DoWindow /F $graphname
1751 setdatafolder savedf
1784 if (ParamIsDefault(do_grids))
1788 dfref savedf = GetDataFolderDFR()
1790 string sproj = GetUserData(graphname,
"",
"projection")
1791 variable projection = str2num(
"0" + sproj)
1793 SetDrawLayer /W=$graphname ProgFront
1796 SetDrawEnv /W=$graphname xcoord=HorizCrossing, ycoord=VertCrossing
1797 SetDrawEnv /W=$graphname linethick= 0.5
1798 SetDrawEnv /W=$graphname dash=2
1799 SetDrawEnv /W=$graphname fillpat=0
1800 SetDrawEnv /W=$graphname fname=
"default", fsize=7
1801 SetDrawEnv /W=$graphname textxjust=1, textyjust=1
1803 SetDrawEnv /W=$graphname save
1806 DrawLine /W=$graphname 0, -2, 0, 2
1807 DrawLine /W=$graphname -2, 0, 2, 0
1813 DrawOval /W=$graphname -radi, radi, radi, -radi
1815 DrawOval /W=$graphname -radi, radi, radi, -radi
1817 DrawOval /W=$graphname -radi, radi, radi, -radi
1819 SetDrawEnv /W=$graphname textxjust= 1,textyjust= 2
1820 SetDrawEnv /W=$graphname save
1822 DrawText /W=$graphname radi, -0.1,
"30" 1824 DrawText /W=$graphname radi, -0.1,
"60" 1827 setdatafolder savedf
1852 variable
draw_diffraction_cone(
string graphname,
string groupname, variable theta_axis, variable theta_inner, variable phi){
1857 variable theta_inner
1865 SetDrawLayer UserFront
1866 DrawAction getgroup=$groupname,
delete 1867 SetDrawEnv gstart, gname=$groupname
1868 variable xc, yc, xr, yr
1871 variable r_center = (r_outer + r_inner) / 2
1872 variable r_radius = (r_outer - r_inner) / 2
1873 xc = r_center * cos(phi * pi / 180)
1874 yc = r_center * sin(phi * pi / 180)
1877 SetDrawEnv xcoord=HorizCrossing, ycoord=VertCrossing
1878 SetDrawEnv dash=11, fillpat=0
1879 DrawOval xc - xr, yc - yr, xc + xr, yc + yr
1882 xc = r_axis * cos(phi * pi / 180)
1883 yc = r_axis * sin(phi * pi / 180)
1887 SetDrawEnv xcoord=HorizCrossing, ycoord=VertCrossing
1888 SetDrawEnv fillfgc=(0,0,0)
1889 DrawOval xc - xr, yc - yr, xc + xr, yc + yr
1916 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){
1926 if (ParamIsDefault(folding))
1929 if (ParamIsDefault(projection))
1934 dfref saveDF = GetDataFolderDFR()
1935 newdatafolder /s/o $nickname
1936 string graphname =
"graph_" + nickname
1938 duplicate /free m_tilt, loc_m_tilt
1939 loc_m_tilt = -m_tilt
1941 make /n=1 /d /free d_polar, d_azi
1942 variable n_alpha = round(alpha_hi - alpha_lo) + 1
1943 make /n=(n_alpha) /d /free analyser
1944 setscale /i x alpha_lo, alpha_hi,
"", analyser
1948 duplicate /free d_polar, d_radius
1953 SetWindow $graphname, userdata(projection)=num2str(projection)
1957 variable nang = numpnts(m_theta)
1961 for (ifold = 0; ifold < folding; ifold += 1)
1962 d_azi = d_azi >= 360 ? d_azi - 360 : d_azi
1963 for (iang = 0; iang < nang; iang += 1)
1964 sprintf s_rad,
"rad_%d_%d", ifold, iang
1965 duplicate /o analyser, $s_rad
1967 w_rad = d_radius[p][iang]
1969 sprintf s_azi,
"azi_%d_%d", ifold, iang
1970 duplicate /o analyser, $s_azi
1972 w_azi = d_azi[p][iang]
1974 if (numtype(sum(w_rad)) == 0)
1975 s_trace = WMPolarAppendTrace(graphname, w_rad, w_azi, 360)
1976 ModifyGraph /w=$graphname mode($s_trace)=0, lsize($s_trace)=0.5
1979 d_azi += 360 / folding
1984 setdatafolder saveDF
2035 if (ParamIsDefault(projection))
2048 radius = polar < 90 ?
kProjScaleGnom * tan(polar * pi / 180) : inf
2076 threadsafe variable
calc_graph_polar(variable x, variable y, variable projection = defaultValue){
2081 if (ParamIsDefault(projection))
2088 radius = sqrt(x^2 + y^2)
2129 threadsafe variable
calc_graph_azi(variable x, variable y, variable projection = defaultValue, variable zeroAngle = defaultValue){
2135 if (ParamIsDefault(projection))
2138 if (ParamIsDefault(zeroAngle))
2144 azi = atan(y / x) * 180 / pi
2146 azi = atan(y / x) * 180 / pi + 180
2156 if (numtype(azi) != 0)
2177 dfref savedf = GetDataFolderDFR()
2179 string graphdf =
"root:packages:WMPolarGraphs:" + graphname
2180 setdatafolder graphdf
2187 string sproj = GetUserData(graphname,
"",
"projection")
2188 variable projection = str2num(
"0" + sproj)
2191 variable x = hcsr(A, graphname)
2192 variable y = vcsr(A, graphname)
2194 csrA_phi =
calc_graph_azi(x, y, projection=projection, zeroAngle=zeroAngleWhere)
2196 x = hcsr(B, graphname)
2197 y = vcsr(B, graphname)
2199 csrB_phi =
calc_graph_azi(x, y, projection=projection, zeroAngle=zeroAngleWhere)
2201 setdatafolder savedf
2210 STRUCT WMWinHookStruct &s
2212 Variable hookResult = 0
2219 TextBox /W=$s.winname /N=tb_angles /C /V=1
2222 TextBox /W=$s.winname /N=tb_angles /C /V=0
2229 variable
set_polar_graph_cursor(
string nickname,
string cursorname, variable polar_angle, variable azim_angle,
string graphname = defaultValue){
2232 variable polar_angle
2236 if (ParamIsDefault(graphname))
2237 if (strlen(nickname) > 0)
2238 graphname = nickname
2240 graphname = GetDataFolder(0)
2244 if (strlen(nickname))
2245 string s_prefix = nickname +
"_" 2249 string s_polar = s_prefix +
"pol" 2250 string s_azim = s_prefix +
"az" 2251 wave /z azim = $s_azim
2252 wave /z polar = $s_polar
2254 FindLevel /P /Q polar, polar_angle
2256 variable polar_level = floor(v_levelx)
2257 FindLevel /P /Q /R=[polar_level] azim, azim_angle
2259 variable azim_level = round(v_levelx)
2260 string tracename =
"polarY0" 2261 Cursor /W=$graphname /P $cursorname $traceName azim_level
2275 variable
hemi_add_anglescan(
string nickname, wave values, wave polar, wave azi, wave weights = defaultValue){
2287 if (ParamIsDefault(weights))
2288 duplicate /free values, weights
2293 if (strlen(nickname))
2294 string s_prefix = nickname +
"_" 2295 string s_int = s_prefix +
"i" 2300 string s_polar = s_prefix +
"pol" 2301 string s_azim = s_prefix +
"az" 2302 string s_theta = s_prefix +
"th" 2304 wave /z w_values = $s_int
2305 wave /z w_azim = $s_azim
2306 wave /z w_polar = $s_polar
2307 wave /z w_theta = $s_theta
2308 if (!waveexists(w_values) || !waveexists(w_azim) || !waveexists(w_polar))
2309 abort
"Missing hemispherical scan grid. Please call make_hemi_grid() first." 2313 duplicate /free values, values_copy
2314 duplicate /free polar, polar_copy
2315 duplicate /free azi, azi_copy
2316 duplicate /free weights, weights_copy
2317 variable nn = dimsize(values, 0) * max(dimsize(values, 1), 1)
2318 redimension /n=(nn) values_copy, polar_copy, azi_copy, weights_copy
2319 sort /r polar_copy, polar_copy, azi_copy, values_copy, weights_copy
2322 variable pol_st = abs(w_theta[1] - w_theta[0])
2325 duplicate /free azi_copy, azi_slice
2326 duplicate /free values_copy, values_slice
2327 duplicate /free weights_copy, weights_slice
2328 for (pol = 90; pol >= 0; pol -= pol_st)
2329 pol1 = pol - pol_st / 2
2330 pol2 = pol + pol_st / 2
2331 extract /free /indx polar_copy, sel, (pol1 < polar_copy) && (polar_copy <= pol2)
2332 if (numpnts(sel) > 0)
2333 redimension /n=(numpnts(sel)) azi_slice, values_slice, weights_slice
2334 azi_slice = azi_copy[sel]
2335 values_slice = values_copy[sel]
2336 weights_slice = weights_copy[sel]
2337 hemi_add_aziscan(nickname, values_slice, pol, azi_slice, weights=weights_slice)
2348 variable
hemi_add_aziscan(
string nickname, wave values, variable polar, wave azi, wave weights = defaultValue){
2358 if (ParamIsDefault(weights))
2359 duplicate /free values, weights
2364 if (strlen(nickname))
2365 string s_prefix = nickname +
"_" 2366 string s_int = s_prefix +
"i" 2371 string s_totals = s_prefix +
"tot" 2372 string s_weights = s_prefix +
"wt" 2373 string s_polar = s_prefix +
"pol" 2374 string s_azim = s_prefix +
"az" 2375 string s_index = s_prefix +
"index" 2376 string s_theta = s_prefix +
"th" 2377 string s_dphi = s_prefix +
"dphi" 2378 string s_nphis = s_prefix +
"nphis" 2380 wave w_polar = $s_polar
2381 wave w_azim = $s_azim
2382 wave w_values = $s_int
2383 wave w_totals = $s_totals
2384 wave w_weights = $s_weights
2385 wave w_index = $s_index
2386 wave w_theta = $s_theta
2387 wave w_dphi = $s_dphi
2388 wave w_nphis = $s_nphis
2393 variable ipol = BinarySearch(w_theta, polar)
2395 abort
"assertion failed in hemi_add_aziscan(): polar angle not found in grid." 2400 d1 = w_index[ipol - 1]
2404 d2 = w_index[ipol] - 1
2405 variable nd = d2 - d1 + 1
2406 variable dphi = w_dphi[ipol]
2411 azi = azi < 0 ? azi + 360 : azi
2412 azi = azi >= 360 - dphi/2 ? azi - 360 : azi
2413 duplicate /free values, sel_values
2414 duplicate /free weights, sel_weights
2418 variable v1, v2, w1, w2
2419 for (
id = 0;
id < nd;
id += 1)
2420 az1 = (
id - 0.5) * dphi
2421 az2 = (
id + 0.5) * dphi
2422 extract /free /indx azi, sel, (az1 <= azi) && (azi < az2)
2423 if (numpnts(sel) > 0)
2424 redimension /n=(numpnts(sel)) sel_values, sel_weights
2425 sel_values = values[sel]
2426 sel_weights = weights[sel]
2427 v1 = w_totals[d1 +
id]
2428 w1 = w_weights[d1 +
id]
2429 if ((numtype(v1) == 2) || (w1 <= 0))
2433 v2 = sum(sel_values)
2434 w2 = sum(sel_weights)
2435 w_totals[d1 + id] = v1 + v2
2436 w_weights[d1 + id] = w1 + w2
2439 w_values[d1, d1 + nd - 1] = w_totals[p] / w_weights[p]
2452 if (strlen(nickname))
2453 string s_prefix = nickname +
"_" 2454 string s_int = s_prefix +
"i" 2460 string s_polar = s_prefix +
"pol" 2461 string s_azim = s_prefix +
"az" 2462 string s_ster_x = s_prefix +
"ster_x" 2463 string s_ster_y = s_prefix +
"ster_y" 2465 wave values = $s_int
2467 wave polar = $s_polar
2468 wave ster_x = $s_ster_x
2469 wave ster_y = $s_ster_y
2471 variable min_ster_x = wavemin(ster_x)
2472 variable max_ster_x = wavemax(ster_x)
2473 variable x0 = min_ster_x
2475 variable dx = (max_ster_x - min_ster_x) / (xn - 1)
2476 make /n=(numpnts(ster_x), 3) /free triplet
2477 triplet[][0] = ster_x[p]
2478 triplet[][1] = ster_y[p]
2479 triplet[][2] = values[p]
2483 make /n=(size, size) /d /o $(s_prefix +
"matrix") /wave=matrix
2484 make /n=(size, size) /free mnorm
2485 ImageFromXYZ /as {ster_x, ster_y, values}, matrix, mnorm
2487 matrixfilter NanZapMedian, matrix
2488 matrixfilter gauss, matrix
2490 matrix = (x^2 + y^2) < 4 ? matrix : nan
2503 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){
2508 variable theta_offset
2509 variable tilt_offset
2517 if (ParamIsDefault(npolar))
2520 if (ParamIsDefault(nograph))
2523 if (ParamIsDefault(folding))
2526 string graphname =
"graph_" + nickname
2527 string s_prefix =
"" 2530 dfref saveDF = GetDataFolderDFR()
2531 dfref dataDF = GetWavesDataFolderDFR(data)
2532 setdatafolder dataDF
2533 if (DataFolderExists(
":attr"))
2536 dfref attrDF = GetDataFolderDFR()
2537 setdatafolder dataDF
2538 newdatafolder /s/o $nickname
2539 dfref destDF = GetDataFolderDFR()
2542 variable timerRefNum
2543 variable /g xyz_perf_secs
2544 timerRefNum = startMSTimer
2546 wave /sdfr=attrDF ManipulatorTheta
2547 wave /sdfr=attrDF ManipulatorTilt
2548 wave /sdfr=attrDF ManipulatorPhi
2549 duplicate /free ManipulatorTheta, m_theta
2550 duplicate /free ManipulatorTilt, m_tilt
2551 duplicate /free ManipulatorPhi, m_phi
2552 m_theta -= theta_offset
2553 m_tilt -= tilt_offset
2558 make /n=1/d/free d_polar, d_azi
2561 d_azi = d_azi >= 360 ? d_azi - 360 : d_azi
2563 duplicate /free data, values
2564 variable nn = dimsize(values, 0) * max(dimsize(values, 1), 1)
2565 redimension /n=(nn) values, d_polar, d_azi
2566 duplicate /o d_polar, ster_rad, ster_x, ster_y
2568 variable projection = 1
2571 ster_rad = 2 * tan(d_polar / 2 * pi / 180)
2574 ster_rad = 2 * cos((180 - d_polar) / 2 * pi / 180)
2577 string s_ster_x = s_prefix +
"ster_x" 2578 string s_ster_y = s_prefix +
"ster_y" 2581 make /n=(nn, nn) /d /o matrix
2582 make /n=(nn, nn) /free mnorm
2583 setscale /i x -2, +2, matrix, mnorm
2584 setscale /i y -2, +2, matrix, mnorm
2589 for (ifold = 0; ifold < folding; ifold += 1)
2590 ster_x = ster_rad * cos(d_azi * pi / 180)
2591 ster_y = ster_rad * sin(d_azi * pi / 180)
2592 ImageFromXYZ {ster_x, ster_y, values}, matrix, mnorm
2593 d_azi = d_azi >= 180 ? d_azi + 360 / folding - 180 : d_azi + 360 / folding
2597 matrixfilter /n=5 NanZapMedian matrix
2598 matrixfilter /n=3 gauss matrix
2603 modifygraph width={Plan,1,bottom,left}
2606 if (timerRefNum >= 0)
2607 xyz_perf_secs = stopMSTimer(timerRefNum) / 1e6
2610 setdatafolder saveDF
2619 dfref savedf = getdatafolderdfr()
2622 if (strlen(nickname))
2623 string s_prefix = nickname +
"_" 2624 string s_int = s_prefix +
"i" 2629 string s_polar = s_prefix +
"pol" 2630 string s_azim = s_prefix +
"az" 2631 string s_theta = s_prefix +
"th" 2632 string s_tot = s_prefix +
"tot" 2633 string s_weight = s_prefix +
"wt" 2635 wave theta1 = $s_theta
2636 wave polar1 = $s_polar
2637 wave azim1 = $s_azim
2639 wave weight1 = $s_weight
2640 wave values1 = $s_int
2642 save /m=
"\r\n" /o /p=$pathname /t theta1, polar1, azim1, tot1, weight1, values1 as filename
2644 setdatafolder saveDF
2655 dfref savedf = getdatafolderdfr()
2664 setdatafolder saveDF
2699 variable
import_tpi_scan(
string nickname, wave theta, wave phi, wave intensity, variable folding = defaultValue, variable npolar = defaultValue, variable nograph = defaultValue, variable xpdplot = defaultValue){
2710 if (ParamIsDefault(npolar))
2713 if (ParamIsDefault(nograph))
2716 if (ParamIsDefault(folding))
2719 if (ParamIsDefault(xpdplot))
2726 duplicate /free phi, fold_phi
2727 for (ifold = 0; ifold < folding; ifold += 1)
2729 fold_phi = fold_phi >= 180 ? fold_phi + 360 / folding - fold_phi : fold_phi + 360 / folding
2752 if (strlen(nickname))
2753 string s_prefix = nickname +
"_" 2754 string s_int = s_prefix +
"i" 2759 string s_totals = s_prefix +
"tot" 2760 string s_weights = s_prefix +
"wt" 2761 string s_polar = s_prefix +
"pol" 2763 wave w_polar = $s_polar
2764 wave w_values = $s_int
2765 wave w_totals = $s_totals
2766 wave w_weights = $s_weights
2768 w_values = w_polar <= theta_max ? w_totals / w_weights : nan
2794 if (strlen(nickname))
2795 string s_prefix = nickname +
"_" 2796 string s_int = s_prefix +
"i" 2801 string s_totals = s_prefix +
"tot" 2802 string s_weights = s_prefix +
"wt" 2803 string s_polar = s_prefix +
"pol" 2804 string s_azim = s_prefix +
"az" 2805 string s_index = s_prefix +
"index" 2806 string s_theta = s_prefix +
"th" 2807 string s_dphi = s_prefix +
"dphi" 2808 string s_nphis = s_prefix +
"nphis" 2810 sprintf s_cut,
"%s_azi%03u", s_int, round(azim)
2812 wave w_polar = $s_polar
2813 wave w_azim = $s_azim
2814 wave w_values = $s_int
2815 wave w_totals = $s_totals
2816 wave w_weights = $s_weights
2817 wave w_index = $s_index
2818 wave w_theta = $s_theta
2819 wave w_dphi = $s_dphi
2820 wave w_nphis = $s_nphis
2822 variable npol = numpnts(w_theta)
2824 variable pol_st = abs(w_theta[1] - w_theta[0])
2828 make /n=(npol) /o $s_cut
2830 setscale /i x w_theta[0], w_theta[numpnts(w_theta)-1],
"deg", w_cut
2831 make /n=1 /free azi_slice
2832 make /n=1 /free values_slice
2834 for (ipol = 0; ipol < npol; ipol += 1)
2836 pol1 = pol - pol_st / 2
2837 pol2 = pol + pol_st / 2
2838 extract /free /indx w_polar, sel, (pol1 < w_polar) && (w_polar <= pol2)
2841 redimension /n=(nsel+2) azi_slice, values_slice
2842 azi_slice[1, nsel] = w_azim[sel[p-1]]
2843 azi_slice[0] = azi_slice[nsel] - 360
2844 azi_slice[nsel+1] = azi_slice[1] + 360
2845 values_slice[1, nsel] = w_values[sel[p-1]]
2846 values_slice[0] = values_slice[nsel]
2847 values_slice[nsel+1] = values_slice[1]
2848 w_cut[ipol] = interp(azim, azi_slice, values_slice)
2878 if (strlen(nickname))
2879 string s_prefix = nickname +
"_" 2880 string s_int = s_prefix +
"i" 2885 string s_totals = s_prefix +
"tot" 2886 string s_weights = s_prefix +
"wt" 2887 string s_polar = s_prefix +
"pol" 2888 string s_azim = s_prefix +
"az" 2889 string s_index = s_prefix +
"index" 2890 string s_theta = s_prefix +
"th" 2891 string s_dphi = s_prefix +
"dphi" 2892 string s_nphis = s_prefix +
"nphis" 2894 sprintf s_cut,
"%s_pol%03u", s_int, round(pol)
2896 wave w_polar = $s_polar
2897 wave w_azim = $s_azim
2898 wave w_values = $s_int
2899 wave w_totals = $s_totals
2900 wave w_weights = $s_weights
2901 wave w_index = $s_index
2902 wave w_theta = $s_theta
2903 wave w_dphi = $s_dphi
2904 wave w_nphis = $s_nphis
2906 variable pol_st = abs(w_theta[1] - w_theta[0])
2910 pol1 = pol - pol_st / 2
2911 pol2 = pol + pol_st / 2
2912 extract /free /indx w_polar, sel, (pol1 < w_polar) && (w_polar <= pol2)
2915 make /n=(nsel) /o $s_cut
2917 w_cut = w_values[sel]
2918 setscale /i x w_azim[sel[0]], w_azim[sel[nsel-1]],
"", w_cut
2925 static variable
check_contrast(wave values, variable pcmin, variable pcmax, variable* vmin, variable* vmax){
2932 dfref save_df = GetDataFolderDFR()
2933 dfref dfr = NewFreeDataFolder()
2935 StatsQuantiles /inan /iw /q /z values
2936 wave index = w_quantilesindex
2937 variable imin = round(numpnts(index) * pcmin / 100)
2938 variable imax = round(numpnts(index) * (100 - pcmax) / 100)
2939 vmin = values[index[imin]]
2940 vmax = values[index[imax]]
2942 setdatafolder save_df
2961 variable
set_contrast(variable pcmin, variable pcmax,
string graphname = defaultValue,
string colortable = defaultValue){
2967 if (ParamIsDefault(graphname))
2970 if (ParamIsDefault(colortable))
2974 dfref save_df = GetDataFolderDFR()
2986 string traces = TraceNameList(graphname,
";", 1+4)
2987 n = ItemsInList(traces,
";")
2988 for (i = 0; i < n; i += 1)
2989 objname = StringFromList(i, traces,
";")
2990 info = TraceInfo(graphname, objname, 0)
2991 if (strlen(info) > 0)
2992 info = StringByKey(
"RECREATION", info,
":",
";")
2993 info = StringByKey(
"zColor(x)", info,
"=",
";")
2994 if (strlen(info) > 2)
2995 info = info[1,strlen(info)-2]
2996 wname = StringFromList(0, info,
",")
2998 ctab = StringFromList(3, info,
",")
2999 rev = str2num(
"0" + StringFromList(4, info,
","))
3000 if (strlen(colortable) > 0)
3004 ModifyGraph /w=$graphname zColor($objname)={w, vmin, vmax, $ctab, rev}
3009 string images = ImageNameList(graphname,
";")
3010 n = ItemsInList(images,
";")
3011 for (i = 0; i < n; i += 1)
3012 objname = StringFromList(i, images,
";")
3013 wave w = ImageNameToWaveRef(graphname, objname)
3014 info = ImageInfo(graphname, objname, 0)
3015 if (strlen(info) > 0)
3016 info = StringByKey(
"RECREATION", info,
":",
";")
3017 info = StringByKey(
"ctab", info,
"=",
";")
3018 if (strlen(info) > 2)
3019 info = info[1,strlen(info)-2]
3020 ctab = StringFromList(2, info,
",")
3021 rev = str2num(
"0" + StringFromList(3, info,
","))
3022 if (strlen(colortable) > 0)
3026 ModifyImage /w=$graphname $objname ctab={vmin, vmax, $ctab, rev}
3031 setdatafolder save_df
wave fit_scienta_ang_transm(wave data, wave params)
wave hemi_polar_cut(string nickname, variable azim)
extract a polar cut from a hemispherical scan.
variable trim_hemi_scan(string nickname, variable theta_max)
trim a hemispherical scan at grazing angle
variable pizza_service_2(wave data, string nickname, wave m_theta, wave m_tilt, wave m_phi, variable npolar=defaultValue, variable nograph=defaultValue, variable folding=defaultValue, variable xpdplot=defaultValue)
create a pizza plot from a measured (energy-integrated) data strip
static const variable kProjScaleOrtho
variable polar2cart_wave(wave in, wave out)
variable normalize_strip_theta(wave strip, wave theta, variable theta_offset=defaultValue, variable smooth_method=defaultValue, variable smooth_factor=defaultValue, variable check=defaultValue)
divide the strip by the average polar distribution.
variable normalize_strip_2d(wave strip, wave theta, variable theta_offset=defaultValue, variable smooth_method=defaultValue, variable smooth_factor=defaultValue, variable check=defaultValue)
divide the strip by a two-dimensional normalization function.
variable crop_strip(wave strip, variable xlo, variable xhi)
crop a strip at the sides.
threadsafe wave ad_profile_y(wave dataset, variable p1, variable p2, string destname, variable noavg=defaultValue)
1D cut through 2D dataset along Y dimension, new destination wave.
variable make_hemi_grid(variable npol, string nickname, variable xpdplot=defaultValue)
create a hemispherical, constant solid angle grid
variable hemi_add_anglescan(string nickname, wave values, wave polar, wave azi, wave weights=defaultValue)
add an arbitrary angle scan to a hemispherical scan grid.
string get_hemi_nickname(wave w)
finds the nick name given any hemi wave
variable interpolate_hemi_scan(string nickname)
interpolate a hemispherical scan onto a rectangular grid
string get_hemi_prefix(wave w)
finds the prefix given any hemi wave
string display_hemi_scan(string nickname, variable projection=defaultValue, variable graphtype=defaultValue, variable do_ticks=defaultValue, variable do_grids=defaultValue, string graphname=defaultValue)
display a plot of a hemispherical angle scan.
static variable CalcN_Theta(string HoloMode, variable Theta_in, variable Theta_ran, variable Theta_st)
calculate the number of thetas for a pattern
dfr find_hemi_data(string nickname, string *prefix, string *intwave)
finds the folder, prefix and name of holo waves given their nick name
variable convert_angles_ttpd2polar(wave theta, wave tilt, wave phi, wave data, wave polar, wave azi)
convert angles from TTPA (theta-tilt-phi-analyser) scheme to polar coordinates.
variable clear_hemi_grid(string nickname)
clear a hemispherical scan grid
static const variable kProjScaleDist
threadsafe variable calc_graph_polar(variable x, variable y, variable projection=defaultValue)
calculate polar angle from Cartesian coordinate
static variable 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
threadsafe variable scienta_ang_transm(wave w, variable x)
variable pizza_service(wave data, string nickname, variable theta_offset, variable tilt_offset, variable phi_offset, variable npolar=defaultValue, variable nograph=defaultValue, variable folding=defaultValue, variable xpdplot=defaultValue)
create a pizza plot from a measured (energy-integrated) data strip
variable rotate_x_wave(wave inout, variable angle)
variable cart2polar_wave(wave in, wave out)
string display_scanlines(string nickname, variable alpha_lo, variable alpha_hi, wave m_theta, wave m_tilt, wave m_phi, variable folding=defaultValue, variable projection=defaultValue)
display a polar graph with lines indicating the angles covered by an angle scan.
wave hemi_azi_cut(string nickname, variable pol)
extract an azimuthal cut from a hemispherical scan
variable draw_diffraction_cone(string graphname, string groupname, variable theta_axis, variable theta_inner, variable phi)
draw the circle of a diffraction cone in a stereographic polar graph.
variable hemi_add_aziscan(string nickname, wave values, variable polar, wave azi, wave weights=defaultValue)
add an azimuthal scan to a hemispherical scan grid.
static const variable kProjScaleGnom
variable rotate_y_wave(wave inout, variable angle)
variable rotate_hemi_scan(string nickname, variable angle)
azimuthally rotate a hemispherical scan dataset.
static const variable kProjScaleStereo
processing and holographic mapping of angle scanned XPD data.
static string display_polar_graph(string graphname, variable angle_offset=defaultValue, variable do_ticks=defaultValue)
displays an empty polar graph
const variable kProjOrtho
variable save_hemi_scan(string nickname, string pathname, string filename)
save a hemispherical scan to an Igor text file
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).
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.