Home > atmlab > randomize > iaaft > load_1d_data.m

load_1d_data

PURPOSE ^

SYNOPSIS ^

function [fourier_coeff, sorted_values, x, y, meanValue, no_values] = load_1d_data(number)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

load_1d_data.m

SOURCE CODE ^

0001 function [fourier_coeff, sorted_values, x, y, meanValue, no_values] = load_1d_data(number)
0002 
0003 switch number
0004     case 1    
0005         load('data_1d_lwp.mat');
0006         y = (lwp_4s(1:4:end)  + lwp_4s(2:4:end)  + lwp_4s(3:4:end)  + lwp_4s(4:4:end))  / 4;
0007         x = (time_4s(1:4:end) + time_4s(2:4:end) + time_4s(3:4:end) + time_4s(4:4:end)) / 4;
0008         no_values = length(y);
0009         
0010         meanValue = mean(y);
0011         sorted_values = sort(y - meanValue);
0012         fourier_coeff = abs(ifft(y - meanValue))';
0013         
0014     case 2    
0015         load('data_1d_lwp.mat'); % Careful, if you make a 2D matrix of this time series it may take some hours.
0016         y = lwp_4s;
0017         x = time_4s;
0018         no_values = length(y);
0019         
0020         meanValue = mean(y);
0021         sorted_values = sort(y - meanValue);
0022         fourier_coeff = abs(ifft(y - meanValue))';
0023        
0024     case 3
0025         % Take theoretical values for the Fourier coefficients
0026         % (corresponding to a -5/3 power spectrum) and the
0027         % amplitude distribution (an exponential distribution)
0028         no_values = 2^8;
0029 
0030         % Make vector with the amplitude distribution
0031         p = ((1:no_values)/no_values) - 1/(2*no_values);
0032         sorted_values = expinv(p,1);            % The second number is the standard deviation
0033         meanValue = mean(sorted_values);
0034         sorted_values = sorted_values - meanValue;
0035         total_variance_pdf = std(sorted_values).^2;
0036 
0037         % Calculate the Fourier coefficients.
0038         k = [1:no_values/2 no_values/2-1:-1:1]
0039         pc = k.^(-5/3);                         % This makes a linear power spectrum with slope -5/3
0040         total_variance_spec = sum(pc);
0041         pc = pc * total_variance_pdf / total_variance_spec;
0042         total_variance_spec = sum(pc);
0043         fourier_coeff = zeros(1,no_values);
0044         fourier_coeff(1) = 0;
0045         fourier_coeff(2:no_values) = sqrt(pc);
0046         
0047         % As the statistics are theoretical, there is no template data.
0048         x = 1:no_values;
0049         y = 0;
0050         
0051     otherwise
0052         % Take theoretical values for the Fourier coefficients
0053         % (corresponding to a -5/3 power spectrum) and the
0054         % amplitude distribution (a Gaussian distribution with discrete values)
0055         % This could, e.g. be used for as a cloud top height in a numerical
0056         % cloud model, with relatively good scaling behaviour.
0057 
0058         no_values = 2^9;
0059         step_size = 10; % the step with which the amplitude distributions are discretized
0060 
0061         % Make vector with the amplitude distribution
0062         % First make Gaussian distribution
0063         sorted_values = zeros(no_values, 1);
0064         p = ((1:no_values)/no_values) - 1/(2*no_values);
0065         sorted_values(:,1) = norminv(p, 0, 25)'; % The second number is the mean, the third the standard deviation
0066         % Then discretize it with with steps of step_size
0067         sorted_values(:,1) = round(sorted_values(:,1) / step_size);
0068         sorted_values(:,1) = sorted_values(:,1) * step_size;
0069         % Remove mean and calculate variance for scaling Fourier spectrum.
0070         meanValue = mean(sorted_values(:,1));
0071         sorted_values(:,1) = sorted_values(:,1) - meanValue;
0072         total_variance_pdf = std(sorted_values(:,1)).^2;
0073 
0074         % Calculate the Fourier coefficients.
0075         k = [1:no_values/2 no_values/2-1:-1:1];
0076         pc = k.^(-5/3);                     % This makes a linear power spectrum with slope -5/3
0077         total_variance_spec = sum(pc);
0078         fourier_coeff = zeros(1, no_values);
0079         fourier_coeff(1, 1) = 0;
0080         fourier_coeff(1, 2:no_values) = sqrt(pc * total_variance_pdf / total_variance_spec);
0081         
0082         % As the statistics are theoretical, there is no template data.
0083         x = 1:no_values;
0084         y = 0;
0085 end
0086

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