% check_fan_alignment - Script to look at fan angles and mult. sweeps which_experiment = 'mvco05' make_plots = 1; switch which_experiment case 'mvco07' settings.fname = 'D:\crs\data\MVCO2007\8369fan_raw.cdf'; case 'mvco05' settings.fname = 'D:\crs\data\Ripple_data\8044fan_raw.cdf'; end %settings.img_nums = 250; settings.sweep = 1; settings.dxy = 0.02; plottype = 'check_sweep'; rev_info= 'SVN $Revision: 982 $'; % Check for raw sonar netcdf file if(exist(settings.fname,'file')~=2), error('Cannot find sonar file %s\n',settings.fname); end % open existing cdf file of raw fan data ncr=netcdf(settings.fname); % set up how many images to process n=length(ncr{'time'}); qa = zeros(n,5); qn = zeros(n,5); qm = zeros(n,5); qf = zeros(n,5); c = zeros(n,5); for i=1:n, ik = i; jt= ncr{'time'}(ik)+ncr{'time2'}(ik)./86400000; fprintf(1,'Processing %s\n',datestr(gregorian(jt),'HHMM dd-mmm-yy')); tmp = size(ncr{'raw_image'}); ntimes=tmp(1); NPoints=tmp(2); nscans=tmp(3); % trim the redundant first and last ping imagedata = ncr{'raw_image'}(ik,:,2:nscans-1); prange = ncr{'profile_range'}(ik,2:nscans-1); headpos = ncr{'head_pos'}(ik,2:nscans-1); %recorded headangle=ncr{'headangle'}(2:nscans-1); % calculated [npoints,nangles] = size(imagedata); % necessary to % trim range to real area of data nearfieldcutoff = 52; farfieldcutoff = NPoints; imagedata = imagedata(nearfieldcutoff:farfieldcutoff,:); %% ib = 10; is = 5; ir=80; ia=(600:800); for j=1:5, %is = input('offset? ') s1s = 1+ib; s1e = nangles/2-ib; %2321-ib; s2s = nangles/2+1+ib+is; % 2322+ib+is; s2e = nangles-ib+is; % 4642-ib+is; s1 = imagedata(:,s1s:s1e); s2 = fliplr(imagedata(:,s2s:s2e)); s3 = s1-s2; C = cov(s1,s2); c(i,j)=C(1,2)./sqrt(C(1,1)*C(2,2)); qa(i,j)=sqrt(mean(mean(s3.^2))); qn(i,j)=sqrt(mean(mean(s3(75:125,:).^2))); qm(i,j)=sqrt(mean(mean(s3(225:275).^2))); qf(i,j)=sqrt(mean(mean(s3(350:400,:).^2))); is = is+1; end if(make_plots), figure(1) clf subplot(121) imagesc((s3)) title(num2str(is)) subplot(122) plot(s1(ir,ia),'b') hold on plot(s2(ir,ia),'-r') plot(s3(ir,ia),'-k') hold off shg figure(4) clf imagesc(log10(0.5*(s1+s2))); figure(2) clf imagesc(log10(s1)) figure(3) clf imagesc(log10(s2)) for m=1:50, fno = 2+mod(m,2); figure(fno) pause(.2) end pause is = is+1; end end