Home > atmlab > deprecated > find_info_from_granule.m

find_info_from_granule

PURPOSE ^

find_info_from_granule Extract info from a granule filename

SYNOPSIS ^

function S = find_info_from_granule(dataset, fname)

DESCRIPTION ^

 find_info_from_granule Extract info from a granule filename

 FIXME DOC! Explanation below related to old-style, before 2012-02-01.
 New style is configured differently!

 For a given dataset and filename, return a structure with information
 extracted from the filename, such as year, month, day. This is just a
 short wrapper around <a href="matlab:help regexp">regexp</a>. If no information
 can be extracted, the result is an empty structure. All structure members
 are string, e.g. no conversions from string to number is done. Members
 that could have been matched but weren't are set to []. Valid
 datasets are those that have a datasets_config('DATASET_regexp') defined,
 which means most of the datasets returned by <a href="matlab:help list_datasets">list_datasets</a>.
 The returned fields are at most those names defined in
 datasets_config('DATASET_regexp').
 Common fields are: year, month, day, doy. But anything matched by the
 regular expression is a field. 

 More information about regular expressions at <a href="http://en.wikipedia.org/wiki/Regular_expression">Wikipedia</a>

 FORMAT

   S = find_info_from_granule(dataset, fname)

 IN

   dataset     string      describing the dataset
   fname       string      the filename

 OUT

   S           structure   members such as 'year', 'month', etc. describe
                           matched info.

 EXAMPLES

 Note: these examples depend on particular settings in datasets_config, in
 particular those set by site-specific/kiruna/datasets_init.m

 >> find_info_from_granule('cpr', '2006333114032_03133_CS_2B-CWC-RO_GRANULE_P_R04_E02.hdf.zip')
 
 ans = 
 
       year: '2006'
        doy: '333'
       hour: '11'
     minute: '40'
 
 >> find_info_from_granule('mhs', '56037363.NSS.MHSX.NP.D09284.S1310.E1456.B0348485.GC.gz')
 
 ans = 
 
        hour: '13'
     satname: []
      minute: '10'
        year: []
       month: []
         day: []

 >> find_info_from_granule('mhs', '/storage3/data/mhs/noaa18_mhs_2009/08/09/56037363.NSS.MHSX.NP.D09284.S1310.E1456.B0348485.GC.gz')
 
 ans = 
 
        hour: '13'
     satname: 'noaa18'
      minute: '10'
        year: '2009'
       month: '08'
         day: '09'


 Feel free to change the regular expressions to return additional
 information, but be sure not to break any existing matches.
 Have fun.

 $Id: find_info_from_granule.m 7553 2012-04-27 19:08:16Z gerrit $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

find_info_from_granule.m

SOURCE CODE ^

0001 function S = find_info_from_granule(dataset, fname)
0002 
0003 % find_info_from_granule Extract info from a granule filename
0004 %
0005 % FIXME DOC! Explanation below related to old-style, before 2012-02-01.
0006 % New style is configured differently!
0007 %
0008 % For a given dataset and filename, return a structure with information
0009 % extracted from the filename, such as year, month, day. This is just a
0010 % short wrapper around <a href="matlab:help regexp">regexp</a>. If no information
0011 % can be extracted, the result is an empty structure. All structure members
0012 % are string, e.g. no conversions from string to number is done. Members
0013 % that could have been matched but weren't are set to []. Valid
0014 % datasets are those that have a datasets_config('DATASET_regexp') defined,
0015 % which means most of the datasets returned by <a href="matlab:help list_datasets">list_datasets</a>.
0016 % The returned fields are at most those names defined in
0017 % datasets_config('DATASET_regexp').
0018 % Common fields are: year, month, day, doy. But anything matched by the
0019 % regular expression is a field.
0020 %
0021 % More information about regular expressions at <a href="http://en.wikipedia.org/wiki/Regular_expression">Wikipedia</a>
0022 %
0023 % FORMAT
0024 %
0025 %   S = find_info_from_granule(dataset, fname)
0026 %
0027 % IN
0028 %
0029 %   dataset     string      describing the dataset
0030 %   fname       string      the filename
0031 %
0032 % OUT
0033 %
0034 %   S           structure   members such as 'year', 'month', etc. describe
0035 %                           matched info.
0036 %
0037 % EXAMPLES
0038 %
0039 % Note: these examples depend on particular settings in datasets_config, in
0040 % particular those set by site-specific/kiruna/datasets_init.m
0041 %
0042 % >> find_info_from_granule('cpr', '2006333114032_03133_CS_2B-CWC-RO_GRANULE_P_R04_E02.hdf.zip')
0043 %
0044 % ans =
0045 %
0046 %       year: '2006'
0047 %        doy: '333'
0048 %       hour: '11'
0049 %     minute: '40'
0050 %
0051 % >> find_info_from_granule('mhs', '56037363.NSS.MHSX.NP.D09284.S1310.E1456.B0348485.GC.gz')
0052 %
0053 % ans =
0054 %
0055 %        hour: '13'
0056 %     satname: []
0057 %      minute: '10'
0058 %        year: []
0059 %       month: []
0060 %         day: []
0061 %
0062 % >> find_info_from_granule('mhs', '/storage3/data/mhs/noaa18_mhs_2009/08/09/56037363.NSS.MHSX.NP.D09284.S1310.E1456.B0348485.GC.gz')
0063 %
0064 % ans =
0065 %
0066 %        hour: '13'
0067 %     satname: 'noaa18'
0068 %      minute: '10'
0069 %        year: '2009'
0070 %       month: '08'
0071 %         day: '09'
0072 %
0073 %
0074 % Feel free to change the regular expressions to return additional
0075 % information, but be sure not to break any existing matches.
0076 % Have fun.
0077 %
0078 % $Id: find_info_from_granule.m 7553 2012-04-27 19:08:16Z gerrit $
0079 
0080 D = datasets;
0081 if isfield(D, dataset)
0082     matchy = D.(dataset).re;
0083 else
0084     matchy = datasets_config([dataset '_regexp']);
0085 end
0086 S = regexp(fname, matchy, 'names');

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