<?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=E_BBstrip.m</id>
	<title>E BBstrip.m - 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=E_BBstrip.m"/>
	<link rel="alternate" type="text/html" href="https://wiki-pnb.eri.ucsb.edu/index.php?title=E_BBstrip.m&amp;action=history"/>
	<updated>2026-04-19T20:18:11Z</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=E_BBstrip.m&amp;diff=197&amp;oldid=prev</id>
		<title>128.111.101.185: Created page with '&lt;pre&gt; function out = E_BBstrip(pb,infile,varargin)%(,infile) %created by Erik Stassinos 2/22/10 %created to replace bbopstrip %this program takes input parameters and the pb numb…'</title>
		<link rel="alternate" type="text/html" href="https://wiki-pnb.eri.ucsb.edu/index.php?title=E_BBstrip.m&amp;diff=197&amp;oldid=prev"/>
		<updated>2010-08-05T22:51:11Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;&amp;lt;pre&amp;gt; function out = E_BBstrip(pb,infile,varargin)%(,infile) %created by Erik Stassinos 2/22/10 %created to replace bbopstrip %this program takes input parameters and the pb numb…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
function out = E_BBstrip(pb,infile,varargin)%(,infile)&lt;br /&gt;
%created by Erik Stassinos 2/22/10&lt;br /&gt;
%created to replace bbopstrip&lt;br /&gt;
%this program takes input parameters and the pb number &lt;br /&gt;
%program locates corresponding column and row positions and writes data to&lt;br /&gt;
%output file which is same as input whith .strip added&lt;br /&gt;
&lt;br /&gt;
%start in processing dir&lt;br /&gt;
&lt;br /&gt;
%infile = 'a110211a.dat.lcd'&lt;br /&gt;
&lt;br /&gt;
%cd(pb)&lt;br /&gt;
clear s&lt;br /&gt;
it =0;&lt;br /&gt;
t=0;&lt;br /&gt;
tfound =1;&lt;br /&gt;
hs6proc =0;&lt;br /&gt;
%dir *a110211*.dat&lt;br /&gt;
%infiles = ls(['a110211a'*'.dat'])&lt;br /&gt;
%=================test to see if varargin has one file or list of params&lt;br /&gt;
vartest = fopen(varargin{1});&lt;br /&gt;
%=================&lt;br /&gt;
%--------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Dirname =   pwd;&lt;br /&gt;
pattern = fullfile(Dirname,'*.lcd')&lt;br /&gt;
directory = dir(pattern);&lt;br /&gt;
directory(1).name;&lt;br /&gt;
directory(2).name;&lt;br /&gt;
size(directory);&lt;br /&gt;
%ignores other .lcd extensions and goes for original if it's been processed&lt;br /&gt;
%already&lt;br /&gt;
for r = 1:size(directory);&lt;br /&gt;
    if strncmp(directory(r).name,'z',1) ==1&lt;br /&gt;
        continue&lt;br /&gt;
    end&lt;br /&gt;
    if strncmp(directory(r).name,'d',1) == 1&lt;br /&gt;
        continue&lt;br /&gt;
    end&lt;br /&gt;
    lcdflist(r,:) = directory(r).name;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
lcdfile = infile&lt;br /&gt;
s = strrep(lcdfile,'z',''); %changes name to open data matrix&lt;br /&gt;
s = strrep(s,'.lcd','.zcal');&lt;br /&gt;
&lt;br /&gt;
if vartest == -1&lt;br /&gt;
    if varargin{2} == 'i'&lt;br /&gt;
        t = 1;&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
if length(varargin) &amp;gt;2&lt;br /&gt;
    if varargin{3} == 'i'&lt;br /&gt;
        t=1;&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
if length(varargin) &amp;gt;2 || t == 1 %varargin{2} == 'i'&lt;br /&gt;
    %if  varargin{2} == 'i' || varargin{3} == 'i'&lt;br /&gt;
    &lt;br /&gt;
    if t ==1&lt;br /&gt;
        sprintf('i is true'); %run independently&lt;br /&gt;
        it =1;&lt;br /&gt;
        s = strrep(s,'.zcal','.lcd');&lt;br /&gt;
        s = strrep(lcdfile,'.lcd','.datmatrix');&lt;br /&gt;
        %s = strrep(lcdfile,'dat.lcd','.datmatrix')&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
%if taking in a file that has a list it assumes that it's being run by&lt;br /&gt;
%merge_ctdac9&lt;br /&gt;
if vartest ~=-1&lt;br /&gt;
    s = strrep(lcdfile,'bmd','binmatmd');&lt;br /&gt;
end&lt;br /&gt;
if strncmp(varargin{1},'hydro_time',10) == 1&lt;br /&gt;
    hs6proc =1&lt;br /&gt;
    s = strrep(infile,'.lcd','.datmat');&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
