function offrate( path, first, last) % determine the offrate of tiles % or on rates, or whatever else. % USEFUL FEATURE: (not yet implemented) % somehow manage to select only a portion to analyze and ignore the rest % useful for cases where portions of the crystal are cut off so false edges % are created, and affect statistics wrongly. % read data from file optfile = '/home/wrightc/find/rateoptions'; textform = '%q %u %u %q %u %u %u %u %u '; [inpath,first,last,outputpath, a,b,c,d,e] = textread( optfile, textform ); global OPTIONS; OPTIONS = [a,b,c,d,e]; %----------------------------------------------------------- % offrate with respect to connections if ( ~isempty(find(OPTIONS == 1)) ) offstat = zeros( 3,6 ); % 0 1 2c 2f 3 4 % full-full [] [] [] [] [] [] % full-empty [] [] [] [] [] [] % total [] [] [] [] [] [] for f = first:last-1 str = form(f); path = [inpath{1},'.',str]; load( '-mat', path, 'conn', 'match', 'N') conn = conn(:,[2,3,5,6]); % [1,2,3,4] = row n % 3 4 % n % 2 1 for a = 1:N % determine constant or off if match(a) ~= 0 % connection exists, full-full r = 1; else % connection does not exist, full-empty r = 2; end % determine neighborhood z = find(conn(a,:)==0); lz = length(z); if lz == 4 c = 1; elseif lz == 0 c = 6; elseif lz == 1 c = 5; elseif lz == 3 c = 2; else % lz = 2 (can be close or far) if (z(2) == 2 & z(1) == 1) | (z(2) == 4 & z(1) == 3) % close c = 3; else % far c = 4; end end offstat(r,c) = offstat(r,c) + 1; end end offstat(3,:) = offstat(1,:) + offstat(2,:); offstat(1:2,:) = offstat(1:2,:) ./ repmat(offstat(3,:), [2,1]) figure(1) hold on % plot(offstat(1,:), 'g') plot(offstat(2,:), 'b') hold off save( [outputpath{1},'.',str], '-mat', 'offstat'); end %----------------------------------------------------------- % off rate hairpins if ( ~isempty(find(OPTIONS == 2)) ) offstathair = zeros (3,2) % hair no hair % full-full [] [] % full-empty [] [] % total [] [] for f = first:last-1 str = form(f); path = [inpath{1},'.',str]; load( '-mat', path, 'hair', 'match', 'N') for a = 1:N % determine constant or off if match(a) ~= 0 % connection exists, full-full r = 1; else % connection does not exist, full-empty r = 2; end if hair(a) == 1 offstathair(r,1) = offstathair(r,1) + 1; offstathair(3,1) = offstathair(3,1) + 1; else offstathair(r,2) = offstathair(r,2) + 1; offstathair(3,2) = offstathair(3,2) + 1; end end end offstathair offstathair(1:2,:) = offstathair(1:2,:) ./ repmat(offstathair(3,:), [2,1]) save( [outputpath{1},'.',str], '-mat', '-append', 'offstathair'); end %----------------------------------------------------------- % # tiles per frame if ( ~isempty(find(OPTIONS == 3)) ) numtiles = zeros(1,last-first+1); % frame 1 2 3 ... % #tiles N1 N2 N3 ... for f = first:last str = form(f); path = [inpath{1},'.',str]; load( '-mat', path, 'N') numtiles( f-first+1 ) = N; end numtiles figure(3) plot(numtiles) end %----------------------------------------------------------- % on rate : locations if ( ~isempty(find(OPTIONS == 4)) ) end %----------------------------------------------------------- % on rate : connections if ( ~isempty(find(OPTIONS == 5)) ) onstatconn = zeros(2, 7, last - first ); % 0 1 2c 2f 3 4 # connections % came on [] [] [] [] [] [] [] used % available conn [] [] [] [] [] [] [] available for f = first:last-1 page = f-first+1; str = form(f+1); path = [inpath{1},'.',str]; load( '-mat', path, 'N', 'conn') N2 = N; conn2 = conn(:,[2,3,5,6]); str = form(f); path = [inpath{1},'.',str]; load( '-mat', path, 'conn', 'match', 'N') conn = conn(:,[2,3,5,6]); % find available tiles in each frame for n = 1:N % determine neighborhood of available connections z = find(conn(n,:)==0); lz = length(z); if lz == 4 c = 6; elseif lz == 0 c = 1; elseif lz == 1 c = 2; elseif lz == 3 c = 5; else % lz = 2 (can be close or far) if (z(2) == 2 & z(1) == 1) | (z(2) == 4 & z(1) == 3) % close c = 3; else % far c = 4; end end onstatconn(2,c,page) = onstatconn(2,c,page)+1; end temp = onstatconn(2,:,page); onstatconn(2,7,page) = temp(2) + (temp(3)+temp(4))*2 + temp(5) * 3 + temp(6) *4; % find tiles that come on, & their neighborhood for n = 1:N2 if isempty(find(match == n)) % determine neighborhood of available connections z = find(conn2(n,:)==0); lz = length(z); if lz == 4 c = 1; elseif lz == 0 c = 6; elseif lz == 1 c = 5; elseif lz == 3 c = 2; else % lz = 2 (can be close or far) if (z(2) == 2 & z(1) == 1) | (z(2) == 4 & z(1) == 3) % close c = 3; else % far c = 4; end end onstatconn(1,c,page) = onstatconn(1,c,page)+1; end end temp = onstatconn(1,:,page); onstatconn(1,7,page) = temp(2) + (temp(3)+temp(4))*2 + temp(5) * 3 + temp(6) *4; end onstatconn; tog = zeros(2,7); for p = 1:last-first tog = tog + onstatconn(:,:,p); end tog figure(5) plot(tog(1,1:6), 'r-*') disp('data not saved') end %----------------------------------------------------------- % offrate connections and hairpins if ( ~isempty(find(OPTIONS == 6)) ) offstat2 = zeros( 3,6 ); % 0 1 2c 2f 3 4 % full-full [] [] [] [] [] [] % full-empty [] [] [] [] [] [] % total [] [] [] [] [] [] % full-full hairpin [] [] [] [] [] [] % full-empty hair [] [] [] [] [] [] % total hair [] [] [] [] [] [] for f = first:last-1 str = form(f); path = [inpath{1},'.',str]; load( '-mat', path, 'conn', 'match', 'N', 'hair') conn = conn(:,[2,3,5,6]); % [1,2,3,4] = row n % 3 4 % n % 2 1 for a = 1:N % determine constant or off if hair(a) == 0 if match(a) ~= 0 % connection exists, full-full r = 1; else % connection does not exist, full-empty r = 2; end else if match(a) ~= 0 % connection exists, full-full hairpin r = 4; else % connection does not exist, full-empty hairpin r = 5; end end % determine neighborhood z = find(conn(a,:)==0); lz = length(z); if lz == 4 c = 1; elseif lz == 0 c = 6; elseif lz == 1 c = 5; elseif lz == 3 c = 2; else % lz = 2 (can be close or far) if (z(2) == 2 & z(1) == 1) | (z(2) == 4 & z(1) == 3) % close c = 3; else % far c = 4; end end offstat2(r,c) = offstat2(r,c) + 1; end end offstat2(3,:) = offstat2(1,:) + offstat2(2,:); offstat2(6,:) = offstat2(4,:) + offstat2(5,:); offstat2 figure(6) hold on plot(offstat2(5,:), 'r') plot(offstat2(2,:), 'b') hold off save( [outputpath{1},'.',str], '-mat', 'offstat2'); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function str = form ( in ) % str = form ( in ) % in : numerical input such as 52 or 4 % str character string output of length three such as '052' or '004' % % convert 'in' to a 3 digit string % ex: 5 --> '005' , 13 --> '013' , 324 --> '324' if (in < 10) str = ['00',int2str(in)]; elseif (in < 100) str = ['0',int2str(in)]; else str = int2str(in); end