Home > . > checkframeconfig.m

checkframeconfig

PURPOSE ^

CHECKFRAMECONFIG - read configuration file/struct for information on frames

SYNOPSIS ^

function [frparms,detList,sigList,nameList] = checkframeconfig(fname)

DESCRIPTION ^

 CHECKFRAMECONFIG - read configuration file/struct for information on frames
   [frparms,detList,sigList,nameList] = checkframeconfig(fname)
       fname    configuration file name (or structure)

   frparms  frame creation parameters
   detList - detId for each channel simulated
   sigList - signal for each channel simulated
   nameList - output name for each channel simulated

  $Id: checkframeconfig.m,v 1.5 2005/04/21 19:58:49 thorne Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [frparms,detList,sigList,nameList] = checkframeconfig(fname)
0002 % CHECKFRAMECONFIG - read configuration file/struct for information on frames
0003 %   [frparms,detList,sigList,nameList] = checkframeconfig(fname)
0004 %       fname    configuration file name (or structure)
0005 %
0006 %   frparms  frame creation parameters
0007 %   detList - detId for each channel simulated
0008 %   sigList - signal for each channel simulated
0009 %   nameList - output name for each channel simulated
0010 %
0011 %  $Id: checkframeconfig.m,v 1.5 2005/04/21 19:58:49 thorne Exp $
0012 
0013 % SET defaults for frame configuration
0014 % IF input is already a structure
0015 %   USE input as reference structure
0016 % ELSE
0017 %   IF frame config file exists
0018 %       READ in frame configuration file
0019 %   ELSE
0020 %       CREATE error and exit
0021 %   ENDIF
0022 %   READ in frame config from file
0023 % ENDIF
0024 % IF frame label defined
0025 %   SET frame label from input
0026 % ENDIF
0027 % IF background defined
0028 %   IF background is valid
0029 %       SET background from input
0030 %   ENDIF
0031 % ENDIF
0032 % IF detector list defined
0033 %   SET detector list from input
0034 % ENDIF
0035 % IF frame channel defined
0036 %   SET frame channel from input
0037 % ENDIF
0038 % IF frame duration defined
0039 %   SET frame duration from input
0040 % ENDIF
0041 DEF_FRAME_TYPE = 'graven';
0042 DEF_CHAN_DESC = '[H1:AS_Q,H2:AS_Q,L1:AS_Q]';
0043 DEF_CHAN_DESC = strassign(DEF_CHAN_DESC);
0044 DEF_DURATION = 16;
0045 frparms = struct('instrument',[],...
0046               'type',DEF_FRAME_TYPE,...
0047               'duration',DEF_DURATION,...
0048               'bkgd','none',...
0049               'chanDesc',[],...
0050               'chanName',[],...
0051               'frameDirFlag',false,...
0052               'frameDir',[]);
0053 frparms.chanDesc = DEF_CHAN_DESC;
0054 detList = [];
0055 sigList = [];
0056 nameList = [];
0057 
0058 tmpStruct = struct('null','');
0059 if(isstruct(fname))
0060     tmpStruct = fname;
0061 else
0062     if(exist(fname,'file'))
0063         d = load(fname);
0064     else
0065         matFile = strcat(fname,'.mat');
0066         if(exist(matFile,'file'))
0067             d = load(matFile);
0068         else
0069             msgId = 'checkframeconfig:noConfigFile';
0070             error(msgId,'%s: Frame config file %s does not exist',msgId,fname);
0071         end
0072     end
0073     if(isfield(d,'frparms'))
0074         tmpStruct = d.frparms;
0075     end
0076 end
0077 if(isfield(tmpStruct,'instrument'))
0078     frparms.instrument = tmpStruct.instrument;
0079 end
0080 if(isfield(tmpStruct,'type'))
0081     frparms.type = tmpStruct.type;
0082 end
0083 if(isfield(tmpStruct,'duration'))
0084     frparms.duration = tmpStruct.duration;
0085 end
0086 if(isfield(tmpStruct,'bkgd'))
0087     frparms.bkgd = tmpStruct.bkgd;
0088 end
0089 if((isfield(tmpStruct,'chanDesc')) && (~isempty(tmpStruct.chanDesc)))
0090     frparms.chanDesc = tmpStruct.chanDesc;
0091 else
0092     frparms.chanDesc = DEF_CHAN_DESC;
0093 end
0094 
0095 chanDesc = frparms.chanDesc;
0096 numChan = numel(chanDesc);
0097 detList = cell(1,numChan);
0098 sigList = cell(1,numChan);
0099 DEF_SIG = [];
0100 for k = 1:numChan
0101     detStr = char(chanDesc{k});
0102     numChar = numel(detStr);
0103     strPos = strfind(detStr,':');
0104     if(strPos > 0)
0105         detEnd = strPos - 1;
0106         chanBeg = strPos + 1;
0107     else
0108         detEnd = numChar;
0109         chanBeg = numChar+1;
0110     end
0111     detList{1,k} = detStr(1:detEnd);
0112     if(numChar < chanBeg)
0113         sigList{1,k} = DEF_SIG;
0114     else
0115         sigList{1,k} = detStr(chanBeg:end);
0116     end
0117 end
0118 if(isfield(tmpStruct,'chanName') && (~isempty(tmpStruct.chanName)))
0119     frparms.chanName = tmpStruct.chanName;
0120     nameList = frparms.chanName;
0121 else
0122     nameList = cell(1,numChan);
0123     for k = 1:numChan
0124         sigId = sigList{1,k};
0125         if(isempty(sigId))
0126             nameList{1,k} = sprintf('%s:GW',...
0127                 char(detList{1,k}));
0128         else
0129             nameList{1,k} = sprintf('%s:GW-%s',...
0130                 char(detList{1,k}),sigId);
0131         end
0132     end
0133     frparms.chanName = nameList;
0134 end
0135 if(isfield(tmpStruct,'frameDir'))
0136     if(~isempty(tmpStruct.frameDir))
0137         frparms.frameDirFlag = true;
0138         frparms.frameDir = tmpStruct.frameDir;
0139     end    
0140 end
0141 return

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