PEARL Procedures
Igor procedures for the analysis of PEARL data
pearl-area-profiles-test.ipf
Go to the documentation of this file.
1 #pragma rtGlobals=3// Use modern global access method and strict wave access.
2 #pragma IgorVersion = 6.1
3 #pragma ModuleName = PearlAreaProfilesTest
4 #pragma version = 1.02
5 
6 #include "pearl-area-profiles"
7 #include "unit-testing"
8 
9 
24 
30 
31 
33 static variable test_ad_profile_x_w(){
34  make /n=(11,21) /d /free source
35  setscale /p x 10, 1, "X", source
36  setscale /p y 100, 100, "Y", source
37  setscale d 0, 0, "D", source
38  source = x + y
39 
40  make /n=11 /d /free expected
41  setscale /p x 10, 1, "X", expected
42  setscale d 0, 0, "D", expected
43  expected = 30 + 3 * p + 500 + 600 + 700
44 
45  make /n=1 /d /free result1, result0
46  variable p1, p2
47 
48  p1 = 4
49  p2 = 6
50  ad_profile_x_w(source, p1, p2, result1, noavg=1)
51  CHECK_EQUAL_WAVES(result1, expected, tol=1e-6)
52 
53  expected /= 3
54  ad_profile_x_w(source, p1, p2, result0, noavg=0)
55  CHECK_EQUAL_WAVES(result0, expected, tol=1e-6)
56 };
57 
59 static variable test_ad_profile_y_w(){
60  make /n=(11,21) /d /free source
61  setscale /p x 10, 1, "X", source
62  setscale /p y 100, 100, "Y", source
63  setscale d 0, 0, "D", source
64  source = x + y
65 
66  make /n=21 /d /free expected
67  setscale /p x 100, 100, "Y", expected
68  setscale d 0, 0, "D", expected
69  expected = 3 * x + 14 + 15 + 16
70 
71  make /n=1 /d /free result1, result0
72  variable p1, p2
73 
74  p1 = 4
75  p2 = 6
76  ad_profile_y_w(source, p1, p2, result1, noavg=1)
77  CHECK_EQUAL_WAVES(result1, expected)
78 
79  expected /= 3
80  ad_profile_y_w(source, p1, p2, result0, noavg=0)
81  CHECK_EQUAL_WAVES(result0, expected)
82 };
83 
85 static variable test_ad_extract_slab_x(){
86  variable nx = 11
87  variable ny = 16
88  variable nz = 21
89  make /n=(nx,ny,nz) /d /free source
90  setscale /i x -1, 1, "X", source
91  setscale /i y -2, 2, "Y", source
92  setscale /i z -3, 3, "Z", source
93  setscale d 0, 0, "D", source
94  source = x + y + z
95  source[4][][] = 1
96  source[5][][] = 1
97 
98  make /n=(ny,nz) /d /free expected
99  setscale /i x -2, 2, "Y", expected
100  setscale /i y -3, 3, "Z", expected
101  setscale d 0, 0, "D", expected
102  expected = 2
103 
104  variable p1, p2
105  p1 = 4
106  p2 = 5
107 
108  wave result = ad_extract_slab_x(source, p1, p2, "", noavg=1)
109  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
110 
111  expected = 1
112  wave result = ad_extract_slab_x(source, p1, p2, "", noavg=0)
113  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
114 
115  p1 = -inf
116  p2 = 5
117  source = y + z
118  expected = (x + y) * 6
119  wave result = ad_extract_slab_x(source, p1, p2, "", noavg=1)
120  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
121 
122  p1 = 4
123  p2 = +inf
124  expected = (x + y) * (nx - 4)
125  wave result = ad_extract_slab_x(source, p1, p2, "", noavg=1)
126  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
127 };
128 
130 static variable test_ad_extract_slab_y(){
131  variable nx = 11
132  variable ny = 16
133  variable nz = 21
134  make /n=(nx,ny,nz) /d /free source
135  setscale /i x -1, 1, "X", source
136  setscale /i y -2, 2, "Y", source
137  setscale /i z -3, 3, "Z", source
138  setscale d 0, 0, "D", source
139  source = x + y + z
140  source[][4][] = 1
141  source[][5][] = 1
142 
143  make /n=(nx,nz) /d /free expected
144  setscale /i x -1, 1, "X", expected
145  setscale /i y -3, 3, "Z", expected
146  setscale d 0, 0, "D", expected
147  expected = 2
148 
149  variable p1, p2
150  p1 = 4
151  p2 = 5
152 
153  wave result = ad_extract_slab_y(source, p1, p2, "", noavg=1)
154  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
155 
156  expected = 1
157  wave result = ad_extract_slab_y(source, p1, p2, "", noavg=0)
158  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
159 
160  p1 = -inf
161  p2 = 5
162  source = x + z
163  expected = (x + y) * 6
164  wave result = ad_extract_slab_y(source, p1, p2, "", noavg=1)
165  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
166 
167  p1 = 4
168  p2 = +inf
169  expected = (x + y) * (ny - 4)
170  wave result = ad_extract_slab_y(source, p1, p2, "", noavg=1)
171  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
172 };
173 
175 static variable test_ad_extract_slab_z(){
176  variable nx = 11
177  variable ny = 16
178  variable nz = 21
179  make /n=(nx,ny,nz) /d /free source
180  setscale /i x -1, 1, "X", source
181  setscale /i y -2, 2, "Y", source
182  setscale /i z -3, 3, "Z", source
183  setscale d 0, 0, "D", source
184  source = x + y + z
185  source[][][4] = 1
186  source[][][5] = 1
187 
188  make /n=(nx,ny) /d /free expected
189  setscale /i x -1, 1, "X", expected
190  setscale /i y -2, 2, "Y", expected
191  setscale d 0, 0, "D", expected
192  expected = 2
193 
194  variable p1, p2
195  p1 = 4
196  p2 = 5
197 
198  wave result = ad_extract_slab_z(source, p1, p2, "", noavg=1)
199  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
200 
201  expected = 1
202  wave result = ad_extract_slab_z(source, p1, p2, "", noavg=0)
203  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
204 
205  p1 = -inf
206  p2 = 5
207  source = x + y
208  expected = (x + y) * 6
209  wave result = ad_extract_slab_z(source, p1, p2, "", noavg=1)
210  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
211 
212  p1 = 4
213  p2 = +inf
214  expected = (x + y) * (nz - 4)
215  wave result = ad_extract_slab_z(source, p1, p2, "", noavg=1)
216  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
217 };
218 
220 static variable test_ad_extract_slab(){
221  variable nx = 11
222  variable ny = 16
223  variable nz = 21
224 
225  make /n=(nx,ny,nz) /d /free source
226  setscale /i x -1, 1, "X", source
227  setscale /i y -2, 2, "Y", source
228  setscale /i z -3, 3, "Z", source
229  setscale d 0, 0, "D", source
230  source = x + y + z
231 
232  variable x1, x2
233  variable y1, y2
234  variable z1, z2
235 
236  make /n=(ny,nz) /d /free expected
237  setscale /i x -2, 2, "Y", expected
238  setscale /i y -3, 3, "Z", expected
239  setscale d 0, 0, "D", expected
240 
241  x1 = 0
242  x2 = 0
243  y1 = nan
244  y2 = nan
245  z1 = nan
246  z2 = nan
247  expected = source[(nx-1)/2][p][q]
248  wave result = ad_extract_slab(source, x1, x2, y1, y2, z1, z2, "", noavg=1)
249  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
250 
251  x1 = -inf
252  x2 = inf
253  expected = (x + y) * nx
254  wave result = ad_extract_slab(source, x1, x2, y1, y2, z1, z2, "", noavg=1)
255  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
256 
257  make /n=(nx,nz) /d /free expected
258  setscale /i x -1, 1, "X", expected
259  setscale /i y -3, 3, "Z", expected
260  setscale d 0, 0, "D", expected
261 
262  x1 = nan
263  x2 = nan
264  y1 = 0
265  y2 = 0
266  z1 = nan
267  z2 = nan
268  expected = source[p][(ny-1)/2][q]
269  wave result = ad_extract_slab(source, x1, x2, y1, y2, z1, z2, "", noavg=1)
270  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
271 
272  y1 = -inf
273  y2 = +inf
274  expected = (x + y) * ny
275  wave result = ad_extract_slab(source, x1, x2, y1, y2, z1, z2, "", noavg=1)
276  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
277 
278  make /n=(nx,ny) /d /free expected
279  setscale /i x -1, 1, "X", expected
280  setscale /i y -2, 2, "Y", expected
281  setscale d 0, 0, "D", expected
282 
283  x1 = nan
284  x2 = nan
285  y1 = nan
286  y2 = nan
287  z1 = 0
288  z2 = 0
289  expected = source[p][q][(nz-1)/2]
290  wave result = ad_extract_slab(source, x1, x2, y1, y2, z1, z2, "", noavg=1)
291  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
292 
293  z1 = -inf
294  z2 = inf
295  expected = (x + y) * nz
296  wave result = ad_extract_slab(source, x1, x2, y1, y2, z1, z2, "", noavg=1)
297  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
298 };
299 
301 static variable test_ad_extract_rod_x(){
302  variable nx = 11
303  variable ny = 16
304  variable nz = 21
305  make /n=(nx,ny,nz) /d /free source
306  setscale /i x -1, 1, "X", source
307  setscale /i y -2, 2, "Y", source
308  setscale /i z -3, 3, "Z", source
309  setscale d 0, 0, "D", source
310  source = x + y + z
311  source[][4][4] = 1
312  source[][4][5] = 1
313  source[][5][4] = 1
314  source[][5][5] = 1
315 
316  make /n=(nx) /d /free expected
317  setscale /i x -1, 1, "X", expected
318  setscale d 0, 0, "D", expected
319  expected = 4
320 
321  variable q1, q2
322  variable r1, r2
323  q1 = 4
324  q2 = 5
325  r1 = 4
326  r2 = 5
327 
328  wave result = ad_extract_rod_x(source, q1, q2, r1, r2, "", noavg=1)
329  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
330 
331  expected = 1
332  wave result = ad_extract_rod_x(source, q1, q2, r1, r2, "", noavg=0)
333  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
334 };
335 
337 static variable test_ad_extract_rod__x(){
338  variable nx = 11
339  variable ny = 16
340  variable nz = 21
341 
342  make /n=(nx,ny,nz) /d /free source
343  setscale /i x -1, 1, "X", source
344  setscale /i y -2, 2, "Y", source
345  setscale /i z -3, 3, "Z", source
346  setscale d 0, 0, "D", source
347  source = x + y + z
348 
349  variable x1, x2
350  variable y1, y2
351  variable z1, z2
352 
353  make /n=(nx) /d /free expected
354  setscale /i x -1, 1, "X", expected
355  setscale d 0, 0, "D", expected
356 
357  x1 = nan
358  x2 = nan
359  y1 = 0
360  y2 = 0
361  z1 = 0
362  z2 = 0
363  expected = source[p][(ny-1)/2][(nz-1)/2]
364  wave result = ad_extract_rod(source, x1, x2, y1, y2, z1, z2, "", noavg=1)
365  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
366 
367  y1 = -inf
368  y2 = +inf
369  z1 = -inf
370  z2 = +inf
371  expected = x * ny * nz
372  wave result = ad_extract_rod(source, x1, x2, y1, y2, z1, z2, "", noavg=1)
373  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
374 };
375 
377 static variable test_ad_extract_rod__y(){
378  variable nx = 11
379  variable ny = 16
380  variable nz = 21
381 
382  make /n=(nx,ny,nz) /d /free source
383  setscale /i x -1, 1, "X", source
384  setscale /i y -2, 2, "Y", source
385  setscale /i z -3, 3, "Z", source
386  setscale d 0, 0, "D", source
387  source = x + y + z
388 
389  variable x1, x2
390  variable y1, y2
391  variable z1, z2
392 
393  make /n=(ny) /d /free expected
394  setscale /i x -2, 2, "Y", expected
395  setscale d 0, 0, "D", expected
396 
397  x1 = 0
398  x2 = 0
399  y1 = nan
400  y2 = nan
401  z1 = 0
402  z2 = 0
403  expected = source[(nx-1)/2][p][(nz-1)/2]
404  wave result = ad_extract_rod(source, x1, x2, y1, y2, z1, z2, "", noavg=1)
405  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
406 
407  x1 = -inf
408  x2 = +inf
409  z1 = -inf
410  z2 = +inf
411  expected = x * nx * nz
412  wave result = ad_extract_rod(source, x1, x2, y1, y2, z1, z2, "", noavg=1)
413  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
414 };
415 
417 static variable test_ad_extract_rod__z(){
418  variable nx = 11
419  variable ny = 16
420  variable nz = 21
421 
422  make /n=(nx,ny,nz) /d /free source
423  setscale /i x -1, 1, "X", source
424  setscale /i y -2, 2, "Y", source
425  setscale /i z -3, 3, "Z", source
426  setscale d 0, 0, "D", source
427  source = x + y + z
428 
429  variable x1, x2
430  variable y1, y2
431  variable z1, z2
432 
433  make /n=(nz) /d /free expected
434  setscale /i x -3, 3, "Z", expected
435  setscale d 0, 0, "D", expected
436 
437  x1 = 0
438  x2 = 0
439  y1 = 0
440  y2 = 0
441  z1 = nan
442  z2 = nan
443  expected = source[(nx-1)/2][(ny-1)/2][p]
444  wave result = ad_extract_rod(source, x1, x2, y1, y2, z1, z2, "", noavg=1)
445  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
446 
447  x1 = -inf
448  x2 = +inf
449  y1 = -inf
450  y2 = +inf
451  expected = x * nx * ny
452  wave result = ad_extract_rod(source, x1, x2, y1, y2, z1, z2, "", noavg=1)
453  CHECK_EQUAL_WAVES(result, expected, tol=0.001)
454 };
455 
threadsafe wave ad_extract_slab_x(wave dataset, variable p1, variable p2, string destname, variable noavg=defaultValue)
threadsafe wave ad_extract_rod_x(wave dataset, variable q1, variable q2, variable r1, variable r2, string destname, variable noavg=defaultValue, variable sdev=defaultValue)
1D cut through 3D dataset along X dimension.
static variable test_ad_extract_rod__x()
test the ad_extract_rod() function, X coordinate
static variable test_ad_extract_slab()
test the ad_extract_slab() function
static variable test_ad_extract_rod__z()
test the ad_extract_rod() function, Z coordinate
threadsafe wave ad_profile_x_w(wave dataset, variable q1, variable q2, wave destwave, variable noavg=defaultValue)
1D cut through 2D dataset along X dimension, existing destination wave.
threadsafe wave ad_extract_slab_z(wave dataset, variable r1, variable r2, string destname, variable noavg=defaultValue)
static variable test_ad_extract_rod__y()
test the ad_extract_rod() function, Y coordinate
threadsafe wave ad_extract_slab_y(wave dataset, variable q1, variable q2, string destname, variable noavg=defaultValue)
static variable test_ad_extract_slab_z()
test the ad_extract_slab_z() function
static variable test_ad_profile_x_w()
test the ad_profile_x() function
static variable test_ad_extract_slab_y()
test the ad_extract_slab_y() function
threadsafe wave ad_profile_y_w(wave dataset, variable p1, variable p2, wave destwave, variable noavg=defaultValue)
1D cut through 2D dataset along X dimension, existing destination wave.
static variable test_ad_extract_rod_x()
test the ad_extract_rod_x() function
static variable test_ad_profile_y_w()
test the ad_profile_y() function
static variable test_ad_extract_slab_x()
test the ad_extract_slab_x() function
threadsafe wave ad_extract_rod(wave dataset, variable x1, variable x2, variable y1, variable y2, variable z1, variable z2, string destname, variable noavg=defaultValue, variable sdev=defaultValue, variable pscale=defaultValue)
1D cut through 3D dataset, integrate in normal dimensions
threadsafe wave ad_extract_slab(wave dataset, variable x1, variable x2, variable y1, variable y2, variable z1, variable z2, string destname, variable noavg=defaultValue, variable pscale=defaultValue)
2D cut through 3D dataset, integrate in normal dimension