Home > atmlab > geophysics > vmrunit.m

vmrunit

PURPOSE ^

VMRUNIT Automatic selection of VMR unit

SYNOPSIS ^

function [x,xtext,xunit] = vmrunit(x,shorttext)

DESCRIPTION ^

 VMRUNIT   Automatic selection of VMR unit

    Converts data in "true" VMR to ppt, ppb, ppm or leaves the data 
    unchanged.

 FORMAT   [x,xtext,xunit] = vmrunit(x[,shorttext])
        
 OUT   x           Data scaled to selected unit.
       xtext       Text describing data: Volume mixing ratio [*xunit*]
       xunit       String just holding selected unit.
 IN    x           VMR data.
 OPT   shorttext   Flag to use 'VMR' in *xtext* instead of longer version.
                   Default is false.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

vmrunit.m

SOURCE CODE ^

0001 % VMRUNIT   Automatic selection of VMR unit
0002 %
0003 %    Converts data in "true" VMR to ppt, ppb, ppm or leaves the data
0004 %    unchanged.
0005 %
0006 % FORMAT   [x,xtext,xunit] = vmrunit(x[,shorttext])
0007 %
0008 % OUT   x           Data scaled to selected unit.
0009 %       xtext       Text describing data: Volume mixing ratio [*xunit*]
0010 %       xunit       String just holding selected unit.
0011 % IN    x           VMR data.
0012 % OPT   shorttext   Flag to use 'VMR' in *xtext* instead of longer version.
0013 %                   Default is false.
0014 
0015 % 2007-03-01   Created by Patrick Eriksson.
0016 
0017 function [x,xtext,xunit] = vmrunit(x,shorttext)
0018   
0019 if max( x ) < 999e-12
0020   xunit = 'ppt';
0021   xfac  = 1e12;
0022 elseif max( x ) < 999e-9
0023   xunit = 'ppb';
0024   xfac  = 1e9;
0025 elseif max( x( ) < 999e-6
0026   xunit = 'ppm';
0027   xfac  = 1e6;
0028 else
0029   xfac  = 1;
0030   xunit = '-';
0031 end
0032 
0033 
0034 if xfac ~= 1
0035   x = xfac * x;  
0036 end
0037 
0038 
0039 if nargin >= 2  |  shorttext
0040   xtext = sprintf( 'VMR [%s]', xunit );
0041 else
0042   xtext = sprintf( 'Volume mixing ratio [%s]', xunit );
0043 end
0044 
0045   
0046 
0047

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