0001 function [asqSeries, abcache] = calibsimfd(IFO,gpsSec,strainSeries,fs,varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 inOk = nargchk(nargin,4,5);
0024 outOk = nargchk(nargout,1,2);
0025 if(~inOk | ~outOk)
0026 error ('syntax is [asqSeries[,abcache]] = calibsim_fd(IFO,gpsSec,strainSeries,fs[,abcache])');
0027 return
0028 end
0029 if(nargin > 4)
0030 if length(varargin) > 1
0031 error('varargin only designed for abcache')
0032 else
0033 abcache=varargin{1};
0034 end
0035 else
0036 abcache=[];
0037 end
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047 DEFAULT_CALIB_DIR = '/usr/center/raid1/s2/calibration';
0048 persistent calDir;
0049 persistent oldAbFile;
0050 persistent oldOlgFile;
0051 persistent oldSfFile;
0052 if isempty(calDir)
0053 calDir = getenv('LIGO_CALIB_DATA');
0054 if isempty(calDir)
0055 calDir = DEFAULT_CALIB_DIR;
0056 fprintf(' LIGO_CALIB_DATA not defined - use %s\n',calDir);
0057 end
0058 end
0059
0060 time=find(abcache >= gpsSec-60 & abcache <= gpsSec-1);
0061 if ~isempty(time)
0062 alpha=abcache(time,2);
0063 beta=abcache(time,3);
0064 else
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077 nd=size(abcache,1)+1;
0078 abFile = strcat(IFO,'AlphaBeta.txt');
0079 if ~isempty(calDir)
0080 abFile = strcat(calDir,'/',abFile);
0081 end
0082 if exist(abFile,'file') == 0
0083 msg = sprintf(' Oops - AlphaBeta file %s not found!\n',abFile);
0084 error(msg);
0085 else
0086 oldAbFile = checkfilechange(oldAbFile,abFile,'ALPHA-BETA');
0087 end
0088 duration = 0.5;
0089 [gpsStartMin,alphaRay,betaRay] = read_alphabetafile(abFile,gpsSec,duration);
0090 abcache(nd,1)=gpsStartMin(1);
0091 alpha = alphaRay(1);
0092 if alpha==0
0093 alpha=1;
0094 end
0095 beta = betaRay(1);
0096 if beta==0
0097 beta=1;
0098 end
0099 abcache(nd,2)=alpha;
0100 abcache(nd,3)=beta;
0101 end
0102
0103
0104
0105
0106
0107
0108
0109 if(IFO == 'H1')
0110 olgFile = 'H1_olg_734073939.txt';
0111 sfFile = 'H1_sf_734073939.txt';
0112 else
0113 if( IFO == 'H2')
0114 if(gpsSec < 731849043)
0115 olgFile = 'H2_olg_734234126.txt';
0116 sfFile = 'H2_sf_734234126.txt';
0117 else
0118 olgFile = 'H2_olg_734234127.txt';
0119 sfFile = 'H2_sf_734234127.txt';
0120 end
0121 else
0122 if( IFO == 'L1')
0123 olgFile = 'H2_olg_734234126.txt';
0124 sfFile = 'H2_sf_734234126.txt';
0125 end
0126 end
0127 end
0128 if ~isempty(calDir)
0129 olgFile = strcat(calDir,'/',olgFile);
0130 sfFile = strcat(calDir,'/',sfFile);
0131 end
0132 oldOlgFile = checkfilechange(oldOlgFile,olgFile,'OPEN-LOOP GAIN');
0133 oldSfFile = checkfilechange(oldSfFile,sfFile,'SENSING FUNCTION');
0134
0135
0136
0137 nsamp = length(strainSeries);
0138 padSeries = zeros([2*nsamp,1]);
0139 nstart = floor(nsamp/2);
0140 nend = nstart + (nsamp-1);
0141 padSeries(nstart:nend) = strainSeries(1:nsamp);
0142 outSeries = h2asq_fd(olgFile,sfFile,alpha,beta,padSeries,fs);
0143 asqSeries = outSeries(nstart:nend);
0144 return
0145
0146 function [oldFile] = checkfilechange(oldFile,newFile,fileType)
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158 if ~isempty(oldFile)
0159 if newFile ~= oldFile
0160 fprintf(' %s file: %s\n',fileType,newFile);
0161 oldFile = newFile;
0162 end
0163 else
0164 fprintf(' %s file: %s\n',fileType,newFile);
0165 oldFile = newFile;
0166 end
0167 return