LAYERMEAN Calculate means between adjacent vector elements Returns a vector with one element less than the original vector, containing the mean values between each two adjacent elements. This is useful to calculate column quantities according to the usual ARTS definition that profile grid values represent point values and the profile behaves linearly in-between. If x is a matrix, then the layermean will be the matrix of row means. In other words, size(m) = [size(x,1)-1, size(x,2)]. In this sense, the functions behaves in analogy to diff. To calculate a column value from given height profile z and concentration profile c, do: col = sum( layermean(c) .* diff(z) ) FORMAT m = layermean(x) OUT m Vector or matrix of mean values IN x Input vector or matrix 2006-02-28 Created by Stefan Buehler

- twvcalc TWVCALC Total column water vapor

0001 % LAYERMEAN Calculate means between adjacent vector elements 0002 % 0003 % Returns a vector with one element less than the original 0004 % vector, containing the mean values between each two adjacent 0005 % elements. This is useful to calculate column quantities 0006 % according to the usual ARTS definition that profile grid 0007 % values represent point values and the profile behaves linearly 0008 % in-between. 0009 % 0010 % If x is a matrix, then the layermean will be the matrix of 0011 % row means. In other words, size(m) = [size(x,1)-1, 0012 % size(x,2)]. In this sense, the functions behaves in analogy to 0013 % diff. To calculate a column value from given height profile z 0014 % and concentration profile c, do: 0015 % 0016 % col = sum( layermean(c) .* diff(z) ) 0017 % 0018 % FORMAT m = layermean(x) 0019 % 0020 % OUT m Vector or matrix of mean values 0021 % IN x Input vector or matrix 0022 % 0023 % 2006-02-28 Created by Stefan Buehler 0024 0025 function m = layermean(x) 0026 0027 if size(x,1) == 1 % Vector case. 0028 0029 if length(x) < 2 0030 error( 'There must be at least two levels to calculate the mean.' ); 0031 end 0032 0033 m = ( x(1:end-1) + x(2:end) ) / 2.0; 0034 0035 else % Matrix case 0036 0037 m = ( x(1:end-1,:) + x(2:end,:) ) / 2.0; 0038 0039 end

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