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 string s_prefix =
"" 1379 string s_int =
"values" 1380 dfref source_df =
find_hemi_data(source_nickname, s_prefix, s_int)
1381 string s_polar = s_prefix +
"pol" 1382 string s_azim = s_prefix +
"az" 1383 string s_theta = s_prefix +
"th" 1384 string s_tot = s_prefix +
"tot" 1385 string s_weight = s_prefix +
"wt" 1386 string s_matrix = s_prefix +
"matrix" 1388 wave /sdfr=source_df theta1 = $s_theta
1389 wave /sdfr=source_df polar1 = $s_polar
1390 wave /sdfr=source_df azim1 = $s_azim
1391 wave /sdfr=source_df tot1 = $s_tot
1392 wave /sdfr=source_df weight1 = $s_weight
1393 wave /sdfr=source_df values1 = $s_int
1394 wave /sdfr=source_df /z matrix1 = $s_matrix
1396 variable npol = numpnts(theta1)
1398 setdatafolder dest_folder
1403 s_polar = s_prefix +
"pol" 1404 s_azim = s_prefix +
"az" 1405 s_theta = s_prefix +
"th" 1406 s_tot = s_prefix +
"tot" 1407 s_weight = s_prefix +
"wt" 1408 s_matrix = s_prefix +
"matrix" 1410 wave /sdfr=dest_df theta2 = $s_theta
1411 wave /sdfr=dest_df polar2 = $s_polar
1412 wave /sdfr=dest_df azim2 = $s_azim
1413 wave /sdfr=dest_df tot2 = $s_tot
1414 wave /sdfr=dest_df weight2 = $s_weight
1415 wave /sdfr=dest_df values2 = $s_int
1420 if (waveexists(matrix1))
1421 setdatafolder dest_df
1422 duplicate /o matrix1, $s_matrix
1425 if (!(NumberByKey(
"version", note(azim1),
"=",
"\r") >= 1.6))
1427 azim2 = azim2 >= 360 ? azim2 - 360 : azim2
1430 setdatafolder saveDF
1444 dfref savedf = getdatafolderdfr()
1446 string s_prefix =
"" 1447 string s_int =
"values" 1450 string s_polar = s_prefix +
"pol" 1451 string s_azim = s_prefix +
"az" 1452 string s_tot = s_prefix +
"tot" 1453 string s_weight = s_prefix +
"wt" 1455 wave /sdfr=df polar = $s_polar
1456 wave /sdfr=df azim = $s_azim
1457 wave /sdfr=df tot = $s_tot
1458 wave /sdfr=df weight = $s_weight
1459 wave /sdfr=df values = $s_int
1462 azim = azim < 0 ? azim + 360 : azim
1463 azim = azim >= 360 ? azim - 360 : azim
1465 duplicate /free polar, neg_polar
1467 sort {neg_polar, azim}, polar, azim, tot, weight, values
1469 setdatafolder saveDF
1516 string display_hemi_scan(
string nickname, variable projection = defaultValue, variable graphtype = defaultValue, variable do_ticks = defaultValue, variable do_grids = defaultValue,
string graphname = defaultValue){
1524 dfref savedf = getdatafolderdfr()
1526 if (ParamIsDefault(projection))
1529 if (ParamIsDefault(graphtype))
1532 if (ParamIsDefault(do_ticks))
1535 if (ParamIsDefault(do_grids))
1538 if (ParamIsDefault(graphname))
1539 if (strlen(nickname) > 0)
1540 graphname = nickname
1542 graphname = GetDataFolder(0)
1547 string s_prefix =
"" 1548 string s_int =
"values" 1551 string s_polar = s_prefix +
"pol" 1552 string s_azim = s_prefix +
"az" 1553 string s_matrix = s_prefix +
"matrix" 1555 wave /sdfr=df /z values = $s_int
1556 wave /sdfr=df /z azim = $s_azim
1557 wave /sdfr=df /z polar = $s_polar
1558 wave /sdfr=df /z matrix = $s_matrix
1561 string s_ster_rad = s_prefix +
"ster_rad" 1562 duplicate /o polar, $s_ster_rad /wave=ster_rad
1565 string s_ster_x = s_prefix +
"ster_x" 1566 string s_ster_y = s_prefix +
"ster_y" 1567 duplicate /o azim, $s_ster_x /wave=ster_x, $s_ster_y /wave=ster_y
1568 ster_x = ster_rad * cos(azim * pi / 180)
1569 ster_y = ster_rad * sin(azim * pi / 180)
1571 variable azim_offset = 0
1572 if (!(NumberByKey(
"version", note(azim),
"=",
"\r") >= 1.6))
1573 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!" 1582 s_trace = WMPolarAppendTrace(graphname, ster_rad, azim, 360)
1583 ModifyGraph /W=$graphname mode($s_trace)=2, lsize($s_trace)=2
1584 ModifyGraph /W=$graphname zColor($s_trace)={values,*,*,BlueGreenOrange,0}
1586 ColorScale /W=$graphname /C /N=text0 /E=2 /F=0 /B=1 /A=RB /X=0.00 /Y=0.00 trace=polarY0
1587 ColorScale /W=$graphname /C /N=text0 side=2, width=5, heightPct=40, frame=0.50, lblMargin=0
1588 ColorScale /W=$graphname /C /N=text0 nticks=2, minor=1, tickLen=4.00, tickThick=0.50
1590 SetWindow $graphname, userdata(projection)=num2str(projection)
1596 s_trace = WMPolarAppendTrace(graphname, ster_rad, azim, 360)
1597 ModifyGraph /W=$graphname mode($s_trace)=0, lsize($s_trace)=0
1598 AppendImage /L=VertCrossing /B=HorizCrossing matrix
1600 ColorScale /W=$graphname /C /N=text0 /E=2 /F=0 /B=1 /A=RB /X=0.00 /Y=0.00 image=$s_matrix
1601 ColorScale /W=$graphname /C /N=text0 side=2, width=5, heightPct=40, frame=0.50, lblMargin=0
1602 ColorScale /W=$graphname /C /N=text0 nticks=2, minor=1, tickLen=4.00, tickThick=0.50
1604 SetWindow $graphname, userdata(projection)=num2str(projection)
1609 setdatafolder savedf
1654 static string display_polar_graph(
string graphname, variable angle_offset = defaultValue, variable do_ticks = defaultValue){
1657 variable angle_offset
1660 dfref savedf = GetDataFolderDFR()
1662 if (ParamIsDefault(angle_offset))
1665 if (ParamIsDefault(do_ticks))
1669 if ((strlen(graphname) == 0) || (wintype(graphname) == 0))
1670 Display /k=1 /W=(10,45,360,345)
1671 DoWindow /C $graphname
1672 graphname = WMNewPolarGraph(
"", graphname)
1673 WMPolarGraphSetVar(graphname,
"zeroAngleWhere", angle_offset)
1675 WMPolarGraphSetVar(graphname,
"angleAxisThick", 0.5)
1676 WMPolarGraphSetStr(graphname,
"doMajorAngleTicks",
"manual")
1677 WMPolarGraphSetVar(graphname,
"majorAngleInc", 30)
1678 WMPolarGraphSetVar(graphname,
"minorAngleTicks", 2)
1679 WMPolarGraphSetStr(graphname,
"angleTicksLocation",
"Outside")
1680 WMPolarGraphSetVar(graphname,
"doAngleTickLabelSubRange", 1)
1681 WMPolarGraphSetVar(graphname,
"angleTickLabelRangeStart", 0)
1682 WMPolarGraphSetVar(graphname,
"angleTickLabelRangeExtent", 90)
1683 WMPolarGraphSetStr(graphname,
"angleTickLabelNotation",
"%g")
1685 WMPolarGraphSetVar(graphname,
"doPolarGrids", 0)
1686 WMPolarGraphSetVar(graphname,
"doRadiusTickLabels", 0)
1687 WMPolarGraphSetStr(graphname,
"radiusAxesWhere",
" Off")
1688 WMPolarGraphSetStr(graphname,
"radiusTicksLocation",
"Off")
1690 WMPolarGraphSetVar(graphname,
"majorTickLength", 2)
1691 WMPolarGraphSetVar(graphname,
"majorTickThick", 0.5)
1692 WMPolarGraphSetVar(graphname,
"minorTickLength", 1)
1693 WMPolarGraphSetVar(graphname,
"minorTickThick", 0.5)
1694 WMPolarGraphSetVar(graphname,
"tickLabelOpaque", 0)
1695 WMPolarGraphSetVar(graphname,
"tickLabelFontSize", 7)
1699 WMPolarGraphSetStr(graphname,
"angleTicksLocation",
"Outside")
1701 WMPolarGraphSetStr(graphname,
"angleTicksLocation",
"Off")
1704 WMPolarGraphSetVar(graphname,
"doMinorAngleTicks", 1)
1706 WMPolarGraphSetVar(graphname,
"doMinorAngleTicks", 0)
1709 DoWindow /T $graphname, graphname
1712 string graphdf =
"root:packages:WMPolarGraphs:" + graphname
1713 setdatafolder graphdf
1715 variable /g csrA_theta
1716 variable /g csrA_phi
1717 variable /g csrB_theta
1718 variable /g csrB_phi
1722 tb = tb +
"\"A = (%.1f, %.1f)\"," 1723 tb = tb + graphdf +
":csrA_theta," 1724 tb = tb + graphdf +
":csrA_phi" 1726 TextBox /W=$graphname /A=LT /B=1 /E=2 /F=0 /N=tb_angles /X=1 /Y=1 /V=0 tb
1728 tb = tb +
"\"B = (%.1f, %.1f)\"," 1729 tb = tb + graphdf +
":csrB_theta," 1730 tb = tb + graphdf +
":csrB_phi" 1732 AppendText /W=$graphname /N=tb_angles tb
1737 DoWindow /F $graphname
1740 setdatafolder savedf
1773 if (ParamIsDefault(do_grids))
1777 dfref savedf = GetDataFolderDFR()
1779 string sproj = GetUserData(graphname,
"",
"projection")
1780 variable projection = str2num(
"0" + sproj)
1782 SetDrawLayer /W=$graphname ProgFront
1785 SetDrawEnv /W=$graphname xcoord=HorizCrossing, ycoord=VertCrossing
1786 SetDrawEnv /W=$graphname linethick= 0.5
1787 SetDrawEnv /W=$graphname dash=2
1788 SetDrawEnv /W=$graphname fillpat=0
1789 SetDrawEnv /W=$graphname fname=
"default", fsize=7
1790 SetDrawEnv /W=$graphname textxjust=1, textyjust=1
1792 SetDrawEnv /W=$graphname save
1795 DrawLine /W=$graphname 0, -2, 0, 2
1796 DrawLine /W=$graphname -2, 0, 2, 0
1802 DrawOval /W=$graphname -radi, radi, radi, -radi
1804 DrawOval /W=$graphname -radi, radi, radi, -radi
1806 DrawOval /W=$graphname -radi, radi, radi, -radi
1808 SetDrawEnv /W=$graphname textxjust= 1,textyjust= 2
1809 SetDrawEnv /W=$graphname save
1811 DrawText /W=$graphname radi, -0.1,
"30" 1813 DrawText /W=$graphname radi, -0.1,
"60" 1816 setdatafolder savedf
1841 variable
draw_diffraction_cone(
string graphname,
string groupname, variable theta_axis, variable theta_inner, variable phi){
1846 variable theta_inner
1854 SetDrawLayer UserFront
1855 DrawAction getgroup=$groupname,
delete 1856 SetDrawEnv gstart, gname=$groupname
1857 variable xc, yc, xr, yr
1860 variable r_center = (r_outer + r_inner) / 2
1861 variable r_radius = (r_outer - r_inner) / 2
1862 xc = r_center * cos(phi * pi / 180)
1863 yc = r_center * sin(phi * pi / 180)
1866 SetDrawEnv xcoord=HorizCrossing, ycoord=VertCrossing
1867 SetDrawEnv dash=11, fillpat=0
1868 DrawOval xc - xr, yc - yr, xc + xr, yc + yr
1871 xc = r_axis * cos(phi * pi / 180)
1872 yc = r_axis * sin(phi * pi / 180)
1876 SetDrawEnv xcoord=HorizCrossing, ycoord=VertCrossing
1877 SetDrawEnv fillfgc=(0,0,0)
1878 DrawOval xc - xr, yc - yr, xc + xr, yc + yr
1905 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){
1915 if (ParamIsDefault(folding))
1918 if (ParamIsDefault(projection))
1923 dfref saveDF = GetDataFolderDFR()
1924 newdatafolder /s/o $nickname
1925 string graphname =
"graph_" + nickname
1927 duplicate /free m_tilt, loc_m_tilt
1928 loc_m_tilt = -m_tilt
1930 make /n=1 /d /free d_polar, d_azi
1931 variable n_alpha = round(alpha_hi - alpha_lo) + 1
1932 make /n=(n_alpha) /d /free analyser
1933 setscale /i x alpha_lo, alpha_hi,
"", analyser
1937 duplicate /free d_polar, d_radius
1942 SetWindow $graphname, userdata(projection)=num2str(projection)
1946 variable nang = numpnts(m_theta)
1950 for (ifold = 0; ifold < folding; ifold += 1)
1951 d_azi = d_azi >= 360 ? d_azi - 360 : d_azi
1952 for (iang = 0; iang < nang; iang += 1)
1953 sprintf s_rad,
"rad_%d_%d", ifold, iang
1954 duplicate /o analyser, $s_rad
1956 w_rad = d_radius[p][iang]
1958 sprintf s_azi,
"azi_%d_%d", ifold, iang
1959 duplicate /o analyser, $s_azi
1961 w_azi = d_azi[p][iang]
1963 if (numtype(sum(w_rad)) == 0)
1964 s_trace = WMPolarAppendTrace(graphname, w_rad, w_azi, 360)
1965 ModifyGraph /w=$graphname mode($s_trace)=0, lsize($s_trace)=0.5
1968 d_azi += 360 / folding
1973 setdatafolder saveDF
2024 if (ParamIsDefault(projection))
2037 radius = polar < 90 ?
kProjScaleGnom * tan(polar * pi / 180) : inf
2065 threadsafe variable
calc_graph_polar(variable x, variable y, variable projection = defaultValue){
2070 if (ParamIsDefault(projection))
2077 radius = sqrt(x^2 + y^2)
2118 threadsafe variable
calc_graph_azi(variable x, variable y, variable projection = defaultValue, variable zeroAngle = defaultValue){
2124 if (ParamIsDefault(projection))
2127 if (ParamIsDefault(zeroAngle))
2133 azi = atan(y / x) * 180 / pi
2135 azi = atan(y / x) * 180 / pi + 180
2145 if (numtype(azi) != 0)
2166 dfref savedf = GetDataFolderDFR()
2168 string graphdf =
"root:packages:WMPolarGraphs:" + graphname
2169 setdatafolder graphdf
2176 string sproj = GetUserData(graphname,
"",
"projection")
2177 variable projection = str2num(
"0" + sproj)
2180 variable x = hcsr(A, graphname)
2181 variable y = vcsr(A, graphname)
2183 csrA_phi =
calc_graph_azi(x, y, projection=projection, zeroAngle=zeroAngleWhere)
2185 x = hcsr(B, graphname)
2186 y = vcsr(B, graphname)
2188 csrB_phi =
calc_graph_azi(x, y, projection=projection, zeroAngle=zeroAngleWhere)
2190 setdatafolder savedf
2199 STRUCT WMWinHookStruct &s
2201 Variable hookResult = 0
2208 TextBox /W=$s.winname /N=tb_angles /C /V=1
2211 TextBox /W=$s.winname /N=tb_angles /C /V=0
2218 variable
set_polar_graph_cursor(
string nickname,
string cursorname, variable polar_angle, variable azim_angle,
string graphname = defaultValue){
2221 variable polar_angle
2225 if (ParamIsDefault(graphname))
2226 if (strlen(nickname) > 0)
2227 graphname = nickname
2229 graphname = GetDataFolder(0)
2233 string s_prefix =
"" 2234 string s_int =
"values" 2237 string s_polar = s_prefix +
"pol" 2238 string s_azim = s_prefix +
"az" 2239 wave /sdfr=df /z azim = $s_azim
2240 wave /sdfr=df /z polar = $s_polar
2242 FindLevel /P /Q polar, polar_angle
2244 variable polar_level = floor(v_levelx)
2245 FindLevel /P /Q /R=[polar_level] azim, azim_angle
2247 variable azim_level = round(v_levelx)
2248 string tracename =
"polarY0" 2249 Cursor /W=$graphname /P $cursorname $traceName azim_level
2263 variable
hemi_add_anglescan(
string nickname, wave values, wave polar, wave azi, wave weights = defaultValue){
2275 if (ParamIsDefault(weights))
2276 duplicate /free values, weights
2281 string s_prefix =
"" 2282 string s_int =
"values" 2285 string s_polar = s_prefix +
"pol" 2286 string s_azim = s_prefix +
"az" 2287 string s_theta = s_prefix +
"th" 2289 wave /sdfr=df /z w_values = $s_int
2290 wave /sdfr=df /z w_azim = $s_azim
2291 wave /sdfr=df /z w_polar = $s_polar
2292 wave /sdfr=df /z w_theta = $s_theta
2293 if (!waveexists(w_values) || !waveexists(w_azim) || !waveexists(w_polar))
2294 abort
"Missing hemispherical scan grid. Please call make_hemi_grid() first." 2298 duplicate /free values, values_copy
2299 duplicate /free polar, polar_copy
2300 duplicate /free azi, azi_copy
2301 duplicate /free weights, weights_copy
2302 variable nn = dimsize(values, 0) * max(dimsize(values, 1), 1)
2303 redimension /n=(nn) values_copy, polar_copy, azi_copy, weights_copy
2304 sort /r polar_copy, polar_copy, azi_copy, values_copy, weights_copy
2307 variable pol_st = abs(w_theta[1] - w_theta[0])
2310 duplicate /free azi_copy, azi_slice
2311 duplicate /free values_copy, values_slice
2312 duplicate /free weights_copy, weights_slice
2313 for (pol = 90; pol >= 0; pol -= pol_st)
2314 pol1 = pol - pol_st / 2
2315 pol2 = pol + pol_st / 2
2316 extract /free /indx polar_copy, sel, (pol1 < polar_copy) && (polar_copy <= pol2)
2317 if (numpnts(sel) > 0)
2318 redimension /n=(numpnts(sel)) azi_slice, values_slice, weights_slice
2319 azi_slice = azi_copy[sel]
2320 values_slice = values_copy[sel]
2321 weights_slice = weights_copy[sel]
2322 hemi_add_aziscan(nickname, values_slice, pol, azi_slice, weights=weights_slice)
2333 variable
hemi_add_aziscan(
string nickname, wave values, variable polar, wave azi, wave weights = defaultValue){
2343 if (ParamIsDefault(weights))
2344 duplicate /free values, weights
2349 string s_prefix =
"" 2350 string s_int =
"values" 2353 string s_totals = s_prefix +
"tot" 2354 string s_weights = s_prefix +
"wt" 2355 string s_polar = s_prefix +
"pol" 2356 string s_azim = s_prefix +
"az" 2357 string s_index = s_prefix +
"index" 2358 string s_theta = s_prefix +
"th" 2359 string s_dphi = s_prefix +
"dphi" 2360 string s_nphis = s_prefix +
"nphis" 2362 wave /sdfr=df w_polar = $s_polar
2363 wave /sdfr=df w_azim = $s_azim
2364 wave /sdfr=df w_values = $s_int
2365 wave /sdfr=df w_totals = $s_totals
2366 wave /sdfr=df w_weights = $s_weights
2367 wave /sdfr=df w_index = $s_index
2368 wave /sdfr=df w_theta = $s_theta
2369 wave /sdfr=df w_dphi = $s_dphi
2370 wave /sdfr=df w_nphis = $s_nphis
2375 variable ipol = BinarySearch(w_theta, polar)
2377 abort
"assertion failed in hemi_add_aziscan(): polar angle not found in grid." 2382 d1 = w_index[ipol - 1]
2386 d2 = w_index[ipol] - 1
2387 variable nd = d2 - d1 + 1
2388 variable dphi = w_dphi[ipol]
2393 azi = azi < 0 ? azi + 360 : azi
2394 azi = azi >= 360 - dphi/2 ? azi - 360 : azi
2395 duplicate /free values, sel_values
2396 duplicate /free weights, sel_weights
2400 variable v1, v2, w1, w2
2401 for (
id = 0;
id < nd;
id += 1)
2402 az1 = (
id - 0.5) * dphi
2403 az2 = (
id + 0.5) * dphi
2404 extract /free /indx azi, sel, (az1 <= azi) && (azi < az2)
2405 if (numpnts(sel) > 0)
2406 redimension /n=(numpnts(sel)) sel_values, sel_weights
2407 sel_values = values[sel]
2408 sel_weights = weights[sel]
2409 v1 = w_totals[d1 +
id]
2410 w1 = w_weights[d1 +
id]
2411 if ((numtype(v1) == 2) || (w1 <= 0))
2415 v2 = sum(sel_values)
2416 w2 = sum(sel_weights)
2417 w_totals[d1 + id] = v1 + v2
2418 w_weights[d1 + id] = w1 + w2
2421 w_values[d1, d1 + nd - 1] = w_totals[p] / w_weights[p]
2442 dfref savedf = GetDataFolderDFR()
2444 string s_prefix =
"" 2445 string s_int =
"values" 2448 string s_polar = s_prefix +
"pol" 2449 string s_azim = s_prefix +
"az" 2450 string s_ster_x = s_prefix +
"ster_x" 2451 string s_ster_y = s_prefix +
"ster_y" 2453 wave /sdfr=df values = $s_int
2454 wave /sdfr=df azim = $s_azim
2455 wave /sdfr=df polar = $s_polar
2456 wave /sdfr=df ster_x = $s_ster_x
2457 wave /sdfr=df ster_y = $s_ster_y
2459 variable min_ster_x = wavemin(ster_x)
2460 variable max_ster_x = wavemax(ster_x)
2461 variable x0 = min_ster_x
2463 variable dx = (max_ster_x - min_ster_x) / (xn - 1)
2464 make /n=(numpnts(ster_x), 3) /free triplet
2465 triplet[][0] = ster_x[p]
2466 triplet[][1] = ster_y[p]
2467 triplet[][2] = values[p]
2471 make /n=(size, size) /d /o $(s_prefix +
"matrix") /wave=matrix
2472 make /n=(size, size) /free mnorm
2473 ImageFromXYZ /as {ster_x, ster_y, values}, matrix, mnorm
2475 matrixfilter NanZapMedian, matrix
2476 matrixfilter gauss, matrix
2478 duplicate /free values, ster_finite
2479 ster_finite = (numtype(values) == 0) * (ster_x^2 + ster_y^2)
2480 variable ster_max = wavemax(ster_finite)
2481 matrix = (x^2 + y^2) <= ster_max ? matrix : nan
2483 setdatafolder savedf
2496 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){
2501 variable theta_offset
2502 variable tilt_offset
2510 if (ParamIsDefault(npolar))
2513 if (ParamIsDefault(nograph))
2516 if (ParamIsDefault(folding))
2519 string graphname =
"graph_" + nickname
2520 string s_prefix =
"" 2523 dfref saveDF = GetDataFolderDFR()
2524 dfref dataDF = GetWavesDataFolderDFR(data)
2525 setdatafolder dataDF
2526 if (DataFolderExists(
":attr"))
2529 dfref attrDF = GetDataFolderDFR()
2530 setdatafolder dataDF
2531 newdatafolder /s/o $nickname
2532 dfref destDF = GetDataFolderDFR()
2535 variable timerRefNum
2536 variable /g xyz_perf_secs
2537 timerRefNum = startMSTimer
2539 wave /sdfr=attrDF ManipulatorTheta
2540 wave /sdfr=attrDF ManipulatorTilt
2541 wave /sdfr=attrDF ManipulatorPhi
2542 duplicate /free ManipulatorTheta, m_theta
2543 duplicate /free ManipulatorTilt, m_tilt
2544 duplicate /free ManipulatorPhi, m_phi
2545 m_theta -= theta_offset
2546 m_tilt -= tilt_offset
2551 make /n=1/d/free d_polar, d_azi
2554 d_azi = d_azi >= 360 ? d_azi - 360 : d_azi
2556 duplicate /free data, values
2557 variable nn = dimsize(values, 0) * max(dimsize(values, 1), 1)
2558 redimension /n=(nn) values, d_polar, d_azi
2559 duplicate /o d_polar, ster_rad, ster_x, ster_y
2561 variable projection = 1
2564 ster_rad = 2 * tan(d_polar / 2 * pi / 180)
2567 ster_rad = 2 * cos((180 - d_polar) / 2 * pi / 180)
2570 string s_ster_x = s_prefix +
"ster_x" 2571 string s_ster_y = s_prefix +
"ster_y" 2574 make /n=(nn, nn) /d /o matrix
2575 make /n=(nn, nn) /free mnorm
2576 setscale /i x -2, +2, matrix, mnorm
2577 setscale /i y -2, +2, matrix, mnorm
2582 for (ifold = 0; ifold < folding; ifold += 1)
2583 ster_x = ster_rad * cos(d_azi * pi / 180)
2584 ster_y = ster_rad * sin(d_azi * pi / 180)
2585 ImageFromXYZ {ster_x, ster_y, values}, matrix, mnorm
2586 d_azi = d_azi >= 180 ? d_azi + 360 / folding - 180 : d_azi + 360 / folding
2590 matrixfilter /n=5 NanZapMedian matrix
2591 matrixfilter /n=3 gauss matrix
2596 modifygraph width={Plan,1,bottom,left}
2599 if (timerRefNum >= 0)
2600 xyz_perf_secs = stopMSTimer(timerRefNum) / 1e6
2603 setdatafolder saveDF
2612 dfref savedf = getdatafolderdfr()
2615 string s_prefix =
"" 2616 string s_int =
"values" 2619 string s_polar = s_prefix +
"pol" 2620 string s_azim = s_prefix +
"az" 2621 string s_theta = s_prefix +
"th" 2622 string s_tot = s_prefix +
"tot" 2623 string s_weight = s_prefix +
"wt" 2625 wave /sdfr=df theta1 = $s_theta
2626 wave /sdfr=df polar1 = $s_polar
2627 wave /sdfr=df azim1 = $s_azim
2628 wave /sdfr=df tot1 = $s_tot
2629 wave /sdfr=df weight1 = $s_weight
2630 wave /sdfr=df values1 = $s_int
2632 save /m=
"\r\n" /o /p=$pathname /t theta1, polar1, azim1, tot1, weight1, values1 as filename
2634 setdatafolder saveDF
2645 dfref savedf = getdatafolderdfr()
2654 setdatafolder saveDF
2689 variable
import_tpi_scan(
string nickname, wave theta, wave phi, wave intensity, variable folding = defaultValue, variable npolar = defaultValue, variable nograph = defaultValue, variable xpdplot = defaultValue){
2700 if (ParamIsDefault(npolar))
2703 if (ParamIsDefault(nograph))
2706 if (ParamIsDefault(folding))
2709 if (ParamIsDefault(xpdplot))
2716 duplicate /free phi, fold_phi
2717 for (ifold = 0; ifold < folding; ifold += 1)
2719 fold_phi = fold_phi >= 180 ? fold_phi + 360 / folding - fold_phi : fold_phi + 360 / folding
2742 string s_prefix =
"" 2743 string s_int =
"values" 2746 string s_totals = s_prefix +
"tot" 2747 string s_weights = s_prefix +
"wt" 2748 string s_polar = s_prefix +
"pol" 2750 wave /sdfr=df w_polar = $s_polar
2751 wave /sdfr=df w_values = $s_int
2752 wave /sdfr=df w_totals = $s_totals
2753 wave /sdfr=df w_weights = $s_weights
2755 w_values = w_polar <= theta_max ? w_totals / w_weights : nan
2781 dfref savedf = getdatafolderdfr()
2782 string s_prefix =
"" 2783 string s_int =
"values" 2786 string s_totals = s_prefix +
"tot" 2787 string s_weights = s_prefix +
"wt" 2788 string s_polar = s_prefix +
"pol" 2789 string s_azim = s_prefix +
"az" 2790 string s_index = s_prefix +
"index" 2791 string s_theta = s_prefix +
"th" 2792 string s_dphi = s_prefix +
"dphi" 2793 string s_nphis = s_prefix +
"nphis" 2795 sprintf s_cut,
"%s_azi%03u", s_int, round(azim)
2797 wave /sdfr=df w_polar = $s_polar
2798 wave /sdfr=df w_azim = $s_azim
2799 wave /sdfr=df w_values = $s_int
2800 wave /sdfr=df w_totals = $s_totals
2801 wave /sdfr=df w_weights = $s_weights
2802 wave /sdfr=df w_index = $s_index
2803 wave /sdfr=df w_theta = $s_theta
2804 wave /sdfr=df w_dphi = $s_dphi
2805 wave /sdfr=df w_nphis = $s_nphis
2807 variable npol = numpnts(w_theta)
2809 variable pol_st = abs(w_theta[1] - w_theta[0])
2815 make /n=(npol) /o $s_cut
2817 setscale /i x w_theta[0], w_theta[numpnts(w_theta)-1],
"deg", w_cut
2818 make /n=1 /free azi_slice
2819 make /n=1 /free values_slice
2821 for (ipol = 0; ipol < npol; ipol += 1)
2823 pol1 = pol - pol_st / 2
2824 pol2 = pol + pol_st / 2
2825 extract /free /indx w_polar, sel, (pol1 < w_polar) && (w_polar <= pol2)
2828 redimension /n=(nsel+2) azi_slice, values_slice
2829 azi_slice[1, nsel] = w_azim[sel[p-1]]
2830 azi_slice[0] = azi_slice[nsel] - 360
2831 azi_slice[nsel+1] = azi_slice[1] + 360
2832 values_slice[1, nsel] = w_values[sel[p-1]]
2833 values_slice[0] = values_slice[nsel]
2834 values_slice[nsel+1] = values_slice[1]
2835 w_cut[ipol] = interp(azim, azi_slice, values_slice)
2841 setdatafolder savedf
2867 dfref savedf = getdatafolderdfr()
2868 string s_prefix =
"" 2869 string s_int =
"values" 2872 string s_totals = s_prefix +
"tot" 2873 string s_weights = s_prefix +
"wt" 2874 string s_polar = s_prefix +
"pol" 2875 string s_azim = s_prefix +
"az" 2876 string s_index = s_prefix +
"index" 2877 string s_theta = s_prefix +
"th" 2878 string s_dphi = s_prefix +
"dphi" 2879 string s_nphis = s_prefix +
"nphis" 2881 sprintf s_cut,
"%s_pol%03u", s_int, round(pol)
2883 wave /sdfr=df w_polar = $s_polar
2884 wave /sdfr=df w_azim = $s_azim
2885 wave /sdfr=df w_values = $s_int
2886 wave /sdfr=df w_totals = $s_totals
2887 wave /sdfr=df w_weights = $s_weights
2888 wave /sdfr=df w_index = $s_index
2889 wave /sdfr=df w_theta = $s_theta
2890 wave /sdfr=df w_dphi = $s_dphi
2891 wave /sdfr=df w_nphis = $s_nphis
2893 variable pol_st = abs(w_theta[1] - w_theta[0])
2897 pol1 = pol - pol_st / 2
2898 pol2 = pol + pol_st / 2
2899 extract /free /indx w_polar, sel, (pol1 < w_polar) && (w_polar <= pol2)
2903 make /n=(nsel) /o $s_cut
2905 w_cut = w_values[sel]
2906 setscale /i x w_azim[sel[0]], w_azim[sel[nsel-1]],
"", w_cut
2907 setdatafolder savedf
2910 setdatafolder savedf
2913 setdatafolder savedf
2916 static variable
check_contrast(wave values, variable pcmin, variable pcmax, variable* vmin, variable* vmax){
2923 dfref save_df = GetDataFolderDFR()
2924 dfref dfr = NewFreeDataFolder()
2926 StatsQuantiles /inan /iw /q /z values
2927 wave index = w_quantilesindex
2928 variable imin = round(numpnts(index) * pcmin / 100)
2929 variable imax = round(numpnts(index) * (100 - pcmax) / 100)
2930 vmin = values[index[imin]]
2931 vmax = values[index[imax]]
2933 setdatafolder save_df
2952 variable
set_contrast(variable pcmin, variable pcmax,
string graphname = defaultValue,
string colortable = defaultValue){
2958 if (ParamIsDefault(graphname))
2961 if (ParamIsDefault(colortable))
2965 dfref save_df = GetDataFolderDFR()
2977 string traces = TraceNameList(graphname,
";", 1+4)
2978 n = ItemsInList(traces,
";")
2979 for (i = 0; i < n; i += 1)
2980 objname = StringFromList(i, traces,
";")
2981 info = TraceInfo(graphname, objname, 0)
2982 if (strlen(info) > 0)
2983 info = StringByKey(
"RECREATION", info,
":",
";")
2984 info = StringByKey(
"zColor(x)", info,
"=",
";")
2985 if (strlen(info) > 2)
2986 info = info[1,strlen(info)-2]
2987 wname = StringFromList(0, info,
",")
2989 ctab = StringFromList(3, info,
",")
2990 rev = str2num(
"0" + StringFromList(4, info,
","))
2991 if (strlen(colortable) > 0)
2995 ModifyGraph /w=$graphname zColor($objname)={w, vmin, vmax, $ctab, rev}
3000 string images = ImageNameList(graphname,
";")
3001 n = ItemsInList(images,
";")
3002 for (i = 0; i < n; i += 1)
3003 objname = StringFromList(i, images,
";")
3004 wave w = ImageNameToWaveRef(graphname, objname)
3005 info = ImageInfo(graphname, objname, 0)
3006 if (strlen(info) > 0)
3007 info = StringByKey(
"RECREATION", info,
":",
";")
3008 info = StringByKey(
"ctab", info,
"=",
";")
3009 if (strlen(info) > 2)
3010 info = info[1,strlen(info)-2]
3011 ctab = StringFromList(2, info,
",")
3012 rev = str2num(
"0" + StringFromList(3, info,
","))
3013 if (strlen(colortable) > 0)
3017 ModifyImage /w=$graphname $objname ctab={vmin, vmax, $ctab, rev}
3022 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.