distro release 2.1.1

This commit is contained in:
2020-06-09 12:31:05 +02:00
parent b7390cb46f
commit ef9d08e5f5
168 changed files with 3286 additions and 1205 deletions

View File

@ -1,11 +1,11 @@
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
#pragma version = 1.7
#pragma version = 1.8
#pragma IgorVersion = 6.2
#pragma ModuleName = PearlAnglescanPanel
#include "pearl-anglescan-process"
#include "pearl-pmsco-import"
// copyright (c) 2018 Paul Scherrer Institut
// copyright (c) 2018-20 Paul Scherrer Institut
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -29,7 +29,7 @@
///
/// @author matthias muntwiler, matthias.muntwiler@psi.ch
///
/// @copyright 2018 Paul Scherrer Institut @n
/// @copyright 2018-20 Paul Scherrer Institut @n
/// Licensed under the Apache License, Version 2.0 (the "License"); @n
/// you may not use this file except in compliance with the License. @n
/// You may obtain a copy of the License at
@ -45,8 +45,6 @@
static strconstant package_name = "pearl_anglescan_panel"
/// data folder path
static strconstant package_path = "root:packages:pearl_anglescan_panel:"
/// semicolon-separated list of persistent variable, string, and wave names
static strconstant 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;"
/// initialize package data once when the procedure is first loaded
static function AfterCompiledHook()
@ -82,19 +80,26 @@ static function init_package()
// configuration (persistent)
string /g graphname = "graph_anglescan_panel"
string /g prefs_objects = "prefs_objects;theta_offset;tilt_offset;phi_offset;alpha_offset;crop_enable;crop_alpha;crop_theta;"
prefs_objects += "norm_alpha_enable;norm_alpha_mode;norm_alpha_smoothing;norm_phi_enable;norm_phi_mode;norm_phi_thetarange;"
prefs_objects += "norm_theta_enable;norm_theta_mode;norm_theta_domain;norm_theta_smoothing;norm_thetaphi_enable;norm_thetaphi_mode;norm_thetaphi_smoothing;"
prefs_objects += "output_folding;output_horizon;graph_mode;graph_projection;graph_colortable;graph_contrast;"
// recently used (persistent)
variable /g theta_offset = 0
variable /g tilt_offset = 0
variable /g phi_offset = 0
variable /g alpha_offset = 0
variable /g crop_alpha_enable = 0
variable /g crop_alpha_value = 25
variable /g crop_enable = 0
variable /g crop_alpha = 25
variable /g crop_theta = 88
string /g crop_rows = ""
variable /g norm_alpha_enable = 0
variable /g norm_alpha_mode = 4
variable /g norm_alpha_smoothing = 0.25
variable /g norm_theta_enable = 0
variable /g norm_theta_mode = 4
variable /g norm_theta_domain = 0
variable /g norm_theta_smoothing = 0.25
variable /g norm_thetaphi_enable = 0
variable /g norm_thetaphi_mode = 4
@ -136,6 +141,8 @@ end
///
static function save_prefs()
dfref saveDF = GetDataFolderDFR()
dfref df = $(package_path)
svar /sdfr=df prefs_objects
string fullPath = SpecialDirPath("Packages", 0, 0, 0)
fullPath += package_name
@ -337,7 +344,7 @@ static function do_init_process(check)
setscale /p x dimoffset(raw, 0) - alpha_offset, dimdelta(raw, 0), waveunits(raw, 0), process_data
end
/// alpha-crop the process data.
/// crop the process data.
///
/// @param[in] check select which output to generate (currently not used).
/// @arg 0 (default) process data, don't calculate check waves.
@ -348,7 +355,7 @@ end
/// @arg 0 (default) apply this filter only if its global enable flag is set.
/// @arg 1 apply this filter even if it is not enabled.
///
static function do_crop_alpha(check, [force])
static function do_crop(check, [force])
variable check
variable force
@ -358,14 +365,80 @@ static function do_crop_alpha(check, [force])
dfref df = $(package_path)
wave /sdfr=df process_data
nvar /sdfr=df crop_alpha_enable
nvar /sdfr=df crop_alpha_value
wave /sdfr=df process_theta
wave /sdfr=df process_tilt
wave /sdfr=df process_phi
nvar /sdfr=df crop_enable
nvar /sdfr=df crop_alpha
nvar /sdfr=df crop_theta
svar /sdfr=df crop_rows
if ((force || crop_alpha_enable) && (crop_alpha_value > abs(dimdelta(process_data, 0))))
crop_strip(process_data, -crop_alpha_value, +crop_alpha_value)
if (force || crop_enable)
if (crop_alpha > abs(dimdelta(process_data, 0)))
crop_strip(process_data, -crop_alpha, +crop_alpha)
endif
if ((crop_theta >= 10) && (crop_theta < 90))
crop_strip_theta(process_data, 0, crop_theta, process_theta, process_tilt, process_phi)
endif
if (strlen(crop_rows) > 0)
delete_rows(crop_rows, process_data, process_theta, process_tilt, process_phi)
endif
endif
end
/// delete individual rows from the data strip
///
/// @param[in] rows comma-separated list of row indices or ranges.
/// ranges are specified by joining the start and end index with a hyphen, e.g. 24-46.
/// the list does not need to be ordered.
/// @param[in,out] data 2D data
/// the original wave is modified.
/// @param[in,out] theta theta positions along Y dimension of data.
/// the original wave is modified.
/// @param[in,out] tilt tilt positions along Y dimension of data
/// the original wave is modified.
/// @param[in,out] phi phi positions along Y dimension of data
/// the original wave is modified.
///
static function delete_rows(rows, data, theta, tilt, phi)
string rows
wave data
wave theta
wave tilt
wave phi
make /n=(numpnts(theta)) /i /free idx
idx = p
variable nrows = ItemsInList(rows, ",")
variable irow
string srow
variable q1, q2
for (irow = 0; irow < nrows; irow += 1)
srow = StringFromList(irow, rows, ",")
q1 = str2num(StringFromList(0, srow, "-"))
q2 = str2num(StringFromList(1, srow, "-"))
if (numtype(q2))
q2 = q1
endif
if (q1 <= q2)
idx[q1,q2] = -1
endif
endfor
extract /free idx, idx, idx >= 0
variable nx = dimsize(data, 0)
variable ny = numpnts(idx)
theta = theta[idx]
tilt = tilt[idx]
phi = phi[idx]
redimension /n=(ny) theta, tilt, phi
duplicate /free data, data_copy
redimension /n=(nx,ny) data
data = data_copy[p][idx[q]]
end
/// alpha-normalize the process data.
///
/// @param[in] check select which output to generate.
@ -475,12 +548,17 @@ static function do_norm_theta(check, [force])
wave /sdfr=df process_theta
nvar /sdfr=df norm_theta_enable
nvar /sdfr=df norm_theta_mode
nvar /sdfr=df norm_theta_domain
nvar /sdfr=df norm_theta_smoothing
if (force || norm_theta_enable)
dfref temp_df = newfreedatafolder()
setdatafolder temp_df
normalize_strip_theta(process_data, process_theta, smooth_method=norm_theta_mode, smooth_factor=norm_theta_smoothing, check=check)
if (norm_theta_domain==1)
normalize_strip_theta_scans(process_data, process_theta, smooth_method=norm_theta_mode, smooth_factor=norm_theta_smoothing, check=check)
else
normalize_strip_theta(process_data, process_theta, smooth_method=norm_theta_mode, smooth_factor=norm_theta_smoothing, check=check)
endif
if (check)
wave check_dist
wave check_smoo
@ -554,7 +632,7 @@ function asp_calculate_output()
nvar horizon=output_horizon
do_init_process(0)
do_crop_alpha(0)
do_crop(0)
do_norm_alpha(0)
do_norm_phi(0)
do_norm_theta(0)
@ -757,62 +835,62 @@ end
static function check_norm_alpha()
do_init_process(0)
do_crop_alpha(0)
do_crop(0)
do_norm_alpha(2, force=1)
asp_display_dist_check(1, 0)
end
static function check_norm_phi()
do_init_process(0)
do_crop_alpha(0)
do_crop(0)
do_norm_phi(2, force=1)
asp_display_dist_check(0, 1)
end
static function check_norm_theta()
do_init_process(0)
do_crop_alpha(0)
do_crop(0)
do_norm_theta(2, force=1)
asp_display_dist_check(0, 1)
end
static function check_norm_thetaphi()
do_init_process(0)
do_crop_alpha(0)
do_crop(0)
do_norm_thetaphi(2, force=1)
asp_display_dist_check(0, 1)
end
static function preview_crop_alpha()
static function preview_crop()
do_init_process(0)
do_crop_alpha(0, force=1)
do_crop(0, force=1)
asp_display_previews()
end
static function preview_norm_alpha()
do_init_process(0)
do_crop_alpha(0)
do_crop(0)
do_norm_alpha(1, force=1)
asp_display_previews()
end
static function preview_norm_phi()
do_init_process(0)
do_crop_alpha(0)
do_crop(0)
do_norm_phi(1, force=1)
asp_display_previews()
end
static function preview_norm_theta()
do_init_process(0)
do_crop_alpha(0)
do_crop(0)
do_norm_theta(1, force=1)
asp_display_previews()
end
static function preview_norm_thetaphi()
do_init_process(0)
do_crop_alpha(0)
do_crop(0)
do_norm_thetaphi(1, force=1)
asp_display_previews()
end
@ -828,7 +906,7 @@ function asp_show_panel()
return 0
endif
NewPanel /K=1 /N=anglescan_panel /W=(200,100,479,854) as "angle scan processing"
NewPanel /K=1 /N=anglescan_panel /W=(200,50,480,874) as "angle scan processing"
panel_name = s_name
GroupBox gb_source, title="data source"
@ -857,15 +935,21 @@ function asp_show_panel()
Button b_load_prefs, size={80,20},proc=PearlAnglescanPanel#bp_load_prefs,title="load prefs"
Button b_load_prefs, help={"load settings from preferences."}
GroupBox gb_crop_alpha, title="crop alpha"
CheckBox cb_crop_alpha_enable, size={50,14}, title="enable"
CheckBox cb_crop_alpha_enable, help={"enable cropping at +/- alpha"}
CheckBox cb_crop_alpha_enable,variable= root:packages:pearl_anglescan_panel:crop_alpha_enable
SetVariable sv_crop_alpha_value, size={90,16},bodyWidth=60,title="angle"
SetVariable sv_crop_alpha_value,limits={0,30,1},value= root:packages:pearl_anglescan_panel:crop_alpha_value
SetVariable sv_crop_alpha_value, help={"alpha (detection angle) cropping angle"}
Button b_crop_alpha_preview, size={80,20},proc=PearlAnglescanPanel#bp_crop_alpha_preview,title="preview"
Button b_crop_alpha_preview, help={"show a preview of the cropped dataset."}
GroupBox gb_crop, title="crop and delete"
CheckBox cb_crop_enable, size={50,14}, title="enable"
CheckBox cb_crop_enable, help={"crop at +/-alpha and +theta, delete arbitrary rows"}
CheckBox cb_crop_enable, variable= root:packages:pearl_anglescan_panel:crop_enable
SetVariable sv_crop_alpha, size={90,16},bodyWidth=60,title="alpha"
SetVariable sv_crop_alpha, limits={0,30,1},value= root:packages:pearl_anglescan_panel:crop_alpha
SetVariable sv_crop_alpha, help={"alpha (detection angle) cropping angle (positive boundary), relative to normal emission"}
SetVariable sv_crop_theta, size={90,16},bodyWidth=60,title="theta"
SetVariable sv_crop_theta, limits={10,90,1},value= root:packages:pearl_anglescan_panel:crop_theta
SetVariable sv_crop_theta, help={"theta (polar angle) upper limit, relative to normal emission"}
SetVariable sv_crop_rows, size={200,16},bodyWidth=160,title="rows"
SetVariable sv_crop_rows, limits={10,90,1},value= root:packages:pearl_anglescan_panel:crop_rows
SetVariable sv_crop_rows, help={"rows to delete from the raw data. comma-separated point indices, hyphen for range."}
Button b_crop_preview, size={80,20},proc=PearlAnglescanPanel#bp_crop_preview,title="preview"
Button b_crop_preview, help={"show a preview of the cropped dataset."}
GroupBox gb_norm_alpha, title="normalize alpha"
CheckBox cb_norm_alpha_enable, size={50,14}, title="enable"
@ -898,6 +982,9 @@ function asp_show_panel()
CheckBox cb_norm_theta_enable, size={50,14},title="enable"
CheckBox cb_norm_theta_enable, variable= root:packages:pearl_anglescan_panel:norm_theta_enable
CheckBox cb_norm_theta_enable, help={"enable normalization of the theta distribution (integrated over phi)"}
PopupMenu pm_norm_theta_domain, size={138,21}, bodyWidth=100, proc=PearlAnglescanPanel#pmp_norm_theta_domain, title="domain"
PopupMenu pm_norm_theta_domain, mode=5, popvalue="loess", value= #"\"global;scans;\""
PopupMenu pm_norm_theta_domain, help={"smoothing domain: global or individual scans. use global unless there is a stronga or irregular phi variation."}
PopupMenu pm_norm_theta_mode, size={138,21},bodyWidth=100,proc=PearlAnglescanPanel#pmp_norm_theta_mode,title="method"
PopupMenu pm_norm_theta_mode,mode=5,popvalue="loess",value= #"\"none;binomial;boxcar;polynomial;loess;\""
PopupMenu pm_norm_theta_mode, help={"theta normalization method. recommended: loess"}
@ -1014,15 +1101,19 @@ static function arrange_controls()
GroupBox gb_offsets, size={272,gb_ht}
gb_top += gb_ht + gb_space
GroupBox gb_crop_alpha,pos={4,gb_top}
GroupBox gb_crop,pos={4,gb_top}
gb_ht = gb_internal_top
CheckBox cb_crop_alpha_enable,pos={73, gb_top + gb_ht + cb_adj},size={50,14}
CheckBox cb_crop_enable,pos={73, gb_top + gb_ht + cb_adj},size={50,14}
gb_ht += line_space
SetVariable sv_crop_alpha_value,pos={44, gb_top + gb_ht + sv_adj},size={90,16}
Button b_crop_alpha_preview,pos={186, gb_top + gb_ht + b_adj},size={80,20}
SetVariable sv_crop_alpha, pos={44, gb_top + gb_ht + sv_adj}, size={90,16}
Button b_crop_preview,pos={186, gb_top + gb_ht + b_adj},size={80,20}
gb_ht += line_space
SetVariable sv_crop_theta, pos={44, gb_top + gb_ht + sv_adj}, size={90,16}
gb_ht += line_space
SetVariable sv_crop_rows, pos={44, gb_top + gb_ht + sv_adj}, size={190,16}
gb_ht += line_space
gb_ht += gb_internal_bot
GroupBox gb_crop_alpha, size={272,gb_ht}
GroupBox gb_crop, size={272,gb_ht}
gb_top += gb_ht + gb_space
GroupBox gb_norm_alpha,pos={4,gb_top}
@ -1055,12 +1146,14 @@ static function arrange_controls()
gb_ht = gb_internal_top
CheckBox cb_norm_theta_enable,pos={73, gb_top + gb_ht + cb_adj},size={50,14}
gb_ht += line_space
PopupMenu pm_norm_theta_mode,pos={35, gb_top + gb_ht + pm_adj},size={138,21}
PopupMenu pm_norm_theta_domain, pos={35, gb_top + gb_ht + pm_adj}, size={138,21}
Button b_norm_theta_check,pos={186, gb_top + gb_ht + b_adj},size={80,20}
gb_ht += line_space
SetVariable sv_norm_theta_smoothing,pos={21, gb_top + gb_ht + sv_adj},size={112,16}
PopupMenu pm_norm_theta_mode,pos={35, gb_top + gb_ht + pm_adj},size={138,21}
Button b_norm_theta_preview,pos={186, gb_top + gb_ht + b_adj},size={80,20}
gb_ht += line_space
SetVariable sv_norm_theta_smoothing,pos={21, gb_top + gb_ht + sv_adj},size={112,16}
gb_ht += line_space
gb_ht += gb_internal_bot
GroupBox gb_norm_theta, size={272,gb_ht}
@ -1122,6 +1215,9 @@ static function update_menus()
nvar /sdfr=df norm_alpha_mode
m = norm_alpha_mode + 1
PopupMenu pm_norm_alpha_mode win=$panel_name, mode=m
nvar /sdfr=df norm_theta_domain
m = norm_theta_domain + 1
PopupMenu pm_norm_theta_domain win=$panel_name, mode=m
nvar /sdfr=df norm_theta_mode
m = norm_theta_mode + 1
PopupMenu pm_norm_theta_mode win=$panel_name, mode=m
@ -1271,12 +1367,12 @@ static function bp_norm_thetaphi_check(ba) : ButtonControl
return 0
End
static function bp_crop_alpha_preview(ba) : ButtonControl
static function bp_crop_preview(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
preview_crop_alpha()
preview_crop()
break
case -1: // control being killed
break
@ -1462,6 +1558,22 @@ static function pmp_norm_alpha_mode(pa) : PopupMenuControl
return 0
End
static function pmp_norm_theta_domain(pa) : PopupMenuControl
STRUCT WMPopupAction &pa
switch( pa.eventCode )
case 2: // mouse up
dfref df = $(package_path)
nvar /sdfr=df norm_theta_domain
norm_theta_domain = pa.popNum - 1
break
case -1: // control being killed
break
endswitch
return 0
End
static function pmp_norm_theta_mode(pa) : PopupMenuControl
STRUCT WMPopupAction &pa