Process CERB
Jump to navigation
Jump to search
function process_CERB()
%created by Erik Stassinos 6-11-2013
%This is the global script which calls all COPS processing scripts
%2-27-2014 modified to check for cast ID matrix
%2-27-2014 modified to check if depths are good
% % %=============
% check if files have already been generated
starttime = tic;
ml = fopen('mCElist_prr.txt');
if ml ~= -1
disp('most processing has already been started')
disp('remove all files other than C*.lcd files to restart')
disp('this will be changed to adapt to processing steps already implemented')
yorn = input('Do you want to remove files and start over? y or n ','s')
yn = lower(yorn)
if strncmp(yn,'n',1) == 1
fclose(ml);
return
end
if strncmp(yn,'y',1) == 1
delete a*
delete A*
delete b*
delete r*
delete t*
delete m*
delete K*
delete l*
delete 'slist.txt'
delete 'Clist.txt'
pause(3)
end
end
prrfile('C') %changed from P list 6/24/2013
movefile('Clist_prr.txt','list_prr.txt') %changed from P list 6/24/2013
%=========================
%%%CERBbt_E
%=========================
%%%pause
%CERBERUS PARAMS: Master_FrameNumber LuZDepth
%opens list_prr.txt inside auto_bt.
%%auto_bt('Master_FrameNumber','LuZDepth')
%=========================
%=========================
%castid check
plist = fopen('list_prr.txt');
while ~feof(plist)
r = fgets(plist);
t = textscan(r,'%s');
p = char(t{1,:});
castcheck = fopen(p);
for i = 1:50
line = fgets(castcheck);
if strncmp(line,'castid',6) == 1
found_castid =1;
end
end
end
if exist('found_castid')
disp('cast id matrix present')
fclose(castcheck)
else
%CERBbt_E
auto_bt('Master_FrameNumber','LuZDepth')
end
fclose(plist);
%=========================
%=========================
num =1;
prrfile('C'); %creates list of prr files "P" %changed from P list 6/24/2013
%changed back to lowercase p list 9-18-2013
prlist = fopen('Clist_prr.txt');%changed from P list 6/24/2013
%changed back to lowercase p list
%9-18-2013
%=========first math sequence
while ~feof(prlist)
newl(num,:) = fgets(prlist);
num = num +1;
end
frewind(prlist)
for i = 1:num -1
filename = newl(i,:);
%domath(filename,'s','LuZDepth',0,0.486,'depth_Lu') %changed 6-24-13
domath (filename,'s','LuZDepth',0,0.4,'depth_ed')
end
cpsfile('mCE')
mlist = fopen('mCElist_prr.txt');
num =1;
%==============radQC sequence
%compares data to limits specified in Copsrqclist.txt
while ~feof(mlist)
newl2(num,:) = fgets(mlist);
num = num +1;
end
%disp('Copy rqclist.txtfrom a previous processing example and update to this folder')
%disp('Press return to continue')
%pause
for i = 1:num -1
filename = newl2(i,:);
%path = '/home/data65/pb/REPROCESS_2010/PRR/rqclist.txt';
path = '/home/oceancolor/Plumes_and_Blooms/workspace/eriks/CERBERUS/CERBrqclist.txt';
COPSradQC(filename,path);
end
cpsfile('rqcm')
rlist = fopen('rqclist_prr.txt');
num =1;
%============doKQ sequence
while ~feof(rlist)
newl3(num,:) = fgets(rlist);
num = num +1;
end
for i = 1:num -1
infile = newl3(i,:);
infile = strtrim(infile);
CERBdoKQ(infile,'m','EdZ412',10,0.005,0.02) %-m 2Es412 10 0.005 0.02
end
cpsfile('Krqc')
Klist = fopen('Krqlist_prr.txt');
num =1;
%============angQ sequence
while ~feof(Klist)
newl4(num,:) = fgets(Klist);
num = num +1;
end
%==>file check
for i = 1:num -1 %======Check if there are actually files to process
infile = newl4(i,:);
if infile ==-1
disp('No files in Klist for angQ!?!?')
disp('Ending program')
return
end
%==>end file check
infile = strtrim(infile);
CPSangQ(infile,'EdZPitch','EdZRoll','EdZ443','LuZ443'); %hard coded range is 10 deg, flag is "2" changed 12-3-12
%keyboard
CPSangQ(strcat('an',infile),'EdZPitch','Ed0Roll','EdZ443','LuZ443');
end
cpsfile('anKr');
movefile('anKlist_prr.txt','list_prr.txt')
%
%
%pause(5)
%=======split cast and binning
%prr_split %takes list_prr.txt %==========replaced with split file
splist = fopen('list_prr.txt');
num =1;
while ~feof(splist)
newlA(num,:) = fgets(splist);
num = num +1;
end
for i = 1:num -1
infile = newlA(i,:);
infile = strtrim(infile);
prr_split_file(infile);
end
list_file = 'slist.txt';
bincolnum =2; %COPS depth column
%%%%prr_binner(list_file,bincolnum)
% % %prr_bincheat(list_file,bincolnum);
% % %cpsfile('banK');
% % %banlist = fopen('banlist_prr.txt'); %binned list
fclose all
banlist = fopen('slist.txt');
num =1;
while ~feof(banlist)
var = strtrim(fgets(banlist));
newl5(num,:) = var;% fgets(banlist)
num = num +1;
end
for i = 1:num -1
infile = newl5(i,:);
infile = strtrim(infile);
%doKQ(infile,'m','2Es412',10,0.005,0.02) %-m 2Es412 10 0.005 0.02
%========bscalc sequence
CERBbscalcloop(infile) %calls bscalc
end
%%movefile('banlist_prr.txt','list_prr.txt')
cpsfile('bsanK')
%bsmlist = fopen('list_prr.txt'); %binned list
bsmlist = fopen('bsalist_prr.txt'); %binned list
num =1;
%==========mathloop squence
while ~feof(bsmlist)
newl6(num,:) = fgets(bsmlist);
num = num +1;
end
for i = 1:num -1
infile = newl6(i,:);
infile = strtrim(infile);
%mathloop('bsbanKrqcmP101216E.lcd.1')
COPSmathloop(infile)
end
% % infile
% % %
% % %
cpsfile('mbs')
movefile('mbslist_prr.txt','list_prr.txt')
mblist = fopen('list_prr.txt'); %binned list
num =1;
while ~feof(mblist)
newl7(num,:) = fgets(mblist);
num = num +1;
end
parfor i = 1:num -1
infi = newl7(i,:);
infi = strtrim(infi);
%kcloop('mbsbanKrqcmP101216E.lcd.1')
COPSkcloop(infi) %used to be bbopkc
end
mkdir final
movefile('kcmbs*',[pwd,'/final'])
delete temp*
% % % % % % % %
elapsed = toc(starttime)
disp('Done!')