PEARL Procedures  rev-distro-3.0.0-0-gfa24916-dirty
Igor procedures for the analysis of PEARL data
pearl-anglescan-panel.ipf
Go to the documentation of this file.
1 #pragma TextEncoding = "UTF-8"
2 #pragma rtGlobals=3 // Use modern global access method and strict wave access.
3 #pragma version = 1.8
4 #pragma IgorVersion = 6.2
5 #pragma ModuleName = PearlAnglescanPanel
6 #include "pearl-anglescan-process"
7 #include "pearl-pmsco-import"
8 #include "pearl-scienta-preprocess"
9 #include "pearl-area-display"
10 
11 // copyright (c) 2018-20 Paul Scherrer Institut
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 // http:///www.apache.org/licenses/LICENSE-2.0
17 //
18 // Please acknowledge the use of this code.
19 
41 
46 
48 static strconstant package_name = "pearl_anglescan_panel"
50 static strconstant package_path = "root:packages:pearl_anglescan_panel:"
51 
53 static function AfterCompiledHook()
54 
55  dfref savedf = GetDataFolderDFR()
56  variable do_init = 1
57  if (DataFolderExists(package_path))
58  setdatafolder $(package_path)
59  nvar /z init_done
60  if (nvar_exists(init_done))
61  if (init_done)
62  do_init = 0
63  endif
64  endif
65  endif
66 
67  if (do_init)
68  init_package()
69  load_prefs()
70  setdatafolder $(package_path)
71  variable /g init_done = 1
72  endif
73 
74  setdatafolder savedf
75  return 0
76 end
77 
78 static function init_package()
79  dfref savedf = getdatafolderdfr()
80  setdatafolder root:
81  newdatafolder /o/s packages
82  newdatafolder /o/s $package_name
83 
84  // configuration (persistent)
85  string /g graphname = "graph_anglescan_panel"
86  string /g prefs_objects = "prefs_objects;theta_offset;tilt_offset;phi_offset;alpha_offset;crop_enable;crop_alpha;crop_theta;"
87  prefs_objects += "norm_alpha_enable;norm_alpha_mode;norm_alpha_smoothing;norm_phi_enable;norm_phi_mode;norm_phi_thetarange;"
88  prefs_objects += "norm_theta_enable;norm_theta_mode;norm_theta_domain;norm_theta_smoothing;norm_thetaphi_enable;norm_thetaphi_mode;norm_thetaphi_smoothing;"
89  prefs_objects += "output_folding;output_horizon;graph_mode;graph_projection;graph_colortable;graph_contrast;"
90 
91  // recently used (persistent)
92  variable /g theta_offset = 0
93  variable /g tilt_offset = 0
94  variable /g phi_offset = 0
95  variable /g alpha_offset = 0
96  variable /g crop_enable = 0
97  variable /g crop_alpha = 25
98  variable /g crop_theta = 88
99  string /g crop_rows = ""
100  variable /g norm_alpha_enable = 0
101  variable /g norm_alpha_mode = 4
102  variable /g norm_alpha_smoothing = 0.25
103  variable /g norm_theta_enable = 0
104  variable /g norm_theta_mode = 4
105  variable /g norm_theta_domain = 0
106  variable /g norm_theta_smoothing = 0.25
107  variable /g norm_thetaphi_enable = 0
108  variable /g norm_thetaphi_mode = 4
109  variable /g norm_thetaphi_smoothing = 0.25
110  variable /g norm_phi_enable = 0
111  variable /g norm_phi_mode = 4
112  variable /g norm_phi_thetarange = 20
113  string /g output_name = "holo1"
114  variable /g output_folding = 1
115  variable /g output_horizon = 88
116  variable /g graph_mode = 1
117  variable /g graph_projection = kProjStereo
118  string /g graph_colortable = "grays"
119  variable /g graph_contrast = 2
120 
121  // recently used (volatile)
122  string /g source_path = ""
123  string /g export_folderpath = "root:"
124  variable /g export_format = 1
125 
126  // administrative data (volatile)
127  string /g panel_name = ""
128  string /g preview_graphname = ""
129  string /g dist_x_graphname = ""
130  string /g dist_y_graphname = ""
131  string /g output_graphname = ""
132 
133  // data (volatile)
134  make /n=(10,10) /o raw_data, process_data
135  make /o dist_x, dist_x_smoo
136  make /o dist_y, dist_y_smoo
137 
138  setdatafolder savedf
139 end
140 
145 static function save_prefs()
146  dfref saveDF = GetDataFolderDFR()
147  dfref df = $(package_path)
148  svar /sdfr=df prefs_objects
149 
150  string fullPath = SpecialDirPath("Packages", 0, 0, 0)
151  fullPath += package_name
152  NewPath/O/C/Q tempPackagePrefsPath, fullPath
153  fullPath += ":preferences.pxp"
154 
155  SetDataFolder root:packages
156  SetDataFolder $package_name
157  SaveData /O /Q /J=prefs_objects fullPath
158 
159  KillPath/Z tempPackagePrefsPath
160 
161  SetDataFolder saveDF
162 end
163 
171 static function load_prefs()
172  dfref saveDF = GetDataFolderDFR()
173 
174  variable result = -1
175  setdatafolder root:
176  NewDataFolder /O/S packages
177  NewDataFolder /O/S $package_name
178  string fullPath = SpecialDirPath("Packages", 0, 0, 0)
179  fullPath += package_name
180 
181  GetFileFolderInfo /Q /Z fullPath
182  if (V_Flag == 0) // Disk directory exists?
183  fullPath += ":preferences.pxp"
184  GetFileFolderInfo /Q /Z fullPath
185  if (V_Flag == 0) // Preference file exist?
186  LoadData /O /R /Q fullPath
187  result = 0
188  endif
189  endif
190 
191  SetDataFolder saveDF
192  return result
193 end
194 
207 function asp_import_raw(raw_data)
208  wave raw_data
209 
210  dfref saveDF = GetDataFolderDFR()
211  dfref datadf = GetWavesDataFolderDFR(raw_data)
212  dfref attrdf = datadf:attr
213  if (!DataFolderRefStatus(attrdf))
214  setdatafolder datadf
215  setdatafolder ::
216  dfref parentdf = GetDataFolderDFR()
217  dfref attrdf = parentdf:attr
218  endif
219  setdatafolder $(package_path)
220 
221  // todo : check dimensions and scales
222 
223  svar source_path
224  source_path = GetWavesDataFolder(raw_data, 2)
225 
226  duplicate /o raw_data, raw, process_data
227 
228  wave /sdfr=attrdf /z ManipulatorTheta
229  wave /sdfr=attrdf /z ManipulatorTilt
230  wave /sdfr=attrdf /z ManipulatorPhi
231  if (WaveExists(ManipulatorTheta) && WaveExists(ManipulatorTilt) && WaveExists(ManipulatorPhi))
232  duplicate /o attrdf:ManipulatorTheta, raw_theta, process_theta
233  duplicate /o attrdf:ManipulatorTilt, raw_tilt, process_tilt
234  duplicate /o attrdf:ManipulatorPhi, raw_phi, process_phi
235  else
236  DoAlert 0, "Can't find manipulator angle waves.\rCheck that the attr folder exists, or provide values in the following table."
237  make /n=(dimsize(raw_data, 1)) /o raw_theta, raw_tilt, raw_phi
238  make /n=(dimsize(raw_data, 1)) /o process_theta, process_tilt, process_phi
239  edit /k=1 raw_theta, raw_tilt, raw_phi
240  endif
241 
242  make /o /n=(dimsize(raw_data, 0)) dist_x, dist_x_smoo
243  make /o /n=(dimsize(raw_data, 1)) dist_y, dist_y_smoo
244 
245  SetDataFolder saveDF
246 end
247 
253  dfref df = $(package_path)
254  wave /sdfr=df process_data
255  svar /sdfr=df preview_graphname
256 
257  if (strlen(preview_graphname) && (wintype(preview_graphname) == 1))
258  ad_update_profiles(process_data)
259  DoWindow /F $preview_graphname
260  else
261  preview_graphname = ad_display_profiles(process_data)
262  endif
263 
264  nvar /sdfr=df graph_contrast
265  svar /sdfr=df graph_colortable
266  set_contrast(graph_contrast, graph_contrast, graphname=preview_graphname, colortable=graph_colortable)
267 end
268 
276 function asp_display_dist_check(xdist, ydist)
277  variable xdist, ydist
278 
279  dfref df = $(package_path)
280  wave /sdfr=df dist_x
281  wave /sdfr=df dist_y
282  wave /sdfr=df dist_x_smoo
283  wave /sdfr=df dist_y_smoo
284  svar /sdfr=df dist_x_graphname
285  svar /sdfr=df dist_y_graphname
286 
287  if (xdist)
288  if (strlen(dist_x_graphname) && (wintype(dist_x_graphname) == 1))
289  DoWindow /F $dist_x_graphname
290  else
291  display /k=1 /n=graph_asp_dist_x dist_x, dist_x_smoo
292  dist_x_graphname = s_name
293  ModifyGraph /w=$dist_x_graphname mode(dist_x)=2
294  ModifyGraph /w=$dist_x_graphname lsize(dist_x)=2
295  ModifyGraph /w=$dist_x_graphname rgb(dist_x)=(0,0,0)
296  endif
297  endif
298 
299  if (ydist)
300  if (strlen(dist_y_graphname) && (wintype(dist_y_graphname) == 1))
301  DoWindow /F $dist_y_graphname
302  else
303  display /k=1 /n=graph_asp_dist_y dist_y, dist_y_smoo
304  dist_y_graphname = s_name
305  ModifyGraph /w=$dist_y_graphname mode(dist_y)=2
306  ModifyGraph /w=$dist_y_graphname lsize(dist_y)=2
307  ModifyGraph /w=$dist_y_graphname rgb(dist_y)=(0,0,0)
308  endif
309  endif
310 end
311 
321 static function do_init_process(check)
322  variable check
323 
324  dfref df = $(package_path)
325  wave /sdfr=df raw
326  wave /sdfr=df raw_theta
327  wave /sdfr=df raw_tilt
328  wave /sdfr=df raw_phi
329  nvar /sdfr=df theta_offset
330  nvar /sdfr=df tilt_offset
331  nvar /sdfr=df phi_offset
332  nvar /sdfr=df alpha_offset
333 
334  duplicate /o raw, df:process_data
335  duplicate /o raw_theta, df:process_theta
336  duplicate /o raw_tilt, df:process_tilt
337  duplicate /o raw_phi, df:process_phi
338 
339  wave /sdfr=df process_data
340  wave /sdfr=df process_theta
341  wave /sdfr=df process_tilt
342  wave /sdfr=df process_phi
343 
344  process_theta = raw_theta - theta_offset
345  process_tilt = raw_tilt - tilt_offset
346  process_phi = raw_phi - phi_offset
347  setscale /p x dimoffset(raw, 0) - alpha_offset, dimdelta(raw, 0), waveunits(raw, 0), process_data
348 end
349 
361 static function do_crop(check, [force])
362  variable check
363  variable force
364 
365  if (ParamIsDefault(force))
366  force = 0
367  endif
368 
369  dfref df = $(package_path)
370  wave /sdfr=df process_data
371  wave /sdfr=df process_theta
372  wave /sdfr=df process_tilt
373  wave /sdfr=df process_phi
374  nvar /sdfr=df crop_enable
375  nvar /sdfr=df crop_alpha
376  nvar /sdfr=df crop_theta
377  svar /sdfr=df crop_rows
378 
379  if (force || crop_enable)
380 
381  if (crop_alpha > abs(dimdelta(process_data, 0)))
382  crop_strip(process_data, -crop_alpha, +crop_alpha)
383  endif
384 
385  if ((crop_theta >= 10) && (crop_theta < 90))
386  crop_strip_theta(process_data, -0.1, crop_theta + 0.1, process_theta, process_tilt, process_phi)
387  endif
388 
389  if (strlen(crop_rows) > 0)
390  delete_rows(crop_rows, process_data, process_theta, process_tilt, process_phi)
391  endif
392  endif
393 end
394 
409 static function delete_rows(rows, data, theta, tilt, phi)
410  string rows
411  wave data
412  wave theta
413  wave tilt
414  wave phi
415 
416  make /n=(numpnts(theta)) /i /free idx
417  idx = p
418  variable nrows = ItemsInList(rows, ",")
419  variable irow
420  string srow
421  variable q1, q2
422  for (irow = 0; irow < nrows; irow += 1)
423  srow = StringFromList(irow, rows, ",")
424  q1 = str2num(StringFromList(0, srow, "-"))
425  q2 = str2num(StringFromList(1, srow, "-"))
426  if (numtype(q2))
427  q2 = q1
428  endif
429  if (q1 <= q2)
430  idx[q1,q2] = -1
431  endif
432  endfor
433  extract /free idx, idx, idx >= 0
434  variable nx = dimsize(data, 0)
435  variable ny = numpnts(idx)
436  theta[0,ny-1] = theta[idx]
437  tilt[0,ny-1] = tilt[idx]
438  phi[0,ny-1] = phi[idx]
439  redimension /n=(ny) theta, tilt, phi
440  duplicate /free data, data_copy
441  redimension /n=(nx,ny) data
442  data = data_copy[p][idx[q]]
443 end
444 
456 static function do_norm_alpha(check, [force])
457  variable check
458  variable force
459 
460  if (ParamIsDefault(force))
461  force = 0
462  endif
463 
464  dfref saveDF = GetDataFolderDFR()
465  dfref df = $(package_path)
466  wave /sdfr=df process_data
467  nvar /sdfr=df norm_alpha_enable
468  nvar /sdfr=df norm_alpha_mode
469  nvar /sdfr=df norm_alpha_smoothing
470 
471  if (force || norm_alpha_enable)
472  dfref temp_df = newfreedatafolder()
473  setdatafolder temp_df
474  normalize_strip_x(process_data, smooth_method=norm_alpha_mode, smooth_factor=norm_alpha_smoothing, check=check)
475  if (check)
476  wave check_dist
477  wave check_smoo
478  duplicate /o check_dist, df:dist_x
479  duplicate /o check_smoo, df:dist_x_smoo
480  endif
481  endif
482 
483  SetDataFolder saveDF
484 end
485 
497 static function do_norm_phi(check, [force])
498  variable check
499  variable force
500 
501  if (ParamIsDefault(force))
502  force = 0
503  endif
504 
505  dfref saveDF = GetDataFolderDFR()
506  dfref df = $(package_path)
507  wave /sdfr=df process_data
508  wave /sdfr=df process_theta
509  wave /sdfr=df process_phi
510  nvar /sdfr=df norm_phi_enable
511  nvar /sdfr=df norm_phi_mode
512  nvar /sdfr=df norm_phi_thetarange
513 
514  if (force || norm_phi_enable)
515  dfref temp_df = newfreedatafolder()
516  setdatafolder temp_df
517  normalize_strip_phi(process_data, process_theta, process_phi, theta_range=norm_phi_thetarange, check=check)
518  if (check)
519  wave check_dist
520  wave check_smoo
521  duplicate /o check_dist, df:dist_y
522  duplicate /o check_smoo, df:dist_y_smoo
523  endif
524  endif
525 
526  SetDataFolder saveDF
527 end
528 
540 static function do_norm_theta(check, [force])
541  variable check
542  variable force
543 
544  if (ParamIsDefault(force))
545  force = 0
546  endif
547 
548  dfref saveDF = GetDataFolderDFR()
549  dfref df = $(package_path)
550  wave /sdfr=df process_data
551  wave /sdfr=df process_theta
552  nvar /sdfr=df norm_theta_enable
553  nvar /sdfr=df norm_theta_mode
554  nvar /sdfr=df norm_theta_domain
555  nvar /sdfr=df norm_theta_smoothing
556 
557  if (force || norm_theta_enable)
558  dfref temp_df = newfreedatafolder()
559  setdatafolder temp_df
560  if (norm_theta_domain==1)
561  normalize_strip_theta_scans(process_data, process_theta, smooth_method=norm_theta_mode, smooth_factor=norm_theta_smoothing, check=check)
562  else
563  normalize_strip_theta(process_data, process_theta, smooth_method=norm_theta_mode, smooth_factor=norm_theta_smoothing, check=check)
564  endif
565  if (check)
566  wave check_dist
567  wave check_smoo
568  duplicate /o check_dist, df:dist_y
569  duplicate /o check_smoo, df:dist_y_smoo
570  endif
571  endif
572 
573  SetDataFolder saveDF
574 end
575 
587 static function do_norm_thetaphi(check, [force])
588  variable check
589  variable force
590 
591  if (ParamIsDefault(force))
592  force = 0
593  endif
594 
595  dfref saveDF = GetDataFolderDFR()
596  dfref df = $(package_path)
597  wave /sdfr=df process_data
598  wave /sdfr=df process_theta
599  wave /sdfr=df process_phi
600  nvar /sdfr=df norm_thetaphi_enable
601  nvar /sdfr=df norm_thetaphi_mode
602  nvar /sdfr=df norm_thetaphi_smoothing
603 
604  if (force || norm_thetaphi_enable)
605  dfref temp_df = newfreedatafolder()
606  setdatafolder temp_df
607  normalize_strip_thetaphi(process_data, process_theta, process_phi, smooth_method=norm_thetaphi_mode, smooth_factor=norm_thetaphi_smoothing, check=check)
608  if (check)
609  wave check_dist
610  wave check_smoo
611  duplicate /o check_dist, df:dist_y
612  duplicate /o check_smoo, df:dist_y_smoo
613  endif
614  endif
615 
616  SetDataFolder saveDF
617 end
618 
624  dfref saveDF = GetDataFolderDFR()
625  setdatafolder $(package_path)
626 
627  svar output_name
628 
629  wave process_data
630  wave process_theta
631  wave process_tilt
632  wave process_phi
633 
634  nvar folding=output_folding
635  nvar horizon=output_horizon
636 
637  do_init_process(0)
638  do_crop(0)
639  do_norm_alpha(0)
640  do_norm_phi(0)
641  do_norm_theta(0)
643 
644  pizza_service_2(process_data, output_name, process_theta, process_tilt, process_phi, folding=folding, nograph=1)
645 
646  setdatafolder $output_name
647  wave values
648  wave pol
649  if (horizon > 0)
650  values = pol <= horizon ? values : nan
651  endif
652 
653  SetDataFolder saveDF
654 end
655 
669 function /s asp_display_output([data_df, data_name])
670  dfref data_df
671  string data_name
672 
673  dfref pkg_df = $(package_path)
674  svar /sdfr=pkg_df output_name
675  svar /sdfr=pkg_df output_graphname
676  nvar /sdfr=pkg_df graph_projection
677  nvar /sdfr=pkg_df graph_mode
678  svar /sdfr=pkg_df graph_colortable
679  nvar /sdfr=pkg_df graph_contrast
680 
681  if (ParamIsDefault(data_df))
682  dfref data_df = pkg_df
683  endif
684  if (ParamIsDefault(data_name))
685  data_name = output_name
686  endif
687 
688  dfref saveDF = GetDataFolderDFR()
689  setdatafolder data_df
690 
691  if (graph_mode == 3)
692  interpolate_hemi_scan(data_name, projection=graph_projection)
693  endif
694 
695  string graphname = data_name
696  graphname = display_hemi_scan(data_name, projection=graph_projection, graphtype=graph_mode, graphname=graphname)
697  if (ParamIsDefault(data_df))
698  output_graphname = graphname
699  endif
700  SetDataFolder saveDF
701 
702  if (strlen(graphname) && (wintype(graphname) == 1))
703  set_contrast(graph_contrast, graph_contrast, graphname=graphname, colortable=graph_colortable)
704  endif
705 
706  return graphname
707 end
708 
714  dfref df = $(package_path)
715 
716  svar /sdfr=df preview_graphname
717  svar /sdfr=df output_graphname
718  svar /sdfr=df graph_colortable
719  nvar /sdfr=df graph_contrast
720 
721  if (strlen(preview_graphname) && (wintype(preview_graphname) == 1))
722  set_contrast(graph_contrast, graph_contrast, graphname=preview_graphname, colortable=graph_colortable)
723  endif
724  if (strlen(output_graphname) && (wintype(output_graphname) == 1))
725  set_contrast(graph_contrast, graph_contrast, graphname=output_graphname, colortable=graph_colortable)
726  endif
727 end
728 
732  dfref df = $(package_path)
733 
734  svar /sdfr=df preview_graphname
735  svar /sdfr=df output_graphname
736  svar /sdfr=df dist_x_graphname
737  svar /sdfr=df dist_y_graphname
738 
739  if (strlen(preview_graphname) && (wintype(preview_graphname) == 1))
740  killwindow $preview_graphname
741  endif
742  if (strlen(output_graphname) && (wintype(output_graphname) == 1))
743  killwindow $output_graphname
744  endif
745  if (strlen(dist_x_graphname) && (wintype(dist_x_graphname) == 1))
746  killwindow $dist_x_graphname
747  endif
748  if (strlen(dist_y_graphname) && (wintype(dist_y_graphname) == 1))
749  killwindow $dist_y_graphname
750  endif
751 
752  preview_graphname = ""
753  output_graphname = ""
754  dist_x_graphname = ""
755  dist_y_graphname = ""
756 end
757 
771 function /s asp_duplicate_output(dest_name, [do_graph])
772  string dest_name
773  variable do_graph
774 
775  if (ParamIsDefault(do_graph))
776  do_graph = 0
777  endif
778 
779  dfref df = $(package_path)
780  svar /sdfr=df source_path
781  svar /sdfr=df output_name
782  svar /sdfr=df output_graphname
783  wave raw_data = $source_path
784 
785  dfref saveDF = GetDataFolderDFR()
786  dfref raw_df = GetWavesDataFolderDFR(raw_data)
787  setdatafolder raw_df
788  newdatafolder /o /s $dest_name
789  dfref dest_df = GetDataFolderDFR()
790  setdatafolder df
791  duplicate_hemi_scan(output_name, dest_df, "")
792 
793  string graphname = ""
794  if (do_graph)
795  graphname = asp_display_output(data_df=raw_df, data_name=dest_name)
796  endif
797 
798  SetDataFolder saveDF
799  return graphname
800 end
801 
805  dfref df = $(package_path)
806  svar /sdfr=df output_name
807 
808  dfref saveDF = GetDataFolderDFR()
809  setdatafolder df
810  save_hemi_scan(output_name, "", "")
811 
812  SetDataFolder saveDF
813 end
814 
819 function asp_save_output_etpi(ekin)
820  variable ekin
821 
822  dfref df = $(package_path)
823  svar /sdfr=df output_name
824  wave /sdfr=df process_data
825 
826  dfref saveDF = GetDataFolderDFR()
827  setdatafolder df
828  string s_prefix = ""
829  string s_int = "values"
830  dfref data_df = find_hemi_data(output_name, s_prefix, s_int)
831  string s_polar = s_prefix + "pol"
832  string s_azim = s_prefix + "az"
833 
834  pmsco_save_scan("", "", num2str(ekin), s_polar, s_azim, "", s_int, "", sdfr=data_df)
835 
836  SetDataFolder saveDF
837 end
838 
839 static function check_norm_alpha()
840  do_init_process(0)
841  do_crop(0)
842  do_norm_alpha(2, force=1)
844 end
845 
846 static function check_norm_phi()
847  do_init_process(0)
848  do_crop(0)
849  do_norm_phi(2, force=1)
851 end
852 
853 static function check_norm_theta()
854  do_init_process(0)
855  do_crop(0)
856  do_norm_theta(2, force=1)
858 end
859 
860 static function check_norm_thetaphi()
861  do_init_process(0)
862  do_crop(0)
863  do_norm_thetaphi(2, force=1)
865 end
866 
867 static function preview_crop()
868  do_init_process(0)
869  do_crop(0, force=1)
871 end
872 
873 static function preview_norm_alpha()
874  do_init_process(0)
875  do_crop(0)
876  do_norm_alpha(1, force=1)
878 end
879 
880 static function preview_norm_phi()
881  do_init_process(0)
882  do_crop(0)
883  do_norm_phi(1, force=1)
885 end
886 
887 static function preview_norm_theta()
888  do_init_process(0)
889  do_crop(0)
890  do_norm_theta(1, force=1)
892 end
893 
894 static function preview_norm_thetaphi()
895  do_init_process(0)
896  do_crop(0)
897  do_norm_thetaphi(1, force=1)
899 end
900 
903 function asp_show_panel()
904  dfref df = $(package_path)
905  svar /sdfr=df panel_name
906 
907  if (strlen(panel_name) && (wintype(panel_name) == 7))
908  DoWindow /F $panel_name
909  return 0
910  endif
911 
912  NewPanel /K=1 /N=anglescan_panel /W=(200,50,480,874) as "angle scan processing"
913  panel_name = s_name
914 
915  GroupBox gb_source, title="data source"
916  Button b_source_select, size={50,20},proc=PearlAnglescanPanel#bp_source_select,title="select..."
917  Button b_source_select, help={"select the source wave, e.g. ReducedData1. it must be in the scan or region data folder. the attr folder with the manipulator waves must be in the same folder or one level up."}
918  Button b_source_update, size={50,20},proc=PearlAnglescanPanel#bp_source_update,title="update"
919  Button b_source_update, help={"reload the process data from the previous source (link displayed below)"}
920  TitleBox tb_source_path, size={240,21}
921  TitleBox tb_source_path,variable= root:packages:pearl_anglescan_panel:source_path
922 
923  GroupBox gb_offsets, title="offsets"
924  SetVariable sv_theta_offset, size={88,16},bodyWidth=60,title="theta"
925  SetVariable sv_theta_offset,value= root:packages:pearl_anglescan_panel:theta_offset
926  SetVariable sv_theta_offset, help={"manipulator theta value that corresponds to normal emission."}
927  SetVariable sv_tilt_offset, size={74,16},bodyWidth=60,title="tilt"
928  SetVariable sv_tilt_offset,value= root:packages:pearl_anglescan_panel:tilt_offset
929  SetVariable sv_tilt_offset, help={"manipulator tilt value that corresponds to normal emission."}
930  SetVariable sv_phi_offset, size={78,16},bodyWidth=60,title="phi"
931  SetVariable sv_phi_offset,value= root:packages:pearl_anglescan_panel:phi_offset
932  SetVariable sv_phi_offset, help={"manipulator phi value that should map to the 3 o'clock angle."}
933  SetVariable sv_alpha_offset, size={90,16},bodyWidth=60,title="alpha"
934  SetVariable sv_alpha_offset,value= root:packages:pearl_anglescan_panel:alpha_offset
935  SetVariable sv_alpha_offset, help={"alpha value that corresponds to normal emission (if the sample normal is properly aligned)."}
936  Button b_save_prefs, size={80,20},proc=PearlAnglescanPanel#bp_save_prefs,title="save prefs"
937  Button b_save_prefs, help={"save settings as preferences."}
938  Button b_load_prefs, size={80,20},proc=PearlAnglescanPanel#bp_load_prefs,title="load prefs"
939  Button b_load_prefs, help={"load settings from preferences."}
940 
941  GroupBox gb_crop, title="crop and delete"
942  CheckBox cb_crop_enable, size={50,14}, title="enable"
943  CheckBox cb_crop_enable, help={"crop at +/-alpha and +theta, delete arbitrary rows"}
944  CheckBox cb_crop_enable, variable= root:packages:pearl_anglescan_panel:crop_enable
945  SetVariable sv_crop_alpha, size={90,16},bodyWidth=60,title="alpha"
946  SetVariable sv_crop_alpha, limits={0,30,1},value= root:packages:pearl_anglescan_panel:crop_alpha
947  SetVariable sv_crop_alpha, help={"alpha (detection angle) cropping angle (positive boundary), relative to normal emission"}
948  SetVariable sv_crop_theta, size={90,16},bodyWidth=60,title="theta"
949  SetVariable sv_crop_theta, limits={10,90,1},value= root:packages:pearl_anglescan_panel:crop_theta
950  SetVariable sv_crop_theta, help={"theta (polar angle) upper limit, relative to normal emission"}
951  SetVariable sv_crop_rows, size={200,16},bodyWidth=160,title="rows"
952  SetVariable sv_crop_rows, limits={10,90,1},value= root:packages:pearl_anglescan_panel:crop_rows
953  SetVariable sv_crop_rows, help={"rows to delete from the raw data. comma-separated point indices, hyphen for range."}
954  Button b_crop_preview, size={80,20},proc=PearlAnglescanPanel#bp_crop_preview,title="preview"
955  Button b_crop_preview, help={"show a preview of the cropped dataset."}
956 
957  GroupBox gb_norm_alpha, title="normalize alpha"
958  CheckBox cb_norm_alpha_enable, size={50,14}, title="enable"
959  CheckBox cb_norm_alpha_enable,variable= root:packages:pearl_anglescan_panel:norm_alpha_enable
960  CheckBox cb_norm_alpha_enable, help={"enable normalization of the alpha distribution"}
961  PopupMenu pm_norm_alpha_mode, size={138,21}, bodyWidth=100, proc=PearlAnglescanPanel#pmp_norm_alpha_mode,title="method"
962  PopupMenu pm_norm_alpha_mode, mode=5, popvalue="loess", value= #"\"none;binomial;boxcar;scienta;loess;\""
963  PopupMenu pm_norm_alpha_mode, help={"alpha normalization method. recommended: loess"}
964  SetVariable sv_norm_alpha_smoothing, size={112,16}, bodyWidth=60, title="smoothing"
965  SetVariable sv_norm_alpha_smoothing, limits={0,1,0.05}, value= root:packages:pearl_anglescan_panel:norm_alpha_smoothing
966  SetVariable sv_norm_alpha_smoothing, help={"smoothing parameter (depends on the normalization method)."}
967  Button b_norm_alpha_check, size={80,20}, proc=PearlAnglescanPanel#bp_norm_alpha_check,title="check"
968  Button b_norm_alpha_check, help={"show a graph of the normalization function"}
969  Button b_norm_alpha_preview, size={80,20}, proc=PearlAnglescanPanel#bp_norm_alpha_preview,title="preview"
970  Button b_norm_alpha_preview, help={"show a preview of the normalized dataset (without other normalizations)."}
971 
972  GroupBox gb_norm_phi, title="normalize phi"
973  CheckBox cb_norm_phi_enable, size={50,14}, title="enable"
974  CheckBox cb_norm_phi_enable,variable= root:packages:pearl_anglescan_panel:norm_phi_enable
975  CheckBox cb_norm_phi_enable, help={"enable normalization of the phi distribution to reduce the effect of wobble"}
976  SetVariable sv_norm_phi_range, size={118,16}, bodyWidth=60, title="theta range"
977  SetVariable sv_norm_phi_range, limits={0,90,1}, value= root:packages:pearl_anglescan_panel:norm_phi_thetarange
978  SetVariable sv_norm_phi_range, help={"theta range (from normal) to factor into the normalization function"}
979  Button b_norm_phi_check, size={80,20}, proc=PearlAnglescanPanel#bp_norm_phi_check, title="check"
980  Button b_norm_phi_check, help={"show a graph of the normalization function"}
981  Button b_norm_phi_preview, size={80,20}, proc=PearlAnglescanPanel#bp_norm_phi_preview, title="preview"
982  Button b_norm_phi_preview, help={"show a preview of the normalized dataset (without other normalizations)."}
983 
984  GroupBox gb_norm_theta, title="normalize theta"
985  CheckBox cb_norm_theta_enable, size={50,14},title="enable"
986  CheckBox cb_norm_theta_enable, variable= root:packages:pearl_anglescan_panel:norm_theta_enable
987  CheckBox cb_norm_theta_enable, help={"enable normalization of the theta distribution (integrated over phi)"}
988  PopupMenu pm_norm_theta_domain, size={138,21}, bodyWidth=100, proc=PearlAnglescanPanel#pmp_norm_theta_domain, title="domain"
989  PopupMenu pm_norm_theta_domain, mode=5, popvalue="loess", value= #"\"global;scans;\""
990  PopupMenu pm_norm_theta_domain, help={"smoothing domain: global or individual scans. use global unless there is a stronga or irregular phi variation."}
991  PopupMenu pm_norm_theta_mode, size={138,21},bodyWidth=100,proc=PearlAnglescanPanel#pmp_norm_theta_mode,title="method"
992  PopupMenu pm_norm_theta_mode,mode=5,popvalue="loess",value= #"\"none;binomial;boxcar;polynomial;loess;\""
993  PopupMenu pm_norm_theta_mode, help={"theta normalization method. recommended: loess"}
994  SetVariable sv_norm_theta_smoothing, size={112,16}, bodyWidth=60, title="smoothing"
995  SetVariable sv_norm_theta_smoothing, limits={0,1,0.05}, value= root:packages:pearl_anglescan_panel:norm_theta_smoothing
996  SetVariable sv_norm_theta_smoothing, help={"smoothing parameter (depends on the normalization method)."}
997  Button b_norm_theta_check, size={80,20}, proc=PearlAnglescanPanel#bp_norm_theta_check, title="check"
998  Button b_norm_theta_check, help={"show a graph of the normalization function"}
999  Button b_norm_theta_preview, size={80,20}, proc=PearlAnglescanPanel#bp_norm_theta_preview, title="preview"
1000  Button b_norm_theta_preview, help={"show a preview of the normalized dataset (without other normalizations)."}
1001 
1002  GroupBox gb_norm_thetaphi, size={272,97},title="normalize (theta,phi)"
1003  CheckBox cb_norm_thetaphi_enable, size={50,14},title="enable"
1004  CheckBox cb_norm_thetaphi_enable, variable= root:packages:pearl_anglescan_panel:norm_thetaphi_enable
1005  CheckBox cb_norm_thetaphi_enable, help={"enable normalization of the (theta, phi) distribution."}
1006  PopupMenu pm_norm_thetaphi_mode, size={138,21}, bodyWidth=100, proc=PearlAnglescanPanel#pmp_norm_thetaphi_mode,title="method"
1007  PopupMenu pm_norm_thetaphi_mode, mode=5, popvalue="loess", value= #"\"none;none;none;none;loess;\""
1008  PopupMenu pm_norm_thetaphi_mode, help={"theta normalization method. recommended: loess"}
1009  SetVariable sv_norm_thetaphi_smoothing, size={112,16}, bodyWidth=60, title="smoothing"
1010  SetVariable sv_norm_thetaphi_smoothing, limits={0,1,0.05}, value= root:packages:pearl_anglescan_panel:norm_thetaphi_smoothing
1011  SetVariable sv_norm_thetaphi_smoothing, help={"smoothing parameter (depends on the normalization method)."}
1012  Button b_norm_thetaphi_check, size={80,20}, proc=PearlAnglescanPanel#bp_norm_thetaphi_check, title="check"
1013  Button b_norm_thetaphi_check, help={"show a graph of the normalization function"}
1014  Button b_norm_thetaphi_preview, size={80,20}, proc=PearlAnglescanPanel#bp_norm_thetaphi_preview, title="preview"
1015  Button b_norm_thetaphi_preview, help={"show a preview of the normalized dataset (without other normalizations)."}
1016 
1017  GroupBox gb_output, title="output"
1018  SetVariable sv_output_folding, size={95,16}, bodyWidth=60, title="folding"
1019  SetVariable sv_output_folding, limits={1,20,1}, value= root:packages:pearl_anglescan_panel:output_folding
1020  SetVariable sv_output_folding, help={"n-fold rotational average. 1=no averaging."}
1021  SetVariable sv_output_horizon, size={98,16}, bodyWidth=60, title="horizon"
1022  SetVariable sv_output_horizon, limits={1,90,1}, value= root:packages:pearl_anglescan_panel:output_horizon
1023  SetVariable sv_output_horizon, help={"highest theta to display"}
1024  PopupMenu pm_graph_projection, size={149,21}, bodyWidth=100, proc=PearlAnglescanPanel#pmp_graph_projection, title="projection"
1025  PopupMenu pm_graph_projection, mode=2, popvalue="stereographic", value= #"\"equidistant;stereographic;equal area;gnomonic;orthographic;\""
1026  PopupMenu pm_graph_projection, help={"projection (theta mapping) mode"}
1027  PopupMenu pm_graph_mode, size={129,21}, bodyWidth=100, proc=PearlAnglescanPanel#pmp_graph_mode,title="mode"
1028  PopupMenu pm_graph_mode, mode=2, popvalue="dots", value= #"\"none;dots;none;image;\""
1029  PopupMenu pm_graph_mode, help={"graph type: dots = coloured dots on circles; image = interpolated matrix"}
1030  Button b_output_calc, size={80,20}, proc=PearlAnglescanPanel#bp_output_calc, title="calc + display"
1031  Button b_output_calc, help={"execute data processing with the enabled filters and display the diffractogram."}
1032  Button b_output_duplicate, size={80,20}, proc=PearlAnglescanPanel#bp_output_duplicate, title="duplicate ..."
1033  Button b_output_duplicate, help={"copy the result to an arbitrary data folder."}
1034  Button b_output_itx, size={80,20}, proc=PearlAnglescanPanel#bp_output_itx, title="save ITX ..."
1035  Button b_output_itx, help={"save the result to an igor text file (itx)."}
1036  Button b_output_etpi, size={80,20}, proc=PearlAnglescanPanel#bp_output_etpi, title="save ETPI ..."
1037  Button b_output_etpi, help={"save the result to a pmsco angle scan file (etpi)."}
1038 
1039  GroupBox gb_graph, title="graph"
1040  PopupMenu pm_graph_colortable, size={152,21}, bodyWidth=100, proc=PearlAnglescanPanel#pmp_graph_colortable, title="color table"
1041  PopupMenu pm_graph_colortable, mode=0, value= #"\"*COLORTABLEPOPNONAMES*\""
1042  PopupMenu pm_graph_colortable, help={"color table to use in pseudocolor graphs."}
1043  SetVariable sv_graph_contrast, size={119,16}, bodyWidth=60, title="contrast (%)"
1044  SetVariable sv_graph_contrast, limits={0,25,1}, value= root:packages:pearl_anglescan_panel:graph_contrast
1045  SetVariable sv_graph_contrast, help={"contrast value (percentile)."}
1046  Button b_graph_update, size={80,20}, proc=PearlAnglescanPanel#bp_graph_update, title="update"
1047  Button b_graph_update, help={"update the existing graph."}
1048  Button b_graph_png, size={80,20}, proc=PearlAnglescanPanel#bp_graph_png, title="save PNG ..."
1049  Button b_graph_png, help={"save the graph in png format."}
1050 
1052  update_menus()
1053 end
1054 
1055 static function arrange_controls()
1056  dfref df = $(package_path)
1057  svar /sdfr=df panel_name
1058 
1059  variable gb_space = 2
1060  variable gb_internal_top = 16
1061  variable gb_internal_bot = 4
1062  variable line_space = 22
1063 
1064  variable cb_adj = 2
1065  variable sv_adj = 2
1066  variable pm_adj = 0
1067  variable b_adj = 0
1068  variable tb_adj = 0
1069 
1070  variable gb_top = 4
1071  variable gb_ht = 0
1072 
1073  // ht = line + 30
1074  // gb = gb + ht + 2
1075  // cb = gb + 18
1076  // pm = gb + 38
1077  // line += 26
1078  // sv = line + 2
1079 
1080  GroupBox gb_source,pos={4,gb_top}
1081  gb_ht = gb_internal_top
1082  Button b_source_select,pos={17, gb_top + gb_ht + b_adj},size={50,20}
1083  Button b_source_update, pos={67, gb_top + gb_ht + b_adj},size={50,20}
1084  gb_ht += line_space
1085  TitleBox tb_source_path,pos={18, gb_top + gb_ht + tb_adj},size={240,21}
1086  gb_ht += line_space
1087  gb_ht += gb_internal_bot
1088  GroupBox gb_source, size={272,gb_ht}
1089 
1090  gb_top += gb_ht + gb_space
1091  GroupBox gb_offsets,pos={4,gb_top}
1092  gb_ht = gb_internal_top
1093  SetVariable sv_theta_offset,pos={46, gb_top + gb_ht + sv_adj},size={88,16}
1094  Button b_save_prefs,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1095  gb_ht += line_space
1096  SetVariable sv_tilt_offset,pos={60, gb_top + gb_ht + sv_adj},size={74,16}
1097  Button b_load_prefs,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1098  gb_ht += line_space
1099  SetVariable sv_phi_offset,pos={56, gb_top + gb_ht + sv_adj},size={78,16}
1100  gb_ht += line_space
1101  SetVariable sv_alpha_offset,pos={44, gb_top + gb_ht + sv_adj},size={90,16}
1102  gb_ht += line_space
1103  gb_ht += gb_internal_bot
1104  GroupBox gb_offsets, size={272,gb_ht}
1105 
1106  gb_top += gb_ht + gb_space
1107  GroupBox gb_crop,pos={4,gb_top}
1108  gb_ht = gb_internal_top
1109  CheckBox cb_crop_enable,pos={73, gb_top + gb_ht + cb_adj},size={50,14}
1110  gb_ht += line_space
1111  SetVariable sv_crop_alpha, pos={44, gb_top + gb_ht + sv_adj}, size={90,16}
1112  Button b_crop_preview,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1113  gb_ht += line_space
1114  SetVariable sv_crop_theta, pos={44, gb_top + gb_ht + sv_adj}, size={90,16}
1115  gb_ht += line_space
1116  SetVariable sv_crop_rows, pos={44, gb_top + gb_ht + sv_adj}, size={190,16}
1117  gb_ht += line_space
1118  gb_ht += gb_internal_bot
1119  GroupBox gb_crop, size={272,gb_ht}
1120 
1121  gb_top += gb_ht + gb_space
1122  GroupBox gb_norm_alpha,pos={4,gb_top}
1123  gb_ht = gb_internal_top
1124  CheckBox cb_norm_alpha_enable,pos={73, gb_top + gb_ht + cb_adj},size={50,14}
1125  gb_ht += line_space
1126  PopupMenu pm_norm_alpha_mode,pos={36, gb_top + gb_ht + pm_adj},size={138,21}
1127  Button b_norm_alpha_check,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1128  gb_ht += line_space
1129  SetVariable sv_norm_alpha_smoothing,pos={22, gb_top + gb_ht + sv_adj},size={112,16}
1130  Button b_norm_alpha_preview,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1131  gb_ht += line_space
1132  gb_ht += gb_internal_bot
1133  GroupBox gb_norm_alpha, size={272,gb_ht}
1134 
1135  gb_top += gb_ht + gb_space
1136  GroupBox gb_norm_phi,pos={4,gb_top}
1137  gb_ht = gb_internal_top
1138  CheckBox cb_norm_phi_enable,pos={73, gb_top + gb_ht + cb_adj},size={50,14}
1139  Button b_norm_phi_check,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1140  gb_ht += line_space
1141  SetVariable sv_norm_phi_range,pos={15, gb_top + gb_ht + sv_adj},size={118,16}
1142  Button b_norm_phi_preview,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1143  gb_ht += line_space
1144  gb_ht += gb_internal_bot
1145  GroupBox gb_norm_phi, size={272,gb_ht}
1146 
1147  gb_top += gb_ht + gb_space
1148  GroupBox gb_norm_theta,pos={4,gb_top}
1149  gb_ht = gb_internal_top
1150  CheckBox cb_norm_theta_enable,pos={73, gb_top + gb_ht + cb_adj},size={50,14}
1151  gb_ht += line_space
1152  PopupMenu pm_norm_theta_domain, pos={35, gb_top + gb_ht + pm_adj}, size={138,21}
1153  Button b_norm_theta_check,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1154  gb_ht += line_space
1155  PopupMenu pm_norm_theta_mode,pos={35, gb_top + gb_ht + pm_adj},size={138,21}
1156  Button b_norm_theta_preview,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1157  gb_ht += line_space
1158  SetVariable sv_norm_theta_smoothing,pos={21, gb_top + gb_ht + sv_adj},size={112,16}
1159  gb_ht += line_space
1160  gb_ht += gb_internal_bot
1161  GroupBox gb_norm_theta, size={272,gb_ht}
1162 
1163  gb_top += gb_ht + gb_space
1164  GroupBox gb_norm_thetaphi,pos={4,gb_top}
1165  gb_ht = gb_internal_top
1166  CheckBox cb_norm_thetaphi_enable,pos={73, gb_top + gb_ht + cb_adj},size={50,14}
1167  gb_ht += line_space
1168  PopupMenu pm_norm_thetaphi_mode,pos={35, gb_top + gb_ht + pm_adj},size={138,21}
1169  Button b_norm_thetaphi_check,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1170  gb_ht += line_space
1171  SetVariable sv_norm_thetaphi_smoothing,pos={21, gb_top + gb_ht + sv_adj},size={112,16}
1172  Button b_norm_thetaphi_preview,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1173  gb_ht += line_space
1174  gb_ht += gb_internal_bot
1175  GroupBox gb_norm_thetaphi, size={272,gb_ht}
1176 
1177  gb_top += gb_ht + gb_space
1178  GroupBox gb_output,pos={4,gb_top}
1179  gb_ht = gb_internal_top
1180  SetVariable sv_output_folding,pos={38, gb_top + gb_ht + sv_adj},size={95,16}
1181  Button b_output_calc,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1182  gb_ht += line_space
1183  SetVariable sv_output_horizon,pos={35, gb_top + gb_ht + sv_adj},size={98,16}
1184  Button b_output_duplicate,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1185  gb_ht += line_space
1186  PopupMenu pm_graph_projection,pos={24, gb_top + gb_ht + pm_adj},size={149,21}
1187  Button b_output_itx,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1188  gb_ht += line_space
1189  PopupMenu pm_graph_mode,pos={44, gb_top + gb_ht + pm_adj},size={129,21}
1190  Button b_output_etpi,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1191  gb_ht += line_space
1192  gb_ht += gb_internal_bot
1193  GroupBox gb_output, size={272,gb_ht}
1194 
1195  gb_top += gb_ht + gb_space
1196  GroupBox gb_graph,pos={4,gb_top}
1197  gb_ht = gb_internal_top
1198  PopupMenu pm_graph_colortable,pos={21, gb_top + gb_ht + pm_adj},size={152,21}
1199  Button b_graph_update,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1200  gb_ht += line_space
1201  SetVariable sv_graph_contrast,pos={14, gb_top + gb_ht + sv_adj},size={119,16}
1202  Button b_graph_png,pos={186, gb_top + gb_ht + b_adj},size={80,20}
1203  gb_ht += line_space
1204  gb_ht += gb_internal_bot
1205  GroupBox gb_graph, size={272,gb_ht}
1206 
1207  gb_top += gb_ht + gb_space
1208  //MoveWindow 200, 100, 479, 100 + gb_top
1209 end
1210 
1213 static function update_menus()
1214  dfref df = $(package_path)
1215  svar /sdfr=df panel_name
1216  if (wintype(panel_name) == 7)
1217  variable m
1218  nvar /sdfr=df norm_alpha_mode
1219  m = norm_alpha_mode + 1
1220  PopupMenu pm_norm_alpha_mode win=$panel_name, mode=m
1221  nvar /sdfr=df norm_theta_domain
1222  m = norm_theta_domain + 1
1223  PopupMenu pm_norm_theta_domain win=$panel_name, mode=m
1224  nvar /sdfr=df norm_theta_mode
1225  m = norm_theta_mode + 1
1226  PopupMenu pm_norm_theta_mode win=$panel_name, mode=m
1227  nvar /sdfr=df norm_thetaphi_mode
1228  m = norm_thetaphi_mode + 1
1229  PopupMenu pm_norm_thetaphi_mode win=$panel_name, mode=m
1230  nvar /sdfr=df graph_mode
1231  m = graph_mode + 1
1232  PopupMenu pm_graph_mode win=$panel_name, mode=m
1233  nvar /sdfr=df graph_projection
1234  m = graph_projection + 1
1235  PopupMenu pm_graph_projection win=$panel_name, mode=m
1236  svar /sdfr=df graph_colortable
1237  m = 1 + WhichListItem(graph_colortable, CTabList())
1238  PopupMenu pm_graph_colortable win=$panel_name, mode=m
1239  endif
1240 end
1241 
1242 static function bp_load_prefs(ba) : ButtonControl
1243  STRUCT WMButtonAction &ba
1244 
1245  switch( ba.eventCode )
1246  case 2: // mouse up
1247  load_prefs()
1248  break
1249  case -1: // control being killed
1250  break
1251  endswitch
1252 
1253  return 0
1254 End
1255 
1256 static function bp_save_prefs(ba) : ButtonControl
1257  STRUCT WMButtonAction &ba
1258 
1259  switch( ba.eventCode )
1260  case 2: // mouse up
1261  save_prefs()
1262  break
1263  case -1: // control being killed
1264  break
1265  endswitch
1266 
1267  return 0
1268 End
1269 
1270 static function bp_source_select(ba) : ButtonControl
1271  STRUCT WMButtonAction &ba
1272 
1273  switch( ba.eventCode )
1274  case 2: // mouse up
1275  dfref dfBefore = GetDataFolderDFR()
1276  Execute /q/z "CreateBrowser prompt=\"Select 2D holo scan wave\", showWaves=1, showVars=0, showStrs=0"
1277  dfref dfAfter = GetDataFolderDFR()
1278  SetDataFolder dfBefore
1279 
1280  SVAR list = S_BrowserList
1281  NVAR flag = V_Flag
1282  if ((flag != 0) && (ItemsInList(list) >= 1))
1283  string wname = StringFromList(0, list)
1284  wave w = $wname
1285  asp_import_raw(w)
1286  endif
1287 
1288  break
1289  case -1: // control being killed
1290  break
1291  endswitch
1292 
1293  return 0
1294 End
1295 
1296 static function bp_source_update(ba) : ButtonControl
1297  STRUCT WMButtonAction &ba
1298 
1299  switch( ba.eventCode )
1300  case 2: // mouse up
1301  dfref packdf = $package_path
1302  svar /sdfr=packdf source_path
1303  wave /z w = $source_path
1304  if (waveexists(w))
1305  asp_import_raw(w)
1306  else
1307  DoAlert 0, "can't find source data."
1308  endif
1309  break
1310  case -1: // control being killed
1311  break
1312  endswitch
1313 
1314  return 0
1315 End
1316 
1317 static function bp_norm_alpha_check(ba) : ButtonControl
1318  STRUCT WMButtonAction &ba
1319 
1320  switch( ba.eventCode )
1321  case 2: // mouse up
1323  break
1324  case -1: // control being killed
1325  break
1326  endswitch
1327 
1328  return 0
1329 End
1330 
1331 static function bp_norm_theta_check(ba) : ButtonControl
1332  STRUCT WMButtonAction &ba
1333 
1334  switch( ba.eventCode )
1335  case 2: // mouse up
1337  break
1338  case -1: // control being killed
1339  break
1340  endswitch
1341 
1342  return 0
1343 End
1344 
1345 static function bp_norm_phi_check(ba) : ButtonControl
1346  STRUCT WMButtonAction &ba
1347 
1348  switch( ba.eventCode )
1349  case 2: // mouse up
1350  check_norm_phi()
1351  break
1352  case -1: // control being killed
1353  break
1354  endswitch
1355 
1356  return 0
1357 End
1358 
1359 static function bp_norm_thetaphi_check(ba) : ButtonControl
1360  STRUCT WMButtonAction &ba
1361 
1362  switch( ba.eventCode )
1363  case 2: // mouse up
1365  break
1366  case -1: // control being killed
1367  break
1368  endswitch
1369 
1370  return 0
1371 End
1372 
1373 static function bp_crop_preview(ba) : ButtonControl
1374  STRUCT WMButtonAction &ba
1375 
1376  switch( ba.eventCode )
1377  case 2: // mouse up
1378  preview_crop()
1379  break
1380  case -1: // control being killed
1381  break
1382  endswitch
1383 
1384  return 0
1385 End
1386 
1387 static function bp_norm_alpha_preview(ba) : ButtonControl
1388  STRUCT WMButtonAction &ba
1389 
1390  switch( ba.eventCode )
1391  case 2: // mouse up
1393  break
1394  case -1: // control being killed
1395  break
1396  endswitch
1397 
1398  return 0
1399 End
1400 
1401 static function bp_norm_phi_preview(ba) : ButtonControl
1402  STRUCT WMButtonAction &ba
1403 
1404  switch( ba.eventCode )
1405  case 2: // mouse up
1407  break
1408  case -1: // control being killed
1409  break
1410  endswitch
1411 
1412  return 0
1413 End
1414 
1415 static function bp_norm_theta_preview(ba) : ButtonControl
1416  STRUCT WMButtonAction &ba
1417 
1418  switch( ba.eventCode )
1419  case 2: // mouse up
1421  break
1422  case -1: // control being killed
1423  break
1424  endswitch
1425 
1426  return 0
1427 End
1428 
1429 static function bp_norm_thetaphi_preview(ba) : ButtonControl
1430  STRUCT WMButtonAction &ba
1431 
1432  switch( ba.eventCode )
1433  case 2: // mouse up
1435  break
1436  case -1: // control being killed
1437  break
1438  endswitch
1439 
1440  return 0
1441 End
1442 
1443 static function bp_output_calc(ba) : ButtonControl
1444  STRUCT WMButtonAction &ba
1445 
1446  switch( ba.eventCode )
1447  case 2: // mouse up
1450  break
1451  case -1: // control being killed
1452  break
1453  endswitch
1454 
1455  return 0
1456 End
1457 
1458 static function bp_output_duplicate(ba) : ButtonControl
1459  STRUCT WMButtonAction &ba
1460 
1461  switch( ba.eventCode )
1462  case 2: // mouse up
1463  string dest_folder
1464  variable do_graph = 1
1465  prompt dest_folder, "destination folder name (relative to data source)"
1466  prompt do_graph, "duplicate graph (yes = 1, no = 0)"
1467  doprompt "duplicate", dest_folder, do_graph
1468  if (!v_flag)
1469  asp_duplicate_output(dest_folder, do_graph=do_graph)
1470  endif
1471  break
1472  case -1: // control being killed
1473  break
1474  endswitch
1475 
1476  return 0
1477 End
1478 
1479 static function bp_output_etpi(ba) : ButtonControl
1480  STRUCT WMButtonAction &ba
1481 
1482  switch( ba.eventCode )
1483  case 2: // mouse up
1484  dfref df = $(package_path)
1485  wave /sdfr=df process_data
1486  variable ekin
1487  ekin = NumberByKey("KineticEnergy", note(process_data), "=", "\r")
1488  prompt ekin, "kinetic energy"
1489  doprompt "save etpi", ekin
1490  if (!v_flag)
1491  asp_save_output_etpi(ekin)
1492  endif
1493  break
1494  case -1: // control being killed
1495  break
1496  endswitch
1497 
1498  return 0
1499 End
1500 
1501 static function bp_output_itx(ba) : ButtonControl
1502  STRUCT WMButtonAction &ba
1503 
1504  switch( ba.eventCode )
1505  case 2: // mouse up
1507  break
1508  case -1: // control being killed
1509  break
1510  endswitch
1511 
1512  return 0
1513 End
1514 
1515 static function bp_graph_update(ba) : ButtonControl
1516  STRUCT WMButtonAction &ba
1517 
1518  switch( ba.eventCode )
1519  case 2: // mouse up
1521  break
1522  case -1: // control being killed
1523  break
1524  endswitch
1525 
1526  return 0
1527 End
1528 
1529 static function bp_graph_png(ba) : ButtonControl
1530  STRUCT WMButtonAction &ba
1531 
1532  switch( ba.eventCode )
1533  case 2: // mouse up
1534  dfref df = $(package_path)
1535  svar /sdfr=df source_path
1536  svar /sdfr=df output_graphname
1537  if (WinType(output_graphname) == 1)
1538  SavePICT /WIN=$output_graphname /E=-5 /B=144 /TRAN=0
1539  endif
1540  break
1541  case -1: // control being killed
1542  break
1543  endswitch
1544 
1545  return 0
1546 End
1547 
1548 static function pmp_norm_alpha_mode(pa) : PopupMenuControl
1549  STRUCT WMPopupAction &pa
1550 
1551  switch( pa.eventCode )
1552  case 2: // mouse up
1553  dfref df = $(package_path)
1554  nvar /sdfr=df norm_alpha_mode
1555  norm_alpha_mode = pa.popNum - 1
1556  break
1557  case -1: // control being killed
1558  break
1559  endswitch
1560 
1561  return 0
1562 End
1563 
1564 static function pmp_norm_theta_domain(pa) : PopupMenuControl
1565  STRUCT WMPopupAction &pa
1566 
1567  switch( pa.eventCode )
1568  case 2: // mouse up
1569  dfref df = $(package_path)
1570  nvar /sdfr=df norm_theta_domain
1571  norm_theta_domain = pa.popNum - 1
1572  break
1573  case -1: // control being killed
1574  break
1575  endswitch
1576 
1577  return 0
1578 End
1579 
1580 static function pmp_norm_theta_mode(pa) : PopupMenuControl
1581  STRUCT WMPopupAction &pa
1582 
1583  switch( pa.eventCode )
1584  case 2: // mouse up
1585  dfref df = $(package_path)
1586  nvar /sdfr=df norm_theta_mode
1587  norm_theta_mode = pa.popNum - 1
1588  break
1589  case -1: // control being killed
1590  break
1591  endswitch
1592 
1593  return 0
1594 End
1595 
1596 static function pmp_norm_thetaphi_mode(pa) : PopupMenuControl
1597  STRUCT WMPopupAction &pa
1598 
1599  switch( pa.eventCode )
1600  case 2: // mouse up
1601  dfref df = $(package_path)
1602  nvar /sdfr=df norm_thetaphi_mode
1603  norm_thetaphi_mode = pa.popNum - 1
1604  break
1605  case -1: // control being killed
1606  break
1607  endswitch
1608 
1609  return 0
1610 End
1611 
1612 static function pmp_graph_mode(pa) : PopupMenuControl
1613  STRUCT WMPopupAction &pa
1614 
1615  switch( pa.eventCode )
1616  case 2: // mouse up
1617  dfref df = $(package_path)
1618  nvar /sdfr=df graph_mode
1619  graph_mode = pa.popNum - 1
1620  break
1621  case -1: // control being killed
1622  break
1623  endswitch
1624 
1625  return 0
1626 End
1627 
1628 static function pmp_graph_projection(pa) : PopupMenuControl
1629  STRUCT WMPopupAction &pa
1630 
1631  switch( pa.eventCode )
1632  case 2: // mouse up
1633  dfref df = $(package_path)
1634  nvar /sdfr=df graph_projection
1635  graph_projection = pa.popNum - 1
1636  break
1637  case -1: // control being killed
1638  break
1639  endswitch
1640 
1641  return 0
1642 End
1643 
1644 static function pmp_graph_colortable(pa) : PopupMenuControl
1645  STRUCT WMPopupAction &pa
1646 
1647  switch( pa.eventCode )
1648  case 2: // mouse up
1649  dfref df = $(package_path)
1650  svar /sdfr=df graph_colortable
1651  graph_colortable = StringFromList(pa.popNum - 1, CTabList())
1653  break
1654  case -1: // control being killed
1655  break
1656  endswitch
1657 
1658  return 0
1659 End
pmp_graph_colortable
static variable pmp_graph_colortable(WMPopupAction *pa)
Definition: pearl-anglescan-panel.ipf:1644
preview_norm_thetaphi
static variable preview_norm_thetaphi()
Definition: pearl-anglescan-panel.ipf:894
asp_save_output_etpi
variable asp_save_output_etpi(variable ekin)
save the output diffractogram to a PMSCO ETPI file
Definition: pearl-anglescan-panel.ipf:819
crop_strip
variable crop_strip(wave strip, variable xlo, variable xhi)
crop a strip at the sides.
Definition: pearl-anglescan-process.ipf:747
bp_norm_phi_preview
static variable bp_norm_phi_preview(WMButtonAction *ba)
Definition: pearl-anglescan-panel.ipf:1401
bp_norm_thetaphi_preview
static variable bp_norm_thetaphi_preview(WMButtonAction *ba)
Definition: pearl-anglescan-panel.ipf:1429
pizza_service_2
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
Definition: pearl-anglescan-process.ipf:936
normalize_strip_theta
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.
Definition: pearl-anglescan-process.ipf:433
normalize_strip_x
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.
Definition: pearl-anglescan-process.ipf:252
asp_update_graph
variable asp_update_graph()
update graphs with new color table or contrast
Definition: pearl-anglescan-panel.ipf:713
bp_load_prefs
static variable bp_load_prefs(WMButtonAction *ba)
Definition: pearl-anglescan-panel.ipf:1242
AfterCompiledHook
static variable AfterCompiledHook()
initialize package data once when the procedure is first loaded
Definition: pearl-anglescan-panel.ipf:53
check_norm_theta
static variable check_norm_theta()
Definition: pearl-anglescan-panel.ipf:853
asp_import_raw
variable asp_import_raw(wave raw_data)
import raw data
Definition: pearl-anglescan-panel.ipf:207
do_norm_alpha
static variable do_norm_alpha(variable check, variable force=defaultValue)
alpha-normalize the process data.
Definition: pearl-anglescan-panel.ipf:456
do_crop
static variable do_crop(variable check, variable force=defaultValue)
crop the process data.
Definition: pearl-anglescan-panel.ipf:361
bp_output_etpi
static variable bp_output_etpi(WMButtonAction *ba)
Definition: pearl-anglescan-panel.ipf:1479
bp_norm_alpha_preview
static variable bp_norm_alpha_preview(WMButtonAction *ba)
Definition: pearl-anglescan-panel.ipf:1387
package_path
static const string package_path
data folder path
Definition: pearl-anglescan-panel.ipf:50
asp_show_panel
variable asp_show_panel()
create the angle scan processing panel
Definition: pearl-anglescan-panel.ipf:903
do_init_process
static variable do_init_process(variable check)
initialize the process data with a copy of the raw data.
Definition: pearl-anglescan-panel.ipf:321
bp_norm_theta_preview
static variable bp_norm_theta_preview(WMButtonAction *ba)
Definition: pearl-anglescan-panel.ipf:1415
normalize_strip_theta_scans
variable normalize_strip_theta_scans(wave strip, wave theta, variable theta_offset=defaultValue, variable smooth_method=defaultValue, variable smooth_factor=defaultValue, variable check=defaultValue)
divide the strip piecewise by a smooth polar distribution.
Definition: pearl-anglescan-process.ipf:594
crop_strip_theta
variable crop_strip_theta(wave strip, variable theta_lo, variable theta_hi, wave theta, wave tilt, wave phi)
crop a strip in theta.
Definition: pearl-anglescan-process.ipf:779
pmp_norm_alpha_mode
static variable pmp_norm_alpha_mode(WMPopupAction *pa)
Definition: pearl-anglescan-panel.ipf:1548
asp_display_previews
variable asp_display_previews()
display a graph window of the processed data.
Definition: pearl-anglescan-panel.ipf:252
asp_display_dist_check
variable asp_display_dist_check(variable xdist, variable ydist)
display a graph window of the distribution checks.
Definition: pearl-anglescan-panel.ipf:276
ad_update_profiles
variable ad_update_profiles(wave image)
update a profiles graph with new data.
Definition: pearl-area-display.ipf:377
bp_norm_theta_check
static variable bp_norm_theta_check(WMButtonAction *ba)
Definition: pearl-anglescan-panel.ipf:1331
find_hemi_data
dfr find_hemi_data(string nickname, string *prefix, string *intwave)
finds the folder, prefix and name of holo waves given their nick name
Definition: pearl-anglescan-process.ipf:1572
check_norm_alpha
static variable check_norm_alpha()
Definition: pearl-anglescan-panel.ipf:839
asp_duplicate_output
string asp_duplicate_output(string dest_name, variable do_graph=defaultValue)
copy the output data to a new folder
Definition: pearl-anglescan-panel.ipf:771
bp_output_itx
static variable bp_output_itx(WMButtonAction *ba)
Definition: pearl-anglescan-panel.ipf:1501
pmp_graph_mode
static variable pmp_graph_mode(WMPopupAction *pa)
Definition: pearl-anglescan-panel.ipf:1612
bp_norm_alpha_check
static variable bp_norm_alpha_check(WMButtonAction *ba)
Definition: pearl-anglescan-panel.ipf:1317
interpolate_hemi_scan
variable interpolate_hemi_scan(string nickname, variable projection=defaultValue)
interpolate a hemispherical scan onto a rectangular grid
Definition: pearl-anglescan-process.ipf:2920
preview_norm_phi
static variable preview_norm_phi()
Definition: pearl-anglescan-panel.ipf:880
pmp_norm_thetaphi_mode
static variable pmp_norm_thetaphi_mode(WMPopupAction *pa)
Definition: pearl-anglescan-panel.ipf:1596
bp_save_prefs
static variable bp_save_prefs(WMButtonAction *ba)
Definition: pearl-anglescan-panel.ipf:1256
load_prefs
static variable load_prefs()
load persistent package data from the preferences file.
Definition: pearl-anglescan-panel.ipf:171
update_menus
static variable update_menus()
update the popup menus to reflect the values of the global variables
Definition: pearl-anglescan-panel.ipf:1213
bp_source_update
static variable bp_source_update(WMButtonAction *ba)
Definition: pearl-anglescan-panel.ipf:1296
do_norm_phi
static variable do_norm_phi(variable check, variable force=defaultValue)
phi-normalize the process data.
Definition: pearl-anglescan-panel.ipf:497
do_norm_theta
static variable do_norm_theta(variable check, variable force=defaultValue)
theta-normalize the process data.
Definition: pearl-anglescan-panel.ipf:540
pmsco_save_scan
string pmsco_save_scan(string pathname, string filename, string energy, string theta, string phi, string alpha, string intensity, string sigma, dfref sdfr=defaultValue)
save waves in a PMSCO scan data file.
Definition: pearl-pmsco-import.ipf:89
pmp_norm_theta_mode
static variable pmp_norm_theta_mode(WMPopupAction *pa)
Definition: pearl-anglescan-panel.ipf:1580
prefs_objects
static const string prefs_objects
semicolon-separated list of persistent variable, string, and wave names
Definition: pearl-anglescan-tracker.ipf:71
asp_close_graphs
variable asp_close_graphs()
close all graphs created by the angle scan panel
Definition: pearl-anglescan-panel.ipf:731
init_package
static variable init_package()
Definition: pearl-anglescan-panel.ipf:78
check_norm_thetaphi
static variable check_norm_thetaphi()
Definition: pearl-anglescan-panel.ipf:860
delete_rows
static variable delete_rows(string rows, wave data, wave theta, wave tilt, wave phi)
delete individual rows from the data strip
Definition: pearl-anglescan-panel.ipf:409
set_contrast
variable set_contrast(variable pcmin, variable pcmax, string graphname=defaultValue, string colortable=defaultValue, variable reversecolors=defaultValue, variable symmetric=defaultValue)
set the pseudocolor contrast by percentile.
Definition: pearl-anglescan-process.ipf:3463
pmp_graph_projection
static variable pmp_graph_projection(WMPopupAction *pa)
Definition: pearl-anglescan-panel.ipf:1628
save_hemi_scan
variable save_hemi_scan(string nickname, string pathname, string filename)
save a hemispherical scan to an Igor text file
Definition: pearl-anglescan-process.ipf:3097
check_norm_phi
static variable check_norm_phi()
Definition: pearl-anglescan-panel.ipf:846
kProjStereo
const variable kProjStereo
Definition: pearl-anglescan-process.ipf:2343
normalize_strip_thetaphi
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.
Definition: pearl-anglescan-process.ipf:533
preview_norm_alpha
static variable preview_norm_alpha()
Definition: pearl-anglescan-panel.ipf:873
arrange_controls
static variable arrange_controls()
Definition: pearl-anglescan-panel.ipf:1055
do_norm_thetaphi
static variable do_norm_thetaphi(variable check, variable force=defaultValue)
theta,phi-normalize the process data.
Definition: pearl-anglescan-panel.ipf:587
pmp_norm_theta_domain
static variable pmp_norm_theta_domain(WMPopupAction *pa)
Definition: pearl-anglescan-panel.ipf:1564
bp_graph_update
static variable bp_graph_update(WMButtonAction *ba)
Definition: pearl-anglescan-panel.ipf:1515
save_prefs
static variable save_prefs()
save persistent package data to the preferences file.
Definition: pearl-anglescan-panel.ipf:145
bp_output_calc
static variable bp_output_calc(WMButtonAction *ba)
Definition: pearl-anglescan-panel.ipf:1443
duplicate_hemi_scan
variable duplicate_hemi_scan(string source_nickname, dfref dest_folder, string dest_nickname, variable xpdplot=defaultValue)
duplicate a hemispherical scan dataset.
Definition: pearl-anglescan-process.ipf:1653
asp_calculate_output
variable asp_calculate_output()
calculate the output using all enabled processing filters.
Definition: pearl-anglescan-panel.ipf:623
bp_output_duplicate
static variable bp_output_duplicate(WMButtonAction *ba)
Definition: pearl-anglescan-panel.ipf:1458
normalize_strip_phi
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).
Definition: pearl-anglescan-process.ipf:348
bp_norm_thetaphi_check
static variable bp_norm_thetaphi_check(WMButtonAction *ba)
Definition: pearl-anglescan-panel.ipf:1359
bp_graph_png
static variable bp_graph_png(WMButtonAction *ba)
Definition: pearl-anglescan-panel.ipf:1529
asp_save_output_itx
variable asp_save_output_itx()
save the output diffractogram to an igor text file
Definition: pearl-anglescan-panel.ipf:804
bp_norm_phi_check
static variable bp_norm_phi_check(WMButtonAction *ba)
Definition: pearl-anglescan-panel.ipf:1345
ad_display_profiles
string ad_display_profiles(wave image, string filter=defaultValue)
open a new profiles graph window.
Definition: pearl-area-display.ipf:168
preview_norm_theta
static variable preview_norm_theta()
Definition: pearl-anglescan-panel.ipf:887
preview_crop
static variable preview_crop()
Definition: pearl-anglescan-panel.ipf:867
asp_display_output
string asp_display_output(dfref data_df=defaultValue, string data_name=defaultValue)
display the output diffractogram
Definition: pearl-anglescan-panel.ipf:669
package_name
static const string package_name
package name is used as data folder name
Definition: pearl-anglescan-panel.ipf:48
bp_crop_preview
static variable bp_crop_preview(WMButtonAction *ba)
Definition: pearl-anglescan-panel.ipf:1373
bp_source_select
static variable bp_source_select(WMButtonAction *ba)
Definition: pearl-anglescan-panel.ipf:1270
display_hemi_scan
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.
Definition: pearl-anglescan-process.ipf:1858
PearlAnglescanPanel
interactive processing of angle scanned XPD data.