-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmearer.pro
62 lines (54 loc) · 2 KB
/
smearer.pro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
FUNCTION smearer, xv=xv, yv=yv, zv=zv, xsigma=xsigma, ysigma=ysigma, zsigma=zsigma, NCYCLES=NCYCLES, XRAN=XRAN, YRAN=YRAN, ZRAN=ZRAN
; It creates a set of x, y, z elements randomly distributed (gaussian)
; around an input list of x, y, z values.
;
; Input
; x = input x vector
; y = input y vector (optional)
; z = input z vector (optional)
; xsigma = smoothing sigma along x axes
; ysigma = smoothing sigma along y axes
; zsigma = smoothing sigma along y axes
; NCYCLES = multiplicative factor for the output number of elements;
; The number of elements in XRAN and YRAN will be
; CYCLES * n_elements(x) = n_elements(XRAN)
; Default value is 1.
; XRAN= output vector containing the randomized elements along x
; YRAN= output vector containing the randomized elements along y
; ZRAN= output vector containing the randomized elements along z
;NOTE:
; x, y and z must have similar number of elements;
; output are float numbers
; Written by Ivano Baronchelli 2018
;--------------------------------------------------------------------
if NOT keyword_set(NCYCLES) then NCYCLES=1
XRAN=fltarr(n_elements(xv)*NCYCLES)
YRAN=fltarr(n_elements(xv)*NCYCLES)
ZRAN=fltarr(n_elements(xv)*NCYCLES)
NCYCLES=long(NCYCLES)
; Smoothing scale for simulated data (sigma)
; Along x
smooth_x_sigma=xsigma
; Along y
if keyword_set(yv) then smooth_y_sigma=ysigma
; Along z
if keyword_set(zv) then smooth_z_sigma=zsigma
RR=0L
WHILE RR lt NCYCLES do begin
ran1=fltarr(n_elements(xv))
ran2=fltarr(n_elements(xv))
ran3=fltarr(n_elements(xv))
NN=0L
while NN lt n_elements(xv) do begin
ran1[NN]=smooth_x_sigma*randomu(seed,/normal) ; along x
if keyword_set(yv) then ran2[NN]=smooth_y_sigma*randomu(seed,/normal) ; along y
if keyword_set(zv) then ran3[NN]=smooth_z_sigma*randomu(seed,/normal) ; along z
XRAN[RR*n_elements(xv)+NN]=xv[NN]+ran1[NN]
if keyword_set(yv) then YRAN[RR*n_elements(xv)+NN]=yv[NN]+ran2[NN]
if keyword_set(zv) then ZRAN[RR*n_elements(xv)+NN]=zv[NN]+ran3[NN]
NN=NN+1
endwhile
RR=RR+1
ENDWHILE
;return
END