update pshell explorer and data import, misc. improvements
FEATURES - pshell: convert scienta data to true counts - pre-process: add gauss2_reduction data reduction function - anglescan: add set_contrast and normalize_strip_phi functions - explorer: show info about multi-region scans - documentation: add detailed instructions for angle-scan processing BUGFIXES - explorer: fix attributes notebook - pshell: fix progress bar - elog: increase the number of accepted attachments
This commit is contained in:
@ -1,12 +1,12 @@
|
||||
#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 = PearlAnglescanProcess
|
||||
#include "pearl-vector-operations"
|
||||
#include "pearl-polar-coordinates"
|
||||
#include <New Polar Graphs>
|
||||
|
||||
// copyright (c) 2013-16 Paul Scherrer Institut
|
||||
// copyright (c) 2013-17 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.
|
||||
@ -64,13 +64,13 @@
|
||||
///
|
||||
/// @author matthias muntwiler, matthias.muntwiler@psi.ch
|
||||
///
|
||||
/// @copyright 2013-16 Paul Scherrer Institut @n
|
||||
/// @copyright 2013-17 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
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// @version 1.6
|
||||
/// @version 1.8
|
||||
/// canonical orientation of spherical coordinate system.
|
||||
///
|
||||
|
||||
@ -241,6 +241,84 @@ function normalize_strip_x(strip, [smooth_method, smooth_factor, check])
|
||||
endif
|
||||
end
|
||||
|
||||
/// divide the strip by a sine function in phi (wobble correction).
|
||||
///
|
||||
/// the sine function is a curve fit to the intensity integrated over detector angle
|
||||
/// with a period of 360°ree;.
|
||||
///
|
||||
/// this normalization may be useful if the intensity varies with a 360°ree; periodicity in the azimuthal angle,
|
||||
/// e.g. due to misalignment of the surface normal and the azimuthal rotation axis of the manipulator (wobble).
|
||||
/// note, however, that this function does not correct other effects of wobble such as angle shifts.
|
||||
///
|
||||
/// the strip is normalized in place, previous data is overwritten.
|
||||
///
|
||||
/// @param[in,out] strip 2D data, X-axis = analyser angle, Y-axis = arbitrary manipulator scan
|
||||
/// @param[in] theta polar manipulator angle.
|
||||
/// @param[in] phi azimuthal manipulator angle, arbitrary offset.
|
||||
/// @param[in] theta_offset theta value corresponding to normal emission (default 0).
|
||||
/// @param[in] theta_range maximum (offset corrected) theta to consider in the sine fit (default 10).
|
||||
///
|
||||
/// @param check enable output of intermediate results
|
||||
/// @arg 0 (default) don't create additional waves
|
||||
/// @arg 1 create check waves in the current folder
|
||||
/// @arg 2 calculate check waves only, do not modify strip
|
||||
///
|
||||
/// @return if check waves are enabled, the following waves are created (overwritten if existing):
|
||||
/// @arg check_dist average theta distribution
|
||||
/// @arg check_smoo smoothed distribution used to normalize the strip
|
||||
///
|
||||
function normalize_strip_phi(strip, theta, phi, [theta_offset, theta_range, check])
|
||||
wave strip
|
||||
wave theta
|
||||
wave phi
|
||||
variable theta_offset
|
||||
variable theta_range
|
||||
variable check
|
||||
|
||||
if (ParamIsDefault(check))
|
||||
check = 0
|
||||
endif
|
||||
if (ParamIsDefault(theta_offset))
|
||||
theta_offset = 0
|
||||
endif
|
||||
if (ParamIsDefault(theta_range))
|
||||
theta_offset = 10
|
||||
endif
|
||||
|
||||
// average over analyser angles
|
||||
wave dist = ad_profile_y(strip, -inf, inf, "")
|
||||
|
||||
// smooth distribution function
|
||||
duplicate /free dist, dist_smoo
|
||||
duplicate /free theta, theta_int
|
||||
theta_int = theta - theta_offset
|
||||
duplicate /free phi, phi_int
|
||||
setscale /p x phi_int[0], phi_int[1] - phi_int[0], waveunits(phi, -1), dist, dist_smoo
|
||||
|
||||
extract /free /indx dist, red_idx, theta_int < theta_range
|
||||
duplicate /free red_idx, red_dist, red_phi
|
||||
red_dist = dist[red_idx]
|
||||
red_phi = phi_int[red_idx]
|
||||
|
||||
variable wavg = mean(red_dist)
|
||||
make /n=4 /d /free coef
|
||||
coef[0] = {wavg, wavg/100, pi/180, 0}
|
||||
CurveFit /q /h="0010" /g /w=2 sin, kwcWave=coef, red_dist /x=red_phi
|
||||
dist_smoo = coef[0] + coef[1] * sin(coef[2] * phi_int[p] + coef[3])
|
||||
|
||||
// divide
|
||||
if (check != 2)
|
||||
strip = strip / dist_smoo[q] * coef[0]
|
||||
endif
|
||||
|
||||
// check
|
||||
if (check)
|
||||
duplicate /o dist, check_dist
|
||||
duplicate /o dist_smoo, check_smoo
|
||||
setscale /p x dimoffset(dist,0), dimdelta(dist,0), waveunits(dist,0), check_dist, check_smoo
|
||||
endif
|
||||
end
|
||||
|
||||
/// divide the strip by the average polar distribution.
|
||||
///
|
||||
/// this is a simple way to remove the polar angle dependence.
|
||||
@ -2843,3 +2921,112 @@ function /wave hemi_azi_cut(nickname, pol)
|
||||
return $""
|
||||
endif
|
||||
end
|
||||
|
||||
static function check_contrast(values, pcmin, pcmax, vmin, vmax)
|
||||
wave values
|
||||
variable pcmin
|
||||
variable pcmax
|
||||
variable &vmin
|
||||
variable &vmax
|
||||
|
||||
dfref save_df = GetDataFolderDFR()
|
||||
dfref dfr = NewFreeDataFolder()
|
||||
setdatafolder dfr
|
||||
StatsQuantiles /inan /iw /q /z values
|
||||
wave index = w_quantilesindex
|
||||
variable imin = round(numpnts(index) * pcmin / 100)
|
||||
variable imax = round(numpnts(index) * (100 - pcmax) / 100)
|
||||
vmin = values[index[imin]]
|
||||
vmax = values[index[imax]]
|
||||
KillDataFolder dfr
|
||||
setdatafolder save_df
|
||||
end
|
||||
|
||||
/// set the pseudocolor contrast by percentile.
|
||||
///
|
||||
/// set the minimum and maximum values of the pseudocolor scale
|
||||
/// such that a specified percentile of the distribution lies outside the limits.
|
||||
///
|
||||
/// the new contrast is applied to traces and images of the selected graph
|
||||
/// that have pseudocolor tables.
|
||||
///
|
||||
/// the function is not specific to angle scans.
|
||||
/// it can be used for any pseudocolor trace or image plots except contour plots.
|
||||
///
|
||||
/// @param pcmin percentile below the minimum color (0-100).
|
||||
/// @param pcmax percentile above the maximum color (0-100).
|
||||
/// @param graphname name of graph. default: top graph.
|
||||
/// @param colortable name of new colortable. default: keep current table.
|
||||
///
|
||||
function set_contrast(pcmin, pcmax, [graphname, colortable])
|
||||
variable pcmin
|
||||
variable pcmax
|
||||
string graphname
|
||||
string colortable
|
||||
|
||||
if (ParamIsDefault(graphname))
|
||||
graphname = ""
|
||||
endif
|
||||
if (ParamIsDefault(colortable))
|
||||
colortable = ""
|
||||
endif
|
||||
|
||||
dfref save_df = GetDataFolderDFR()
|
||||
|
||||
string objname
|
||||
string info
|
||||
string wname
|
||||
string ctab
|
||||
variable rev
|
||||
variable n
|
||||
variable i
|
||||
variable vmin
|
||||
variable vmax
|
||||
|
||||
string traces = TraceNameList(graphname, ";", 1+4)
|
||||
n = ItemsInList(traces, ";")
|
||||
for (i = 0; i < n; i += 1)
|
||||
objname = StringFromList(i, traces, ";")
|
||||
info = TraceInfo(graphname, objname, 0)
|
||||
if (strlen(info) > 0)
|
||||
info = StringByKey("RECREATION", info, ":", ";")
|
||||
info = StringByKey("zColor(x)", info, "=", ";")
|
||||
if (strlen(info) > 2)
|
||||
info = info[1,strlen(info)-2]
|
||||
wname = StringFromList(0, info, ",")
|
||||
wave w = $wname
|
||||
ctab = StringFromList(3, info, ",")
|
||||
rev = str2num("0" + StringFromList(4, info, ","))
|
||||
if (strlen(colortable) > 0)
|
||||
ctab = colortable
|
||||
endif
|
||||
check_contrast(w, pcmin, pcmax, vmin, vmax)
|
||||
ModifyGraph /w=$graphname zColor($objname)={w, vmin, vmax, $ctab, rev}
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
string images = ImageNameList(graphname, ";")
|
||||
n = ItemsInList(images, ";")
|
||||
for (i = 0; i < n; i += 1)
|
||||
objname = StringFromList(i, images, ";")
|
||||
wave w = ImageNameToWaveRef(graphname, objname)
|
||||
info = ImageInfo(graphname, objname, 0)
|
||||
if (strlen(info) > 0)
|
||||
info = StringByKey("RECREATION", info, ":", ";")
|
||||
info = StringByKey("ctab", info, "=", ";")
|
||||
if (strlen(info) > 2)
|
||||
info = info[1,strlen(info)-2]
|
||||
ctab = StringFromList(2, info, ",")
|
||||
rev = str2num("0" + StringFromList(3, info, ","))
|
||||
if (strlen(colortable) > 0)
|
||||
ctab = colortable
|
||||
endif
|
||||
check_contrast(w, pcmin, pcmax, vmin, vmax)
|
||||
ModifyImage /w=$graphname $objname ctab={vmin, vmax, $ctab, rev}
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
setdatafolder save_df
|
||||
end
|
||||
|
Reference in New Issue
Block a user