Home > atmlab > arts > scenegen > asg_zeropad.m

asg_zeropad

PURPOSE ^

ASG_ZEROPAD Add zeros in ASG data so that the fields

SYNOPSIS ^

function G=asg_zeropad(G,Q,varargin)

DESCRIPTION ^

 ASG_ZEROPAD  Add zeros in ASG data so that the fields
              are defined everywhere

              zeros are added at the edges
              (as example lat=-90 and lat=90)
              and just outside the defined
              region of the original G data,
              where the grids will be defined
              by values of DX.

 FORMAT   G = asg_zeropad( G, Q ,DX )
        
 OUT   G   Extrapolated ASG data.
 IN    
       G   ASG data.
       Q   Qarts setting structure.
 Opt.  DX  vector. 
           DX(1) corresponds pressure.
           DX(2) to latitude.
           DX(3) to longitude.
           default is [1 0.01 0.01]
           As example G.GRID1+DX(1) will
           be a new grid point where the data
           will be set to zeros.

 2007-11-13   Created by Bengt Rydberg

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

asg_zeropad.m

SOURCE CODE ^

0001 % ASG_ZEROPAD  Add zeros in ASG data so that the fields
0002 %              are defined everywhere
0003 %
0004 %              zeros are added at the edges
0005 %              (as example lat=-90 and lat=90)
0006 %              and just outside the defined
0007 %              region of the original G data,
0008 %              where the grids will be defined
0009 %              by values of DX.
0010 %
0011 % FORMAT   G = asg_zeropad( G, Q ,DX )
0012 %
0013 % OUT   G   Extrapolated ASG data.
0014 % IN
0015 %       G   ASG data.
0016 %       Q   Qarts setting structure.
0017 % Opt.  DX  vector.
0018 %           DX(1) corresponds pressure.
0019 %           DX(2) to latitude.
0020 %           DX(3) to longitude.
0021 %           default is [1 0.01 0.01]
0022 %           As example G.GRID1+DX(1) will
0023 %           be a new grid point where the data
0024 %           will be set to zeros.
0025 %
0026 % 2007-11-13   Created by Bengt Rydberg
0027 
0028 function G=asg_zeropad(G,Q,varargin)
0029 %
0030 DX = optargs( varargin, { [1 0.01 0.01] } );
0031 
0032 
0033 %- Basic checks of input
0034 %
0035 qcheck( @qarts, Q );
0036 %
0037 rqre_in_range( Q.ATMOSPHERE_DIM, 1, 3 );
0038 
0039 %- New grids for p, lat and lon .
0040 %
0041 expandg = { [1.1e5 1e-9], [-90 90], [-180 180] };
0042 
0043 for ig = 1 : length(G)
0044 
0045   %- Do nothing if DATA field is empty.
0046   %
0047   if isempty( G(ig).DATA )
0048     continue;
0049   end
0050   for i=1:G(ig).DIM
0051       gname = sprintf( 'GRID%d', i );
0052       grid=G(ig).(gname);
0053       gname=sprintf( 'GRID%d_NAME', i );
0054       if strcmp(lower(G(ig).(gname)),'pressure') 
0055         grid_add=[grid(1)+DX(i) grid(end)-DX(i)];
0056       else
0057         grid_add=[grid(1)-DX(i) grid(end)+DX(i)];
0058       end    
0059       grid=sort([vec2col(grid)' grid_add expandg{i}])';
0060       if strcmp(G.(gname),'Pressure')
0061         grid=flipud(grid);
0062       end
0063       gname = sprintf( 'GRID%d', i );
0064       G(ig).(gname)=grid;
0065 
0066       %add the zeros
0067       if isvector(G(ig).DATA)
0068          G(ig).DATA=vec2col(G(ig).DATA);
0069       end
0070       data_size=size(G(ig).DATA);
0071       data_size(i)= data_size(i)+4;
0072       data=zeros(data_size);    
0073       %shift dimensions
0074       data_dim=dimens(data);     
0075       old_data=shiftdim(G(ig).DATA,i-1);
0076       data=shiftdim(data,i-1);    
0077       data(3:end-2,:,:)=old_data;
0078       %shift back dimensions
0079       G(ig).DATA=shiftdim(data,data_dim-i+1);
0080       if isvector(G(ig).DATA)
0081          G(ig).DATA=vec2col(G(ig).DATA);
0082       end
0083    end
0084 end

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