function plotfan(fn,settings,plottype); % PLOTFAN - Plot Imagenex imaging sonar data % plotfan(fn,rot,settings,plottype); % % fn = file name % imagedata = the image as [angle, point] % headangle = the head position in degrees % prange = profile range in cm % metadata: % settings.SectorSweep % settings.StepSize % settings.DataPoints % settings.Height % settings.datayear % plottype = | 'polar' | 'prange' | % Last revised by Chris Sherwood, USGS, 4/29/03 % - add polar plot % Notes to Marinna and Peter Howd: % There are a couple of weird things: % 1) imagedata(:,449) = 252 all the time. I just blank it out...is that % one point too far out the range? % 2) the real head angle goes retrograde sometimes. This is either a weird reading % in the file, or maybe an integer math thing with the angle calcs. I % make fake angles. % Revised 3/8/04 by Chris Sherwood % fan beam specific things %settings.DegPerStep = 0.3; settings.DegPerStep = 0.15; pingsperrec = ((settings.SectorSweep./(settings.StepSize.*settings.DegPerStep))+1)*2; [nangles, npoints] = size(imagedata); slantrange = settings.SonarRange/npoints:(settings.SonarRange/npoints):settings.SonarRange; horizrange = real((slantrange.^2 - settings.Height^2).^(1/2)); if exist('plottype') ~= 1, plottype = 'polar'; % default end switch plottype case 'square' % plot linear set(gcf,'name','Square') set(gcf,'numbertitle','off') clims = [0 190]; imagesc(headangle,horizrange,imagedata',clims) colormap(bone); colorbar ylabel('Horizontal Range, meters') xlabel('Head Position, degrees') text(0.01,0.05,[fname,' Fan beam image taken ',... datestr(datenum(gdate))],... 'units','normalized','color','w') case 'polar' fillval = 4; % sets value of no-data region rot = settings.rot max_range = 5; dxy = 0.01; % Key setting...determines image resolution at cost of % speed (reasonable range 0.02 to 0.005) %figure(1) %clf Xplot = (- max_range:dxy:max_range); Yplot = Xplot; [Xi, Yi] = meshgrid(Xplot,Yplot); [thi, ri]=cart2pol(Xi,Yi); thi = thi*180/pi; thi = thi+rot; thi(thi>180)=thi(thi>180)-360; thi(thi< -180)=thi(thi< -180)+360; fakeheadangle = linspace(headangle(1), headangle(nangles), ... nangles)'; fakeheadangle = -fakeheadangle; % because sonar scans from -160 to +170 % pad ranges slantrange = [0,slantrange(1,1)-.1,... slantrange(1,:), slantrange(1,npoints)+.1, 9]; % pad angles to get complete circle lopad = [180; fakeheadangle(1)+.01]; hipad = [fakeheadangle(nangles)-.01; -179.999]; nlo = length(lopad); nhi = length(hipad); fakeheadangle = [lopad(:); fakeheadangle; hipad(:)]; % pad data Zpad = (fillval)*ones(nangles+nlo+nhi,npoints+4); imagedata(imagedata<(1))=(fillval); % kludge...last range values always seems to be 252 imagedata(:,449)=(fillval); Zpad(nlo+1:nangles+nlo,3:npoints+2)=imagedata; Zpad = log10(Zpad); % interpolate [ripad,thpad] = meshgrid(slantrange,fakeheadangle); Zi = interp2( ripad,thpad,Zpad, ri, thi); % Zi(Zi<1)=(8); % produces weird contrasty plot imagesc(Xplot,Yplot,Zi) set(gca,'ydir','normal') % because imagesc is sidedownup colormap gray; axis equal tight if(1), % plot range circles hold on for icirc = 1:5, h = circle(icirc,0,0); set(h,'color',[.7 .7 .6]) end end text(0.01,0.03,fname,... 'units','normalized','color','y','fontsize',14) text(0.8,0.95,'\uparrow North',... 'units','normalized','color','y','fontsize',14) text(0.57,0.03,datestr(datenum(gdate)),... 'units','normalized','color','y','fontsize',14) case 'prange' % plot headposition and prange [ax, h1, h2] = plotyy(1:nangles,headangle,1:nangles,prange); title([fname,' Fan beam image taken ',datestr(datenum(gdate))]) xlabel('Head position and profile range by ping') ylabel('Deg') %set(ax(2),'ylabel',text(0,0,'string','Prange')) otherwise % no plot end