Home > atmlab > arts > scenegen > asg_bin.m

asg_bin

PURPOSE ^

ASG_BIN bin data on gformat

SYNOPSIS ^

function [G]=asg_bin(G,grids,dims)

DESCRIPTION ^

 ASG_BIN   bin data on gformat

          Bin data in G. The binning is performed in
          one dimension. If binning in more than one 
          dimension is desired the binning is performed
          in order of how the grids are in GRIDS. 

 FORMAT   G=asg_bin( G, GRIDS , DIMS)
 
 IN       G        original gformat data             
          GRIDS    cell array with grids
          DIMS     vector with dimensions corresonding
                   to G.GRID*. If DIMS(1)=1 the
                   dimension is as defined in G.GRID1 
      
 example usage:
 z_grid=[0:1e3:20e3];lat_grid=[0:0.05:5];
 grids{1}=z_grid;grids{2}=lat_grid;
 dims(1)=1;dims(2)=2;
 G=asg_bin(G,grids,dims); 
  
 2007-11-05 created by Bengt Rydberg

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

asg_bin.m

SOURCE CODE ^

0001 % ASG_BIN   bin data on gformat
0002 %
0003 %          Bin data in G. The binning is performed in
0004 %          one dimension. If binning in more than one
0005 %          dimension is desired the binning is performed
0006 %          in order of how the grids are in GRIDS.
0007 %
0008 % FORMAT   G=asg_bin( G, GRIDS , DIMS)
0009 %
0010 % IN       G        original gformat data
0011 %          GRIDS    cell array with grids
0012 %          DIMS     vector with dimensions corresonding
0013 %                   to G.GRID*. If DIMS(1)=1 the
0014 %                   dimension is as defined in G.GRID1
0015 %
0016 % example usage:
0017 % z_grid=[0:1e3:20e3];lat_grid=[0:0.05:5];
0018 % grids{1}=z_grid;grids{2}=lat_grid;
0019 % dims(1)=1;dims(2)=2;
0020 % G=asg_bin(G,grids,dims);
0021 %
0022 % 2007-11-05 created by Bengt Rydberg
0023 %
0024    
0025 function [G]=asg_bin(G,grids,dims)
0026    
0027 %if length(grids)~= length(G.dims)
0028 %   error('Mismatch in size between grids and dims')
0029 %end
0030 
0031  
0032 for i=1:length(grids)
0033     grids{i}=vec2col(grids{i});
0034     if ~isvector(grids{i})
0035        error('the elements in GRIDS must be a vector')
0036     end
0037 end
0038 
0039 
0040 
0041 for j=1:length(G)
0042     for ig=1:length(grids)
0043         gname = sprintf( 'GRID%d', dims(ig) );
0044         old_grids{ig}=vec2col([G(j).(gname)]);
0045         if ~isempty(old_grids{ig}) 
0046           if min(grids{ig})<min(old_grids{ig}) | ...
0047                  max(grids{ig})>max(old_grids{ig})
0048             warning('grids is outside the range of original grids')
0049           end
0050            %find the dimension of data
0051            old_dim=dims(ig);
0052            data=G(j).DATA;
0053            warning off
0054            funhandle = @(data) binning(grids{ig},old_grids{ig},data);
0055            data = fun2Dwrapper(data,old_dim,funhandle,'X'); 
0056            warning on
0057            G(j).DATA=data;
0058            G(j).(gname)=grids{ig};
0059         end
0060    end
0061 end   
0062 
0063

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