-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjanus5beam2xyz.m
81 lines (74 loc) · 2.7 KB
/
janus5beam2xyz.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
function [Vx, Vy, Vz, Vz5] = janus5beam2xyz(b1, b2, b3, b4, b5, theta, varargin)
% Usage
% -----
% [Vx, Vy, Vz, Vz5] = janus5beam2xyz(b1, b2, b3, b4, b5, theta, ...
% r, ptch, roll, BinmapType, use3BeamSol)
%
% Where 'BinmapType' is the type of bin mapping to perform on the raw beam velocities.
%
% theta, ptch and roll in RADIANS.
%
% INPUTS
% -------
% b1, b2, b3, b4, b5 [nz -by- nt] matrices of along-beam velocity components.
%
% theta angle between local vertical and the direction
% of the Janus beams.
%
% BinmapType ['linear' or 'nearest' or 'none']
% Whether to map the beam velocities to fixed horizontal
% planes with linear interpolation ('linear') or
% nearest-neighbor interpolation ('nearest') prior to converting
% to instrument coordinates (Ott, 2002; Dewey & Stringer, 2007).
%
% OUTPUTS
% -------
% [Vx, Vy, Vz, Vz5] [x, y, z]-ward components of instrument-referenced velocity vector.
% ** Vz5 is the z velocity component from beam 5 only.**
% Vz is the z velocity component considering the conventional form
% of w (average of the estimates of w from planes 1-2 and 3-4).
%
% x-axis: Increases in beam 1's direction, away from instrument.
% y-axis: Increases in beam 3's direction, away from instrument.
% z-axis: Increases in beam 5's direction, away from instrument.
if length(varargin)>0
r = varargin{1};
ptch = varargin{2};
roll = varargin{3};
BinmapType = varargin{4};
use3BeamSol = varargin{5};
else
BinmapType = 'none';
use3BeamSol = false;
end
if strcmp(BinmapType, 'none')
disp('Bin mapping NOT applied.')
else
disp(['Mapping bins to horizontal planes with *',BinmapType,'* interpolation.'])
[b1, b2, b3, b4, b5] = binmap5(b1, b2, b3, b4, b5, r, theta, ptch, roll, BinmapType);
end
if use3BeamSol==true
[b1, b2, b3, b4] = janus3beamsol(b1, b2, b3, b4);
end
[Nz Nt] = size(b1);
B = cat(3, b1, b2, b3, b4, b5);
uvfac = 1./(2.*sin(theta));
wfac = 1./(4.*cos(theta)); % For w derived from beams 1-4.
% 3rd row: w from the average of the 4 Janus beams.
% 4rd row: w from the 5th beam only.
A = [-1 1 0 0 0;
0 0 -1 1 0;
-1 -1 -1 -1 0;
0 0 0 0 -1];
vxyz = zeros(Nz, Nt, 4);
for nz=1:Nz
disp(['Calculating Vx, Vy, Vz at bin ', num2str(nz), '/', num2str(Nz)])
for nt=1:Nt
vxyz(nz,nt,:) = A*squeeze(B(nz,nt,:));
end
end
Vx = vxyz(:,:,1)*uvfac;
Vy = vxyz(:,:,2)*uvfac;
Vz = vxyz(:,:,3)*wfac;
Vz5 = vxyz(:,:,4);
end