-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathfft_ma.m
79 lines (72 loc) · 1.87 KB
/
fft_ma.m
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
% fft_ma :
% Call :
% [out,z,options,logL]=fft_ma(x,y,z,Va,options)
%
% x: array, ex : x=1:1:80:
% y: array, ex : y=1:1:50:
% z: array, ex : y=1:1:30:
% Va: variogram def, ex : Va="1 Sph (10,.4,30)";
%
%
% "
% Ravalec, M.L. and Noetinger, B. and Hu, L.Y.},
% Mathematical Geology 32(6), 2000, pp 701-723
% The FFT moving average (FFT-MA) generator: An efficient numerical
% method for generating and conditioning Gaussian simulations
% "
%
% Example:
% x=[1:1:40];y=1:1:35;z=1:30;
% Va='1 Sph(10,30,.5)';
% [out,z]=fft_ma(x,Va); % 1D
% [out,z]=fft_ma(x,y,Va); % 2D
% [out,z]=fft_ma(x,y,z,Va); %3D
%
% See also: fft_ma_1d, fft_ma_2d, fft_ma_3d
%
%
% original (FFT_MA) Knud S. Cordua (June 2009)
% Thomas M. Hansen (September, 2009)
% Jan Frydendall (April, 2011) Zero padding
%
function [out,z_rand,options,logL]=fft_ma(x,y,z,Va,options)
%try
% disp(format_variogram(Va));
%catch
% disp(Va);
%end
if nargin>1,
if (ischar(y)|ischar(y))
Va=y;
y=1;
% 1D
if nargin==3, options=z; else; options.null='';end
y=1;
[out,z_rand,options,logL]=fft_ma_2d(x,y,Va,options);
return
end
end
if nargin>2,
if (ischar(z)|isstruct(z))
% 2D
if nargin==4,options=Va; else; options.null='';end
Va=z;
[out,z_rand,options,logL]=fft_ma_2d(x,y,Va,options);
return
end
end
options.null='';
if (length(z)==1)&(length(y)==1)
% [out,z_rand,options,logL]=fft_ma_1d(x,Va,options);
% Maybe there is a problem with fft_ma_1d for resim...!
try
[out,z_rand,options,logL]=fft_ma_2d(x,0,Va,options);
catch
keyboard
end
elseif (length(z)==1)
[out,z_rand,options,logL]=fft_ma_2d(x,y,Va,options);
else
[out,z_rand,options,logL]=fft_ma_3d(x,y,z,Va,options);
end
out=squeeze(out);