Home > atmlab > datasets > granule_blacklisted.m

granule_blacklisted

PURPOSE ^

granule_blacklisted Check whether granule is blacklisted

SYNOPSIS ^

function status = granule_blacklisted(sat, sensor, datevec)

DESCRIPTION ^

 granule_blacklisted Check whether granule is blacklisted

 FORMAT

   status = granule_blacklisted(sat, sensor, datevec)

 IN

   sat
   sensor (dataset)
   datevec (see details below)

 OUT

   status
       <0  could not determine (probably no blacklist-file found)
       0   not blacklisted
       >0  blacklisted, probably not wise to use

 Compares 'datevec' against all those listed in the associated 'blacklist'
 file. If the blacklist file contains less columns than datevec, the
 superfluous columns in datevec are ignored. If the blacklist file
 contains less columns than datevec, an error is thrown.

 Note: currently (2011-10-10), the only return values are -1, 0 and 1.
 In the future, statuses may contain more information, e.g.
 the code may indicate why the granule is blacklisted or why it could not
 be determined.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

granule_blacklisted.m

SOURCE CODE ^

0001 function status = granule_blacklisted(sat, sensor, datevec)
0002 
0003 % granule_blacklisted Check whether granule is blacklisted
0004 %
0005 % FORMAT
0006 %
0007 %   status = granule_blacklisted(sat, sensor, datevec)
0008 %
0009 % IN
0010 %
0011 %   sat
0012 %   sensor (dataset)
0013 %   datevec (see details below)
0014 %
0015 % OUT
0016 %
0017 %   status
0018 %       <0  could not determine (probably no blacklist-file found)
0019 %       0   not blacklisted
0020 %       >0  blacklisted, probably not wise to use
0021 %
0022 % Compares 'datevec' against all those listed in the associated 'blacklist'
0023 % file. If the blacklist file contains less columns than datevec, the
0024 % superfluous columns in datevec are ignored. If the blacklist file
0025 % contains less columns than datevec, an error is thrown.
0026 %
0027 % Note: currently (2011-10-10), the only return values are -1, 0 and 1.
0028 % In the future, statuses may contain more information, e.g.
0029 % the code may indicate why the granule is blacklisted or why it could not
0030 % be determined.
0031 
0032 % $Id: granule_blacklisted.m 7175 2011-10-10 09:06:45Z gerrit $
0033 
0034 errid = 'atmlab:granule_blacklisted';
0035 
0036 assert(isvector(datevec), errid, 'datevec must be a vector, it appears not to be');
0037 
0038 status = -1;
0039 
0040 try
0041     blfile = datasets_config('blacklist');
0042 catch ME
0043     if strcmp(ME.identifier, 'atmlab:input:undefined')
0044         return
0045     else
0046         ME.rethrow();
0047     end
0048 end
0049 
0050 if isnan(blfile)
0051     return;
0052 end
0053 
0054 blfile = strrep(blfile, '$SAT', num2str(sat));
0055 blfile = strrep(blfile, '$SENSOR', num2str(sensor));
0056 
0057 if ~exist(blfile, 'file')
0058     return;
0059 end
0060 
0061 M = load(blfile);
0062 ncol = size(M, 2);
0063 dvsize = numel(datevec);
0064 
0065 if dvsize < ncol
0066     error(errid, ['datevec must contain at least as many elements as ' ...
0067                   'blacklistfile has columns. Found %d datevec elements ' ...
0068                   'and %d blacklistfile columns.'], ...
0069           dvsize, ncol);
0070 end
0071 
0072 status = any(all(bsxfun(@(a, b) a==b, M, datevec(1:ncol)), 2));
0073 
0074 end

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