Home > atmlab > geophysics > profile2column.m

profile2column

PURPOSE ^

PROFILE2COLUMN Calculates column values for profiles

SYNOPSIS ^

function [CC] = profile2column( Z,X,varargin )

DESCRIPTION ^

 PROFILE2COLUMN Calculates column values for profiles
 
   Returns the cumulative columns or the columns at a single threshold 
   altitude z0. Integration is done by the trapezoidal rule.
   
   The concentrations are given as a nxm matrix where n is
   number of altitude levels(first element has the lowest altitude) 
   and m number of measurements. The altitudes
   can either be given as a single column vector(nx1) or a nxm matrix.
   If the altitudes are given as a vector z0 is scalar, if they are 
   given as a matrix z0 must be a vetor of length m.

   The function is made with ground based mesurements in mind, if your data
   has more than two dimensions see example:

   example: X is 4 dimensional matrix containing concentration at points
   in a lat,lon,p,t grid. Z is a 4 dimensional matrix containing altitude
   at point lat,lon,p,t. Note that altitudelevels are the second last
   dimension of the X and Z matrix.

   for n = number of latitudes
       for m = number of longitudes
           CC(n,m,:) = profile2column(Z(n,m,:,:),X(n,m,:,:))
       end
   end

   
   
 FORMAT   [CC]    = PROFILE2COLUMN(Z,X)
        or
          [CC] = PROFILE2COLUMN(Z,X[,z0])
     
 OUT   CC       The cululative column of concentration [m^-2] or the 
               column value at threshold altitude z0.
 IN    Z       The altitude vector [m] or altitude matrix Z(1) is the lowest
               altitude.
       X       Concentration matrix [m^-3].
 OPT   z0        Threshold altitude[m] or threshold altitude vector.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

profile2column.m

SOURCE CODE ^

0001 % PROFILE2COLUMN Calculates column values for profiles
0002 %
0003 %   Returns the cumulative columns or the columns at a single threshold
0004 %   altitude z0. Integration is done by the trapezoidal rule.
0005 %
0006 %   The concentrations are given as a nxm matrix where n is
0007 %   number of altitude levels(first element has the lowest altitude)
0008 %   and m number of measurements. The altitudes
0009 %   can either be given as a single column vector(nx1) or a nxm matrix.
0010 %   If the altitudes are given as a vector z0 is scalar, if they are
0011 %   given as a matrix z0 must be a vetor of length m.
0012 %
0013 %   The function is made with ground based mesurements in mind, if your data
0014 %   has more than two dimensions see example:
0015 %
0016 %   example: X is 4 dimensional matrix containing concentration at points
0017 %   in a lat,lon,p,t grid. Z is a 4 dimensional matrix containing altitude
0018 %   at point lat,lon,p,t. Note that altitudelevels are the second last
0019 %   dimension of the X and Z matrix.
0020 %
0021 %   for n = number of latitudes
0022 %       for m = number of longitudes
0023 %           CC(n,m,:) = profile2column(Z(n,m,:,:),X(n,m,:,:))
0024 %       end
0025 %   end
0026 %
0027 %
0028 %
0029 % FORMAT   [CC]    = PROFILE2COLUMN(Z,X)
0030 %        or
0031 %          [CC] = PROFILE2COLUMN(Z,X[,z0])
0032 %
0033 % OUT   CC       The cululative column of concentration [m^-2] or the
0034 %               column value at threshold altitude z0.
0035 % IN    Z       The altitude vector [m] or altitude matrix Z(1) is the lowest
0036 %               altitude.
0037 %       X       Concentration matrix [m^-3].
0038 % OPT   z0        Threshold altitude[m] or threshold altitude vector.
0039 %
0040 
0041 % 2010-09-24   Created by Ole Martin Christensen.
0042 
0043 function [CC] = profile2column( Z,X,varargin )
0044 %
0045 Z = squeeze(Z);                            
0046 X = squeeze(X);
0047 rqre_datatype( Z, @istensor2 );                                          %&%
0048 rqre_datatype( X, @istensor2 );                                          %&%
0049 z0 = optargs(varargin,{[]});                                             %&%
0050 
0051 if size(Z,2) == 1;
0052     CC = cumtrapz(Z,X);
0053 else
0054     CC = zeros(size(X));
0055     for n = 1:size(Z,2)
0056         CC(:,n) = cumtrapz(Z(:,n),X(:,n));
0057     end
0058 end
0059 
0060 %Subtract away the column beneath the threshold value
0061 if ~isempty(z0)
0062     if size(Z,2) == 1
0063         c = CC(end,:) - interp1(Z,CC,z0);
0064     else
0065         c = zeros(size(X,2),1);
0066         for n = 1:size(Z,2)
0067             c(n) = CC(end,n) - interp1(Z(:,n),CC(:,n),z0(n));
0068         end
0069     end
0070     CC = c;      
0071 end
0072 
0073 
0074 
0075

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