80 lines
2.0 KiB
Igor
80 lines
2.0 KiB
Igor
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
|
|
#pragma IgorVersion = 6.1
|
|
#pragma ModuleName = PearlAnglescanProcessTest
|
|
#pragma version = 1.0
|
|
|
|
#include "pearl-anglescan-process"
|
|
#include "unit-testing"
|
|
|
|
// test suite for pearl-anglescan-process.ipf
|
|
|
|
// unit testing framework: http://www.igorexchange.com/project/unitTesting
|
|
// run all test cases with RunTest("pearl-anglescan-process.ipf")
|
|
// if wave equalities fail, EnableDebugOutput() and read Igor help on equalWaves().
|
|
|
|
// created: matthias.muntwiler@psi.ch, 2013-11-18
|
|
// Copyright (c) 2013 Paul Scherrer Institut
|
|
// $Id$
|
|
|
|
static function test_convert_angles_ttpa()
|
|
// function parameters
|
|
variable ntests = 3
|
|
make /n=(ntests)/d/free i_theta, i_tilt, i_phi
|
|
make /n=3/d/free i_ana
|
|
make /n=1/d/free o_polar, o_azi
|
|
i_theta = {0, 90, 90}
|
|
i_tilt = {0, 0, 0}
|
|
i_phi = {0, 0, 10}
|
|
i_ana = {-30, 0, +30}
|
|
|
|
make /n=(3,ntests)/d/free e_polar, e_azi
|
|
e_polar[][0] = {30, 0, 30}
|
|
e_azi[][0] = {-90, 0, 90} // 180, 90, 0
|
|
|
|
e_polar[][1] = {90, 90, 90}
|
|
e_azi[][1] = {-30, 0, +30}
|
|
|
|
e_polar[][2] = {90, 90, 90}
|
|
e_azi[][2] = {-20, 10, +40}
|
|
|
|
variable phi0 = 0
|
|
e_azi += phi0
|
|
|
|
convert_angles_ttpa2polar(i_theta, i_tilt, i_phi, i_ana, o_polar, o_azi)
|
|
|
|
|
|
CHECK_EQUAL_WAVES(o_polar, e_polar, tol=0.001)
|
|
CHECK_EQUAL_WAVES(o_azi, e_azi, tol=0.001)
|
|
|
|
nvar /z errors = root:packages:unittesting:error_count
|
|
if ((nvar_exists(errors)) && (errors > 0))
|
|
print o_azi
|
|
print e_azi
|
|
endif
|
|
end
|
|
|
|
static function test_hist_hemi_aziscan()
|
|
CHECK_EMPTY_FOLDER()
|
|
|
|
make /n=360/d/free value, azi
|
|
azi = p
|
|
value = 1
|
|
variable polar = 45 // dphi = 2
|
|
|
|
make_hemi_grid(91, "")
|
|
wave w_index = index
|
|
wave w_nphis = nphis
|
|
wave w_dphi = dphi
|
|
wave w_values = values
|
|
wave w_azim = azim
|
|
wave w_polar = polar
|
|
|
|
duplicate /free w_values, e_values
|
|
variable p1 = w_index[44]
|
|
variable p2 = w_index[45]
|
|
e_values = (p >= p1) && (p < p2) ? 1 : 0
|
|
|
|
hemi_add_aziscan("", value, polar, azi)
|
|
|
|
CHECK_EQUAL_WAVES(w_values, e_values, tol=0.001)
|
|
end |