Home > atmlab > arts > arts_datatypes.m

arts_datatypes

PURPOSE ^

ARTS_DATATYPES Mapping between ARTS data types and container dimensionality

SYNOPSIS ^

function [oa,datagroup] = arts_datatypes( ia, datagroup )

DESCRIPTION ^

 ARTS_DATATYPES   Mapping between ARTS data types and container dimensionality

    This function can be used to automatically determine the name or
    dimensionality of an ARTS data type. Its main purpose is to determine
    the variable group for when going up one step in dimensionality.

    For example:
       [oa,datagroup] = arts_datatypes('Vector');
       arts_datatypes(oa+1,datagroup)
    gives 
       'Matrix'
    and
       [oa,datagroup] = arts_datatypes('ArrayOfString');
       arts_datatypes(oa+1,datagroup)
    gives 
       'ArrayOfArrayOfString'

 FORMAT   [oa,datagroup] = arts_datatypes( artstype )
        
 OUT   oa          Variable dimensionality. 0 returned for aray variables
                   not part of 'num' and 'int' types.
       datagroup   Type of data. Defined choices are:
                      'num'  : Numeric, Vector, Matrix, Tensor3 ... Tensor7
                      'int'  : Index, ArrayOfIndex
                   *artstype* returned for all other array variables.
 IN    artstype    ARTS variable group

   or

 FORMAT   [artstype] = arts_datatypes( oa, datagroup )
        
 OUT   artstype    ARTS variable group
 IN    oa          As output argument above with same name.
       datagroup   As output argument above with same name.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

arts_datatypes.m

SOURCE CODE ^

0001 % ARTS_DATATYPES   Mapping between ARTS data types and container dimensionality
0002 %
0003 %    This function can be used to automatically determine the name or
0004 %    dimensionality of an ARTS data type. Its main purpose is to determine
0005 %    the variable group for when going up one step in dimensionality.
0006 %
0007 %    For example:
0008 %       [oa,datagroup] = arts_datatypes('Vector');
0009 %       arts_datatypes(oa+1,datagroup)
0010 %    gives
0011 %       'Matrix'
0012 %    and
0013 %       [oa,datagroup] = arts_datatypes('ArrayOfString');
0014 %       arts_datatypes(oa+1,datagroup)
0015 %    gives
0016 %       'ArrayOfArrayOfString'
0017 %
0018 % FORMAT   [oa,datagroup] = arts_datatypes( artstype )
0019 %
0020 % OUT   oa          Variable dimensionality. 0 returned for aray variables
0021 %                   not part of 'num' and 'int' types.
0022 %       datagroup   Type of data. Defined choices are:
0023 %                      'num'  : Numeric, Vector, Matrix, Tensor3 ... Tensor7
0024 %                      'int'  : Index, ArrayOfIndex
0025 %                   *artstype* returned for all other array variables.
0026 % IN    artstype    ARTS variable group
0027 %
0028 %   or
0029 %
0030 % FORMAT   [artstype] = arts_datatypes( oa, datagroup )
0031 %
0032 % OUT   artstype    ARTS variable group
0033 % IN    oa          As output argument above with same name.
0034 %       datagroup   As output argument above with same name.
0035 
0036 % 2005-05-26   Created by Patrick Eriksson.
0037 
0038 
0039 function [oa,datagroup] = arts_datatypes( ia, datagroup )
0040 
0041 
0042 numtypes = {
0043 'Numeric' , ...
0044 'Vector' , ...
0045 'Matrix' , ...
0046 'Tensor3' , ...
0047 'Tensor4' , ...
0048 'Tensor5' , ...
0049 'Tensor6' , ...
0050 'Tensor7'
0051 };
0052 
0053 inttypes = {
0054 'Index', ...
0055 'ArrayOfIndex'
0056 };
0057 
0058 
0059 
0060 if nargin == 1
0061   %
0062   i         = find( strcmp( numtypes, ia ) );
0063   datagroup = 'num';
0064   %
0065   if isempty(i)
0066     i         = find( strcmp( inttypes, ia ) );
0067     oa        = i - 1;
0068     datagroup = 'int';
0069   else
0070     oa = i - 1;
0071   end
0072   %
0073   if isempty(i)  & strncmp( ia, 'ArrayOf', 7 )
0074     i         = 1;
0075     oa        = 0; 
0076     datagroup = ia;
0077   end
0078 
0079   if isempty(i)
0080     error( sprintf('The type %s was not found.', ia ) );
0081   end
0082 
0083 
0084 else
0085   %
0086   rqre_datatype( datagroup, @ischar );                               %&%
0087   %
0088   if strcmp( lower(datagroup), 'num' )
0089     %
0090     oa  = numtypes{ia+1};
0091 
0092   elseif strcmp( lower(datagroup), 'int' )
0093     %
0094     oa  = inttypes{ia+1};
0095 
0096   elseif strncmp( datagroup, 'ArrayOf', 7 )
0097     %
0098     for i = 1:ia
0099       datagroup = sprintf( 'ArrayOf%s', datagroup );
0100     end
0101     %
0102     oa = datagroup;
0103     
0104   else
0105      error( sprintf('Unknown datagroup (%s)',datagroup) );
0106   end
0107 
0108 end

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