Home > atmlab > randomize > iaaft > surrogate_1d_2d.m

surrogate_1d_2d

PURPOSE ^

surrogate_1d_2d

SYNOPSIS ^

function [surrogate]=surrogate_1d_2d(x,y)

DESCRIPTION ^

 surrogate_1d_2d

 This is the main program of the Iterative Amplitude Adapted Fourier
 Transform  (IAAFT) method to make surrogate fields. This version makes 2D
 fields based on the statistical properties of 1D fields.

 The IAAFT method was developped by Schreiber and Schmitz (see e.g. Phys. 
 Rev Lett. 77, pp. 635-, 1996) for statistical non-linearity tests for time series.
 This method makes fields that have a specified amplitude distribution and
 power spectral coefficients. It works by iteratively adaptation the amplitude 
 distribution and the Fourier coefficients (the phases are not changed in this 
 step). Do not use this program without understanding the function
 iaaft_loop_2d and tuning its variables to your needs.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

surrogate_1d_2d.m

SOURCE CODE ^

0001 % surrogate_1d_2d
0002 %
0003 % This is the main program of the Iterative Amplitude Adapted Fourier
0004 % Transform  (IAAFT) method to make surrogate fields. This version makes 2D
0005 % fields based on the statistical properties of 1D fields.
0006 %
0007 % The IAAFT method was developped by Schreiber and Schmitz (see e.g. Phys.
0008 % Rev Lett. 77, pp. 635-, 1996) for statistical non-linearity tests for time series.
0009 % This method makes fields that have a specified amplitude distribution and
0010 % power spectral coefficients. It works by iteratively adaptation the amplitude
0011 % distribution and the Fourier coefficients (the phases are not changed in this
0012 % step). Do not use this program without understanding the function
0013 % iaaft_loop_2d and tuning its variables to your needs.
0014 
0015 % This Matlab version was written by Victor Venema,
0016 % Victor.Venema@uni-bonn.de, http:\\www.meteo.uni-bonn.de\victor, or
0017 % http:\\www.meteo.uni-bonn.de\victor\themes\surrogates\
0018 % for the generation of surrogate cloud fields.
0019 % First version: May 2003.
0020 % This version:  November 2003.
0021 
0022 % Copyright (C) 2003 Victor Venema
0023 % This program is free software; you can redistribute it and/or
0024 % modify it under the terms of the GNU General Public License
0025 % as published by the Free Software Foundation; version 2
0026 % of the License.
0027 %
0028 % This program is distributed in the hope that it will be useful,
0029 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0030 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0031 % GNU General Public License for more details.
0032 %
0033 % To get a copy of the GNU General Public License look on internet
0034 % or write to the Free Software Foundation, Inc., 59 Temple Place -
0035 % Suite 330, Boston, MA  02111-1307, USA.
0036 
0037 function [surrogate]=surrogate_1d_2d(x,y)  
0038 %[fourier_coeff, sorted_values, x, template, meanValue, no_values] = load_1d_data(1);
0039 
0040 
0041 %load('/home/bengt/CIWSIR/Dataset_gen/CloudSAT_data/cloud_eof.mat')
0042 template=y;
0043 no_values = length(y);
0044 meanValue = mean(y);
0045 sorted_values = sort(y - meanValue);
0046 fourier_coeff = abs(ifft(y - meanValue))';
0047 %plot(x,y)
0048 
0049 % Enlarge the vector with the sorted values to the number of points of
0050 % the 2D field.
0051 sorted_values2 = zeros(no_values, no_values, 1);
0052 for t2 = 1:no_values
0053     sorted_values2(t2, :)=sorted_values';
0054 end
0055 sorted_values = reshape(sorted_values2, no_values*no_values, 1);
0056 clear sorted_values2
0057 total_variance_pdf = std(sorted_values).^2;
0058 
0059 % Calculate the 2D Fourier spectrum assuming anisotropy
0060 coeff_2d = fourier_coeff_isotrop(fourier_coeff);
0061 clear fourier_coeff
0062     
0063 % Scale the total variance to the power spectrum to the variance of the
0064 % amplitude distributon.
0065 coeff_2d = coeff_2d.^2;
0066 total_variance_spec = sum(sum(coeff_2d));
0067 coeff_2d = coeff_2d * total_variance_pdf / total_variance_spec;
0068 coeff_2d = sqrt(coeff_2d);
0069    
0070 % Generate 2D field.
0071 [surrogate, error_amplitude, error_spec] = iaaft_loop_2d_horizontal(coeff_2d, sorted_values);
0072 surrogate = surrogate + meanValue;
0073 
0074 % Plot results
0075 if 0
0076 plot_1d_surrogate(x, template,  'template')
0077 plot_2d_surrogate(x, x, surrogate, 'surrogate')
0078 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005