forked from athurnherr/LDEO_IX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
switchbeams.m
81 lines (65 loc) · 1.63 KB
/
switchbeams.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
function [d,p]=switchbeams(d,p)
% function [d,p]=switchbeams(d,p)
%
% simple routine to "correct" if beams are switched
% it only performs this in 2D which is only roughly correct
%
% p.beam_switch=[ 1 1 1] switch u and v beam pairs down looker
% p.beam_switch=[ 1 0 2] switch u not v beam pairs up looker
%
%
disp('SWITCHBEAMS: ******** switch beams ***********')
if existf(p,'beam_switch')==0
disp(' need to give switch matix p.beam_switch ')
return
end
% first rotate to instrument coordinates
%
% heading of beam 3 is
hrot = p.drot + d.hdg(p.beam_switch(3),:);
% check if called before
if existf(d,'ru_orig')==0
d.ru_orig=d.ru;
d.rv_orig=d.rv;
d.bvel_orig=d.bvel;
else
disp(' found ru_orig, will use those to rotate from ')
end
if p.beam_switch(3)==1
iz=d.izd;
elseif p.beam_switch(3)==2
iz=d.izu;
else
disp(' which instrument shall I switch? ')
return
end
% backrotate to instrument coordinates
[rui,rvi]=uvrot(d.ru_orig(iz,:),d.rv_orig(iz,:),repmat(-hrot,[length(iz),1]));
if p.beam_switch(3)==1
[bui,bvi]=uvrot(d.bvel_orig(:,1),d.bvel_orig(:,2),-hrot');
end
% switch beams
if p.beam_switch(1)
rui=-rui;
bui=-bui;
warn=(' switched u-beam pair in instrument coordinates');
disp(warn)
p.warnp(size(p.warnp,1)+1,1:length(warn))=warn;
end
if p.beam_switch(2)
rvi=-rvi;
bvi=-bvi;
warn=(' switched v-beam pair in instrument coordinates');
disp(warn)
p.warnp(size(p.warnp,1)+1,1:length(warn))=warn;
end
% rotate to earth coordinates
[ru,rv]=uvrot(rui,rvi,repmat(hrot,[length(iz),1]));
[bu,bv]=uvrot(bui,bvi,hrot');
d.ru(iz,:)=ru;
d.rv(iz,:)=rv;
if p.beam_switch(3)==1
d.bvel(:,1)=bu;
d.bvel(:,2)=bv;
end
return