UH_LADCPshear2ANTS.m
changeset 3 5e3caf9c0f2e
equal deleted inserted replaced
2:06bf500b8e22 3:5e3caf9c0f2e
       
     1 %======================================================================
       
     2 %                    U H _ L A D C P S H E A R 2 A N T S . M 
       
     3 %                    doc: Thu Sep 30 11:06:14 2010
       
     4 %                    dlm: Wed Oct 13 11:45:10 2010
       
     5 %                    (c) 2006 A.M. Thurnherr
       
     6 %                    uE-Info: 24 56 NIL 0 0 72 2 2 4 NIL ofnI
       
     7 %======================================================================
       
     8 %
       
     9 % export UH-processed LADCP shear output to ANTS file
       
    10 %
       
    11 % USAGE: UH_LADCPshear2ANTS(stn|[stns])
       
    12 %
       
    13 % NOTES:
       
    14 %	- execute this function in [./casts] subdir
       
    15 %	- output files <stn>.sh are written in current directory
       
    16 %	- run_name = 'h' (defined in [proc/set_da.m]) is assumed
       
    17 
       
    18 % HISTORY:
       
    19 %	Sep 30, 2010: - created
       
    20 %	Oct 11, 2010: - BUG: merge output is variance, rather than stddev
       
    21 %	Oct 13, 2010: - modified to be callable from [./casts] subdir
       
    22 %				  - added usage info when called without args
       
    23 %				  - added option to call with vector
       
    24 %				  - adapted to include both dependencies
       
    25 
       
    26 function [] = UH_LADCPshear2ANTS(stn)
       
    27 
       
    28 	if nargin~=1
       
    29 		help UH_LADCPshear2ANTS
       
    30 		return
       
    31 	end
       
    32 
       
    33 	if length(stn) > 1
       
    34 		for i=1:length(stn)
       
    35 			UH_LADCPshear2ANTS(stn(i))
       
    36 		end
       
    37 		return
       
    38 	end
       
    39 
       
    40 	run_name = 'h';
       
    41 
       
    42 	subdir = dir(sprintf('*%03d',stn));
       
    43 	if length(subdir) ~= 1
       
    44 		error Cannot determine cast subdirectory
       
    45 	end
       
    46 	
       
    47 	dc_file = sprintf('%s/merge/%s_dn.mat',subdir.name,run_name);
       
    48 	uc_file = sprintf('%s/merge/%s_up.mat',subdir.name,run_name);
       
    49 	
       
    50 	load(dc_file)
       
    51 	dc_U = U; dc_V = V; dc_W = W;
       
    52 	load(uc_file)
       
    53 	uc_U = U; uc_V = V; uc_W = W;
       
    54 
       
    55 	goodbins = find(dc_U(:,2)>0 | uc_U(:,2)>0);
       
    56 	i1 = min(goodbins); i2 = max(goodbins);
       
    57 
       
    58 	prof.depth 		= dc_U(i1:i2,1);
       
    59 
       
    60 	prof.dc_nshear	= dc_U(i1:i2,2);
       
    61 	prof.dc_u_z		= dc_U(i1:i2,3);
       
    62 	prof.dc_u_z_sig	= sqrt(dc_U(i1:i2,4));
       
    63 	prof.dc_v_z		= dc_V(i1:i2,3);
       
    64 	prof.dc_v_z_sig	= sqrt(dc_V(i1:i2,4));
       
    65 	prof.dc_w_z		= dc_W(i1:i2,3);
       
    66 	prof.dc_w_z_sig	= sqrt(dc_W(i1:i2,4));
       
    67 
       
    68 	prof.uc_nshear	= uc_U(i1:i2,2);
       
    69 	prof.uc_u_z		= uc_U(i1:i2,3);
       
    70 	prof.uc_u_z_sig	= sqrt(uc_U(i1:i2,4));
       
    71 	prof.uc_v_z		= uc_V(i1:i2,3);
       
    72 	prof.uc_v_z_sig	= sqrt(uc_V(i1:i2,4));
       
    73 	prof.uc_w_z		= uc_W(i1:i2,3);
       
    74 	prof.uc_w_z_sig	= sqrt(uc_W(i1:i2,4));
       
    75 
       
    76 	struct2ANTS(prof,{dc_file,uc_file},sprintf('%03d.sh',stn));