fp = load(s,'.ASC');&lt;br /&gt;
in = fopen(lcdfile);&lt;br /&gt;
linecount = 1;&lt;br /&gt;
&lt;br /&gt;
%--------------------------------------------------------------------------&lt;br /&gt;
%if input is a file instead of a parameter it gets number of params and&lt;br /&gt;
%loads&lt;br /&gt;
looplength = length(varargin);&lt;br /&gt;
countvar =1;&lt;br /&gt;
if length(varargin) == 1 &amp;amp;&amp;amp; vartest ~=-1&lt;br /&gt;
    var = fopen(varargin{1});&lt;br /&gt;
    while feof(var) ~= 1&lt;br /&gt;
        fgets(var);&lt;br /&gt;
        countvar = countvar + 1;&lt;br /&gt;
    end&lt;br /&gt;
    frewind(var);&lt;br /&gt;
    for i = 1:countvar&lt;br /&gt;
        varargin{i} = fgets(var);&lt;br /&gt;
    end&lt;br /&gt;
    looplength = countvar  ;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
%--------------------------------------------------------------------------&lt;br /&gt;
%------------------------------gets arguments position----------------------&lt;br /&gt;
i=1;&lt;br /&gt;
if it == 1 %varargin{3} == 'i')%length(varargin) ==3&lt;br /&gt;
    looplength = length(varargin) -1;&lt;br /&gt;
end&lt;br /&gt;
if vartest ~=-1&lt;br /&gt;
    varcounter = 1;&lt;br /&gt;
    frewind(vartest);&lt;br /&gt;
    while feof(vartest) ~=1&lt;br /&gt;
        tline = fgets(vartest);&lt;br /&gt;
        tline = strtrim(tline);&lt;br /&gt;
        vararg{varcounter,:}  = tline; %fgets(vartest)&lt;br /&gt;
        varcounter = varcounter +1;&lt;br /&gt;
    end&lt;br /&gt;
    tfound = 0;&lt;br /&gt;
    found =0;&lt;br /&gt;
    looplength = varcounter -1;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
ic =0; %initialize variable for hs6 loop counter&lt;br /&gt;
found =0;&lt;br /&gt;
while i &amp;lt; looplength +1 %length(varargin)+1 %because while statement, has to be one over the actual &amp;lt;&lt;br /&gt;
    &lt;br /&gt;
    while ~feof(in) %end of file tester&lt;br /&gt;
        l = fgets(in);&lt;br /&gt;
        if linecount == 2&lt;br /&gt;
            head = l;&lt;br /&gt;
        end&lt;br /&gt;
        if linecount ==3 &amp;amp;&amp;amp; tfound ~= 1 %so not to interfere with head location just skips to third line&lt;br /&gt;
            threepos = ftell(in);&lt;br /&gt;
        end&lt;br /&gt;
        linecount = linecount +1; %keeps counting lines until it's found the first thing looking for&lt;br /&gt;
        if vartest == -1 &amp;amp;&amp;amp; hs6proc ~=1&lt;br /&gt;
            if strncmp(l,varargin{i},length(varargin{i})) ==1;&lt;br /&gt;
                column = (linecount -16);&lt;br /&gt;
                % val = column;&lt;br /&gt;
                eval(['locin',num2str(i) '= column']) ;&lt;br /&gt;
                break&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        &lt;br /&gt;
        if vartest == -1 &amp;amp;&amp;amp; hs6proc ==1&lt;br /&gt;
            if strncmp(l,varargin{i},length(varargin{i})) ==1;&lt;br /&gt;
                if strncmp(l,varargin{1},length(varargin{i})) ==1;&lt;br /&gt;
                    prevleng = linecount %sets first part of params to one.  takes in total lines before first param&lt;br /&gt;
                    pl = 1;&lt;br /&gt;
                end&lt;br /&gt;
                column = (linecount - prevleng);&lt;br /&gt;
                if pl ==1&lt;br /&gt;
                    column = (linecount -prevleng +1); %used to be 38 for latest HS6 processing&lt;br /&gt;
                end&lt;br /&gt;
                eval(['locin',num2str(i) '= column']) ;&lt;br /&gt;
                break&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        if vartest ~=-1 %for processing of list file&lt;br /&gt;
            if strncmp(l,'&amp;lt;derived_parameters&amp;gt;',20) ==1 %line does not count&lt;br /&gt;
                linecount = linecount -1;&lt;br /&gt;
            end&lt;br /&gt;
            if strncmp(l,vararg{i},length(vararg{i,:})) ==1&lt;br /&gt;
                &lt;br /&gt;
                % disp('=======in here for column assgn++++++++')&lt;br /&gt;
                &lt;br /&gt;
                %Because there are some descrepencies between the zeroth column as seen by the computer and&lt;br /&gt;
                %the 1st column seen by matlab some offsets need to be done in order to get&lt;br /&gt;
                %the correct column.  Also, because there are section header &amp;lt; &amp;gt; neglected&lt;br /&gt;
                %it is important to remove those from the column count.&lt;br /&gt;
                &lt;br /&gt;
                &lt;br /&gt;
                %first header doesn't count but sampled and derived do for first&lt;br /&gt;
                %run through&lt;br /&gt;
              &lt;br /&gt;
                column = linecount -20;&lt;br /&gt;
                if found == 0&lt;br /&gt;
                    column = linecount -21;&lt;br /&gt;
                end&lt;br /&gt;
                found = found +1;&lt;br /&gt;
                if found &amp;lt; looplength&lt;br /&gt;
                    fseek(in,threepos,-1);&lt;br /&gt;
                    linecount =3; %goes to third line and starts fresh&lt;br /&gt;
                    tfound = 1;&lt;br /&gt;
                    %clear column&lt;br /&gt;
                end&lt;br /&gt;
                break&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    x(:,i) =  fp(:,column);%places column data in to columns in x&lt;br /&gt;
    &lt;br /&gt;
    if column ==22 &amp;amp;&amp;amp; vartest ==-1 &amp;amp;&amp;amp; hs6proc ~=1&lt;br /&gt;
        x(:,i) = -1*x(:,i);&lt;br /&gt;
    end&lt;br /&gt;
    if hs6proc ==1&lt;br /&gt;
        if column ==2&lt;br /&gt;
            x(:,i) = -1*x(:,i);&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    i = i +1;&lt;br /&gt;
    &lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
