Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% SETUP VARIABLES
- % load the sonar
- p = '\\storebox\Aquacoustic\Job Data\55562_Hydromax_Baltimore-County\Processed\Ready for Splitting\Mother''s Arms\47174 47175 47176 47178 47179 47180_001 CONCAT_dblchk.MAT'
- a = load(p)
- xsect = a.xsect
- uconv = 0.3048
- runlengths = [ 269 202 601 100 92] .*uconv
- splits = zeros(1,numel(runlengths))
- deltas = Inf(1,numel(runlengths))
- thresh_2 = 1 %squared threshold for search function
- %perform discrete integration of runlengths to find absolute payout of
- %potential split locations
- abspos = cumsum(runlengths)
- %we're going to need to reset these cable lengths to 0 for the output files
- %so we make an array for easily grabbing the offsets out of. it will have
- %one extra value we dont need at the end that we can just ignore
- offsets = [0 abspos]
- %%FIND THE SPLITS
- %find the split locations (looking for profile that most closely
- %matches the absolute position)
- for i = 1:numel(xsect.img)
- for j = 1:numel(runlengths)
- delta = xsect.img(i).cable - abspos(j);
- delta = delta*delta;
- if(delta<thresh_2)
- if(delta<deltas(j))
- splits(j) = i;
- deltas(j) = delta;
- end
- end
- end
- end
- %% build an array of indices for splitting
- %start by padding the splits
- splits_1 = splits+1
- split_ind = reshape([splits;splits_1],1,[]) %this interleaves splits
- %and split_1
- split_ind = [1 split_ind numel(xsect.img)] %this adds a 1 and N entry
- %to split matrix
- split_ind = reshape(split_ind',2,[])'
- IN = xsect % we call the xsect var. "IN" now, the output var has to be called
- % "xsect" so it will still load in sonar express
- %% DO THE SPLITTING
- for row = 1 : size(split_ind,1)
- xsect = struct; %create the output structure
- % these are just some variables that need to be saved
- % with the file
- xsect.currentStation = 1;
- xsect.unit = IN.unit;
- xsect.renderOptions = IN.renderOptions;
- xsect.longVer = IN.longVer;
- %slice from the input
- xsect.img = IN.img( split_ind(row,1):split_ind(row,2));
- xsect.oper = IN.oper(split_ind(row,1):split_ind(row,2));
- %reset the payout (cable distance) so the segment starts
- %at 0
- for i=1:numel(xsect.img)
- %cable length is stored in 2 places in the output
- %structure
- xsect.img(i).cable = xsect.img(i).cable - offsets(row)
- xsect.oper(i).cable = xsect.oper(i).cable - offsets(row)
- end
- %finally, save the segment
- fprintf('Writing...\n');
- save(sprintf('%s.part%.0f.mat',p,row),...
- 'xsect');
- end
Add Comment
Please, Sign In to add comment