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