%--------------------------------end gets----------------------------------&lt;br /&gt;
%--------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
%cd('processing')&lt;br /&gt;
if length(varargin) == 2&lt;br /&gt;
    output = fopen(strrep(lcdfile,'.lcd','.lcd.strip'),'w+');%creates .lcd.strip&lt;br /&gt;
end&lt;br /&gt;
if length(varargin) &amp;gt; 2&lt;br /&gt;
    if it == 1  %varargin{3} =='i'&lt;br /&gt;
        %delete output&lt;br /&gt;
        % cd('processing')&lt;br /&gt;
        pwd&lt;br /&gt;
        output = fopen(strrep(lcdfile,'.lcd','.lcd.strip'),'w+')&lt;br /&gt;
        if varargin{3} == 'i'&lt;br /&gt;
            %cd ..&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
if vartest ==-1&lt;br /&gt;
    output = fopen(strcat(lcdfile,'.strip'),'w+')&lt;br /&gt;
end&lt;br /&gt;
if vartest ~= -1 &lt;br /&gt;
    output = fopen(strcat(lcdfile,'.strip'),'w+')&lt;br /&gt;
end&lt;br /&gt;
if vartest == -1&lt;br /&gt;
    fprintf(output,'%s','#',head);&lt;br /&gt;
    if length(varargin) &amp;gt;2&lt;br /&gt;
        for i = 1:length(varargin) -1&lt;br /&gt;
            fprintf(output,'%s %s\n','#',varargin{i});&lt;br /&gt;
        end&lt;br /&gt;
    else    &lt;br /&gt;
        for i = 1:length(varargin)&lt;br /&gt;
            fprintf(output,'%s %s\n','#',varargin{i});&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    for t = 1:length(x);&lt;br /&gt;
        fprintf(output,'%f %f\n',x(t,:));&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
%need to create temporary output matrix because matlab sucks at string&lt;br /&gt;
%formating for columns&lt;br /&gt;
if vartest ~=-1&lt;br /&gt;
    for cfoy = 1:length(x(:,1))&lt;br /&gt;
        for cfox = 1:length(x(1,:));&lt;br /&gt;
            p(cfoy,cfox) = x(cfoy,cfox);&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    if strncmp(lcdfile(1,length(lcdfile)),'2',1) ==1&lt;br /&gt;
                lcdfile(1,length(lcdfile));&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    dlmwrite('temp_merge',p,'delimiter',' ','precision',6);&lt;br /&gt;
    tm = fopen('temp_merge','r');&lt;br /&gt;
    fprintf(output,'%s','#',head);&lt;br /&gt;
    for i = 1:length(vararg)&lt;br /&gt;
        fprintf(output,'%s%s\n','#',vararg{i});&lt;br /&gt;
    end&lt;br /&gt;
    while ~feof(tm)&lt;br /&gt;
        tml = fgets(tm);&lt;br /&gt;
        fprintf(output,'%s\n',tml);&lt;br /&gt;
    end&lt;br /&gt;
    delete temp_merge&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
sprintf('done with E_BBstrip')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
fclose(in);&lt;br /&gt;
fclose(output);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;[[E_BBstrip]]&amp;lt;big&amp;gt;&lt;/div&gt;</summary>
		<author><name>128.111.101.185</name></author>
		
	</entry>
</feed>