% ------------------------------------------------------- % averaged881b.m % % adapt Jim and Peter's program for use with 881a % % first skips 61 bytes of header for file then % for each of 50 pings % read 13 bytes of header % read 50 pings per record (in arc) % each ping is 251 bytes of data % 1 bytes per sample % this works with s1080117.f59 although weird angles in fig 1 rcs 8/1/02 % -------------------------------------------------------- sect = 60; fname = input('What is the filename ','s'); fid = fopen(fname,'r'); pingsperrec = 102; %pingsperrec = input('how many records (sector to sweep/step size) ?','d'); % len=265; %points per ping lon=len*pingsperrec+61; %[X1,count] = fread(fid,lon,'uint8'); %[X1,count] = fscanf(fid,'%x',lon); [X1,count] = fread(fid,lon,'uint8'); %count %X1 fclose(fid); x1 = reshape(X1(62:lon),len,pingsperrec); % % clear X1 count fid % %header type, should be IMX hdr(1:34)=setstr(X1(1:34)') hdr(35:61)=X1(35:61) imx=setstr(x1(1:3,:)); if (imx(1:3,1)'=='IMX'), disp('Mode = IMX, OK'), end if (imx(1:3,1)'~='IMX'), disp('Mode is not IMX'), end % sonar head ID, should be 16 id=(x1(4,:)); if (id==16), disp('ID = 16, OK'), end if (id~=16), disp('ID is not 16'), end % serial Status, should be 64 ss=(x1(5,:)); if (ss==64), disp('Serial Status = 64, OK'), end if (ss~=64), disp('Serial Status is not 64'), end % head position high=bitand(62,x1(7,:)); high=high./2; low=bitand(127,x1(6,:)); lowbit = bitand(1,x1(7,:)); lowbit = lowbit.*128; low = bitor(low,lowbit); d=bitand(64,x1(7,:)); intermedpt = (256.*high); i2 = intermedpt+low; i3 = 0.15.*i2; hp=-210+i3; %Mod - rcs % range, should be 10 for 3 m rr=(x1(8,:)); if (rr==10), disp('Range = 10, OK'), end if (rr~=10), disp('Range is not 10'), end % profile Rainge - should vary with data pr=(256*x1(10,:)+x1(9)); if (pr==0), disp('Profile Range = 0, OK'), end if (pr~=0), disp('Profile Range is not 0'), end high=bitand(127,x1(12,:)); low=bitand(127,x1(11,:)); % number of data points, with 25, should be 251 points num=127*high+low; if (num==251), disp('Number of Data Bytes = 251, OK'), end if (num~=251), disp('Number of Data Bytes is not 251'), end % % clear high low imx id ss r pr num % % plot head position figure(1) clf %plot(1:50,hp,1:50,d),grid plot(1:pingsperrec,hp,1:pingsperrec,d),grid %881A Mod - rcs title([fname]) xlabel('Step'),ylabel('Degrees Orientation') % % plot linear figure(2) clf; imagesc(x1(12:len,1:pingsperrec)); colormap(jet); colorbar title([fname]) % % plot polar figure(3) clf usenr=len-14; nt=pingsperrec; nr=length(0:(usenr-10)); theta=-linspace(0,sect,nt)*pi/180; % R=linspace(0,210,nr)'; %h=pingsperrec/4; r=linspace(10,usenr,nr)'; %R= r.*sin(acos(h./r));R=R(:); x=r*cos(theta);y=r*sin(theta); Z = zeros(nr,nt); sx1 = x1(10:usenr,:); surface(x,y,Z,log10(sx1+eps));shading flat;colormap(jet) % axis([0,300,-300,0]) axis('square'); caxis([min(min(log10(1+sx1))) max(max(log10(1+sx1)))]); title([fname]) % cleanup % clear