Home > atmlab > gformat > isatmdata.m

isatmdata

PURPOSE ^

ISATMDATA Determines if the variable is of atmdata type

SYNOPSIS ^

function b = isatmdata( G )

DESCRIPTION ^

 ISATMDATA   Determines if the variable is of atmdata type

   Atmdata is a format for storing atmospheric climatology data. The gformat 
   is used where the dimensions are pressure, latitude, longitude, day and
   hour. That is, up to five dimensions can be used.

   Three options exist for the day dimension:
      'mjd'     : Modified julian date.
      'doy'     : Day of the year. Valid range is [1,367[. See also *mjd2doy*.
      'datenum' : Matlab's datenum (with default pivot year).

   The valid range for hour is [0,24]. This dimesion refers to local
   (solar) time.

   The identification of atmdata is performed by checking the TYPE field and
   grid names. These fields of G must be set as follows:
     TYPE = 'atmdata'
     GRID1_NAME = 'pressure'
     GRID2_NAME = 'latitude'
     GRID3_NAME = 'longitude'
     GRID4_NAME = 'doy', 'mjd' or 'datenum'
     GRID5_NAME = 'hour'.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

isatmdata.m

SOURCE CODE ^

0001 % ISATMDATA   Determines if the variable is of atmdata type
0002 %
0003 %   Atmdata is a format for storing atmospheric climatology data. The gformat
0004 %   is used where the dimensions are pressure, latitude, longitude, day and
0005 %   hour. That is, up to five dimensions can be used.
0006 %
0007 %   Three options exist for the day dimension:
0008 %      'mjd'     : Modified julian date.
0009 %      'doy'     : Day of the year. Valid range is [1,367[. See also *mjd2doy*.
0010 %      'datenum' : Matlab's datenum (with default pivot year).
0011 %
0012 %   The valid range for hour is [0,24]. This dimesion refers to local
0013 %   (solar) time.
0014 %
0015 %   The identification of atmdata is performed by checking the TYPE field and
0016 %   grid names. These fields of G must be set as follows:
0017 %     TYPE = 'atmdata'
0018 %     GRID1_NAME = 'pressure'
0019 %     GRID2_NAME = 'latitude'
0020 %     GRID3_NAME = 'longitude'
0021 %     GRID4_NAME = 'doy', 'mjd' or 'datenum'
0022 %     GRID5_NAME = 'hour'.
0023   
0024 %   Only used grids are checked (determined by G(i).DIM). No distinction is
0025 %   made between lower- and upper-case letters.
0026 %
0027 %   There is NO check of actual data beside the grid names.
0028 %
0029 %   Functions specific for atmdata are named as atmdata_xxx. MJD is expected
0030 %   when the input of these functions include any date.
0031 %
0032 % FORMAT   b = isatmdata( G )
0033 %
0034 % OUT   b     True or false.
0035 % IN    G     A gformat structure (array).
0036 
0037 % 2010-01-07   Created by Patrick Eriksson.
0038 
0039 function b = isatmdata( G )
0040 
0041 b = false;
0042 
0043 if ~isstruct(G) ||  ~isfield(G,'DIM'), return, end
0044 
0045 Gt = atmdata_empty( max( G(:).DIM ) );
0046 
0047 if ~all( isfield( G, fieldnames(Gt) ) ), return, end
0048 
0049 for i = 1 : length(G)
0050 
0051   if ~strcmp( lower(G(i).TYPE), 'atmdata' )
0052     return
0053   end
0054 
0055   for d = 1 : min([ G(i).DIM 3 ] )
0056     gname = sprintf( 'GRID%d_NAME', d );
0057     if ~strcmp( lower(G(i).(gname)), lower(Gt.(gname)) )
0058       return
0059     end
0060   end
0061   if G(i).DIM >= 4
0062     gname = sprintf( 'GRID%d_NAME', 4 );
0063     if ~any( strcmp( lower(G(i).(gname)), {'doy','mjd','datenum'} ) )
0064       return
0065     end
0066     if G(i).DIM >= 5
0067       gname = sprintf( 'GRID%d_NAME', 5 );
0068     if ~strcmp( lower(G(i).(gname)), lower(Gt.(gname)) )
0069       return
0070     end
0071   end
0072   end
0073     
0074     
0075 end
0076 
0077 b = true;
0078

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