PEARL Procedures  rev-distro-1.6.1-0-ge1f1aa9-dirty
Igor procedures for the analysis of PEARL data
pearl-anglescan-panel.ipf
Go to the documentation of this file.
1 #pragma rtGlobals=3// Use modern global access method and strict wave access.
2 #pragma version = 1.7
3 #pragma IgorVersion = 6.2
4 #pragma ModuleName = PearlAnglescanPanel
5 #include "pearl-anglescan-process"
6 #include "pearl-pmsco-import"
7 
8 // copyright (c) 2018 Paul Scherrer Institut
9 //
10 // Licensed under the Apache License, Version 2.0 (the "License");
11 // you may not use this file except in compliance with the License.
12 // You may obtain a copy of the License at
13 // http:///www.apache.org/licenses/LICENSE-2.0
14 //
15 // Please acknowledge the use of this code.
16 
38 
43 
45 static const string package_name = "pearl_anglescan_panel";
47 static const string package_path = "root:packages:pearl_anglescan_panel:";
49 static const string prefs_objects = "theta_offset;tilt_offset;phi_offset;alpha_offset;crop_alpha_enable;crop_alpha_value;norm_alpha_enable;norm_alpha_mode;norm_alpha_smoothing;norm_phi_enable;norm_phi_mode;norm_phi_thetarange;norm_theta_enable;norm_theta_mode;norm_theta_smoothing;norm_thetaphi_enable;norm_thetaphi_mode;norm_theta_smoothing;output_folding;output_horizon;graph_mode;graph_projection;graph_colortable;graph_contrast;";
50 
52 static variable AfterCompiledHook(){
53 
54  dfref savedf = GetDataFolderDFR()
55  variable do_init = 1
56  if (DataFolderExists(package_path))
57  setdatafolder $(package_path)
58  nvar /z init_done
59  if (nvar_exists(init_done))
60  if (init_done)
61  do_init = 0
62  endif
63  endif
64  endif
65 
66  if (do_init)
67  init_package()
68  load_prefs()
69  setdatafolder $(package_path)
70  variable /g init_done = 1
71  endif
72 
73  setdatafolder savedf
74  return 0
75 };
76 
77 static variable init_package(){
78  dfref savedf = getdatafolderdfr()
79  setdatafolder root:
80  newdatafolder /o/s packages
81  newdatafolder /o/s $package_name
82 
83  // configuration (persistent)
84  string /g graphname = "graph_anglescan_panel"
85 
86  // recently used (persistent)
87  variable /g theta_offset = 0
88  variable /g tilt_offset = 0
89  variable /g phi_offset = 0
90  variable /g alpha_offset = 0
91  variable /g crop_alpha_enable = 0
92  variable /g crop_alpha_value = 25
93  variable /g norm_alpha_enable = 0
94  variable /g norm_alpha_mode = 4
95  variable /g norm_alpha_smoothing = 0.25
96  variable /g norm_theta_enable = 0
97  variable /g norm_theta_mode = 4
98  variable /g norm_theta_smoothing = 0.25
99  variable /g norm_thetaphi_enable = 0
100  variable /g norm_thetaphi_mode = 4
101  variable /g norm_thetaphi_smoothing = 0.25
102  variable /g norm_phi_enable = 0
103  variable /g norm_phi_mode = 4
104  variable /g norm_phi_thetarange = 20
105  string /g output_name = "holo1"
106  variable /g output_folding = 1
107  variable /g output_horizon = 88
108  variable /g graph_mode = 1
109  variable /g graph_projection = kProjStereo
110  string /g graph_colortable = "grays"
111  variable /g graph_contrast = 2
112 
113  // recently used (volatile)
114  string /g source_path = ""
115  string /g export_folderpath = "root:"
116  variable /g export_format = 1
117 
118  // administrative data (volatile)
119  string /g panel_name = ""
120  string /g preview_graphname = ""
121  string /g dist_x_graphname = ""
122  string /g dist_y_graphname = ""
123  string /g output_graphname = ""
124 
125  // data (volatile)
126  make /n=(10,10) /o raw_data, process_data
127  make /o dist_x, dist_x_smoo
128  make /o dist_y, dist_y_smoo
129 
130  setdatafolder savedf
131 };
132 
137 static variable save_prefs(){
138  dfref saveDF = GetDataFolderDFR()
139 
140  string fullPath = SpecialDirPath("Packages", 0, 0, 0)
141  fullPath += package_name
142  NewPath/O/C/Q tempPackagePrefsPath, fullPath
143  fullPath += ":preferences.pxp"
144 
145  SetDataFolder root:packages
146  SetDataFolder $package_name
147  SaveData /O /Q /J=prefs_objects fullPath
148 
149  KillPath/Z tempPackagePrefsPath
150 
151  SetDataFolder saveDF
152 };
153 
161 static variable load_prefs(){
162  dfref saveDF = GetDataFolderDFR()
163 
164  variable result = -1
165  setdatafolder root:
166  NewDataFolder /O/S packages
167  NewDataFolder /O/S $package_name
168  string fullPath = SpecialDirPath("Packages", 0, 0, 0)
169  fullPath += package_name
170 
171  GetFileFolderInfo /Q /Z fullPath
172  if (V_Flag == 0)// Disk directory exists?
173  fullPath += ":preferences.pxp"
174  GetFileFolderInfo /Q /Z fullPath
175  if (V_Flag == 0)// Preference file exist?
176  LoadData /O /R /Q fullPath
177  result = 0
178  endif
179  endif
180 
181  SetDataFolder saveDF
182  return result
183 };
184 
197 variable asp_import_raw(wave raw_data){
198  wave raw_data
199 
200  dfref saveDF = GetDataFolderDFR()
201  dfref datadf = GetWavesDataFolderDFR(raw_data)
202  dfref attrdf = datadf:attr
203  setdatafolder $(package_path)
204 
205  // todo : check dimensions and scales
206 
207  svar source_path
208  source_path = GetWavesDataFolder(raw_data, 2)
209 
210  duplicate /o raw_data, raw, process_data
211  duplicate /o attrdf:ManipulatorTheta, raw_theta, process_theta
212  duplicate /o attrdf:ManipulatorTilt, raw_tilt, process_tilt
213  duplicate /o attrdf:ManipulatorPhi, raw_phi, process_phi
214 
215  make /o /n=(dimsize(raw_data, 0)) dist_x, dist_x_smoo
216  make /o /n=(dimsize(raw_data, 1)) dist_y, dist_y_smoo
217 
218  SetDataFolder saveDF
219 };
220 
226  dfref df = $(package_path)
227  wave /sdfr=df process_data
228  svar /sdfr=df preview_graphname
229 
230  if (strlen(preview_graphname) && (wintype(preview_graphname) == 1))
231  ad_update_profiles(process_data)
232  DoWindow /F $preview_graphname
233  else
234  preview_graphname = ad_display_profiles(process_data)
235  endif
236 
237  nvar /sdfr=df graph_contrast
238  svar /sdfr=df graph_colortable
239  set_contrast(graph_contrast, graph_contrast, graphname=preview_graphname, colortable=graph_colortable)
240 };
241 
249 variable asp_display_dist_check(variable xdist, variable ydist){
250  variable xdist, ydist
251 
252  dfref df = $(package_path)
253  wave /sdfr=df dist_x
254  wave /sdfr=df dist_y
255  wave /sdfr=df dist_x_smoo
256  wave /sdfr=df dist_y_smoo
257  svar /sdfr=df dist_x_graphname
258  svar /sdfr=df dist_y_graphname
259 
260  if (xdist)
261  if (strlen(dist_x_graphname) && (wintype(dist_x_graphname) == 1))
262  DoWindow /F $dist_x_graphname
263  else
264  display /k=1 /n=graph_asp_dist_x dist_x, dist_x_smoo
265  dist_x_graphname = s_name
266  ModifyGraph /w=$dist_x_graphname mode(dist_x)=2
267  ModifyGraph /w=$dist_x_graphname lsize(dist_x)=2
268  ModifyGraph /w=$dist_x_graphname rgb(dist_x)=(0,0,0)
269  endif
270  endif
271 
272  if (ydist)
273  if (strlen(dist_y_graphname) && (wintype(dist_y_graphname) == 1))
274  DoWindow /F $dist_y_graphname
275  else
276  display /k=1 /n=graph_asp_dist_y dist_y, dist_y_smoo
277  dist_y_graphname = s_name
278  ModifyGraph /w=$dist_y_graphname mode(dist_y)=2
279  ModifyGraph /w=$dist_y_graphname lsize(dist_y)=2
280  ModifyGraph /w=$dist_y_graphname rgb(dist_y)=(0,0,0)
281  endif
282  endif
283 };
284 
294 static variable do_init_process(variable check){
295  variable check
296 
297  dfref df = $(package_path)
298  wave /sdfr=df raw
299  wave /sdfr=df raw_theta
300  wave /sdfr=df raw_tilt
301  wave /sdfr=df raw_phi
302  nvar /sdfr=df theta_offset
303  nvar /sdfr=df tilt_offset
304  nvar /sdfr=df phi_offset
305  nvar /sdfr=df alpha_offset
306 
307  duplicate /o raw, df:process_data
308  duplicate /o raw_theta, df:process_theta
309  duplicate /o raw_tilt, df:process_tilt
310  duplicate /o raw_phi, df:process_phi
311 
312  wave /sdfr=df process_data
313  wave /sdfr=df process_theta
314  wave /sdfr=df process_tilt
315  wave /sdfr=df process_phi
316 
317  process_theta = raw_theta - theta_offset
318  process_tilt = raw_tilt - tilt_offset
319  process_phi = raw_phi - phi_offset
320  setscale /p x dimoffset(raw, 0) - alpha_offset, dimdelta(raw, 0), waveunits(raw, 0), process_data
321 };
322 
334 static variable do_crop_alpha(variable check, variable force = defaultValue){
335  variable check
336  variable force
337 
338  if (ParamIsDefault(force))
339  force = 0
340  endif
341 
342  dfref df = $(package_path)
343  wave /sdfr=df process_data
344  nvar /sdfr=df crop_alpha_enable
345  nvar /sdfr=df crop_alpha_value
346 
347  if ((force || crop_alpha_enable) && (crop_alpha_value > abs(dimdelta(process_data, 0))))
348  crop_strip(process_data, -crop_alpha_value, +crop_alpha_value)
349  endif
350 };
351 
363 static variable do_norm_alpha(variable check, variable force = defaultValue){
364  variable check
365  variable force
366 
367  if (ParamIsDefault(force))
368  force = 0
369  endif
370 
371  dfref saveDF = GetDataFolderDFR()
372  dfref df = $(package_path)
373  wave /sdfr=df process_data
374  nvar /sdfr=df norm_alpha_enable
375  nvar /sdfr=df norm_alpha_mode
376  nvar /sdfr=df norm_alpha_smoothing
377 
378  if (force || norm_alpha_enable)
379  dfref temp_df = newfreedatafolder()
380  setdatafolder temp_df
381  normalize_strip_x(process_data, smooth_method=norm_alpha_mode, smooth_factor=norm_alpha_smoothing, check=check)
382  if (check)
383  wave check_dist
384  wave check_smoo
385  duplicate /o check_dist, df:dist_x
386  duplicate /o check_smoo, df:dist_x_smoo
387  endif
388  endif
389 
390  SetDataFolder saveDF
391 };
392 
404 static variable do_norm_phi(variable check, variable force = defaultValue){
405  variable check
406  variable force
407 
408  if (ParamIsDefault(force))
409  force = 0
410  endif
411 
412  dfref saveDF = GetDataFolderDFR()
413  dfref df = $(package_path)
414  wave /sdfr=df process_data
415  wave /sdfr=df process_theta
416  wave /sdfr=df process_phi
417  nvar /sdfr=df norm_phi_enable
418  nvar /sdfr=df norm_phi_mode
419  nvar /sdfr=df norm_phi_thetarange
420 
421  if (force || norm_phi_enable)
422  dfref temp_df = newfreedatafolder()
423  setdatafolder temp_df
424  normalize_strip_phi(process_data, process_theta, process_phi, theta_range=norm_phi_thetarange, check=check)
425  if (check)
426  wave check_dist
427  wave check_smoo
428  duplicate /o check_dist, df:dist_y
429  duplicate /o check_smoo, df:dist_y_smoo
430  endif
431  endif
432 
433  SetDataFolder saveDF
434 };
435 
447 static variable do_norm_theta(variable check, variable force = defaultValue){
448  variable check
449  variable force
450 
451  if (ParamIsDefault(force))
452  force = 0
453  endif
454 
455  dfref saveDF = GetDataFolderDFR()
456  dfref df = $(package_path)
457  wave /sdfr=df process_data
458  wave /sdfr=df process_theta
459  nvar /sdfr=df norm_theta_enable
460  nvar /sdfr=df norm_theta_mode
461  nvar /sdfr=df norm_theta_smoothing
462 
463  if (force || norm_theta_enable)
464  dfref temp_df = newfreedatafolder()
465  setdatafolder temp_df
466  normalize_strip_theta(process_data, process_theta, smooth_method=norm_theta_mode, smooth_factor=norm_theta_smoothing, check=check)
467  if (check)
468  wave check_dist
469  wave check_smoo
470  duplicate /o check_dist, df:dist_y
471  duplicate /o check_smoo, df:dist_y_smoo
472  endif
473  endif
474 
475  SetDataFolder saveDF
476 };
477 
489 static variable do_norm_thetaphi(variable check, variable force = defaultValue){
490  variable check
491  variable force
492 
493  if (ParamIsDefault(force))
494  force = 0
495  endif
496 
497  dfref saveDF = GetDataFolderDFR()
498  dfref df = $(package_path)
499  wave /sdfr=df process_data
500  wave /sdfr=df process_theta
501  wave /sdfr=df process_phi
502  nvar /sdfr=df norm_thetaphi_enable
503  nvar /sdfr=df norm_thetaphi_mode
504  nvar /sdfr=df norm_thetaphi_smoothing
505 
506  if (force || norm_thetaphi_enable)
507  dfref temp_df = newfreedatafolder()
508  setdatafolder temp_df
509  normalize_strip_thetaphi(process_data, process_theta, process_phi, smooth_method=norm_thetaphi_mode, smooth_factor=norm_thetaphi_smoothing, check=check)
510  if (check)
511  wave check_dist
512  wave check_smoo
513  duplicate /o check_dist, df:dist_y
514  duplicate /o check_smoo, df:dist_y_smoo
515  endif
516  endif
517 
518  SetDataFolder saveDF
519 };
520 
526  dfref saveDF = GetDataFolderDFR()
527  setdatafolder $(package_path)
528 
529  svar output_name
530 
531  wave process_data
532  wave process_theta
533  wave process_tilt
534  wave process_phi
535 
536  nvar folding=output_folding
537  nvar horizon=output_horizon
538 
539  do_init_process(0)
540  do_crop_alpha(0)
541  do_norm_alpha(0)
542  do_norm_phi(0)
543  do_norm_theta(0)
545 
546  pizza_service_2(process_data, output_name, process_theta, process_tilt, process_phi, folding=folding, nograph=1)
547 
548  setdatafolder $output_name
549  wave values
550  wave pol
551  if (horizon > 0)
552  values = pol <= horizon ? values : nan
553  endif
554 
555  SetDataFolder saveDF
556 };
557 
561  dfref df = $(package_path)
562 
563  svar /sdfr=df output_name
564  svar /sdfr=df output_graphname
565  nvar /sdfr=df graph_projection
566  nvar /sdfr=df graph_mode
567 
568  dfref saveDF = GetDataFolderDFR()
569  setdatafolder $(package_path)
570  output_graphname = output_name
571  output_graphname = display_hemi_scan(output_name, projection=graph_projection, graphtype=graph_mode, graphname=output_graphname)
572  SetDataFolder saveDF
574 };
575 
580 variable asp_update_graph(){
581  dfref df = $(package_path)
582 
583  svar /sdfr=df preview_graphname
584  svar /sdfr=df output_graphname
585  svar /sdfr=df graph_colortable
586  nvar /sdfr=df graph_contrast
587 
588  if (strlen(preview_graphname) && (wintype(preview_graphname) == 1))
589  set_contrast(graph_contrast, graph_contrast, graphname=preview_graphname, colortable=graph_colortable)
590  endif
591  if (strlen(output_graphname) && (wintype(output_graphname) == 1))
592  set_contrast(graph_contrast, graph_contrast, graphname=output_graphname, colortable=graph_colortable)
593  endif
594 };
595 
598 variable asp_close_graphs(){
599  dfref df = $(package_path)
600 
601  svar /sdfr=df preview_graphname
602  svar /sdfr=df output_graphname
603  svar /sdfr=df dist_x_graphname
604  svar /sdfr=df dist_y_graphname
605 
606  if (strlen(preview_graphname) && (wintype(preview_graphname) == 1))
607  killwindow $preview_graphname
608  endif
609  if (strlen(output_graphname) && (wintype(output_graphname) == 1))
610  killwindow $output_graphname
611  endif
612  if (strlen(dist_x_graphname) && (wintype(dist_x_graphname) == 1))
613  killwindow $dist_x_graphname
614  endif
615  if (strlen(dist_y_graphname) && (wintype(dist_y_graphname) == 1))
616  killwindow $dist_y_graphname
617  endif
618 
619  preview_graphname = ""
620  output_graphname = ""
621  dist_x_graphname = ""
622  dist_y_graphname = ""
623 };
624 
633 variable asp_duplicate_output(string dest_name){
634  string dest_name
635 
636  dfref df = $(package_path)
637  svar /sdfr=df source_path
638  svar /sdfr=df output_name
639  svar /sdfr=df output_graphname
640  wave raw_data = $source_path
641 
642  dfref saveDF = GetDataFolderDFR()
643  dfref dest_df = GetWavesDataFolderDFR(raw_data)
644  setdatafolder dest_df
645  newdatafolder /o /s $dest_name
646  dfref dest_df = GetDataFolderDFR()
647  setdatafolder df
648  duplicate_hemi_scan(output_name, dest_df, "")
649 
650  SetDataFolder saveDF
651 };
652 
656  dfref df = $(package_path)
657  svar /sdfr=df output_name
658 
659  dfref saveDF = GetDataFolderDFR()
660  setdatafolder df
661  save_hemi_scan(output_name, "", "")
662 
663  SetDataFolder saveDF
664 };
665 
670 variable asp_save_output_etpi(variable ekin){
671  variable ekin
672 
673  dfref df = $(package_path)
674  svar /sdfr=df output_name
675  wave /sdfr=df process_data
676 
677  dfref saveDF = GetDataFolderDFR()
678  setdatafolder df
679  string s_prefix = ""
680  string s_int = "values"
681  dfref data_df = find_hemi_data(output_name, s_prefix, s_int)
682  string s_polar = s_prefix + "pol"
683  string s_azim = s_prefix + "az"
684 
685  pmsco_save_scan("", "", num2str(ekin), s_polar, s_azim, "", s_int, "", sdfr=data_df)
686 
687  SetDataFolder saveDF
688 };
689 
690 static variable check_norm_alpha(){
691  do_init_process(0)
692  do_crop_alpha(0)
693  do_norm_alpha(2, force=1)
695 };
696 
697 static variable check_norm_phi(){
698  do_init_process(0)
699  do_crop_alpha(0)
700  do_norm_phi(2, force=1)
702 };
703 
704 static variable check_norm_theta(){
705  do_init_process(0)
706  do_crop_alpha(0)
707  do_norm_theta(2, force=1)
709 };
710 
711 static variable check_norm_thetaphi(){
712  do_init_process(0)
713  do_crop_alpha(0)
714  do_norm_thetaphi(2, force=1)
716 };
717 
718 static variable preview_crop_alpha(){
719  do_init_process(0)
720  do_crop_alpha(0, force=1)
722 };
723 
724 static variable preview_norm_alpha(){
725  do_init_process(0)
726  do_crop_alpha(0)
727  do_norm_alpha(1, force=1)
729 };
730 
731 static variable preview_norm_phi(){
732  do_init_process(0)
733  do_crop_alpha(0)
734  do_norm_phi(1, force=1)
736 };
737 
738 static variable preview_norm_theta(){
739  do_init_process(0)
740  do_crop_alpha(0)
741  do_norm_theta(1, force=1)
743 };
744 
745 static variable preview_norm_thetaphi(){
746  do_init_process(0)
747  do_crop_alpha(0)
748  do_norm_thetaphi(1, force=1)
750 };
751 
754 variable asp_show_panel(){
755  dfref df = $(package_path)
756  svar /sdfr=df panel_name
757 
758  if (strlen(panel_name) && (wintype(panel_name) == 7))
759  DoWindow /F $panel_name
760  return 0
761  endif
762 
763  NewPanel /K=1 /N=anglescan_panel /W=(200,100,479,1027) as "angle scan processing"
764  panel_name = s_name
765 
766  GroupBox gb_source, title="data source"
767  Button b_source_select, size={50,20},proc=PearlAnglescanPanel#bp_source_select,title="select..."
768  Button b_source_select, help={"select the source wave, e.g. ReducedData1. it must be in the original scan data folder along with the attr folder and the manipulator positions."}
769  TitleBox tb_source_path, size={240,21}
770  TitleBox tb_source_path,variable= root:packages:pearl_anglescan_panel:source_path
771 
772  GroupBox gb_offsets, title="offsets"
773  SetVariable sv_theta_offset, size={88,16},bodyWidth=60,title="theta"
774  SetVariable sv_theta_offset,value= root:packages:pearl_anglescan_panel:theta_offset
775  SetVariable sv_theta_offset, help={"manipulator theta value that corresponds to normal emission."}
776  SetVariable sv_tilt_offset, size={74,16},bodyWidth=60,title="tilt"
777  SetVariable sv_tilt_offset,value= root:packages:pearl_anglescan_panel:tilt_offset
778  SetVariable sv_tilt_offset, help={"manipulator tilt value that corresponds to normal emission."}
779  SetVariable sv_phi_offset, size={78,16},bodyWidth=60,title="phi"
780  SetVariable sv_phi_offset,value= root:packages:pearl_anglescan_panel:phi_offset
781  SetVariable sv_phi_offset, help={"manipulator phi value that should map to the 3 o'clock angle."}
782  SetVariable sv_alpha_offset, size={90,16},bodyWidth=60,title="alpha"
783  SetVariable sv_alpha_offset,value= root:packages:pearl_anglescan_panel:alpha_offset
784  SetVariable sv_alpha_offset, help={"alpha value that corresponds to normal emission (if the sample normal is properly aligned)."}
785 
786  GroupBox gb_crop_alpha, title="crop alpha"
787  CheckBox cb_crop_alpha_enable, size={50,14}, title="enable"
788  CheckBox cb_crop_alpha_enable, help={"enable cropping at +/- alpha"}
789  CheckBox cb_crop_alpha_enable,variable= root:packages:pearl_anglescan_panel:crop_alpha_enable
790  SetVariable sv_crop_alpha_value, size={90,16},bodyWidth=60,title="angle"
791  SetVariable sv_crop_alpha_value,limits={0,30,1},value= root:packages:pearl_anglescan_panel:crop_alpha_value
792  SetVariable sv_crop_alpha_value, help={"alpha (detection angle) cropping angle"}
793  Button b_crop_alpha_preview, size={80,20},proc=PearlAnglescanPanel#bp_crop_alpha_preview,title="preview"
794  Button b_crop_alpha_preview, help={"show a preview of the cropped dataset."}
795 
796  GroupBox gb_norm_alpha, title="normalize alpha"
797  CheckBox cb_norm_alpha_enable, size={50,14}, title="enable"
798  CheckBox cb_norm_alpha_enable,variable= root:packages:pearl_anglescan_panel:norm_alpha_enable
799  CheckBox cb_norm_alpha_enable, help={"enable normalization of the alpha distribution"}
800  PopupMenu pm_norm_alpha_mode, size={138,21}, bodyWidth=100, proc=PearlAnglescanPanel#pmp_norm_alpha_mode,title="method"
801  PopupMenu pm_norm_alpha_mode, mode=5, popvalue="loess", value= #"\"none;binomial;boxcar;scienta;loess;\""
802  PopupMenu pm_norm_alpha_mode, help={"alpha normalization method. recommended: loess"}
803  SetVariable sv_norm_alpha_smoothing, size={112,16}, bodyWidth=60, title="smoothing"
804  SetVariable sv_norm_alpha_smoothing, limits={0,1,0.05}, value= root:packages:pearl_anglescan_panel:norm_alpha_smoothing
805  SetVariable sv_norm_alpha_smoothing, help={"smoothing parameter (depends on the normalization method)."}
806  Button b_norm_alpha_check, size={80,20}, proc=PearlAnglescanPanel#bp_norm_alpha_check,title="check"
807  Button b_norm_alpha_check, help={"show a graph of the normalization function"}
808  Button b_norm_alpha_preview, size={80,20}, proc=PearlAnglescanPanel#bp_norm_alpha_preview,title="preview"
809  Button b_norm_alpha_preview, help={"show a preview of the normalized dataset (without other normalizations)."}
810 
811  GroupBox gb_norm_phi, title="normalize phi"
812  CheckBox cb_norm_phi_enable, size={50,14}, title="enable"
813  CheckBox cb_norm_phi_enable,variable= root:packages:pearl_anglescan_panel:norm_phi_enable
814  CheckBox cb_norm_phi_enable, help={"enable normalization of the phi distribution to reduce the effect of wobble"}
815  SetVariable sv_norm_phi_range, size={118,16}, bodyWidth=60, title="theta range"
816  SetVariable sv_norm_phi_range, limits={0,90,1}, value= root:packages:pearl_anglescan_panel:norm_phi_thetarange
817  SetVariable sv_norm_phi_range, help={"theta range (from normal) to factor into the normalization function"}
818  Button b_norm_phi_check, size={80,20}, proc=PearlAnglescanPanel#bp_norm_phi_check, title="check"
819  Button b_norm_phi_check, help={"show a graph of the normalization function"}
820  Button b_norm_phi_preview, size={80,20}, proc=PearlAnglescanPanel#bp_norm_phi_preview, title="preview"
821  Button b_norm_phi_preview, help={"show a preview of the normalized dataset (without other normalizations)."}
822 
823  GroupBox gb_norm_theta, title="normalize theta"
824  CheckBox cb_norm_theta_enable, size={50,14},title="enable"
825  CheckBox cb_norm_theta_enable, variable= root:packages:pearl_anglescan_panel:norm_theta_enable
826  CheckBox cb_norm_theta_enable, help={"enable normalization of the theta distribution (integrated over phi)"}
827  PopupMenu pm_norm_theta_mode, size={138,21},bodyWidth=100,proc=PearlAnglescanPanel#pmp_norm_theta_mode,title="method"
828  PopupMenu pm_norm_theta_mode,mode=5,popvalue="loess",value= #"\"none;binomial;boxcar;polynomial;loess;\""
829  PopupMenu pm_norm_theta_mode, help={"theta normalization method. recommended: loess"}
830  SetVariable sv_norm_theta_smoothing, size={112,16}, bodyWidth=60, title="smoothing"
831  SetVariable sv_norm_theta_smoothing, limits={0,1,0.05}, value= root:packages:pearl_anglescan_panel:norm_theta_smoothing
832  SetVariable sv_norm_theta_smoothing, help={"smoothing parameter (depends on the normalization method)."}
833  Button b_norm_theta_check, size={80,20}, proc=PearlAnglescanPanel#bp_norm_theta_check, title="check"
834  Button b_norm_theta_check, help={"show a graph of the normalization function"}
835  Button b_norm_theta_preview, size={80,20}, proc=PearlAnglescanPanel#bp_norm_theta_preview, title="preview"
836  Button b_norm_theta_preview, help={"show a preview of the normalized dataset (without other normalizations)."}
837 
838  GroupBox gb_norm_thetaphi, size={272,97},title="normalize (theta,phi)"
839  CheckBox cb_norm_thetaphi_enable, size={50,14},title="enable"
840  CheckBox cb_norm_thetaphi_enable, variable= root:packages:pearl_anglescan_panel:norm_thetaphi_enable
841  CheckBox cb_norm_thetaphi_enable, help={"enable normalization of the (theta, phi) distribution."}
842  PopupMenu pm_norm_thetaphi_mode, size={138,21}, bodyWidth=100, proc=PearlAnglescanPanel#pmp_norm_thetaphi_mode,title="method"
843  PopupMenu pm_norm_thetaphi_mode, mode=5, popvalue="loess", value= #"\"none;none;none;none;loess;\""
844  PopupMenu pm_norm_thetaphi_mode, help={"theta normalization method. recommended: loess"}
845  SetVariable sv_norm_thetaphi_smoothing, size={112,16}, bodyWidth=60, title="smoothing"
846  SetVariable sv_norm_thetaphi_smoothing, limits={0,1,0.05}, value= root:packages:pearl_anglescan_panel:norm_thetaphi_smoothing
847  SetVariable sv_norm_thetaphi_smoothing, help={"smoothing parameter (depends on the normalization method)."}
848  Button b_norm_thetaphi_check, size={80,20}, proc=PearlAnglescanPanel#bp_norm_thetaphi_check, title="check"
849  Button b_norm_thetaphi_check, help={"show a graph of the normalization function"}
850  Button b_norm_thetaphi_preview, size={80,20}, proc=PearlAnglescanPanel#bp_norm_thetaphi_preview, title="preview"
851  Button b_norm_thetaphi_preview, help={"show a preview of the normalized dataset (without other normalizations)."}
852 
853  GroupBox gb_output, title="output"
854  SetVariable sv_output_folding, size={95,16}, bodyWidth=60, title="folding"
855  SetVariable sv_output_folding, limits={1,20,1}, value= root:packages:pearl_anglescan_panel:output_folding
856  SetVariable sv_output_folding, help={"n-fold rotational average. 1=no averaging."}
857  SetVariable sv_output_horizon, size={98,16}, bodyWidth=60, title="horizon"
858  SetVariable sv_output_horizon, limits={1,90,1}, value= root:packages:pearl_anglescan_panel:output_horizon
859  SetVariable sv_output_horizon, help={"highest theta to display"}
860  PopupMenu pm_graph_projection, size={149,21}, bodyWidth=100, proc=PearlAnglescanPanel#pmp_graph_projection, title="projection"
861  PopupMenu pm_graph_projection, mode=2, popvalue="stereographic", value= #"\"equidistant;stereographic;equal area;gnomonic;orthographic;\""
862  PopupMenu pm_graph_projection, help={"projection (theta mapping) mode"}
863  PopupMenu pm_graph_mode, size={129,21}, bodyWidth=100, proc=PearlAnglescanPanel#pmp_graph_mode,title="mode"
864  PopupMenu pm_graph_mode, mode=2, popvalue="polar plot", value= #"\"none;polar plot;none;image;\""
865  PopupMenu pm_graph_mode, help={"graph mode"}
866  Button b_output_calc, size={80,20}, proc=PearlAnglescanPanel#bp_output_calc, title="calc + display"
867  Button b_output_calc, help={"execute data processing with the enabled filters and display the diffractogram."}
868  Button b_output_duplicate, size={80,20}, proc=PearlAnglescanPanel#bp_output_duplicate, title="duplicate ..."
869  Button b_output_duplicate, help={"copy the result to an arbitrary data folder."}
870  Button b_output_itx, size={80,20}, proc=PearlAnglescanPanel#bp_output_itx, title="save ITX ..."
871  Button b_output_itx, help={"save the result to an igor text file (itx)."}
872  Button b_output_etpi, size={80,20}, proc=PearlAnglescanPanel#bp_output_etpi, title="save ETPI ..."
873  Button b_output_etpi, help={"save the result to a pmsco angle scan file (etpi)."}
874 
875  GroupBox gb_graph, title="graph"
876  PopupMenu pm_graph_colortable, size={152,21}, bodyWidth=100, proc=PearlAnglescanPanel#pmp_graph_colortable, title="color table"
877  PopupMenu pm_graph_colortable, mode=0, value= #"\"*COLORTABLEPOPNONAMES*\""
878  PopupMenu pm_graph_colortable, help={"color table to use in pseudocolor graphs."}
879  SetVariable sv_graph_contrast, size={119,16}, bodyWidth=60, title="contrast (%)"
880  SetVariable sv_graph_contrast, limits={0,25,1}, value= root:packages:pearl_anglescan_panel:graph_contrast
881  SetVariable sv_graph_contrast, help={"contrast value (percentile)."}
882  Button b_graph_update, size={80,20}, proc=PearlAnglescanPanel#bp_graph_update, title="update"
883  Button b_graph_update, help={"update the existing graph."}
884  Button b_graph_png, size={80,20}, proc=PearlAnglescanPanel#bp_graph_png, title="save PNG ..."
885  Button b_graph_png, help={"save the graph in png format."}
886 
888  update_menus()
889 };
890 
891 static variable arrange_controls(){
892  dfref df = $(package_path)
893  svar /sdfr=df panel_name
894 
895  variable gb_space = 2
896  variable gb_internal_top = 20
897  variable gb_internal_bot = 8
898  variable line_space = 26
899 
900  variable cb_adj = 2
901  variable sv_adj = 2
902  variable pm_adj = 0
903  variable b_adj = 0
904  variable tb_adj = 0
905 
906  variable gb_top = 4
907  variable gb_ht = 0
908 
909  // ht = line + 30
910  // gb = gb + ht + 2
911  // cb = gb + 18
912  // pm = gb + 38
913  // line += 26
914  // sv = line + 2
915 
916  GroupBox gb_source,pos={4,gb_top}
917  gb_ht = gb_internal_top
918  Button b_source_select,pos={17, gb_top + gb_ht + b_adj},size={50,20}
919  gb_ht += line_space
920  TitleBox tb_source_path,pos={18, gb_top + gb_ht + tb_adj},size={240,21}
921  gb_ht += line_space
922  gb_ht += gb_internal_bot
923  GroupBox gb_source, size={272,gb_ht}
924 
925  gb_top += gb_ht + gb_space
926  GroupBox gb_offsets,pos={4,gb_top}
927  gb_ht = gb_internal_top
928  SetVariable sv_theta_offset,pos={46, gb_top + gb_ht + sv_adj},size={88,16}
929  gb_ht += line_space
930  SetVariable sv_tilt_offset,pos={60, gb_top + gb_ht + sv_adj},size={74,16}
931  gb_ht += line_space
932  SetVariable sv_phi_offset,pos={56, gb_top + gb_ht + sv_adj},size={78,16}
933  gb_ht += line_space
934  SetVariable sv_alpha_offset,pos={44, gb_top + gb_ht + sv_adj},size={90,16}
935  gb_ht += line_space
936  gb_ht += gb_internal_bot
937  GroupBox gb_offsets, size={272,gb_ht}
938 
939  gb_top += gb_ht + gb_space
940  GroupBox gb_crop_alpha,pos={4,gb_top}
941  gb_ht = gb_internal_top
942  CheckBox cb_crop_alpha_enable,pos={73, gb_top + gb_ht + cb_adj},size={50,14}
943  gb_ht += line_space
944  SetVariable sv_crop_alpha_value,pos={44, gb_top + gb_ht + sv_adj},size={90,16}
945  Button b_crop_alpha_preview,pos={186, gb_top + gb_ht + b_adj},size={80,20}
946  gb_ht += line_space
947  gb_ht += gb_internal_bot
948  GroupBox gb_crop_alpha, size={272,gb_ht}
949 
950  gb_top += gb_ht + gb_space
951  GroupBox gb_norm_alpha,pos={4,gb_top}
952  gb_ht = gb_internal_top
953  CheckBox cb_norm_alpha_enable,pos={73, gb_top + gb_ht + cb_adj},size={50,14}
954  gb_ht += line_space
955  PopupMenu pm_norm_alpha_mode,pos={36, gb_top + gb_ht + pm_adj},size={138,21}
956  Button b_norm_alpha_check,pos={186, gb_top + gb_ht + b_adj},size={80,20}
957  gb_ht += line_space
958  SetVariable sv_norm_alpha_smoothing,pos={22, gb_top + gb_ht + sv_adj},size={112,16}
959  Button b_norm_alpha_preview,pos={186, gb_top + gb_ht + b_adj},size={80,20}
960  gb_ht += line_space
961  gb_ht += gb_internal_bot
962  GroupBox gb_norm_alpha, size={272,gb_ht}
963 
964  gb_top += gb_ht + gb_space
965  GroupBox gb_norm_phi,pos={4,gb_top}
966  gb_ht = gb_internal_top
967  CheckBox cb_norm_phi_enable,pos={73, gb_top + gb_ht + cb_adj},size={50,14}
968  Button b_norm_phi_check,pos={186, gb_top + gb_ht + b_adj},size={80,20}
969  gb_ht += line_space
970  SetVariable sv_norm_phi_range,pos={15, gb_top + gb_ht + sv_adj},size={118,16}
971  Button b_norm_phi_preview,pos={186, gb_top + gb_ht + b_adj},size={80,20}
972  gb_ht += line_space
973  gb_ht += gb_internal_bot
974  GroupBox gb_norm_phi, size={272,gb_ht}
975 
976  gb_top += gb_ht + gb_space
977  GroupBox gb_norm_theta,pos={4,gb_top}
978  gb_ht = gb_internal_top
979  CheckBox cb_norm_theta_enable,pos={73, gb_top + gb_ht + cb_adj},size={50,14}
980  gb_ht += line_space
981  PopupMenu pm_norm_theta_mode,pos={35, gb_top + gb_ht + pm_adj},size={138,21}
982  Button b_norm_theta_check,pos={186, gb_top + gb_ht + b_adj},size={80,20}
983  gb_ht += line_space
984  SetVariable sv_norm_theta_smoothing,pos={21, gb_top + gb_ht + sv_adj},size={112,16}
985  Button b_norm_theta_preview,pos={186, gb_top + gb_ht + b_adj},size={80,20}
986  gb_ht += line_space
987  gb_ht += gb_internal_bot
988  GroupBox gb_norm_theta, size={272,gb_ht}
989 
990  gb_top += gb_ht + gb_space
991  GroupBox gb_norm_thetaphi,pos={4,gb_top}
992  gb_ht = gb_internal_top
993  CheckBox cb_norm_thetaphi_enable,pos={73, gb_top + gb_ht + cb_adj},size={50,14}
994  gb_ht += line_space
995  PopupMenu pm_norm_thetaphi_mode,pos={35, gb_top + gb_ht + pm_adj},size={138,21}
996  Button b_norm_thetaphi_check,pos={186, gb_top + gb_ht + b_adj},size={80,20}
997  gb_ht += line_space
998  SetVariable sv_norm_thetaphi_smoothing,pos={21, gb_top + gb_ht + sv_adj},size={112,16}
999  Button b_norm_thetaphi_preview,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1000  gb_ht += line_space
1001  gb_ht += gb_internal_bot
1002  GroupBox gb_norm_thetaphi, size={272,gb_ht}
1003 
1004  gb_top += gb_ht + gb_space
1005  GroupBox gb_output,pos={4,gb_top}
1006  gb_ht = gb_internal_top
1007  SetVariable sv_output_folding,pos={38, gb_top + gb_ht + sv_adj},size={95,16}
1008  Button b_output_calc,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1009  gb_ht += line_space
1010  SetVariable sv_output_horizon,pos={35, gb_top + gb_ht + sv_adj},size={98,16}
1011  Button b_output_duplicate,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1012  gb_ht += line_space
1013  PopupMenu pm_graph_projection,pos={24, gb_top + gb_ht + pm_adj},size={149,21}
1014  Button b_output_itx,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1015  gb_ht += line_space
1016  PopupMenu pm_graph_mode,pos={44, gb_top + gb_ht + pm_adj},size={129,21}
1017  Button b_output_etpi,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1018  gb_ht += line_space
1019  gb_ht += gb_internal_bot
1020  GroupBox gb_output, size={272,gb_ht}
1021 
1022  gb_top += gb_ht + gb_space
1023  GroupBox gb_graph,pos={4,gb_top}
1024  gb_ht = gb_internal_top
1025  PopupMenu pm_graph_colortable,pos={21, gb_top + gb_ht + pm_adj},size={152,21}
1026  Button b_graph_update,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1027  gb_ht += line_space
1028  SetVariable sv_graph_contrast,pos={14, gb_top + gb_ht + sv_adj},size={119,16}
1029  Button b_graph_png,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1030  gb_ht += line_space
1031  gb_ht += gb_internal_bot
1032  GroupBox gb_graph, size={272,gb_ht}
1033 };
1034 
1037 static variable update_menus(){
1038  dfref df = $(package_path)
1039  svar /sdfr=df panel_name
1040  if (wintype(panel_name) == 7)
1041  variable m
1042  nvar /sdfr=df norm_alpha_mode
1043  m = norm_alpha_mode + 1
1044  PopupMenu pm_norm_alpha_mode win=$panel_name, mode=m
1045  nvar /sdfr=df norm_theta_mode
1046  m = norm_theta_mode + 1
1047  PopupMenu pm_norm_theta_mode win=$panel_name, mode=m
1048  nvar /sdfr=df norm_thetaphi_mode
1049  m = norm_thetaphi_mode + 1
1050  PopupMenu pm_norm_thetaphi_mode win=$panel_name, mode=m
1051  nvar /sdfr=df graph_mode
1052  m = graph_mode + 1
1053  PopupMenu pm_graph_mode win=$panel_name, mode=m
1054  nvar /sdfr=df graph_projection
1055  m = graph_projection + 1
1056  PopupMenu pm_graph_projection win=$panel_name, mode=m
1057  svar /sdfr=df graph_colortable
1058  m = 1 + WhichListItem(graph_colortable, CTabList())
1059  PopupMenu pm_graph_colortable win=$panel_name, mode=m
1060  endif
1061 };
1062 
1063 static variable bp_source_select(WMButtonAction* ba){
1064  STRUCT WMButtonAction &ba
1065 
1066  switch( ba.eventCode )
1067  case 2:// mouse up
1068  dfref dfBefore = GetDataFolderDFR()
1069  Execute /q/z "CreateBrowser prompt=\"Select 2D holo scan wave\", showWaves=1, showVars=0, showStrs=0"
1070  dfref dfAfter = GetDataFolderDFR()
1071  SetDataFolder dfBefore
1072 
1073  SVAR list = S_BrowserList
1074  NVAR flag = V_Flag
1075  if ((flag != 0) && (ItemsInList(list) >= 1))
1076  string wname = StringFromList(0, list)
1077  wave w = $wname
1078  asp_import_raw(w)
1079  endif
1080 
1081  break
1082  case -1:// control being killed
1083  break
1084  endswitch
1085 
1086  return 0
1087 };
1088 
1089 static variable bp_norm_alpha_check(WMButtonAction* ba){
1090  STRUCT WMButtonAction &ba
1091 
1092  switch( ba.eventCode )
1093  case 2:// mouse up
1095  break
1096  case -1:// control being killed
1097  break
1098  endswitch
1099 
1100  return 0
1101 };
1102 
1103 static variable bp_norm_theta_check(WMButtonAction* ba){
1104  STRUCT WMButtonAction &ba
1105 
1106  switch( ba.eventCode )
1107  case 2:// mouse up
1109  break
1110  case -1:// control being killed
1111  break
1112  endswitch
1113 
1114  return 0
1115 };
1116 
1117 static variable bp_norm_phi_check(WMButtonAction* ba){
1118  STRUCT WMButtonAction &ba
1119 
1120  switch( ba.eventCode )
1121  case 2:// mouse up
1122  check_norm_phi()
1123  break
1124  case -1:// control being killed
1125  break
1126  endswitch
1127 
1128  return 0
1129 };
1130 
1131 static variable bp_norm_thetaphi_check(WMButtonAction* ba){
1132  STRUCT WMButtonAction &ba
1133 
1134  switch( ba.eventCode )
1135  case 2:// mouse up
1137  break
1138  case -1:// control being killed
1139  break
1140  endswitch
1141 
1142  return 0
1143 };
1144 
1145 static variable bp_crop_alpha_preview(WMButtonAction* ba){
1146  STRUCT WMButtonAction &ba
1147 
1148  switch( ba.eventCode )
1149  case 2:// mouse up
1151  break
1152  case -1:// control being killed
1153  break
1154  endswitch
1155 
1156  return 0
1157 };
1158 
1159 static variable bp_norm_alpha_preview(WMButtonAction* ba){
1160  STRUCT WMButtonAction &ba
1161 
1162  switch( ba.eventCode )
1163  case 2:// mouse up
1165  break
1166  case -1:// control being killed
1167  break
1168  endswitch
1169 
1170  return 0
1171 };
1172 
1173 static variable bp_norm_phi_preview(WMButtonAction* ba){
1174  STRUCT WMButtonAction &ba
1175 
1176  switch( ba.eventCode )
1177  case 2:// mouse up
1179  break
1180  case -1:// control being killed
1181  break
1182  endswitch
1183 
1184  return 0
1185 };
1186 
1187 static variable bp_norm_theta_preview(WMButtonAction* ba){
1188  STRUCT WMButtonAction &ba
1189 
1190  switch( ba.eventCode )
1191  case 2:// mouse up
1193  break
1194  case -1:// control being killed
1195  break
1196  endswitch
1197 
1198  return 0
1199 };
1200 
1201 static variable bp_norm_thetaphi_preview(WMButtonAction* ba){
1202  STRUCT WMButtonAction &ba
1203 
1204  switch( ba.eventCode )
1205  case 2:// mouse up
1207  break
1208  case -1:// control being killed
1209  break
1210  endswitch
1211 
1212  return 0
1213 };
1214 
1215 static variable bp_output_calc(WMButtonAction* ba){
1216  STRUCT WMButtonAction &ba
1217 
1218  switch( ba.eventCode )
1219  case 2:// mouse up
1222  break
1223  case -1:// control being killed
1224  break
1225  endswitch
1226 
1227  return 0
1228 };
1229 
1230 static variable bp_output_duplicate(WMButtonAction* ba){
1231  STRUCT WMButtonAction &ba
1232 
1233  switch( ba.eventCode )
1234  case 2:// mouse up
1235  string dest_folder
1236  prompt dest_folder, "destination folder name (relative to data source)"
1237  doprompt "duplicate", dest_folder
1238  if (!v_flag)
1239  asp_duplicate_output(dest_folder)
1240  endif
1241  break
1242  case -1:// control being killed
1243  break
1244  endswitch
1245 
1246  return 0
1247 };
1248 
1249 static variable bp_output_etpi(WMButtonAction* ba){
1250  STRUCT WMButtonAction &ba
1251 
1252  switch( ba.eventCode )
1253  case 2:// mouse up
1254  dfref df = $(package_path)
1255  wave /sdfr=df process_data
1256  variable ekin
1257  ekin = NumberByKey("KineticEnergy", note(process_data), "=", "\r")
1258  prompt ekin, "kinetic energy"
1259  doprompt "save etpi", ekin
1260  if (!v_flag)
1261  asp_save_output_etpi(ekin)
1262  endif
1263  break
1264  case -1:// control being killed
1265  break
1266  endswitch
1267 
1268  return 0
1269 };
1270 
1271 static variable bp_output_itx(WMButtonAction* ba){
1272  STRUCT WMButtonAction &ba
1273 
1274  switch( ba.eventCode )
1275  case 2:// mouse up
1277  break
1278  case -1:// control being killed
1279  break
1280  endswitch
1281 
1282  return 0
1283 };
1284 
1285 static variable bp_graph_update(WMButtonAction* ba){
1286  STRUCT WMButtonAction &ba
1287 
1288  switch( ba.eventCode )
1289  case 2:// mouse up
1291  break
1292  case -1:// control being killed
1293  break
1294  endswitch
1295 
1296  return 0
1297 };
1298 
1299 static variable bp_graph_png(WMButtonAction* ba){
1300  STRUCT WMButtonAction &ba
1301 
1302  switch( ba.eventCode )
1303  case 2:// mouse up
1304  dfref df = $(package_path)
1305  svar /sdfr=df source_path
1306  svar /sdfr=df output_graphname
1307  if (WinType(output_graphname) == 1)
1308  SavePICT /WIN=$output_graphname /E=-5 /B=144 /TRAN=0
1309  endif
1310  break
1311  case -1:// control being killed
1312  break
1313  endswitch
1314 
1315  return 0
1316 };
1317 
1318 static variable pmp_norm_alpha_mode(WMPopupAction* pa){
1319  STRUCT WMPopupAction &pa
1320 
1321  switch( pa.eventCode )
1322  case 2:// mouse up
1323  dfref df = $(package_path)
1324  nvar /sdfr=df norm_alpha_mode
1325  norm_alpha_mode = pa.popNum - 1
1326  break
1327  case -1:// control being killed
1328  break
1329  endswitch
1330 
1331  return 0
1332 };
1333 
1334 static variable pmp_norm_theta_mode(WMPopupAction* pa){
1335  STRUCT WMPopupAction &pa
1336 
1337  switch( pa.eventCode )
1338  case 2:// mouse up
1339  dfref df = $(package_path)
1340  nvar /sdfr=df norm_theta_mode
1341  norm_theta_mode = pa.popNum - 1
1342  break
1343  case -1:// control being killed
1344  break
1345  endswitch
1346 
1347  return 0
1348 };
1349 
1350 static variable pmp_norm_thetaphi_mode(WMPopupAction* pa){
1351  STRUCT WMPopupAction &pa
1352 
1353  switch( pa.eventCode )
1354  case 2:// mouse up
1355  dfref df = $(package_path)
1356  nvar /sdfr=df norm_thetaphi_mode
1357  norm_thetaphi_mode = pa.popNum - 1
1358  break
1359  case -1:// control being killed
1360  break
1361  endswitch
1362 
1363  return 0
1364 };
1365 
1366 static variable pmp_graph_mode(WMPopupAction* pa){
1367  STRUCT WMPopupAction &pa
1368 
1369  switch( pa.eventCode )
1370  case 2:// mouse up
1371  dfref df = $(package_path)
1372  nvar /sdfr=df graph_mode
1373  graph_mode = pa.popNum - 1
1374  break
1375  case -1:// control being killed
1376  break
1377  endswitch
1378 
1379  return 0
1380 };
1381 
1382 static variable pmp_graph_projection(WMPopupAction* pa){
1383  STRUCT WMPopupAction &pa
1384 
1385  switch( pa.eventCode )
1386  case 2:// mouse up
1387  dfref df = $(package_path)
1388  nvar /sdfr=df graph_projection
1389  graph_projection = pa.popNum - 1
1390  break
1391  case -1:// control being killed
1392  break
1393  endswitch
1394 
1395  return 0
1396 };
1397 
1398 static variable pmp_graph_colortable(WMPopupAction* pa){
1399  STRUCT WMPopupAction &pa
1400 
1401  switch( pa.eventCode )
1402  case 2:// mouse up
1403  dfref df = $(package_path)
1404  svar /sdfr=df graph_colortable
1405  graph_colortable = StringFromList(pa.popNum - 1, CTabList())
1407  break
1408  case -1:// control being killed
1409  break
1410  endswitch
1411 
1412  return 0
1413 };
1414 
static variable bp_norm_phi_preview(WMButtonAction *ba)
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
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.
static variable do_init_process(variable check)
initialize the process data with a copy of the raw data.
static variable preview_norm_alpha()
variable asp_calculate_output()
calculate the output using all enabled processing filters.
static variable check_norm_alpha()
variable asp_import_raw(wave raw_data)
import raw data
variable crop_strip(wave strip, variable xlo, variable xhi)
crop a strip at the sides.
variable ad_update_profiles(wave image)
update a profiles graph with new data.
variable asp_duplicate_output(string dest_name)
copy the output data to a new folder
variable asp_save_output_itx()
save the output diffractogram to an igor text file
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 pmp_graph_colortable(WMPopupAction *pa)
static variable save_prefs()
save persistent package data to the preferences file.
static variable bp_graph_update(WMButtonAction *ba)
dfr find_hemi_data(string nickname, string *prefix, string *intwave)
finds the folder, prefix and name of holo waves given their nick name
static variable bp_norm_alpha_preview(WMButtonAction *ba)
static variable preview_crop_alpha()
static variable pmp_norm_alpha_mode(WMPopupAction *pa)
static variable init_package()
static variable preview_norm_theta()
static variable bp_norm_thetaphi_check(WMButtonAction *ba)
static variable bp_norm_theta_preview(WMButtonAction *ba)
static variable do_crop_alpha(variable check, variable force=defaultValue)
alpha-crop the process data.
static const string package_path
data folder path
static variable bp_crop_alpha_preview(WMButtonAction *ba)
static variable do_norm_thetaphi(variable check, variable force=defaultValue)
theta,phi-normalize the process data.
static variable bp_output_etpi(WMButtonAction *ba)
variable asp_display_dist_check(variable xdist, variable ydist)
display a graph window of the distribution checks.
static variable bp_graph_png(WMButtonAction *ba)
static variable pmp_graph_mode(WMPopupAction *pa)
static variable preview_norm_phi()
static variable pmp_norm_theta_mode(WMPopupAction *pa)
static variable do_norm_phi(variable check, variable force=defaultValue)
phi-normalize the process data.
static variable bp_norm_thetaphi_preview(WMButtonAction *ba)
static variable do_norm_theta(variable check, variable force=defaultValue)
theta-normalize the process data.
static variable check_norm_phi()
static const string prefs_objects
semicolon-separated list of persistent variable, string, and wave names
variable asp_show_panel()
create the angle scan processing panel
static variable bp_output_calc(WMButtonAction *ba)
static variable arrange_controls()
static variable bp_norm_theta_check(WMButtonAction *ba)
variable save_hemi_scan(string nickname, string pathname, string filename)
save a hemispherical scan to an Igor text file
variable normalize_strip_phi(wave strip, wave theta, wave phi, variable theta_offset=defaultValue, variable theta_range=defaultValue, variable check=defaultValue)
divide the strip by a sine function in phi (wobble correction).
variable normalize_strip_thetaphi(wave strip, wave theta, wave phi, variable theta_offset=defaultValue, variable smooth_method=defaultValue, variable smooth_factor=defaultValue, variable check=defaultValue)
divide the strip by a smooth polar-azimuthal distribution.
const variable kProjStereo
static variable update_menus()
update the popup menus to reflect the values of the global variables
static variable bp_output_itx(WMButtonAction *ba)
variable asp_close_graphs()
close all graphs created by the angle scan panel
static variable do_norm_alpha(variable check, variable force=defaultValue)
alpha-normalize the process data.
string ad_display_profiles(wave image, string filter=defaultValue)
open a new profiles graph window.
static variable load_prefs()
load persistent package data from the preferences file.
static variable check_norm_theta()
variable set_contrast(variable pcmin, variable pcmax, string graphname=defaultValue, string colortable=defaultValue)
set the pseudocolor contrast by percentile.
variable asp_display_previews()
display a graph window of the processed data.
variable asp_save_output_etpi(variable ekin)
save the output diffractogram to a PMSCO ETPI file
static variable bp_output_duplicate(WMButtonAction *ba)
static variable bp_norm_alpha_check(WMButtonAction *ba)
static variable check_norm_thetaphi()
static variable bp_norm_phi_check(WMButtonAction *ba)
static variable bp_source_select(WMButtonAction *ba)
static variable AfterCompiledHook()
initialize package data once when the procedure is first loaded
variable asp_display_output()
display the output diffractogram in a new graph
variable duplicate_hemi_scan(string source_nickname, dfref dest_folder, string dest_nickname, variable xpdplot=defaultValue)
duplicate a hemispherical scan dataset.
static variable pmp_norm_thetaphi_mode(WMPopupAction *pa)
static variable preview_norm_thetaphi()
static const string package_name
package name is used as data folder name
variable asp_update_graph()
update graphs with new color table or contrast
interactive processing of angle scanned XPD data.
static variable pmp_graph_projection(WMPopupAction *pa)
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.