Home > atmlab > arts > scenegen > asg_2d23d.m

asg_2d23d

PURPOSE ^

ASG_2D23D expand 2-dimensional Gformat data into

SYNOPSIS ^

function G = asg_2d23d( G, Q );

DESCRIPTION ^

ASG_2D23D  expand 2-dimensional Gformat data into
           3-dimensional data using an Iterative
           Amplitude Adapted Fourier Transform (IAAFT)
           algorithm.
 

OUT  G   Modified Gformat data
    
IN  
     G   ASG data.
     Q   Qarts setting structure
         Only Q.SENSOR_LOS and Q.SENSOR_POS are considered

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

asg_2d23d.m

SOURCE CODE ^

0001 %ASG_2D23D  expand 2-dimensional Gformat data into
0002 %           3-dimensional data using an Iterative
0003 %           Amplitude Adapted Fourier Transform (IAAFT)
0004 %           algorithm.
0005 %
0006 %
0007 %OUT  G   Modified Gformat data
0008 %
0009 %IN
0010 %     G   ASG data.
0011 %     Q   Qarts setting structure
0012 %         Only Q.SENSOR_LOS and Q.SENSOR_POS are considered
0013 %
0014 
0015 % 2007-12-04   Created by Bengt Rydberg
0016 
0017 function G = asg_2d23d( G, Q );
0018 
0019 X.p_grid=G.GRID1;
0020 X.lat_grid=G.GRID2;
0021 X.data=G.DATA;
0022 
0023 %the function reguires the input matrix to be of even size
0024 if isodd(length(X.lat_grid))
0025   X.data=X.data(:,1:end-1);
0026   X.lat_grid=X.lat_grid(1:end-1);
0027 end
0028 if isodd(length(X.p_grid))
0029   X.data=X.data(1:end-1,:);
0030   X.p_grid=X.p_grid(1:end-1);
0031 end
0032 
0033 %now prepare data for surrogate_2d_3d
0034 
0035 template=X.data;
0036 [no_values_y, no_values_x] = size(template); 
0037 x = 1:no_values_x;
0038 y = 1:no_values_y;
0039 mean_pdf_profile = squeeze(mean(template, 2));
0040 
0041 % Make sorted vector.
0042 template = remove_average_profile(template, mean_pdf_profile);
0043 sorted_values_prof = sort(template, 2);
0044 sorted_values_prof = sorted_values_prof';
0045 total_variance_pdf = std(sorted_values_prof(:)).^2;
0046     
0047 % Calculate Fourier coeffients and scale them.
0048 fourier_coeff_2d = abs(ifft2( template ));
0049 power = fourier_coeff_2d.^2;
0050 total_variance_spec = sum(sum(power));
0051 power = power * total_variance_pdf / total_variance_spec;
0052 fourier_coeff_2d = sqrt(power');
0053 
0054 surrogate_2d_3d
0055 
0056 
0057 [i1,i2,i3]=size(surrogate);
0058 %rearrange the data grid
0059 P=zeros(i3,i1,i2);
0060 for i=1:i1
0061   for j=1:i2
0062      P(:,i,j)=surrogate(i,j,:);  
0063  end
0064 end
0065 
0066 Y.p_grid=X.p_grid;
0067 Y.lat_grid=X.lat_grid;
0068 %dlat=abs(X.lat_grid(end)-X.lat_grid(1));
0069 %Y.lon_grid=linspace(-dlat/2,dlat/2,length(X.lat_grid));
0070 Y.data=P;
0071 
0072 data=zeros([size(G.DATA) size(G.DATA,2)]);
0073 
0074 %if the size of the input matrix was odd
0075 %fill out the last elements with the same values
0076 %as the neighbouring
0077 ilen=1:length(Y.p_grid);
0078 
0079 if isodd(length(G.GRID2))
0080   data(ilen,1:end-1,1:end-1)=Y.data;
0081   data(ilen,1:end-1,end)=Y.data(ilen,:,end);
0082   data(ilen,end,1:end-1)=Y.data(ilen,end,:);
0083   data(ilen,end,end)=Y.data(ilen,end,end);
0084   Y.data=data;
0085 end
0086 
0087 if isodd(length(G.GRID1))
0088   data(end,:,:)=Y.data(end-1,:,:);
0089   Y.data=data;
0090 end
0091 
0092 %the data is now on a lon_grid corresponding to our lat_grid
0093 %we want to have it on Q.LON_GRID, so we bin it on this grid
0094 G.DATA=Y.data;
0095 G.GRID3=G.GRID2-mean(G.GRID2);
0096 G.DIM=3;
0097 m1=mean(Q.LON_GRID);
0098 GRIDS{1}=Q.LON_GRID-m1;
0099 DIMS=3;
0100 
0101 %round off the grids not to have any problems
0102 G.GRID3=round(G.GRID3*1e6)/1e6;
0103 GRIDS{1}=round(GRIDS{1}*1e6)/1e6;
0104 G=asg_bin( G, GRIDS , DIMS);
0105 G.GRID3=G.GRID3+m1;

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