Home > atmlab > randomize > iaaft > load_2d_data_horizontal.m

load_2d_data_horizontal

PURPOSE ^

Load a 2D field.

SYNOPSIS ^

function [fourier_coeff_2d, sorted_values, x, y, template, meanValue, no_values_x, no_values_y] = load_2d_data_horizontal(number)

DESCRIPTION ^

 Load a 2D field.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

load_2d_data_horizontal.m

SOURCE CODE ^

0001 function [fourier_coeff_2d, sorted_values, x, y, template, meanValue, no_values_x, no_values_y] = load_2d_data_horizontal(number)
0002 
0003 % Load a 2D field.
0004 switch number
0005     case 1
0006         load data_thin_cumulus
0007         template = double(template);
0008         % This field is mirrored and flipped twice to get larger field
0009         % without jumps at the edges.
0010         template = [template  flipdim(template,2)];   
0011         template = [template; flipdim(template,1)];
0012         
0013     case 2 
0014         % The highly nonlinear structure of the height map of England is
0015         % used to show the limitation of the IAAFT method.
0016         load data_england.mat
0017         template = double(template);
0018         template = flipdim(template,1);
0019         
0020     otherwise
0021         % The line pattern of lightning is used to show the limitation of
0022         % the IAAFT method.
0023         load data_lightning
0024         template = double(template);
0025         % This field is mirrored and flipped twice to get larger field
0026         % without jumps at the edges.
0027         template = [template  flipdim(template,2)];   
0028         template = [template; flipdim(template,1)];       
0029 end    
0030 
0031 [no_values_x, no_values_y] = size(template); 
0032 x = 1:no_values_x;
0033 y = 1:no_values_y;
0034 meanValue = mean(mean(template));
0035 
0036 % Make sorted vector.
0037 sorted_values = sort(reshape(template, no_values_x*no_values_y, 1) - meanValue);
0038 total_variance_pdf = std(sorted_values).^2;
0039     
0040 % Calculate Fourier coeffients and scale them.
0041 fourier_coeff_2d = abs(ifft2( template - meanValue ));
0042 power = fourier_coeff_2d.^2;
0043 total_variance_spec = sum(sum(power));
0044 power = power * total_variance_pdf / total_variance_spec;
0045 fourier_coeff_2d = sqrt(power);

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