Home > atmlab > deprecated > granule_first_line.m

granule_first_line

PURPOSE ^

granule_first_line Returns first scanline not present in previous granule

SYNOPSIS ^

function first = granule_first_line(sat, sensor, d, reload)

DESCRIPTION ^

 granule_first_line Returns first scanline not present in previous granule

 For a certain granule, return the number of the first scanline that
 is not in the previous scanline. This m-file uses a previously created
 database (a hashtable). This hash-table is cached between subsequent
 calls of the function.

 There should exist an entry for each satellite/sensor granule. If it's
 not found, an error is raised, and there is probably a bug somewhere. If
 the satellite/sensor granule exists, but there is no (unique) previous
 granule, line -2 is returned.

 FORMAT

   first = granule_first_line(sat, sensor, datevec[, reload])

 IN

   sat         string      Satellite
   sensor      string      Sensor
   datevec     vector      Starting date/time for granule
   reload      logical     (optional) Reload scanline data (i.e. not
                           cached). Defaults to false.

 OUT

   first       number      First scanline not in previous granule.
                           Special values: -1 (no data found), -2 (no
                           previous granule found)

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

granule_first_line.m

SOURCE CODE ^

0001 function first = granule_first_line(sat, sensor, d, reload)
0002 
0003 % granule_first_line Returns first scanline not present in previous granule
0004 %
0005 % For a certain granule, return the number of the first scanline that
0006 % is not in the previous scanline. This m-file uses a previously created
0007 % database (a hashtable). This hash-table is cached between subsequent
0008 % calls of the function.
0009 %
0010 % There should exist an entry for each satellite/sensor granule. If it's
0011 % not found, an error is raised, and there is probably a bug somewhere. If
0012 % the satellite/sensor granule exists, but there is no (unique) previous
0013 % granule, line -2 is returned.
0014 %
0015 % FORMAT
0016 %
0017 %   first = granule_first_line(sat, sensor, datevec[, reload])
0018 %
0019 % IN
0020 %
0021 %   sat         string      Satellite
0022 %   sensor      string      Sensor
0023 %   datevec     vector      Starting date/time for granule
0024 %   reload      logical     (optional) Reload scanline data (i.e. not
0025 %                           cached). Defaults to false.
0026 %
0027 % OUT
0028 %
0029 %   first       number      First scanline not in previous granule.
0030 %                           Special values: -1 (no data found), -2 (no
0031 %                           previous granule found)
0032 %
0033 % $Id: granule_first_line.m 7553 2012-04-27 19:08:16Z gerrit $
0034 
0035 persistent S;
0036 
0037 warning(['atmlab:' mfilename], 'old style function, being phased out, use OO way');
0038 
0039 if isempty(S)
0040     S = struct;
0041 end
0042 
0043 if ~exist('reload', 'var')
0044     reload = false;
0045 end
0046 
0047 if isfield(S, sat) && isfield(S.(sat), sensor) && ~reload
0048     ht = S.(sat).(sensor);
0049 else
0050     scanfile = datasets_config('firstline_data');
0051     scanfile = strrep(scanfile, '$SAT', sat);
0052     scanfile = strrep(scanfile, '$SENSOR', sensor);
0053     
0054     t = load(scanfile);
0055     ht = t.ht;
0056     S.(sat).(sensor) = ht;
0057 end
0058 
0059 if isscalar(d)
0060     unisecs = uint32(d);
0061 else
0062     dv = num2cell(d);
0063     unisecs = uint32(date2unixsecs(dv{:}));
0064 end
0065 
0066 first = ht.get(unisecs);
0067 if isempty(first)
0068     error('atmlab:granule_first_line', 'no data found for %s/%s @ %d', ...
0069         sat, sensor, unisecs);
0070 end

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