%% Preparation run /users/swinkels/deploy/MatlabVirgoTools/trunk/startup.m phase_ch = 'V1:SQZ_B1_PD1_7MHz_phi0'; I_ch = 'V1:SDB2_B1_PD1_7MHz_I_50Hz'; Q_ch = 'V1:SDB2_B1_PD1_7MHz_Q_50Hz'; shut_ch = 'V1:SQZ_FAST_SHUTTER_sts'; ffl = '/virgoData/ffl/raw.ffl'; ffl50 = '/virgoData/ffl/rds.ffl'; %% Parameters meas = { %t_start %t_stop %title %gain %PHI %Notes 1231372134 1231372600 'HighDC-Al2' 20 0 '' 1231372994 1231373477 'HighDC-Al1' 20 0 '' 1231261708 1231262210 'LowDC-Al2 a' 20 0 '' 1231262254 1231262757 'LowDc-Al2 b' 20 0 'Same conditions as previous, different scan' 1231274555 1231275053 'LowDc-Al2 c*' 20 0 'Less than 1000s from unlock' 1231275167 1231275669 'LowDc-Al2 d*' 20 0 'Less than 1000s from unlock' 1231276807 1231277306 'LowDc-Al2 e' 20 0 '' 1231281455 1231281906 'LowDc-Al2 f*' 20 0 'Not locked at start???' }; %TODO: currently can't change this because script relies on phase data %vector being same length as BLRMS BLRMSlen = 1; BLRMSstep = 1; BLRMSfl = 2600; BLRMSfh = 2800; toff = 1; % seconds of margin to keep from some transitions m_idx = 8; %% Load phase and shutter data t_start = meas{m_idx,1}+5; dur = meas{m_idx,2}-t_start; [shutdata, shuttime] = frgetvectN(ffl, shut_ch, t_start, dur); [phasedata, phasetime] = frgetvectN(ffl, phase_ch, t_start, dur); [Idata, Itime] = frgetvectN(ffl50, I_ch, t_start, dur); [Qdata, Qtime] = frgetvectN(ffl50, Q_ch, t_start, dur); %% Define periods scan_start = shuttime(find(shutdata > -2,1)); scan_stop = shuttime(find(shutdata > -2,1,'last')); %% [OPT] Plot periods figure('windowstyle','docked') plot(shuttime, shutdata) hold all plot([0 scan_start-toff],-2*[1 1],'g+-') plot([scan_start+toff scan_stop-toff],-2*[1 1],'r+-') xlabel(['Time from GPS = ' num2str(t_start) ' [s]']) title([meas{m_idx,3} ' - Shutter']) %% [OPT] Check phase data figure('windowstyle','docked') plot(Itime, Idata) hold all plot(Qtime, Qdata) magdata = sqrt(Idata.^2+Qdata.^2); plot(Itime, magdata) grid on xlabel(['Time from GPS = ' num2str(t_start) ' [s]']) yyaxis right plot(phasetime, 180/pi*phasedata) hold all calcphase = atan2(Idata, Qdata); plot(Itime, 180/pi*calcphase) legend({strrep(I_ch,'_','\_'), strrep(Q_ch,'_','\_'), '$\sqrt{I^2+Q^2}$',strrep(phase_ch,'_','\_'), '$atan2(I,Q)$'}, 'interpreter', 'latex', 'Location', 'SouthEast') title([meas{m_idx,3} ' - Sidebands timeseries']) %% [OPT] Plot magnitude vs phase figure('windowstyle','docked') plot(mod(calcphase*180/pi,360),magdata,'*') title('Sideband amplitude vs phase') xlabel('Demodulation phase [deg]') ylabel('Sideband amplitude [au]') title([meas{m_idx,3} ' - Sidebands vs Phase']) %% Load DARM, Hrec and range data [BLRMStime, BLRMSdata] = fastBLRMS('V1:LSC_DARM', 10000, t_start, dur, BLRMSfl, BLRMSfh, BLRMSlen, BLRMSstep, 0, 1); [BLRMSHtime, BLRMSHdata] = fastBLRMS('V1:Hrec_hoft_20000Hz', 20000, t_start, dur, BLRMSfl, BLRMSfh, BLRMSlen, BLRMSstep, 0, 1); [rangedata, rangetime] = frgetvectN(ffl, 'V1:Hrec_Range_BNS', t_start, dur); %% Analyze timeidx = phasetime >= scan_start+toff & phasetime <= scan_stop-toff; phasevals = unique(phasedata(timeidx)); % Unique values of phase for which to computer averages phasedata2 = ([0; phasedata(1:end-1)] + phasedata + [phasedata(2:end); 0])/3; %averaged phase data to remove transition points from computation BLRMSmean = zeros(length(phasevals),1); BLRMSstd = zeros(length(phasevals),1); BLRMSstdm = zeros(length(phasevals),1); BLRMSHmean = zeros(length(phasevals),1); BLRMSHstd = zeros(length(phasevals),1); BLRMSHstdm = zeros(length(phasevals),1); for kk=1:length(phasevals) BLRMSvals = BLRMSdata(phasedata==phasevals(kk) & timeidx); BLRMSmean(kk) = sqrt(mean(BLRMSvals.^2)); % the mean is computed on the square of the BLRMS BLRMSstd(kk) = 1/(2*BLRMSmean(kk))*std(BLRMSvals.^2); %standard deviation of the square BLRMS, propagated through the sqrt BLRMSstdm(kk) = BLRMSstd(kk)/sqrt(length(BLRMSvals)); %standard deviation of the mean BLRMSHvals = BLRMSHdata(phasedata==phasevals(kk) & timeidx); BLRMSHmean(kk) = sqrt(mean(BLRMSHvals.^2)); % the mean is computed on the square of the BLRMS BLRMSHstd(kk) = 1/(2*BLRMSHmean(kk))*std(BLRMSHvals.^2); %standard deviation of the square BLRMS, propagated through the sqrt BLRMSHstdm(kk) = BLRMSHstd(kk)/sqrt(length(BLRMSHvals)); %standard deviation of the mean end baseBLRMSidx = BLRMStime < scan_start-2*toff; baseBLRMSmean = sqrt(mean(BLRMSdata(baseBLRMSidx).^2)); baseBLRMSstd = 1/(2*baseBLRMSmean)*std(BLRMSdata(baseBLRMSidx).^2); baseBLRMSstdm = baseBLRMSstd/sqrt(length(BLRMSdata(baseBLRMSidx))); baseBLRMSHmean = sqrt(mean(BLRMSHdata(baseBLRMSidx).^2)); baseBLRMSHstd = 1/(2*baseBLRMSHmean)*std(BLRMSHdata(baseBLRMSidx).^2); baseBLRMSHstdm = baseBLRMSHstd/sqrt(length(BLRMSHdata(baseBLRMSidx))); baserangeidx = rangetime <= scan_start-2*toff & rangedata~=0; baserangemean = mean(rangedata(baserangeidx)); baserangestd = std(rangedata(baserangeidx)); baserangestdm = baserangestd/sqrt(length(rangedata(baserangeidx))); %% Plots: phase and BLRM time series figure sb1 = subplot(4,1,1); plot(phasetime,phasedata*180/pi,'.') grid on ylabel(['CC phase [deg]']) title([meas{m_idx,5} ' - GPS time: ' num2str(t_start)]) set(gca,'YTick',(0:45:225)) sb2 = subplot(4,1,2); plot(BLRMStime, BLRMSdata) hold all plot([BLRMStime(1), BLRMStime(end)],[1, 1]*baseBLRMSmean,'r-') plot([BLRMStime(1), BLRMStime(end)],[1, 1]*(baseBLRMSmean+baseBLRMSstd),'r--') plot([BLRMStime(1), BLRMStime(end)],[1, 1]*(baseBLRMSmean-baseBLRMSstd),'r--') ylims=get(gca,'ylim'); plot([1 1],ylims,'r--','linewidth',3) plot(scan_start*[1 1],ylims,'r--','linewidth',3) grid on ylabel(['DARM BLRMS (' num2str(BLRMSfl) '-' num2str(BLRMSfh) ' Hz)']) legend({'Measured data', 'Reference with shutter closed (\pm 1\sigma)'}) sb3 = subplot(4,1,3); plot(BLRMSHtime, BLRMSHdata) hold all plot([BLRMSHtime(1), BLRMSHtime(end)],[1, 1]*baseBLRMSHmean,'r-') plot([BLRMSHtime(1), BLRMSHtime(end)],[1, 1]*(baseBLRMSHmean+baseBLRMSHstd),'r--') plot([BLRMSHtime(1), BLRMSHtime(end)],[1, 1]*(baseBLRMSHmean-baseBLRMSHstd),'r--') ylims=get(gca,'ylim'); plot([1 1],ylims,'r--','linewidth',3) plot(scan_start*[1 1],ylims,'r--','linewidth',3) grid on ylabel(['Hrec BLRMS (' num2str(BLRMSfl) '-' num2str(BLRMSfh) ' Hz)']) legend({'Measured data', 'Reference with shutter closed (\pm 1\sigma)'}) sb4 = subplot(4,1,4); rangeidx = rangedata~=0; plot(rangetime(rangeidx), rangedata(rangeidx)) hold all plot([BLRMStime(1), BLRMStime(end)],[1, 1]*baserangemean,'r-') plot([BLRMStime(1), BLRMStime(end)],[1, 1]*(baserangemean+baserangestd),'r--') plot([BLRMStime(1), BLRMStime(end)],[1, 1]*(baserangemean-baserangestd),'r--') ylims=get(gca,'ylim'); plot([0 0],ylims,'r--','linewidth',3) plot(scan_start*[1 1],ylims,'r--','linewidth',3) grid on ylabel('BNS range') xlabel(['Time from GPS = ' num2str(t_start) ' [s]']) title([meas{m_idx,3} ' - BLRM time series']) linkaxes([sb1, sb2, sb3, sb4],'x') %% Plots: BLRMS vs phase figure errorbar(phasevals*180/pi, BLRMSmean, BLRMSstdm) grid on ylabel(['DARM BLRMS (' num2str(BLRMSfl) '-' num2str(BLRMSfh) ' Hz)']) yyaxis right errorbar(phasevals*180/pi, BLRMSHmean, BLRMSHstdm) grid on ylabel(['Hrec BLRMS (' num2str(BLRMSfl) '-' num2str(BLRMSfh) ' Hz)']) xlabel('CC phase [deg]') set(gca,'XTick',(0:45:225)) title([meas{m_idx,3} ' - BLRMS vs phase']) %% Plots: BLRMS vs phase in DB figure errorbar(phasevals*180/pi, 20*log10(BLRMSmean/baseBLRMSmean), 20/log(10)*(BLRMSstdm./BLRMSmean+baseBLRMSstdm./baseBLRMSmean)) grid on hold on errorbar(phasevals*180/pi, 20*log10(BLRMSHmean/baseBLRMSHmean), 20/log(10)*(BLRMSHstdm./BLRMSHmean+baseBLRMSHstdm./baseBLRMSHmean)) ylabel(['BLRMS (' num2str(BLRMSfl) '-' num2str(BLRMSfh) ' Hz) ratio wrt reference [dB]']) xlabel('CC phase [deg]') set(gca,'XTick',(0:45:225)) legend({'DARM','Hrec'}) title([meas{m_idx,3} ' - relative BLRMS vs phase'])