<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki-pnb.eri.ucsb.edu/index.php?action=history&amp;feed=atom&amp;title=Auto_bt</id>
	<title>Auto bt - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki-pnb.eri.ucsb.edu/index.php?action=history&amp;feed=atom&amp;title=Auto_bt"/>
	<link rel="alternate" type="text/html" href="https://wiki-pnb.eri.ucsb.edu/index.php?title=Auto_bt&amp;action=history"/>
	<updated>2026-04-08T00:15:31Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.0</generator>
	<entry>
		<id>https://wiki-pnb.eri.ucsb.edu/index.php?title=Auto_bt&amp;diff=744&amp;oldid=prev</id>
		<title>Eriks: Created page with &quot;Picks points for the downcast matrix for PRR/C-OPS/CERBERUS  &lt;pre&gt;   function auto_bt(varargin) %Erik Stassinos 2-26-2014 %to automate picking tops and bottoms of casts %this ...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki-pnb.eri.ucsb.edu/index.php?title=Auto_bt&amp;diff=744&amp;oldid=prev"/>
		<updated>2014-04-10T21:27:03Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Picks points for the downcast matrix for PRR/C-OPS/CERBERUS  &amp;lt;pre&amp;gt;   function auto_bt(varargin) %Erik Stassinos 2-26-2014 %to automate picking tops and bottoms of casts %this ...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Picks points for the downcast matrix for PRR/C-OPS/CERBERUS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function auto_bt(varargin)&lt;br /&gt;
%Erik Stassinos 2-26-2014&lt;br /&gt;
%to automate picking tops and bottoms of casts&lt;br /&gt;
%this is needed for the CERBERUS where multiple casts are done&lt;br /&gt;
%prrstrip(1,prr_lcd,'Master_FrameNumber','LuZDepth') example function call&lt;br /&gt;
&lt;br /&gt;
%==populate list_prr&lt;br /&gt;
fid=fopen('list_prr.txt','r');&lt;br /&gt;
list_prr = [];&lt;br /&gt;
badfilectr =0;&lt;br /&gt;
tmpfile=fullfile(pwd,'goprrbt_tmp');&lt;br /&gt;
while fid,&lt;br /&gt;
  check=fgetl(fid);&lt;br /&gt;
  if check == -1, break, end&lt;br /&gt;
  list_prr=[list_prr; check];&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
%==check if files are present&lt;br /&gt;
for i=1:size(list_prr,1)&lt;br /&gt;
    [s,m]=unix(['ls ',list_prr(i,:)]);&lt;br /&gt;
    if s&lt;br /&gt;
        badfilectr=badfilectr+1;&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
clear i&lt;br /&gt;
if badfilectr&lt;br /&gt;
    if badfilectr==1&lt;br /&gt;
        msg=sprintf('%i missing prr file.',badfilectr);&lt;br /&gt;
        disp(msg)&lt;br /&gt;
        error('Your prrlist includes a file not in pwd.')&lt;br /&gt;
    else&lt;br /&gt;
        msg=sprintf('%i missing prr files.',badfilectr);&lt;br /&gt;
        disp(msg)&lt;br /&gt;
        error('Your prrlist includes files not in pwd.')&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
clear s m badfilectr msg&lt;br /&gt;
%===end check if files are present&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
for i=1:size(list_prr,1)&lt;br /&gt;
&lt;br /&gt;
prr_lcd=list_prr(i,:);&lt;br /&gt;
prr_strip=[prr_lcd '.strip'];&lt;br /&gt;
var_1 = varargin{1};&lt;br /&gt;
var_2 = varargin{2};&lt;br /&gt;
&lt;br /&gt;
prrstrip(1,prr_lcd,var_1,var_2) %pull columnds to create two variable file&lt;br /&gt;
%prrstrip(1,prr_lcd,'FrameCount','LuZDepth')&lt;br /&gt;
&lt;br /&gt;
[fileA,headA]=read_strip(prr_strip);&lt;br /&gt;
depth = fileA(:,2);&lt;br /&gt;
index = fileA(:,1); %time&lt;br /&gt;
&lt;br /&gt;
%shallowest points on shallow depth&lt;br /&gt;
rowmn = find(fileA(:,2) == max(fileA(:,2)));%shallowest point--use this to start&lt;br /&gt;
&lt;br /&gt;
%downcast deepest point&lt;br /&gt;
rowdcmx = find(fileA(:,2) == min(fileA(rowmn:end,2)));&lt;br /&gt;
rowmx = find(fileA(:,2) == min(fileA(:,2)));%deepest point&lt;br /&gt;
&lt;br /&gt;
%==========visualize points=====================&lt;br /&gt;
plot(index,depth) %plot all the data&lt;br /&gt;
hold on&lt;br /&gt;
plot(index(rowmx:rowmn),depth(rowmx:rowmn),'g-.') %plot deepest to shallowest green&lt;br /&gt;
hold on&lt;br /&gt;
plot(index(rowmn:rowdcmx),depth(rowmn:rowdcmx),'r-.') %plot downcast only red&lt;br /&gt;
%=========end visualize=====================&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
%========creat bt file=====================&lt;br /&gt;
fid=fopen( 'bt.pts', 'w' ); %create bt.pts file&lt;br /&gt;
fprintf(fid,'castid	index	1mer_time	1depth\n');&lt;br /&gt;
bt_pts = [[rowmn(1);rowdcmx(1)], [index(rowmn(1));index(rowdcmx(1))],[sqrt((depth(rowmn(1)))^2);sqrt((depth(rowdcmx(1)))^2)]]; %assemble parameters for castid&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
%btpts is index, time, depth&lt;br /&gt;
%id is number of casts processed---- always going to be one per file at&lt;br /&gt;
%this time&lt;br /&gt;
bt_castname=[ prr_lcd(1:9),'dt','1']; %castdir is dt db for downcast top or bottom&lt;br /&gt;
fprintf(fid,'%s %1.7e %1.7e %1.7e \n',bt_castname,bt_pts(1,:)); %print castID matrix&lt;br /&gt;
fprintf(fid,'%s %1.7e %1.7e %1.7e \n',bt_castname,bt_pts(2,:));&lt;br /&gt;
fclose(fid);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
eval(['!mv ' prr_lcd ' ' tmpfile])&lt;br /&gt;
unix(sprintf('sed ''-e /&amp;lt;sampled_parameters&amp;gt;/ r bt.pts'' -e//N %s &amp;gt; %s',tmpfile,prr_lcd))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
% eval([ '!awk &amp;lt; ' prr_lcd ' &amp;gt; ' tmpfile...&lt;br /&gt;
% 	  ' ''$1==&amp;quot;&amp;lt;sampled_parameters&amp;gt;&amp;quot;{system(&amp;quot;cat bt.pts&amp;quot;)}{print $0}'''])&lt;br /&gt;
%     eval([ '!mv ' tmpfile ' ' prr_lcd ]);&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Eriks</name></author>
		
	</entry>
</feed>