PEARL Procedures  rev-distro-2.0.0-0-gfda49c3-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  if (!DataFolderRefStatus(attrdf))
204  setdatafolder datadf
205  setdatafolder ::
206  dfref parentdf = GetDataFolderDFR()
207  dfref attrdf = parentdf:attr
208  endif
209  setdatafolder $(package_path)
210 
211  // todo : check dimensions and scales
212 
213  svar source_path
214  source_path = GetWavesDataFolder(raw_data, 2)
215 
216  duplicate /o raw_data, raw, process_data
217 
218  wave /sdfr=attrdf /z ManipulatorTheta
219  wave /sdfr=attrdf /z ManipulatorTilt
220  wave /sdfr=attrdf /z ManipulatorPhi
221  if (WaveExists(ManipulatorTheta) && WaveExists(ManipulatorTilt) && WaveExists(ManipulatorPhi))
222  duplicate /o attrdf:ManipulatorTheta, raw_theta, process_theta
223  duplicate /o attrdf:ManipulatorTilt, raw_tilt, process_tilt
224  duplicate /o attrdf:ManipulatorPhi, raw_phi, process_phi
225  else
226  DoAlert 0, "Can't find manipulator angle waves.\rCheck that the attr folder exists, or provide values in the following table."
227  make /n=(dimsize(raw_data, 1)) /o raw_theta, raw_tilt, raw_phi
228  make /n=(dimsize(raw_data, 1)) /o process_theta, process_tilt, process_phi
229  edit /k=1 raw_theta, raw_tilt, raw_phi
230  endif
231 
232  make /o /n=(dimsize(raw_data, 0)) dist_x, dist_x_smoo
233  make /o /n=(dimsize(raw_data, 1)) dist_y, dist_y_smoo
234 
235  SetDataFolder saveDF
236 };
237 
243  dfref df = $(package_path)
244  wave /sdfr=df process_data
245  svar /sdfr=df preview_graphname
246 
247  if (strlen(preview_graphname) && (wintype(preview_graphname) == 1))
248  ad_update_profiles(process_data)
249  DoWindow /F $preview_graphname
250  else
251  preview_graphname = ad_display_profiles(process_data)
252  endif
253 
254  nvar /sdfr=df graph_contrast
255  svar /sdfr=df graph_colortable
256  set_contrast(graph_contrast, graph_contrast, graphname=preview_graphname, colortable=graph_colortable)
257 };
258 
266 variable asp_display_dist_check(variable xdist, variable ydist){
267  variable xdist, ydist
268 
269  dfref df = $(package_path)
270  wave /sdfr=df dist_x
271  wave /sdfr=df dist_y
272  wave /sdfr=df dist_x_smoo
273  wave /sdfr=df dist_y_smoo
274  svar /sdfr=df dist_x_graphname
275  svar /sdfr=df dist_y_graphname
276 
277  if (xdist)
278  if (strlen(dist_x_graphname) && (wintype(dist_x_graphname) == 1))
279  DoWindow /F $dist_x_graphname
280  else
281  display /k=1 /n=graph_asp_dist_x dist_x, dist_x_smoo
282  dist_x_graphname = s_name
283  ModifyGraph /w=$dist_x_graphname mode(dist_x)=2
284  ModifyGraph /w=$dist_x_graphname lsize(dist_x)=2
285  ModifyGraph /w=$dist_x_graphname rgb(dist_x)=(0,0,0)
286  endif
287  endif
288 
289  if (ydist)
290  if (strlen(dist_y_graphname) && (wintype(dist_y_graphname) == 1))
291  DoWindow /F $dist_y_graphname
292  else
293  display /k=1 /n=graph_asp_dist_y dist_y, dist_y_smoo
294  dist_y_graphname = s_name
295  ModifyGraph /w=$dist_y_graphname mode(dist_y)=2
296  ModifyGraph /w=$dist_y_graphname lsize(dist_y)=2
297  ModifyGraph /w=$dist_y_graphname rgb(dist_y)=(0,0,0)
298  endif
299  endif
300 };
301 
311 static variable do_init_process(variable check){
312  variable check
313 
314  dfref df = $(package_path)
315  wave /sdfr=df raw
316  wave /sdfr=df raw_theta
317  wave /sdfr=df raw_tilt
318  wave /sdfr=df raw_phi
319  nvar /sdfr=df theta_offset
320  nvar /sdfr=df tilt_offset
321  nvar /sdfr=df phi_offset
322  nvar /sdfr=df alpha_offset
323 
324  duplicate /o raw, df:process_data
325  duplicate /o raw_theta, df:process_theta
326  duplicate /o raw_tilt, df:process_tilt
327  duplicate /o raw_phi, df:process_phi
328 
329  wave /sdfr=df process_data
330  wave /sdfr=df process_theta
331  wave /sdfr=df process_tilt
332  wave /sdfr=df process_phi
333 
334  process_theta = raw_theta - theta_offset
335  process_tilt = raw_tilt - tilt_offset
336  process_phi = raw_phi - phi_offset
337  setscale /p x dimoffset(raw, 0) - alpha_offset, dimdelta(raw, 0), waveunits(raw, 0), process_data
338 };
339 
351 static variable do_crop_alpha(variable check, variable force = defaultValue){
352  variable check
353  variable force
354 
355  if (ParamIsDefault(force))
356  force = 0
357  endif
358 
359  dfref df = $(package_path)
360  wave /sdfr=df process_data
361  nvar /sdfr=df crop_alpha_enable
362  nvar /sdfr=df crop_alpha_value
363 
364  if ((force || crop_alpha_enable) && (crop_alpha_value > abs(dimdelta(process_data, 0))))
365  crop_strip(process_data, -crop_alpha_value, +crop_alpha_value)
366  endif
367 };
368 
380 static variable do_norm_alpha(variable check, variable force = defaultValue){
381  variable check
382  variable force
383 
384  if (ParamIsDefault(force))
385  force = 0
386  endif
387 
388  dfref saveDF = GetDataFolderDFR()
389  dfref df = $(package_path)
390  wave /sdfr=df process_data
391  nvar /sdfr=df norm_alpha_enable
392  nvar /sdfr=df norm_alpha_mode
393  nvar /sdfr=df norm_alpha_smoothing
394 
395  if (force || norm_alpha_enable)
396  dfref temp_df = newfreedatafolder()
397  setdatafolder temp_df
398  normalize_strip_x(process_data, smooth_method=norm_alpha_mode, smooth_factor=norm_alpha_smoothing, check=check)
399  if (check)
400  wave check_dist
401  wave check_smoo
402  duplicate /o check_dist, df:dist_x
403  duplicate /o check_smoo, df:dist_x_smoo
404  endif
405  endif
406 
407  SetDataFolder saveDF
408 };
409 
421 static variable do_norm_phi(variable check, variable force = defaultValue){
422  variable check
423  variable force
424 
425  if (ParamIsDefault(force))
426  force = 0
427  endif
428 
429  dfref saveDF = GetDataFolderDFR()
430  dfref df = $(package_path)
431  wave /sdfr=df process_data
432  wave /sdfr=df process_theta
433  wave /sdfr=df process_phi
434  nvar /sdfr=df norm_phi_enable
435  nvar /sdfr=df norm_phi_mode
436  nvar /sdfr=df norm_phi_thetarange
437 
438  if (force || norm_phi_enable)
439  dfref temp_df = newfreedatafolder()
440  setdatafolder temp_df
441  normalize_strip_phi(process_data, process_theta, process_phi, theta_range=norm_phi_thetarange, check=check)
442  if (check)
443  wave check_dist
444  wave check_smoo
445  duplicate /o check_dist, df:dist_y
446  duplicate /o check_smoo, df:dist_y_smoo
447  endif
448  endif
449 
450  SetDataFolder saveDF
451 };
452 
464 static variable do_norm_theta(variable check, variable force = defaultValue){
465  variable check
466  variable force
467 
468  if (ParamIsDefault(force))
469  force = 0
470  endif
471 
472  dfref saveDF = GetDataFolderDFR()
473  dfref df = $(package_path)
474  wave /sdfr=df process_data
475  wave /sdfr=df process_theta
476  nvar /sdfr=df norm_theta_enable
477  nvar /sdfr=df norm_theta_mode
478  nvar /sdfr=df norm_theta_smoothing
479 
480  if (force || norm_theta_enable)
481  dfref temp_df = newfreedatafolder()
482  setdatafolder temp_df
483  normalize_strip_theta(process_data, process_theta, smooth_method=norm_theta_mode, smooth_factor=norm_theta_smoothing, check=check)
484  if (check)
485  wave check_dist
486  wave check_smoo
487  duplicate /o check_dist, df:dist_y
488  duplicate /o check_smoo, df:dist_y_smoo
489  endif
490  endif
491 
492  SetDataFolder saveDF
493 };
494 
506 static variable do_norm_thetaphi(variable check, variable force = defaultValue){
507  variable check
508  variable force
509 
510  if (ParamIsDefault(force))
511  force = 0
512  endif
513 
514  dfref saveDF = GetDataFolderDFR()
515  dfref df = $(package_path)
516  wave /sdfr=df process_data
517  wave /sdfr=df process_theta
518  wave /sdfr=df process_phi
519  nvar /sdfr=df norm_thetaphi_enable
520  nvar /sdfr=df norm_thetaphi_mode
521  nvar /sdfr=df norm_thetaphi_smoothing
522 
523  if (force || norm_thetaphi_enable)
524  dfref temp_df = newfreedatafolder()
525  setdatafolder temp_df
526  normalize_strip_thetaphi(process_data, process_theta, process_phi, smooth_method=norm_thetaphi_mode, smooth_factor=norm_thetaphi_smoothing, check=check)
527  if (check)
528  wave check_dist
529  wave check_smoo
530  duplicate /o check_dist, df:dist_y
531  duplicate /o check_smoo, df:dist_y_smoo
532  endif
533  endif
534 
535  SetDataFolder saveDF
536 };
537 
543  dfref saveDF = GetDataFolderDFR()
544  setdatafolder $(package_path)
545 
546  svar output_name
547 
548  wave process_data
549  wave process_theta
550  wave process_tilt
551  wave process_phi
552 
553  nvar folding=output_folding
554  nvar horizon=output_horizon
555 
556  do_init_process(0)
557  do_crop_alpha(0)
558  do_norm_alpha(0)
559  do_norm_phi(0)
560  do_norm_theta(0)
562 
563  pizza_service_2(process_data, output_name, process_theta, process_tilt, process_phi, folding=folding, nograph=1)
564 
565  setdatafolder $output_name
566  wave values
567  wave pol
568  if (horizon > 0)
569  values = pol <= horizon ? values : nan
570  endif
571 
572  SetDataFolder saveDF
573 };
574 
578  dfref df = $(package_path)
579 
580  svar /sdfr=df output_name
581  svar /sdfr=df output_graphname
582  nvar /sdfr=df graph_projection
583  nvar /sdfr=df graph_mode
584 
585  dfref saveDF = GetDataFolderDFR()
586  setdatafolder $(package_path)
587  output_graphname = output_name
588  output_graphname = display_hemi_scan(output_name, projection=graph_projection, graphtype=graph_mode, graphname=output_graphname)
589  SetDataFolder saveDF
591 };
592 
597 variable asp_update_graph(){
598  dfref df = $(package_path)
599 
600  svar /sdfr=df preview_graphname
601  svar /sdfr=df output_graphname
602  svar /sdfr=df graph_colortable
603  nvar /sdfr=df graph_contrast
604 
605  if (strlen(preview_graphname) && (wintype(preview_graphname) == 1))
606  set_contrast(graph_contrast, graph_contrast, graphname=preview_graphname, colortable=graph_colortable)
607  endif
608  if (strlen(output_graphname) && (wintype(output_graphname) == 1))
609  set_contrast(graph_contrast, graph_contrast, graphname=output_graphname, colortable=graph_colortable)
610  endif
611 };
612 
615 variable asp_close_graphs(){
616  dfref df = $(package_path)
617 
618  svar /sdfr=df preview_graphname
619  svar /sdfr=df output_graphname
620  svar /sdfr=df dist_x_graphname
621  svar /sdfr=df dist_y_graphname
622 
623  if (strlen(preview_graphname) && (wintype(preview_graphname) == 1))
624  killwindow $preview_graphname
625  endif
626  if (strlen(output_graphname) && (wintype(output_graphname) == 1))
627  killwindow $output_graphname
628  endif
629  if (strlen(dist_x_graphname) && (wintype(dist_x_graphname) == 1))
630  killwindow $dist_x_graphname
631  endif
632  if (strlen(dist_y_graphname) && (wintype(dist_y_graphname) == 1))
633  killwindow $dist_y_graphname
634  endif
635 
636  preview_graphname = ""
637  output_graphname = ""
638  dist_x_graphname = ""
639  dist_y_graphname = ""
640 };
641 
650 variable asp_duplicate_output(string dest_name){
651  string dest_name
652 
653  dfref df = $(package_path)
654  svar /sdfr=df source_path
655  svar /sdfr=df output_name
656  svar /sdfr=df output_graphname
657  wave raw_data = $source_path
658 
659  dfref saveDF = GetDataFolderDFR()
660  dfref dest_df = GetWavesDataFolderDFR(raw_data)
661  setdatafolder dest_df
662  newdatafolder /o /s $dest_name
663  dfref dest_df = GetDataFolderDFR()
664  setdatafolder df
665  duplicate_hemi_scan(output_name, dest_df, "")
666 
667  SetDataFolder saveDF
668 };
669 
673  dfref df = $(package_path)
674  svar /sdfr=df output_name
675 
676  dfref saveDF = GetDataFolderDFR()
677  setdatafolder df
678  save_hemi_scan(output_name, "", "")
679 
680  SetDataFolder saveDF
681 };
682 
687 variable asp_save_output_etpi(variable ekin){
688  variable ekin
689 
690  dfref df = $(package_path)
691  svar /sdfr=df output_name
692  wave /sdfr=df process_data
693 
694  dfref saveDF = GetDataFolderDFR()
695  setdatafolder df
696  string s_prefix = ""
697  string s_int = "values"
698  dfref data_df = find_hemi_data(output_name, s_prefix, s_int)
699  string s_polar = s_prefix + "pol"
700  string s_azim = s_prefix + "az"
701 
702  pmsco_save_scan("", "", num2str(ekin), s_polar, s_azim, "", s_int, "", sdfr=data_df)
703 
704  SetDataFolder saveDF
705 };
706 
707 static variable check_norm_alpha(){
708  do_init_process(0)
709  do_crop_alpha(0)
710  do_norm_alpha(2, force=1)
712 };
713 
714 static variable check_norm_phi(){
715  do_init_process(0)
716  do_crop_alpha(0)
717  do_norm_phi(2, force=1)
719 };
720 
721 static variable check_norm_theta(){
722  do_init_process(0)
723  do_crop_alpha(0)
724  do_norm_theta(2, force=1)
726 };
727 
728 static variable check_norm_thetaphi(){
729  do_init_process(0)
730  do_crop_alpha(0)
731  do_norm_thetaphi(2, force=1)
733 };
734 
735 static variable preview_crop_alpha(){
736  do_init_process(0)
737  do_crop_alpha(0, force=1)
739 };
740 
741 static variable preview_norm_alpha(){
742  do_init_process(0)
743  do_crop_alpha(0)
744  do_norm_alpha(1, force=1)
746 };
747 
748 static variable preview_norm_phi(){
749  do_init_process(0)
750  do_crop_alpha(0)
751  do_norm_phi(1, force=1)
753 };
754 
755 static variable preview_norm_theta(){
756  do_init_process(0)
757  do_crop_alpha(0)
758  do_norm_theta(1, force=1)
760 };
761 
762 static variable preview_norm_thetaphi(){
763  do_init_process(0)
764  do_crop_alpha(0)
765  do_norm_thetaphi(1, force=1)
767 };
768 
771 variable asp_show_panel(){
772  dfref df = $(package_path)
773  svar /sdfr=df panel_name
774 
775  if (strlen(panel_name) && (wintype(panel_name) == 7))
776  DoWindow /F $panel_name
777  return 0
778  endif
779 
780  NewPanel /K=1 /N=anglescan_panel /W=(200,100,479,1027) as "angle scan processing"
781  panel_name = s_name
782 
783  GroupBox gb_source, title="data source"
784  Button b_source_select, size={50,20},proc=PearlAnglescanPanel#bp_source_select,title="select..."
785  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."}
786  TitleBox tb_source_path, size={240,21}
787  TitleBox tb_source_path,variable= root:packages:pearl_anglescan_panel:source_path
788 
789  GroupBox gb_offsets, title="offsets"
790  SetVariable sv_theta_offset, size={88,16},bodyWidth=60,title="theta"
791  SetVariable sv_theta_offset,value= root:packages:pearl_anglescan_panel:theta_offset
792  SetVariable sv_theta_offset, help={"manipulator theta value that corresponds to normal emission."}
793  SetVariable sv_tilt_offset, size={74,16},bodyWidth=60,title="tilt"
794  SetVariable sv_tilt_offset,value= root:packages:pearl_anglescan_panel:tilt_offset
795  SetVariable sv_tilt_offset, help={"manipulator tilt value that corresponds to normal emission."}
796  SetVariable sv_phi_offset, size={78,16},bodyWidth=60,title="phi"
797  SetVariable sv_phi_offset,value= root:packages:pearl_anglescan_panel:phi_offset
798  SetVariable sv_phi_offset, help={"manipulator phi value that should map to the 3 o'clock angle."}
799  SetVariable sv_alpha_offset, size={90,16},bodyWidth=60,title="alpha"
800  SetVariable sv_alpha_offset,value= root:packages:pearl_anglescan_panel:alpha_offset
801  SetVariable sv_alpha_offset, help={"alpha value that corresponds to normal emission (if the sample normal is properly aligned)."}
802 
803  GroupBox gb_crop_alpha, title="crop alpha"
804  CheckBox cb_crop_alpha_enable, size={50,14}, title="enable"
805  CheckBox cb_crop_alpha_enable, help={"enable cropping at +/- alpha"}
806  CheckBox cb_crop_alpha_enable,variable= root:packages:pearl_anglescan_panel:crop_alpha_enable
807  SetVariable sv_crop_alpha_value, size={90,16},bodyWidth=60,title="angle"
808  SetVariable sv_crop_alpha_value,limits={0,30,1},value= root:packages:pearl_anglescan_panel:crop_alpha_value
809  SetVariable sv_crop_alpha_value, help={"alpha (detection angle) cropping angle"}
810  Button b_crop_alpha_preview, size={80,20},proc=PearlAnglescanPanel#bp_crop_alpha_preview,title="preview"
811  Button b_crop_alpha_preview, help={"show a preview of the cropped dataset."}
812 
813  GroupBox gb_norm_alpha, title="normalize alpha"
814  CheckBox cb_norm_alpha_enable, size={50,14}, title="enable"
815  CheckBox cb_norm_alpha_enable,variable= root:packages:pearl_anglescan_panel:norm_alpha_enable
816  CheckBox cb_norm_alpha_enable, help={"enable normalization of the alpha distribution"}
817  PopupMenu pm_norm_alpha_mode, size={138,21}, bodyWidth=100, proc=PearlAnglescanPanel#pmp_norm_alpha_mode,title="method"
818  PopupMenu pm_norm_alpha_mode, mode=5, popvalue="loess", value= #"\"none;binomial;boxcar;scienta;loess;\""
819  PopupMenu pm_norm_alpha_mode, help={"alpha normalization method. recommended: loess"}
820  SetVariable sv_norm_alpha_smoothing, size={112,16}, bodyWidth=60, title="smoothing"
821  SetVariable sv_norm_alpha_smoothing, limits={0,1,0.05}, value= root:packages:pearl_anglescan_panel:norm_alpha_smoothing
822  SetVariable sv_norm_alpha_smoothing, help={"smoothing parameter (depends on the normalization method)."}
823  Button b_norm_alpha_check, size={80,20}, proc=PearlAnglescanPanel#bp_norm_alpha_check,title="check"
824  Button b_norm_alpha_check, help={"show a graph of the normalization function"}
825  Button b_norm_alpha_preview, size={80,20}, proc=PearlAnglescanPanel#bp_norm_alpha_preview,title="preview"
826  Button b_norm_alpha_preview, help={"show a preview of the normalized dataset (without other normalizations)."}
827 
828  GroupBox gb_norm_phi, title="normalize phi"
829  CheckBox cb_norm_phi_enable, size={50,14}, title="enable"
830  CheckBox cb_norm_phi_enable,variable= root:packages:pearl_anglescan_panel:norm_phi_enable
831  CheckBox cb_norm_phi_enable, help={"enable normalization of the phi distribution to reduce the effect of wobble"}
832  SetVariable sv_norm_phi_range, size={118,16}, bodyWidth=60, title="theta range"
833  SetVariable sv_norm_phi_range, limits={0,90,1}, value= root:packages:pearl_anglescan_panel:norm_phi_thetarange
834  SetVariable sv_norm_phi_range, help={"theta range (from normal) to factor into the normalization function"}
835  Button b_norm_phi_check, size={80,20}, proc=PearlAnglescanPanel#bp_norm_phi_check, title="check"
836  Button b_norm_phi_check, help={"show a graph of the normalization function"}
837  Button b_norm_phi_preview, size={80,20}, proc=PearlAnglescanPanel#bp_norm_phi_preview, title="preview"
838  Button b_norm_phi_preview, help={"show a preview of the normalized dataset (without other normalizations)."}
839 
840  GroupBox gb_norm_theta, title="normalize theta"
841  CheckBox cb_norm_theta_enable, size={50,14},title="enable"
842  CheckBox cb_norm_theta_enable, variable= root:packages:pearl_anglescan_panel:norm_theta_enable
843  CheckBox cb_norm_theta_enable, help={"enable normalization of the theta distribution (integrated over phi)"}
844  PopupMenu pm_norm_theta_mode, size={138,21},bodyWidth=100,proc=PearlAnglescanPanel#pmp_norm_theta_mode,title="method"
845  PopupMenu pm_norm_theta_mode,mode=5,popvalue="loess",value= #"\"none;binomial;boxcar;polynomial;loess;\""
846  PopupMenu pm_norm_theta_mode, help={"theta normalization method. recommended: loess"}
847  SetVariable sv_norm_theta_smoothing, size={112,16}, bodyWidth=60, title="smoothing"
848  SetVariable sv_norm_theta_smoothing, limits={0,1,0.05}, value= root:packages:pearl_anglescan_panel:norm_theta_smoothing
849  SetVariable sv_norm_theta_smoothing, help={"smoothing parameter (depends on the normalization method)."}
850  Button b_norm_theta_check, size={80,20}, proc=PearlAnglescanPanel#bp_norm_theta_check, title="check"
851  Button b_norm_theta_check, help={"show a graph of the normalization function"}
852  Button b_norm_theta_preview, size={80,20}, proc=PearlAnglescanPanel#bp_norm_theta_preview, title="preview"
853  Button b_norm_theta_preview, help={"show a preview of the normalized dataset (without other normalizations)."}
854 
855  GroupBox gb_norm_thetaphi, size={272,97},title="normalize (theta,phi)"
856  CheckBox cb_norm_thetaphi_enable, size={50,14},title="enable"
857  CheckBox cb_norm_thetaphi_enable, variable= root:packages:pearl_anglescan_panel:norm_thetaphi_enable
858  CheckBox cb_norm_thetaphi_enable, help={"enable normalization of the (theta, phi) distribution."}
859  PopupMenu pm_norm_thetaphi_mode, size={138,21}, bodyWidth=100, proc=PearlAnglescanPanel#pmp_norm_thetaphi_mode,title="method"
860  PopupMenu pm_norm_thetaphi_mode, mode=5, popvalue="loess", value= #"\"none;none;none;none;loess;\""
861  PopupMenu pm_norm_thetaphi_mode, help={"theta normalization method. recommended: loess"}
862  SetVariable sv_norm_thetaphi_smoothing, size={112,16}, bodyWidth=60, title="smoothing"
863  SetVariable sv_norm_thetaphi_smoothing, limits={0,1,0.05}, value= root:packages:pearl_anglescan_panel:norm_thetaphi_smoothing
864  SetVariable sv_norm_thetaphi_smoothing, help={"smoothing parameter (depends on the normalization method)."}
865  Button b_norm_thetaphi_check, size={80,20}, proc=PearlAnglescanPanel#bp_norm_thetaphi_check, title="check"
866  Button b_norm_thetaphi_check, help={"show a graph of the normalization function"}
867  Button b_norm_thetaphi_preview, size={80,20}, proc=PearlAnglescanPanel#bp_norm_thetaphi_preview, title="preview"
868  Button b_norm_thetaphi_preview, help={"show a preview of the normalized dataset (without other normalizations)."}
869 
870  GroupBox gb_output, title="output"
871  SetVariable sv_output_folding, size={95,16}, bodyWidth=60, title="folding"
872  SetVariable sv_output_folding, limits={1,20,1}, value= root:packages:pearl_anglescan_panel:output_folding
873  SetVariable sv_output_folding, help={"n-fold rotational average. 1=no averaging."}
874  SetVariable sv_output_horizon, size={98,16}, bodyWidth=60, title="horizon"
875  SetVariable sv_output_horizon, limits={1,90,1}, value= root:packages:pearl_anglescan_panel:output_horizon
876  SetVariable sv_output_horizon, help={"highest theta to display"}
877  PopupMenu pm_graph_projection, size={149,21}, bodyWidth=100, proc=PearlAnglescanPanel#pmp_graph_projection, title="projection"
878  PopupMenu pm_graph_projection, mode=2, popvalue="stereographic", value= #"\"equidistant;stereographic;equal area;gnomonic;orthographic;\""
879  PopupMenu pm_graph_projection, help={"projection (theta mapping) mode"}
880  PopupMenu pm_graph_mode, size={129,21}, bodyWidth=100, proc=PearlAnglescanPanel#pmp_graph_mode,title="mode"
881  PopupMenu pm_graph_mode, mode=2, popvalue="polar plot", value= #"\"none;polar plot;none;image;\""
882  PopupMenu pm_graph_mode, help={"graph mode"}
883  Button b_output_calc, size={80,20}, proc=PearlAnglescanPanel#bp_output_calc, title="calc + display"
884  Button b_output_calc, help={"execute data processing with the enabled filters and display the diffractogram."}
885  Button b_output_duplicate, size={80,20}, proc=PearlAnglescanPanel#bp_output_duplicate, title="duplicate ..."
886  Button b_output_duplicate, help={"copy the result to an arbitrary data folder."}
887  Button b_output_itx, size={80,20}, proc=PearlAnglescanPanel#bp_output_itx, title="save ITX ..."
888  Button b_output_itx, help={"save the result to an igor text file (itx)."}
889  Button b_output_etpi, size={80,20}, proc=PearlAnglescanPanel#bp_output_etpi, title="save ETPI ..."
890  Button b_output_etpi, help={"save the result to a pmsco angle scan file (etpi)."}
891 
892  GroupBox gb_graph, title="graph"
893  PopupMenu pm_graph_colortable, size={152,21}, bodyWidth=100, proc=PearlAnglescanPanel#pmp_graph_colortable, title="color table"
894  PopupMenu pm_graph_colortable, mode=0, value= #"\"*COLORTABLEPOPNONAMES*\""
895  PopupMenu pm_graph_colortable, help={"color table to use in pseudocolor graphs."}
896  SetVariable sv_graph_contrast, size={119,16}, bodyWidth=60, title="contrast (%)"
897  SetVariable sv_graph_contrast, limits={0,25,1}, value= root:packages:pearl_anglescan_panel:graph_contrast
898  SetVariable sv_graph_contrast, help={"contrast value (percentile)."}
899  Button b_graph_update, size={80,20}, proc=PearlAnglescanPanel#bp_graph_update, title="update"
900  Button b_graph_update, help={"update the existing graph."}
901  Button b_graph_png, size={80,20}, proc=PearlAnglescanPanel#bp_graph_png, title="save PNG ..."
902  Button b_graph_png, help={"save the graph in png format."}
903 
905  update_menus()
906 };
907 
908 static variable arrange_controls(){
909  dfref df = $(package_path)
910  svar /sdfr=df panel_name
911 
912  variable gb_space = 2
913  variable gb_internal_top = 20
914  variable gb_internal_bot = 8
915  variable line_space = 26
916 
917  variable cb_adj = 2
918  variable sv_adj = 2
919  variable pm_adj = 0
920  variable b_adj = 0
921  variable tb_adj = 0
922 
923  variable gb_top = 4
924  variable gb_ht = 0
925 
926  // ht = line + 30
927  // gb = gb + ht + 2
928  // cb = gb + 18
929  // pm = gb + 38
930  // line += 26
931  // sv = line + 2
932 
933  GroupBox gb_source,pos={4,gb_top}
934  gb_ht = gb_internal_top
935  Button b_source_select,pos={17, gb_top + gb_ht + b_adj},size={50,20}
936  gb_ht += line_space
937  TitleBox tb_source_path,pos={18, gb_top + gb_ht + tb_adj},size={240,21}
938  gb_ht += line_space
939  gb_ht += gb_internal_bot
940  GroupBox gb_source, size={272,gb_ht}
941 
942  gb_top += gb_ht + gb_space
943  GroupBox gb_offsets,pos={4,gb_top}
944  gb_ht = gb_internal_top
945  SetVariable sv_theta_offset,pos={46, gb_top + gb_ht + sv_adj},size={88,16}
946  gb_ht += line_space
947  SetVariable sv_tilt_offset,pos={60, gb_top + gb_ht + sv_adj},size={74,16}
948  gb_ht += line_space
949  SetVariable sv_phi_offset,pos={56, gb_top + gb_ht + sv_adj},size={78,16}
950  gb_ht += line_space
951  SetVariable sv_alpha_offset,pos={44, gb_top + gb_ht + sv_adj},size={90,16}
952  gb_ht += line_space
953  gb_ht += gb_internal_bot
954  GroupBox gb_offsets, size={272,gb_ht}
955 
956  gb_top += gb_ht + gb_space
957  GroupBox gb_crop_alpha,pos={4,gb_top}
958  gb_ht = gb_internal_top
959  CheckBox cb_crop_alpha_enable,pos={73, gb_top + gb_ht + cb_adj},size={50,14}
960  gb_ht += line_space
961  SetVariable sv_crop_alpha_value,pos={44, gb_top + gb_ht + sv_adj},size={90,16}
962  Button b_crop_alpha_preview,pos={186, gb_top + gb_ht + b_adj},size={80,20}
963  gb_ht += line_space
964  gb_ht += gb_internal_bot
965  GroupBox gb_crop_alpha, size={272,gb_ht}
966 
967  gb_top += gb_ht + gb_space
968  GroupBox gb_norm_alpha,pos={4,gb_top}
969  gb_ht = gb_internal_top
970  CheckBox cb_norm_alpha_enable,pos={73, gb_top + gb_ht + cb_adj},size={50,14}
971  gb_ht += line_space
972  PopupMenu pm_norm_alpha_mode,pos={36, gb_top + gb_ht + pm_adj},size={138,21}
973  Button b_norm_alpha_check,pos={186, gb_top + gb_ht + b_adj},size={80,20}
974  gb_ht += line_space
975  SetVariable sv_norm_alpha_smoothing,pos={22, gb_top + gb_ht + sv_adj},size={112,16}
976  Button b_norm_alpha_preview,pos={186, gb_top + gb_ht + b_adj},size={80,20}
977  gb_ht += line_space
978  gb_ht += gb_internal_bot
979  GroupBox gb_norm_alpha, size={272,gb_ht}
980 
981  gb_top += gb_ht + gb_space
982  GroupBox gb_norm_phi,pos={4,gb_top}
983  gb_ht = gb_internal_top
984  CheckBox cb_norm_phi_enable,pos={73, gb_top + gb_ht + cb_adj},size={50,14}
985  Button b_norm_phi_check,pos={186, gb_top + gb_ht + b_adj},size={80,20}
986  gb_ht += line_space
987  SetVariable sv_norm_phi_range,pos={15, gb_top + gb_ht + sv_adj},size={118,16}
988  Button b_norm_phi_preview,pos={186, gb_top + gb_ht + b_adj},size={80,20}
989  gb_ht += line_space
990  gb_ht += gb_internal_bot
991  GroupBox gb_norm_phi, size={272,gb_ht}
992 
993  gb_top += gb_ht + gb_space
994  GroupBox gb_norm_theta,pos={4,gb_top}
995  gb_ht = gb_internal_top
996  CheckBox cb_norm_theta_enable,pos={73, gb_top + gb_ht + cb_adj},size={50,14}
997  gb_ht += line_space
998  PopupMenu pm_norm_theta_mode,pos={35, gb_top + gb_ht + pm_adj},size={138,21}
999  Button b_norm_theta_check,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1000  gb_ht += line_space
1001  SetVariable sv_norm_theta_smoothing,pos={21, gb_top + gb_ht + sv_adj},size={112,16}
1002  Button b_norm_theta_preview,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1003  gb_ht += line_space
1004  gb_ht += gb_internal_bot
1005  GroupBox gb_norm_theta, size={272,gb_ht}
1006 
1007  gb_top += gb_ht + gb_space
1008  GroupBox gb_norm_thetaphi,pos={4,gb_top}
1009  gb_ht = gb_internal_top
1010  CheckBox cb_norm_thetaphi_enable,pos={73, gb_top + gb_ht + cb_adj},size={50,14}
1011  gb_ht += line_space
1012  PopupMenu pm_norm_thetaphi_mode,pos={35, gb_top + gb_ht + pm_adj},size={138,21}
1013  Button b_norm_thetaphi_check,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1014  gb_ht += line_space
1015  SetVariable sv_norm_thetaphi_smoothing,pos={21, gb_top + gb_ht + sv_adj},size={112,16}
1016  Button b_norm_thetaphi_preview,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1017  gb_ht += line_space
1018  gb_ht += gb_internal_bot
1019  GroupBox gb_norm_thetaphi, size={272,gb_ht}
1020 
1021  gb_top += gb_ht + gb_space
1022  GroupBox gb_output,pos={4,gb_top}
1023  gb_ht = gb_internal_top
1024  SetVariable sv_output_folding,pos={38, gb_top + gb_ht + sv_adj},size={95,16}
1025  Button b_output_calc,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1026  gb_ht += line_space
1027  SetVariable sv_output_horizon,pos={35, gb_top + gb_ht + sv_adj},size={98,16}
1028  Button b_output_duplicate,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1029  gb_ht += line_space
1030  PopupMenu pm_graph_projection,pos={24, gb_top + gb_ht + pm_adj},size={149,21}
1031  Button b_output_itx,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1032  gb_ht += line_space
1033  PopupMenu pm_graph_mode,pos={44, gb_top + gb_ht + pm_adj},size={129,21}
1034  Button b_output_etpi,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1035  gb_ht += line_space
1036  gb_ht += gb_internal_bot
1037  GroupBox gb_output, size={272,gb_ht}
1038 
1039  gb_top += gb_ht + gb_space
1040  GroupBox gb_graph,pos={4,gb_top}
1041  gb_ht = gb_internal_top
1042  PopupMenu pm_graph_colortable,pos={21, gb_top + gb_ht + pm_adj},size={152,21}
1043  Button b_graph_update,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1044  gb_ht += line_space
1045  SetVariable sv_graph_contrast,pos={14, gb_top + gb_ht + sv_adj},size={119,16}
1046  Button b_graph_png,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1047  gb_ht += line_space
1048  gb_ht += gb_internal_bot
1049  GroupBox gb_graph, size={272,gb_ht}
1050 };
1051 
1054 static variable update_menus(){
1055  dfref df = $(package_path)
1056  svar /sdfr=df panel_name
1057  if (wintype(panel_name) == 7)
1058  variable m
1059  nvar /sdfr=df norm_alpha_mode
1060  m = norm_alpha_mode + 1
1061  PopupMenu pm_norm_alpha_mode win=$panel_name, mode=m
1062  nvar /sdfr=df norm_theta_mode
1063  m = norm_theta_mode + 1
1064  PopupMenu pm_norm_theta_mode win=$panel_name, mode=m
1065  nvar /sdfr=df norm_thetaphi_mode
1066  m = norm_thetaphi_mode + 1
1067  PopupMenu pm_norm_thetaphi_mode win=$panel_name, mode=m
1068  nvar /sdfr=df graph_mode
1069  m = graph_mode + 1
1070  PopupMenu pm_graph_mode win=$panel_name, mode=m
1071  nvar /sdfr=df graph_projection
1072  m = graph_projection + 1
1073  PopupMenu pm_graph_projection win=$panel_name, mode=m
1074  svar /sdfr=df graph_colortable
1075  m = 1 + WhichListItem(graph_colortable, CTabList())
1076  PopupMenu pm_graph_colortable win=$panel_name, mode=m
1077  endif
1078 };
1079 
1080 static variable bp_source_select(WMButtonAction* ba){
1081  STRUCT WMButtonAction &ba
1082 
1083  switch( ba.eventCode )
1084  case 2:// mouse up
1085  dfref dfBefore = GetDataFolderDFR()
1086  Execute /q/z "CreateBrowser prompt=\"Select 2D holo scan wave\", showWaves=1, showVars=0, showStrs=0"
1087  dfref dfAfter = GetDataFolderDFR()
1088  SetDataFolder dfBefore
1089 
1090  SVAR list = S_BrowserList
1091  NVAR flag = V_Flag
1092  if ((flag != 0) && (ItemsInList(list) >= 1))
1093  string wname = StringFromList(0, list)
1094  wave w = $wname
1095  asp_import_raw(w)
1096  endif
1097 
1098  break
1099  case -1:// control being killed
1100  break
1101  endswitch
1102 
1103  return 0
1104 };
1105 
1106 static variable bp_norm_alpha_check(WMButtonAction* ba){
1107  STRUCT WMButtonAction &ba
1108 
1109  switch( ba.eventCode )
1110  case 2:// mouse up
1112  break
1113  case -1:// control being killed
1114  break
1115  endswitch
1116 
1117  return 0
1118 };
1119 
1120 static variable bp_norm_theta_check(WMButtonAction* ba){
1121  STRUCT WMButtonAction &ba
1122 
1123  switch( ba.eventCode )
1124  case 2:// mouse up
1126  break
1127  case -1:// control being killed
1128  break
1129  endswitch
1130 
1131  return 0
1132 };
1133 
1134 static variable bp_norm_phi_check(WMButtonAction* ba){
1135  STRUCT WMButtonAction &ba
1136 
1137  switch( ba.eventCode )
1138  case 2:// mouse up
1139  check_norm_phi()
1140  break
1141  case -1:// control being killed
1142  break
1143  endswitch
1144 
1145  return 0
1146 };
1147 
1148 static variable bp_norm_thetaphi_check(WMButtonAction* ba){
1149  STRUCT WMButtonAction &ba
1150 
1151  switch( ba.eventCode )
1152  case 2:// mouse up
1154  break
1155  case -1:// control being killed
1156  break
1157  endswitch
1158 
1159  return 0
1160 };
1161 
1162 static variable bp_crop_alpha_preview(WMButtonAction* ba){
1163  STRUCT WMButtonAction &ba
1164 
1165  switch( ba.eventCode )
1166  case 2:// mouse up
1168  break
1169  case -1:// control being killed
1170  break
1171  endswitch
1172 
1173  return 0
1174 };
1175 
1176 static variable bp_norm_alpha_preview(WMButtonAction* ba){
1177  STRUCT WMButtonAction &ba
1178 
1179  switch( ba.eventCode )
1180  case 2:// mouse up
1182  break
1183  case -1:// control being killed
1184  break
1185  endswitch
1186 
1187  return 0
1188 };
1189 
1190 static variable bp_norm_phi_preview(WMButtonAction* ba){
1191  STRUCT WMButtonAction &ba
1192 
1193  switch( ba.eventCode )
1194  case 2:// mouse up
1196  break
1197  case -1:// control being killed
1198  break
1199  endswitch
1200 
1201  return 0
1202 };
1203 
1204 static variable bp_norm_theta_preview(WMButtonAction* ba){
1205  STRUCT WMButtonAction &ba
1206 
1207  switch( ba.eventCode )
1208  case 2:// mouse up
1210  break
1211  case -1:// control being killed
1212  break
1213  endswitch
1214 
1215  return 0
1216 };
1217 
1218 static variable bp_norm_thetaphi_preview(WMButtonAction* ba){
1219  STRUCT WMButtonAction &ba
1220 
1221  switch( ba.eventCode )
1222  case 2:// mouse up
1224  break
1225  case -1:// control being killed
1226  break
1227  endswitch
1228 
1229  return 0
1230 };
1231 
1232 static variable bp_output_calc(WMButtonAction* ba){
1233  STRUCT WMButtonAction &ba
1234 
1235  switch( ba.eventCode )
1236  case 2:// mouse up
1239  break
1240  case -1:// control being killed
1241  break
1242  endswitch
1243 
1244  return 0
1245 };
1246 
1247 static variable bp_output_duplicate(WMButtonAction* ba){
1248  STRUCT WMButtonAction &ba
1249 
1250  switch( ba.eventCode )
1251  case 2:// mouse up
1252  string dest_folder
1253  prompt dest_folder, "destination folder name (relative to data source)"
1254  doprompt "duplicate", dest_folder
1255  if (!v_flag)
1256  asp_duplicate_output(dest_folder)
1257  endif
1258  break
1259  case -1:// control being killed
1260  break
1261  endswitch
1262 
1263  return 0
1264 };
1265 
1266 static variable bp_output_etpi(WMButtonAction* ba){
1267  STRUCT WMButtonAction &ba
1268 
1269  switch( ba.eventCode )
1270  case 2:// mouse up
1271  dfref df = $(package_path)
1272  wave /sdfr=df process_data
1273  variable ekin
1274  ekin = NumberByKey("KineticEnergy", note(process_data), "=", "\r")
1275  prompt ekin, "kinetic energy"
1276  doprompt "save etpi", ekin
1277  if (!v_flag)
1278  asp_save_output_etpi(ekin)
1279  endif
1280  break
1281  case -1:// control being killed
1282  break
1283  endswitch
1284 
1285  return 0
1286 };
1287 
1288 static variable bp_output_itx(WMButtonAction* ba){
1289  STRUCT WMButtonAction &ba
1290 
1291  switch( ba.eventCode )
1292  case 2:// mouse up
1294  break
1295  case -1:// control being killed
1296  break
1297  endswitch
1298 
1299  return 0
1300 };
1301 
1302 static variable bp_graph_update(WMButtonAction* ba){
1303  STRUCT WMButtonAction &ba
1304 
1305  switch( ba.eventCode )
1306  case 2:// mouse up
1308  break
1309  case -1:// control being killed
1310  break
1311  endswitch
1312 
1313  return 0
1314 };
1315 
1316 static variable bp_graph_png(WMButtonAction* ba){
1317  STRUCT WMButtonAction &ba
1318 
1319  switch( ba.eventCode )
1320  case 2:// mouse up
1321  dfref df = $(package_path)
1322  svar /sdfr=df source_path
1323  svar /sdfr=df output_graphname
1324  if (WinType(output_graphname) == 1)
1325  SavePICT /WIN=$output_graphname /E=-5 /B=144 /TRAN=0
1326  endif
1327  break
1328  case -1:// control being killed
1329  break
1330  endswitch
1331 
1332  return 0
1333 };
1334 
1335 static variable pmp_norm_alpha_mode(WMPopupAction* pa){
1336  STRUCT WMPopupAction &pa
1337 
1338  switch( pa.eventCode )
1339  case 2:// mouse up
1340  dfref df = $(package_path)
1341  nvar /sdfr=df norm_alpha_mode
1342  norm_alpha_mode = pa.popNum - 1
1343  break
1344  case -1:// control being killed
1345  break
1346  endswitch
1347 
1348  return 0
1349 };
1350 
1351 static variable pmp_norm_theta_mode(WMPopupAction* pa){
1352  STRUCT WMPopupAction &pa
1353 
1354  switch( pa.eventCode )
1355  case 2:// mouse up
1356  dfref df = $(package_path)
1357  nvar /sdfr=df norm_theta_mode
1358  norm_theta_mode = pa.popNum - 1
1359  break
1360  case -1:// control being killed
1361  break
1362  endswitch
1363 
1364  return 0
1365 };
1366 
1367 static variable pmp_norm_thetaphi_mode(WMPopupAction* pa){
1368  STRUCT WMPopupAction &pa
1369 
1370  switch( pa.eventCode )
1371  case 2:// mouse up
1372  dfref df = $(package_path)
1373  nvar /sdfr=df norm_thetaphi_mode
1374  norm_thetaphi_mode = pa.popNum - 1
1375  break
1376  case -1:// control being killed
1377  break
1378  endswitch
1379 
1380  return 0
1381 };
1382 
1383 static variable pmp_graph_mode(WMPopupAction* pa){
1384  STRUCT WMPopupAction &pa
1385 
1386  switch( pa.eventCode )
1387  case 2:// mouse up
1388  dfref df = $(package_path)
1389  nvar /sdfr=df graph_mode
1390  graph_mode = pa.popNum - 1
1391  break
1392  case -1:// control being killed
1393  break
1394  endswitch
1395 
1396  return 0
1397 };
1398 
1399 static variable pmp_graph_projection(WMPopupAction* pa){
1400  STRUCT WMPopupAction &pa
1401 
1402  switch( pa.eventCode )
1403  case 2:// mouse up
1404  dfref df = $(package_path)
1405  nvar /sdfr=df graph_projection
1406  graph_projection = pa.popNum - 1
1407  break
1408  case -1:// control being killed
1409  break
1410  endswitch
1411 
1412  return 0
1413 };
1414 
1415 static variable pmp_graph_colortable(WMPopupAction* pa){
1416  STRUCT WMPopupAction &pa
1417 
1418  switch( pa.eventCode )
1419  case 2:// mouse up
1420  dfref df = $(package_path)
1421  svar /sdfr=df graph_colortable
1422  graph_colortable = StringFromList(pa.popNum - 1, CTabList())
1424  break
1425  case -1:// control being killed
1426  break
1427  endswitch
1428 
1429  return 0
1430 };
1431 
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.