Home > atmlab > datasets > strrep_variables.m

strrep_variables

PURPOSE ^

strrep_variables Replace 'magic' variables

SYNOPSIS ^

function s_out = strrep_variables(s, satname, datevec)

DESCRIPTION ^

 strrep_variables Replace 'magic' variables

 NOTE: DEPRECATED!  Inside SatDataset, use self.repvar.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

strrep_variables.m

SOURCE CODE ^

0001 function s_out = strrep_variables(s, satname, datevec)
0002 
0003 % strrep_variables Replace 'magic' variables
0004 %
0005 % NOTE: DEPRECATED!  Inside SatDataset, use self.repvar.
0006 
0007 %
0008 % Replace the 'magic' variables:
0009 %
0010 % $YEAR4
0011 % $YEAR2
0012 % $MONTH
0013 % $DAY
0014 % $DOY
0015 % $SAT  or  $SAT1 and $SAT2
0016 % $HOUR
0017 % $MINUTE
0018 %
0019 % FORMAT
0020 %
0021 %   s_out = strrep_variables(s, satname, datevec)
0022 %
0023 % IN
0024 %
0025 %   s       string  where magic is replaced
0026 %   satname string/ name of satellite/satellites
0027 %           cellstr
0028 %   datevec vector  date-vector [year month day]
0029 %
0030 % OUT
0031 %
0032 %   s_out   string  with magic replaced
0033 %
0034 % $Id: strrep_variables.m 8516 2013-06-26 21:33:48Z gerrit $
0035 
0036 year = num2str(datevec(1), '%04d');
0037 month = num2str(datevec(2), '%02d');
0038 day = num2str(datevec(3), '%02d');
0039 if length(datevec)>3
0040     hour = num2str(datevec(4), '%02d');
0041     minute = num2str(datevec(5), '%02d');
0042 else
0043     hour = '0';
0044     minute = '0';
0045 end
0046 year02 = year(3:4);
0047 doy = num2str(round(dayofyear(datevec(1), datevec(2), datevec(3))), '%03d');
0048 
0049 to_replace = {'$YEAR4', year, '$MONTH', month, '$DAY', day, ...
0050     '$YEAR2', year02, '$DOY', doy, '$HOUR', hour, '$MINUTE', minute};
0051 
0052 if iscellstr(satname)
0053     to_replace = [to_replace {'$SAT1', satname{1}, '$SAT2', satname{2}}];
0054 else
0055     if strfind(s, '$SAT1')
0056         warning('atmlab:strrep_variables', ...
0057             ['replacing $SAT, but having $SAT1; are you sure you don''t ' ...
0058              'want to pass TWO satellites?']);
0059     end
0060     to_replace = [to_replace {'$SAT', satname}];
0061 end
0062 
0063 s_out = strrep_multi(s, to_replace{:});
0064 
0065 end

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