CERBbscalcloop
Jump to navigation
Jump to search
function CERBbscalcloop(infile) %loop for calling bscalc %Erik Stassinos %modified for C-OPScast 6-20-2013 scale = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]; %will be changed to be read from a file. %interval = [10,10,10,12,12,12,12,12,12,12,12,12,10,10,10,10,10,10,10,10,10,12,12,12,12,12,12,12,12,12,10,10,10,10,10,10]; interval = [5,5,5,5,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,2,2,2,2,2,2,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5]; %%%% old % -r EdZ320 1 5 % -r EdZ340 1 5 % -r EdZ380 1 5 % -r EdZ395 1 5 % -r EdZ412 1 10 % -r Edz443 1 10 % -r Edz465 1 10 % -r EdZ490 1 10 % -r EdZ510 1 10 % -r EdZ532 1 10 % -r EdZ555 1 10 % -r EdZ560 1 10 % -r EdZ625 1 10 % -r Edz665 1 10 % -r EdZ670 1 10 % -r EdZ683 1 10 % -r EdZ710 1 10 % -r EdZ780 1 10 % -r LuZ320 1 10 % -r LuZ340 1 10 % -r LuZ380 1 10 % -r LuZ395 1 10 % -r LuZ412 1 10 % -r Luz443 1 10 % -r Luz465 1 10 % -r LuZ490 1 10 % -r LuZ510 1 10 % -r LuZ532 1 10 % -r LuZ555 1 2 % -r LuZ560 1 2 % -r LuZ625 1 2 % -r 1lu665 1 2 % -r LuZ670 1 2 % -r LuZ683 1 2 % -r LuZ710 1 2 % -r LuZ780 1 5 % -r EuZ320 1 5 % -r EuZ340 1 5 % -r EuZ380 1 5 % -r EuZ395 1 5 % -r EuZ412 1 5 % -r Euz443 1 5 % -r Euz465 1 5 % -r EuZ490 1 5 % -r EuZ510 1 5 % -r EuZ532 1 5 % -r EuZ555 1 5 % -r EuZ560 1 5 % -r EuZ625 1 5 % -r Elu665 1 5 % -r EuZ670 1 5 % -r EuZ683 1 5 % -r EuZ710 1 5 % -r EuZ780 1 5 %infile = 'akrmP101216B.lcd.1'; %rqfid = fopen('/home/data65/pb/REPROCESS_2010/PRR/rqclist.txt') %rqfid = fopen('/home/oceancolor/Plumes_and_Blooms/workspace/eriks/C-OPS/Copsrqclist.txt'); rqfid = fopen([pwd,'/CERBrqclist.txt']); chin = 1; while ~feof(rqfid) chline = fgets(rqfid); %if chin >= 37 if isempty(strtrim(chline)) break end if strncmp({chline(1:3)},'Ed0',3) ==1 continue else channels3(chin,:) = {chline(1:6)}; chin = chin + 1; end end channels3 = channels3'; s = struct('channel',channels3,'scale',scale,'interval',interval); valac = []; for L = 1:size(scale,2) %vars =%bscalcE(s(L).channel,s(L).scale(L),s(L).interval(L),'bananKrqcmmP101216B.l%cd.1') vars = bscalcE_angQ(s(L).channel,s(L).scale(L),s(L).interval(L),infile); valac = [valac;{vars}]; if ~ischar(valac) % added by ES 9-18-2012 %%char(valac) %why is this here?? end end %===generate new file===== newfile = strcat('bs',infile); nf = fopen(newfile,'w+'); infp = fopen(infile,'r+'); pull =[]; %write file and put in (0-) values "a" %----------------------- %Find index of Ed and Lu chans to generate 0- line ct = 0;%channel index counter p =1; %pulling index infi = fopen(infile); %for L2 = 1:size(scale,2) while ~feof(infi) s(p).channel; ckl = fgets(infi); %if strncmp(ckl,'1mer_time',9) ==1; %changed 12-3-12 1mer_time if strncmp(ckl,'Master_FrameNumber',10) ==1; %changed 3-2-14 ct =1; %keyboard end if strncmp(ckl,s(p).channel,6) ==1 %ct = ct+1 pull(p) = ct; p = p +1; end if length(pull) >= size(scale,2) %should only be Ed and Lu break end if ct >=1 ct = ct+1; end end %=========++++++get # of columns frewind(infi); ctr =0; flag = 0; %while ~feof(infi) for i = 1:1000 tt = fgets(infi); %if strncmp(tt,'1mer_time',9) ==1; %changed 12-3-12 0prr_record from 1mer_time if strncmp(tt,'Master_FrameNumber',10) ==1; %changed 3-2-14 % ctr = ctr+1; flag =1; end %while strncmp(tt,'<data>',6) ~=1 % tt = fgets(infi); if flag == 1 ctr = ctr+1; end if strncmp(tt,'<derived_parameters>',20) ==1 ctr = ctr -1; end if strncmp(tt,'<data>',6) ==1 ctr = ctr - 1; break end %end %end end zeromin_line = ones(1,ctr)*-9.9E35; %zeromin_line = ones(1,ctr-2)*-9.9E35; %for prr_bincheat fclose(infi); clear i; for i = 1:length(pull) oneval = char(valac(i)); [a,b,c] = strread(oneval,'%s%s%s','delimiter',' '); val = char(c(2)); zerominus = str2num(val); zeromin_line(pull(i)) = zerominus; end %------------------------- while ~feof(infp) linep = fgets(infp); fprintf(nf,linep); if strncmp(linep,'<data>',6) == 1 %fprintf(nf,linep) %fprintf(nf,'%s',zeromin_line) dlmwrite(newfile,zeromin_line,'-append','delimiter',' ','precision','%.5d'); fseek(nf,0,'eof'); % dlmwrite(newfile,' ','-append') %fprintf(nf,'%s\n','') end end %===end generate new file==== %===add stats line== for L = 1:size(scale,2) fprintf(nf,'%s\n',['bscalc ', s(L).channel,' ', num2str(s(L).scale(L)),' ', num2str(s(L).interval(L)),' ', infile]); if ~ischar(valac) %added by ES 9-18-2012 ln = valac(L); fprintf(nf,'%s\n',char(ln)); end %fprintf(nf,'%s/n') end