diff --git a/README.md b/README.md index 690bbe0..ef7a4a9 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ License The source code of PEARL Procedures is available under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) at . Please read and respect the respective license agreements. -Please share your extensions of the code with the original author. +Please acknowledge the use of the code and share your extensions with the original author. Author ------ @@ -34,7 +34,7 @@ Matthias Muntwiler, Copyright --------- -Copyright 2009-2016 by [Paul Scherrer Institut](http://www.psi.ch) +Copyright 2009-2018 by [Paul Scherrer Institut](http://www.psi.ch) Release Notes diff --git a/doc/html/PageProjections.html b/doc/html/PageProjections.html index d21ea6e..5b852da 100644 --- a/doc/html/PageProjections.html +++ b/doc/html/PageProjections.html @@ -32,7 +32,7 @@
PEARL Procedures -  rev-distro-1.6.1-0-ge1f1aa9-dirty +  rev-distro-2.0.0-0-gfda49c3-dirty
Igor procedures for the analysis of PEARL data
@@ -126,7 +126,7 @@ $(document).ready(function(){initNavTree('PageProjections.html','');}); @@ -1418,7 +1418,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
-

Definition at line 489 of file pearl-anglescan-panel.ipf.

+

Definition at line 506 of file pearl-anglescan-panel.ipf.

@@ -1498,7 +1498,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
-

Definition at line 1398 of file pearl-anglescan-panel.ipf.

+

Definition at line 1415 of file pearl-anglescan-panel.ipf.

@@ -1524,7 +1524,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
-

Definition at line 1366 of file pearl-anglescan-panel.ipf.

+

Definition at line 1383 of file pearl-anglescan-panel.ipf.

@@ -1550,7 +1550,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
-

Definition at line 1382 of file pearl-anglescan-panel.ipf.

+

Definition at line 1399 of file pearl-anglescan-panel.ipf.

@@ -1576,7 +1576,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
-

Definition at line 1318 of file pearl-anglescan-panel.ipf.

+

Definition at line 1335 of file pearl-anglescan-panel.ipf.

@@ -1602,7 +1602,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
-

Definition at line 1334 of file pearl-anglescan-panel.ipf.

+

Definition at line 1351 of file pearl-anglescan-panel.ipf.

@@ -1628,7 +1628,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
-

Definition at line 1350 of file pearl-anglescan-panel.ipf.

+

Definition at line 1367 of file pearl-anglescan-panel.ipf.

@@ -1653,7 +1653,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
-

Definition at line 718 of file pearl-anglescan-panel.ipf.

+

Definition at line 735 of file pearl-anglescan-panel.ipf.

@@ -1678,7 +1678,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
-

Definition at line 724 of file pearl-anglescan-panel.ipf.

+

Definition at line 741 of file pearl-anglescan-panel.ipf.

@@ -1703,7 +1703,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
-

Definition at line 731 of file pearl-anglescan-panel.ipf.

+

Definition at line 748 of file pearl-anglescan-panel.ipf.

@@ -1728,7 +1728,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
-

Definition at line 738 of file pearl-anglescan-panel.ipf.

+

Definition at line 755 of file pearl-anglescan-panel.ipf.

@@ -1753,7 +1753,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
-

Definition at line 745 of file pearl-anglescan-panel.ipf.

+

Definition at line 762 of file pearl-anglescan-panel.ipf.

@@ -1808,7 +1808,7 @@ Licensed under the Apache License, Version 2.0 (the "License");

update the popup menus to reflect the values of the global variables

-

Definition at line 1037 of file pearl-anglescan-panel.ipf.

+

Definition at line 1054 of file pearl-anglescan-panel.ipf.

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