COPSkcloop
Jump to navigation
Jump to search
function COPSkcloop(infile) %channels %={'0Ed412','0Ed443','0Ed490','0Ed510','0Ed555','0Ed665','1Lu412','1Lu443', %'1Lu490','1Lu510','1Lu555','1Lu665'}; %prr channels rqfid = fopen('/home/oceancolor/Plumes_and_Blooms/workspace/eriks/C-OPS/Copsrqclist.txt') chin = 1; while ~feof(rqfid) chline = fgets(rqfid); channels2(chin,:) = {chline(1:6)}; chin = chin + 1; if chin > 36 break end end channels2 = channels2'; depth_width = [10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10]; %interval = [12,12,12,12,12,10,12,12,12,12,12,10]; % -r 1ed412 1 12 % -r 1ed443 1 12 % -r 1ed490 1 12 % -r 1ed510 1 12 % -r 1ed555 1 12 % -r 1ed665 1 10 % -r 1lu412 1 12 % -r 1lu443 1 12 % -r 1lu490 1 12 % -r 1lu510 1 12 % -r 1lu555 1 12 % -r 1lu665 1 10 %infile = 'bsakrmP101216B.lcd.1'; s = struct('channel',channels2,'depthwidth',depth_width); valac = []; donebefore =0; %=============main loop============ for L = 1:size(depth_width,2) %vars %=%bscalcE(s(L).channel,s(L).scale(L),s(L).interval(L),'bananKrqcmmP101216B.l%cd.1') %-------------end changed 12-4-12 %valac = valac; %changed 12-4-12 from ' to not %===generate new file and checking what input files to use======= %======== newfile = strcat('kc',infile); infp = fopen(newfile,'r+'); if infp ~= -1 infile = newfile; end if infp ==-1 && donebefore == 0 %if first time through using "mbs" file nf = fopen(newfile,'w+'); %open a new file for writing as usual infp = fopen(infile,'r+'); %open original as usual else if infp == -1 && donebefore == 1 newfile = infile; end temp = strcat('tempkclcd',newfile); %write stuff to this and then rename... to "kc" nf = fopen(temp,'w+');%open a temp file that will be renaimed 'kc..' if donebefore ==1 && L < 2 ; infile = newfile;%just need to assign this once otherwise infile will keep having an extra kc on it.(kckckc..) end infp = fopen(infile,'r+'); end if donebefore ==1 %disp('done before') end donebefore =1; vars = []; %======================================================================= %=====runs the kc stuff================================================= %===================================== vars = CPSbopkc(s(L).channel,s(L).depthwidth(L),infile); vars = vars';% changed 12-4-12 valac = [valac,vars]; %======================================================================= %======================================================================= %===========print filters to while ~feof(infp) linep = fgets(infp); if strncmp(linep,'<data>',6) == 1 fprintf(nf,'%s\n',['kcr-',s(L).channel]); fprintf(nf,'%s\n','<data>'); break end fprintf(nf,linep); %moved to after channel print 12-4-12 end %========================================================================== %-----open temp data file for reading and add new data columns to it. %========================================================================== mname = strcat('temp',infile); %this is the same temp data file generated by bopkc tn = load(mname); if L ==1 tempm = [tn,valac]; %added 12-4-12 ' making first line of data to write else tempm = [tempm,vars]; end %disp('keyboard in kcloop') %keyboard %#===++ dlmwrite(mname,tempm,'delimiter',' ','precision',6); %overwrites data file with new columns matfile = fopen(mname); while ~feof(matfile) nln = fgets(matfile); fprintf(nf,'%s',nln); %writes matfile to new lcd end %------add filters to end of file while ~feof(infp) tl = fgets(infp); if strncmp(tl,'<filters_used>',14) == 1 fprintf(nf,tl); while ~feof(infp) npf = fgets(infp); fprintf(nf,'%s',npf); end end end %===add stats line== %for L = 1:size(depth_width,2) commented 12-4-12 fprintf(nf,'%s\n',['bopkc', s(L).channel,' ', num2str(s(L).depthwidth(L)),' ', infile]); %fprintf(nf,'%s\n',char(valac(L))) %fprintf(nf,'%s/n') %end commented 12-4-12 fclose(nf); fclose(infp); if donebefore ==1 && L > 1 %movefile(tempname,newfile) movefile(temp,infile); end infile = newfile; %needs to update filename otherwise infile will always be the same. end fclose all
back to C-OPS/CERBERUS Mfiles