function [time, BLRMS] = fastBLRMS(chname, fs, t_start, t_dur, f_low, f_high, fft_len, fft_step, plotfig, printpr) % [time, BLRMS] = fastBLRMS(chname, fs, t_start, t_dur, f_low, f_high, fft_len, fft_step, plotfig, printpr) % % Computes Band Limited RMS time series of a channel in a user-selected % band, averaging over time segments of arbitrary length and overlap. % NOTE: requires virgo tools to be already loaded using: % run /users/swinkels/deploy/MatlabVirgoTools/trunk/startup.m % % PARAMETERS % chname name of the channel to analyze % fs sampling frequency fo the channel to analyze % t_start starting time for the analysis % t_dur duration of the analysis % f_low lower bound of the frequency band to consider % f_high upper bound of the frequency band to consider % fft_len length of the time segment to consider for each data point % fft_step time step between adjacent data point % plotf plot a figure of the BLRMS time series % printpr print computation progress messages % % OUTPUTS % t time vector of computer BLRMS values % BLRMS vector containing BLRMS time series %% Preparation ffl = '/virgoData/ffl/raw.ffl'; % frame source %% load data if printpr disp('Loading data') end data = frgetvectN(ffl, chname, t_start, t_dur); %% compute BLRMS if printpr disp('Computing Band Limited RMS') end npoints = floor((t_dur-fft_len)/fft_step)+1; BLRMS = zeros(npoints,1); time = (0:fft_step:t_dur-fft_len)'; lastsize = 0; for kk = 1:length(BLRMS) start_smpl = round(1+(kk-1)*fft_step*fs); end_smpl = start_smpl+round(fft_len*fs)-1; %TODO: adjust pwelch options (window type!) [pxx,f] = pwelch(data(start_smpl:end_smpl),fft_len*fs,0,fft_len*fs,fs); mean_idx = f>=f_low & f<=f_high; BLRMS(kk) = sqrt(mean(pxx(mean_idx))*(f_high-f_low)); if printpr fprintf(repmat('\b', 1, lastsize)); lastsize = fprintf('%d',round(kk*100/length(BLRMS))); end end if printpr fprintf('\n'); end %% data if plotfig figure plot(time, BLRMS) grid on xlabel('Time [s]') ylabel(['BLRMS (' num2str(f_low) '-' num2str(f_high) ' Hz)']) title([chname ' (at GPS' num2str(t_start) ')'], 'interpreter', 'none') end