Home > atmlab > deprecated > collocate_and_store_date.m

collocate_and_store_date

PURPOSE ^

collocate_and_store_date Collect collocations and store appropiately

SYNOPSIS ^

function collocate_and_store_date(year, month, day,sat1, sensor1, sat2, sensor2)

DESCRIPTION ^

 collocate_and_store_date Collect collocations and store appropiately

 For a given date, check whether a collocation datafile exists.
 If it doesn't (or colloc_config('overwrite') is set), collocate the indicated
 satellites and sensors with each other and store the result in the
 appropiate datafile.

 FORMAT

   collocate_and_store_date(year, month, day, sat1, sensor1, sat2, sensor2)

 IN

   year    (numeric)   Year for which to write collocations
   month   (numeric)   Month for which to write collocations
   day     (numeric)   Day for which to write collocations
   sat1    string      Primary satellite to consider
   sensor1 string      Sensor at sat1 to consider
   sat2    string      Secondary satellite to consider (POES means many)
   sensor2 string      Sensor at secondary satellite to consider

 OUT

   none (but writes file with write_collocations)

 $Id$

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

collocate_and_store_date.m

SOURCE CODE ^

0001 function collocate_and_store_date(year, month, day, ...
0002     sat1, sensor1, sat2, sensor2)
0003 
0004 % collocate_and_store_date Collect collocations and store appropiately
0005 %
0006 % For a given date, check whether a collocation datafile exists.
0007 % If it doesn't (or colloc_config('overwrite') is set), collocate the indicated
0008 % satellites and sensors with each other and store the result in the
0009 % appropiate datafile.
0010 %
0011 % FORMAT
0012 %
0013 %   collocate_and_store_date(year, month, day, sat1, sensor1, sat2, sensor2)
0014 %
0015 % IN
0016 %
0017 %   year    (numeric)   Year for which to write collocations
0018 %   month   (numeric)   Month for which to write collocations
0019 %   day     (numeric)   Day for which to write collocations
0020 %   sat1    string      Primary satellite to consider
0021 %   sensor1 string      Sensor at sat1 to consider
0022 %   sat2    string      Secondary satellite to consider (POES means many)
0023 %   sensor2 string      Sensor at secondary satellite to consider
0024 %
0025 % OUT
0026 %
0027 %   none (but writes file with write_collocations)
0028 %
0029 % $Id$
0030 
0031 %% get filename
0032 
0033 % check whether one or two sats should be passed.
0034 
0035 warning(['atmlab:' mfilename], 'old style function, being phased out, use OO way');
0036 
0037 switch number_sats_in_dataset(['collocation_' sensor1 '_' sensor2])
0038     case 1
0039         s = sat2;
0040     case 2
0041         s = {sat1, sat2};
0042 end
0043 
0044 if strcmp(sat2, 'poes')
0045     allsats = datasets_constants('POES_satellite_names');
0046     if iscellstr(s) % make satellite pairs {'noaa15', 'noaa18'} rather than
0047                     % looping over just the satellites
0048         allsats = mat2cell([allsats; repmat({sat1}, size(allsats))], ...
0049             2, ones(1, length(allsats)));
0050     end
0051     fileexists = all(cellfun(@(v) ...
0052         exist(...
0053             find_datafile_by_date([year month day], v, ...
0054                 ['collocation_' sensor1 '_' sensor2]), ...
0055             'file'), ...
0056         allsats));
0057 else
0058     fn = find_datafile_by_date([year month day], s, ...
0059         ['collocation_' sensor1 '_' sensor2]);
0060     fileexists = exist(fn, 'file');
0061 end
0062 
0063 %% check if file exists and if no, collocate
0064 
0065 % no. of outputs of collocate_date is 1–3 depending on overlap, data, mean.
0066 % For some, mean is N/A, so check colloc_constants('no_SENSOR1_SENSOR2').
0067 % When writing collocations, all three are passed, but -1 is interpreted as
0068 % "no value".
0069 
0070 C = {-1 -1 -1};
0071 
0072 if ~fileexists || colloc_config('overwrite')
0073     try
0074         [C{1:colloc_constants(['no_' sensor1 '_' sensor2])}] = ...
0075             collocate_date(year, month, day, sat1, sensor1, sat2, sensor2);
0076         writethingy = true;
0077      catch ME
0078          if strcmp(ME.identifier, 'atmlab:collocate_date:nosource')
0079              logtext(atmlab('ERR'), ...
0080                  'No succesful collocations at %04d-%02d-%02d, not writing\n', ...
0081                  year, month, day);
0082              writethingy = false;
0083          else
0084              ME.rethrow();
0085          end
0086     end
0087     if writethingy
0088         write_collocations_netcdf(year, month, day, C{1:3}, sat1, sensor1, sat2, sensor2);
0089     end
0090 else
0091     logtext(atmlab('OUT'), 'Output file(s) %s already exist\n', fn);
0092 end
0093 end

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