Home > . > pregenlist.m

pregenlist

PURPOSE ^

PREGENLIST - alternate listing function for pre-generated waveform

SYNOPSIS ^

function list = pregenlist(varargin)

DESCRIPTION ^

 PREGENLIST - alternate listing function for pre-generated waveform

 list = pregenlist(inputFileName, startSamp, external, detId);
   Generate list; 1 simulation
 list = pregenlist(nSim, inputFileName, startSamp, external, detId);
   Generate list; nSim times

 nSim              number of simulations to generate
 inputFileName     1x1 or 1x2 cell containing a string with name of input 
                   file (must include file extention) and an optional
                   field path for *.ilwd files 
 startSamp         1x2 vector defining range of allowed start times in
                   samples wrt the beginning of data set
 external          struct or vector with sky location & polarization angle 
                   or string 'RANDOM' or 'OPTIMAL'; if struct, must have 
                   fields x, phi and psi
 detId             (optional) detector identifier string; only needed for
                   'OPTIMAL' external angles

 list              Cell array containing simulations list.  Each row is a
                   simulation. Each component of the row represent:
                   [simId ampl startSamp int1 int2 ext1 ext2 ext3], in this 
                   order. N.B. startSamp is now a scalar - start time has 
                   been determined

 SEE ALSO: MAKELIST, GRAVEN

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function list = pregenlist(varargin)
0002 
0003 % PREGENLIST - alternate listing function for pre-generated waveform
0004 %
0005 % list = pregenlist(inputFileName, startSamp, external, detId);
0006 %   Generate list; 1 simulation
0007 % list = pregenlist(nSim, inputFileName, startSamp, external, detId);
0008 %   Generate list; nSim times
0009 %
0010 % nSim              number of simulations to generate
0011 % inputFileName     1x1 or 1x2 cell containing a string with name of input
0012 %                   file (must include file extention) and an optional
0013 %                   field path for *.ilwd files
0014 % startSamp         1x2 vector defining range of allowed start times in
0015 %                   samples wrt the beginning of data set
0016 % external          struct or vector with sky location & polarization angle
0017 %                   or string 'RANDOM' or 'OPTIMAL'; if struct, must have
0018 %                   fields x, phi and psi
0019 % detId             (optional) detector identifier string; only needed for
0020 %                   'OPTIMAL' external angles
0021 %
0022 % list              Cell array containing simulations list.  Each row is a
0023 %                   simulation. Each component of the row represent:
0024 %                   [simId ampl startSamp int1 int2 ext1 ext2 ext3], in this
0025 %                   order. N.B. startSamp is now a scalar - start time has
0026 %                   been determined
0027 %
0028 % SEE ALSO: MAKELIST, GRAVEN
0029 
0030 % $Id: pregenlist.m,v 1.10 2005/04/08 18:07:09 stuver Exp $
0031 
0032 % INITIALIZE output variable
0033 % CHECK varargin for error
0034 % SET simId to inputFileName (parse if needed)
0035 % SET ampl to -1 to mark log file as using pre-generated waveform
0036 % SET start time
0037 % SET int1 and int2 (internal angles) to optimal orientation
0038 % SET external angles
0039 % ASSEMBLE list
0040 % RETURN list
0041 
0042 % Initialize list
0043 list = {};
0044 
0045 % Check varargin for error
0046 if length(varargin) ~= 4 & length(varargin) ~= 5
0047     error(['pregenlist: varargin can only be [inputFileName, ' ...
0048             'startSamp, external, detId] or [nSim, inputFileName, ' ...
0049             'startSamp, external, detId]'])
0050 elseif length(varargin) == 4
0051     [inputFileName, startSamp, external, detId] = deal(varargin{:});
0052     % Determine number of simulations in the list
0053     nSim = size(inputFileName, 1); 
0054 elseif length(varargin) == 5
0055     [nSim, inputFileName, startSamp, external, detId] = deal(varargin{:});
0056     inputFileName = repmat(inputFileName, nSim, 1);
0057     startSamp = repmat(startSamp, nSim, 1);
0058     external = repmat(external, nSim, 1);
0059 end
0060 
0061 for iSim = 1:nSim
0062     % Set simId to be the inputFileName
0063     if strcmp(class(inputFileName(iSim,:)), 'cell') & ...
0064             length(inputFileName(iSim,:)) == 1
0065         simId{iSim} = [inputFileName{iSim,1}];
0066         if ~strcmp(class(simId{iSim}), 'char')
0067             simId{iSim}
0068             error('pregenlist: simId must be a string')
0069         end
0070     elseif strcmp(class(inputFileName(iSim,:)), 'cell') & ...
0071             length(inputFileName(iSim,:)) == 2
0072         simId{iSim}= [inputFileName{iSim,1} ',' inputFileName{iSim,2}];
0073         if ~strcmp(class(simId{iSim}), 'char')
0074             simId{iSim}
0075             error('pregenlist: simId must be a string')
0076         end
0077     elseif strcmp(class(inputFileName(iSim,:)), 'cell') & ...
0078             length(inputFileName(iSim,:)) == 4
0079         simId{iSim}= [inputFileName{iSim,1} ',' inputFileName{iSim,2} ';' inputFileName{iSim,3} ',' inputFileName{iSim,4}];
0080         if ~strcmp(class(simId{iSim}), 'char')
0081             simId{iSim}
0082             error('pregenlist: simId must be a string')
0083         end
0084     elseif strcmp(class(inputFileName(iSim,:)), 'char')
0085         simId{iSim} = [inputFileName(iSim,:)];
0086     else
0087         inputFileName{iSim}
0088         error('pregenlist: simId must be either cell or char class')
0089     end
0090 
0091     % Set ampl
0092     ampl(iSim) = -1;
0093     % This -1 in the ampl holder of the list is the flag that will mark the
0094     % log file as being produced for a pre-generated waveform.
0095 
0096     % Pick start time
0097     [startSamp1(iSim), startSamp2(iSim)] = deal(startSamp(iSim,1), ...
0098         startSamp(iSim,2));
0099     nuStartSamp(iSim) = pickstime(startSamp1(iSim), startSamp2(iSim));
0100     if isempty(startSamp(iSim))
0101         error('pregenlist: pickstime returned empty startSamp')
0102     end
0103 
0104     % Assume optimal orientation angles for the source (this would leave the
0105     % time series unchanged if run through makett)
0106     int1(iSim) = 1;
0107     int2(iSim) = 0;
0108 
0109     % Set external angles
0110     if ~strcmp(class(external), 'cell')
0111         nuExternal(iSim,:) = setexternal(-2, external(iSim,:), 1, detId);
0112     elseif strcmp(class(external), 'cell')
0113         nuExternal(iSim,:) = setexternal(-1, external{iSim}, 1, detId);
0114     end
0115 
0116     if isempty(external)
0117         error('pregenlist: setexternal returned empty external')
0118     end
0119 
0120 end
0121 
0122 % Assemble list
0123 for k=1:size(simId,2)
0124     list(k,:) = {simId{:,k}, ampl(k), nuStartSamp(k), int1(k), int2(k),...
0125         nuExternal(k,1), nuExternal(k,2), nuExternal(k,3)};
0126 end
0127 
0128 return

Generated on Thu 12-May-2005 11:48:48 by m2html © 2003