Hs6bt.m
Revision as of 15:52, 2 August 2010 by 128.111.101.185 (talk) (Created page with '<pre> % AC9BT % FEB 98,FEB 99 % Stephen Wolfe % Input: none % Look for: list_hs6 % Output: z*.lcd.?, z*.lcd.strip % Assumptions: fixed for either single casts or yo-yo's. Have t…')
% AC9BT % FEB 98,FEB 99 % Stephen Wolfe % Input: none % Look for: list_hs6 % Output: z*.lcd.?, z*.lcd.strip % Assumptions: fixed for either single casts or yo-yo's. Have to % pick something for at least 1 profile of each yo-yo % for the profile numbers to work correctly. Can't tell % if you skip a down-up pair. % % Purpose: pick tops and bottoms % % Calls: bt_ac9 % Maintain: {filename, columnarraylist, disp_text} % Uses: perfect for hs6 processing, ref: hs6.ins % Example: hs6bt % Notes: This will run on NT if the call to bbopstrip is % commented out and the files are already stripped % Should label direction in castid table as well as % profile number. Work from left to right. If you % choose not to save points for a profile, you can % repick them and choose save and then go on. % TO DO: The archive scheme does not work due to changes in % naming convention. Doesn't create the log directory % if it's not there either. %cd('pb218') pb=1; clf; list_hs6=[]; hs6_files=[]; not_hs6_files=[]; tmpfile=fullfile(pwd,'gohs6bt_tmp'); % check for list_hs6 in pwd [s,m]=unix('ls list_hs6'); if isempty(m) msg=sprintf('Check your list_hs6.'); disp(msg) return end clear s m % load list_hs6 fid=fopen('list_hs6','r'); while fid, check=fgetl(fid); if check == -1, break, end list_hs6=[list_hs6; check]; end list_hs6 clear fid check % check presence of hs6 files badfilectr=0; for i=1:size(list_hs6,1) [s,m]=unix(['ls ',list_hs6(i,:)]); if s badfilectr=badfilectr+1; end end clear i if badfilectr if badfilectr==1 msg=sprintf('%i missing hs6 file.',badfilectr); disp(msg) error('Your hs6list includes a file not in pwd.') else msg=sprintf('%i missing hs6 files.',badfilectr); disp(msg) error('Your hs6list includes files not in pwd.') end end clear s m badfilectr msg % loop through for i=1:size(list_hs6,1) hs6_lcd=list_hs6(i,:) % strip em hs6_strip=[hs6_lcd '.strip'] % eval(['!sbtprr_mob ',hs6_lcd]) % eval(['!bbopstrip -sz hydro_time depth ' hs6_lcd ' 'hs6_strip]); E_BBstrip(pb,hs6_lcd,'hydro_time','depth') [fileA,headA]=read_strip(hs6_strip); %eval(['!rm ''hs6_strip']); %cd .. [bt_pts]=bt_ac9(fileA); if ~isempty(bt_pts), %create header, castid matrix %castid index hydro_time 1depth %zub11008adt1 7.5000000e+01 2.1710000e+04 2.0443990e+02 %zub11008adb1 1.2810000e+03 3.7655000e+05 1.3007170e+00 %castdir={ 'dt','db','ub','ut' }; %castdir=[castdir castdir castdir castdir]; % good for 4 yoyo's %if size(bt_pts,1)>size(castdir,2), % error('hs6bt: increase size of castdir.'); %end dd=[]; idir=[]; dd=diff(bt_pts(:,3)); dd=[dd; 0]; id=1; fid=fopen( 'bt.pts', 'w' ); fprintf(fid,'castid index hydro_time depth\n'); for i=1:2:size(bt_pts,1), if dd(i)>0, if idir==1, id=id+1; end idir=1; castdir1(i:i+1,:)=['dt'; 'db']; else, idir=2; castdir1(i:i+1,:)=['ub'; 'ut']; end bt_castname=[ hs6_lcd(1:9),castdir1(i,:),num2str(id) ]; fprintf(fid,'%s %1.7e %1.7e %1.7e \n',bt_castname,bt_pts(i,:)); bt_castname=[ hs6_lcd(1:9),castdir1(i+1,:),num2str(id) ]; fprintf(fid,'%s %1.7e %1.7e %1.7e \n',bt_castname,bt_pts(i+1,:)); if idir==2, id=id+1; end end fclose(fid); %do this by calling a script that takes care of the awk and archive eval([ '!awk < ' hs6_lcd ' > ' tmpfile... ' ''$1=="<sampled_parameters>"{system("cat bt.pts")}{print $0}''']) eval([ '!mv ' tmpfile ' ' hs6_lcd ]); %archive %cruisename=eval(['echo ' hs6_lcd ' | cut -b 3-6']) cruisename=hs6_lcd(3:6); %archive=[ pwd '/ARCHIVE/' ]; archive=[ '/home/data92/bbop/ARCHIVE/' ]; %cp $lcd_file /home/data92/bbop/ARCHIVE/$cruisename/hs6 eval(['!cp ' hs6_lcd ' ' archive cruisename '/hs6']); %echo $lcd_file has been archived to /home/data92/bbop/ARCHIVE/$cruisename/hs6 eval(['!echo ' hs6_lcd ' has been archived to ',archive, cruisename '/hs6']); hs6_files=[hs6_files; hs6_lcd]; else not_hs6_files=[not_hs6_files; hs6_lcd]; end %cleanup %clear hs6_lcd bt_pts fileA headA hs6_strip; %eval('!rm bt.pts'); end %cd .. hs6_files not_hs6_files