Home > atmlab > h2o > parametrisations > complex_refr_indexFromFunc.m

complex_refr_indexFromFunc

PURPOSE ^

COMPLEX_REFR_INFDEXFROMFUN Sets up complex_refr_index

SYNOPSIS ^

function N = complex_refr_indexFromFunc(f_grid,t_grid,nfun,mapfun)

DESCRIPTION ^

 COMPLEX_REFR_INFDEXFROMFUN   Sets up complex_refr_index 

    The function creates a variable matching ARTS's definition of
    complex_refr_index. That is, data of complex refractive index is
    compiled in to a single variable, of type GriddedField3.

    The function to be used for calculating refractive index is 
    specified as a function handle (nfun). For higher flexibility, 
    the data returned by this function can be modified further by 
    setting *mapfun*. The standard usage of *mapfun* should be to
    convert dielectric constant data to refractive index, by setting
    mapfun = @sqrt. An example:

    N = complex_refr_indexFromFunc(fg,tg,@eps_water_liebe93,@sqrt);

 FORMAT   N = complex_refr_indexFromFunc(f_grid,t_grid,nfun[,mapfun])
        
 OUT   G        Data in GriddedField3 format.
 IN    f_grid   Frequency grid.
       t_grid   Temperature grid.
       nfun     Handle to function returning relevant data.
 OPT   mapfun   Mapping function, see above.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

complex_refr_indexFromFunc.m

SOURCE CODE ^

0001 % COMPLEX_REFR_INFDEXFROMFUN   Sets up complex_refr_index
0002 %
0003 %    The function creates a variable matching ARTS's definition of
0004 %    complex_refr_index. That is, data of complex refractive index is
0005 %    compiled in to a single variable, of type GriddedField3.
0006 %
0007 %    The function to be used for calculating refractive index is
0008 %    specified as a function handle (nfun). For higher flexibility,
0009 %    the data returned by this function can be modified further by
0010 %    setting *mapfun*. The standard usage of *mapfun* should be to
0011 %    convert dielectric constant data to refractive index, by setting
0012 %    mapfun = @sqrt. An example:
0013 %
0014 %    N = complex_refr_indexFromFunc(fg,tg,@eps_water_liebe93,@sqrt);
0015 %
0016 % FORMAT   N = complex_refr_indexFromFunc(f_grid,t_grid,nfun[,mapfun])
0017 %
0018 % OUT   G        Data in GriddedField3 format.
0019 % IN    f_grid   Frequency grid.
0020 %       t_grid   Temperature grid.
0021 %       nfun     Handle to function returning relevant data.
0022 % OPT   mapfun   Mapping function, see above.
0023 
0024 % 2013-08-18   Created by Patrick Eriksson.
0025 
0026 
0027 function N = complex_refr_indexFromFunc(f_grid,t_grid,nfun,mapfun)
0028 
0029 % Check input
0030 %
0031 rqre_datatype( f_grid, @istensor1 );
0032 rqre_datatype( t_grid, @istensor1 );
0033 rqre_datatype( nfun, @isfunction_handle );
0034 if nargin > 3
0035   rqre_datatype( mapfun, @isfunction_handle );
0036 end
0037 
0038 
0039 % Set aux data
0040 N.name = sprintf( 'Complex n data obtained in Atmlab by %s', ...
0041                                                 func2str(nfun ) );
0042 
0043 N.gridnames = { 'Frequency', 'Temperature', 'Complex' };
0044 N.grids     = { f_grid, t_grid, [1 2]' };
0045 N.dataname  = 'Complex refractive index';
0046 
0047 
0048 % Fill data
0049 %
0050 N.data      = zeros( length(f_grid), length(t_grid), 2 );
0051 %
0052 for i = 1 : length(f_grid)
0053   for j = 1 : length(t_grid)
0054 
0055     n = nfun( f_grid(i), t_grid(j) );
0056     
0057     if nargin > 3
0058       n = mapfun(n);
0059     end
0060     
0061     N.data(i,j,:) = [ real(n) imag(n) ];
0062     
0063   end
0064 end

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