-
Notifications
You must be signed in to change notification settings - Fork 2
/
contour_angle.m
139 lines (123 loc) · 4.29 KB
/
contour_angle.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
%==========================================================================
% Draw 2d contour for angle (0-360)
%
% input :
% xx --- grid x coordinate
% yy --- grid y coordinate
% zz_360 --- grid angle ranging [0, 360]
% zz_180 --- grid angle ranging [-180, 180]
% LevelList --- isolines list
%
% output :
%
% Usage:
% contour_angle(xx, yy, zz_360, zz_180, LevelList);
%
% Siqi Li, SMAST
% 2020-07-16
%==========================================================================
function contour_angle(xx, yy, zz_360, zz_180, LevelList, varargin)
varargin = read_varargin(varargin, ...
{'FontSize', 'LabelSpacing', 'Color'}, ...
{ 12, 200, 'k'});
% 1) draw isolines for (0 90)
theta = zz_180;
theta(theta>=90 | theta<=0) = nan;
vals = sind(theta);
list = LevelList;
list(list>=90 | list<=0) = [];
[C, h] = contour(xx, yy, vals, 'LevelList', sind(list), 'LabelFormat', @fun1, 'Color', Color);
% [~, C] = read_contourC(C, 'MinNum', MinNum);
clabel(C, h, 'fontsize',FontSize, ...
'LabelSpacing', LabelSpacing, ...
'Color', Color);
% 2) draw isolines for (90 180)
theta = zz_360;
theta(theta>=180 | theta<=90) = nan;
vals = sind(theta);
list = LevelList;
list(list>=180 | list<=90) = [];
[C, h] = contour(xx, yy, vals, 'LevelList', sind(list), 'LabelFormat', @fun2, 'Color', Color);
% [~, C] = read_contourC(C, 'MinNum', MinNum);
clabel(C, h, 'fontsize',FontSize, ...
'LabelSpacing', LabelSpacing, ...
'Color', Color);
% 3) draw isolines for (180 270]
theta = zz_360;
theta(theta>=270 | theta<=180) = nan;
vals = cosd(theta);
list = LevelList;
list(list>=270 | list<=180) = [];
[C, h] = contour(xx, yy, vals, 'LevelList', cosd(list), 'LabelFormat', @fun3, 'Color', Color);
% [~, C] = read_contourC(C, 'MinNum', MinNum);
clabel(C, h, 'fontsize',FontSize, ...
'LabelSpacing', LabelSpacing, ...
'Color', Color);
% 4) draw isolines for (270 360)
theta = zz_180;
theta(theta<=-90 | theta>=0) = nan;
vals = cosd(theta);
list = calc_lon_180(LevelList);
list(list<=-90 | list>=0) = [];
[C, h] = contour(xx, yy, vals, 'LevelList', cosd(list), 'LabelFormat', @fun3, 'Color', Color);
% [~, C] = read_contourC(C, 'MinNum', MinNum);
clabel(C, h, 'fontsize',FontSize, ...
'LabelSpacing', LabelSpacing, ...
'Color', Color);
% 5) draw isolines for 0
if ismember(0, LevelList) || ismember(360, LevelList)
theta = zz_180;
theta(theta<-70 | theta>70) = nan;
vals = sind(theta);
[C, h] = contour(xx, yy, vals, 'LevelList', sind(0), 'LabelFormat', @fun1, 'Color', Color);
% [~, C] = read_contourC(C, 'MinNum', MinNum);
clabel(C, h, 'fontsize',FontSize, ...
'LabelSpacing', LabelSpacing, ...
'Color', Color);
end
% 6) draw isolines for 90
if ismember(90, LevelList)
theta = zz_360;
theta(theta>=160 | theta<=20) = nan;
vals = cosd(theta);
[C, h] = contour(xx, yy, vals, 'LevelList', cosd(90), 'LabelFormat', @fun4, 'Color', Color);
% [~, C] = read_contourC(C, 'MinNum', MinNum);
clabel(C, h, 'fontsize',FontSize, ...
'LabelSpacing', LabelSpacing, ...
'Color', Color);
end
% 7) draw isolines for 180
if ismember(180, LevelList)
theta = zz_360;
theta(theta<110 | theta>250) = nan;
vals = sind(theta);
[C, h] = contour(xx, yy, vals, 'LevelList', sind(180), 'LabelFormat', @fun2, 'Color', Color);
% [~, C] = read_contourC(C, 'MinNum', MinNum);
clabel(C, h, 'fontsize',FontSize, ...
'LabelSpacing', LabelSpacing, ...
'Color', Color);
end
% 8) draw isolines for 270
if ismember(270, LevelList)
theta = zz_360;
theta(theta<200 | theta>340) = nan;
vals = cosd(theta);
[C, h] = contour(xx, yy, vals, 'LevelList', cosd(90), 'LabelFormat', @fun3, 'Color', Color);
% [~, C] = read_contourC(C, 'MinNum', MinNum);
clabel(C, h, 'fontsize',FontSize, ...
'LabelSpacing', LabelSpacing, ...
'Color', Color);
end
end
function labels = fun1(vals)
labels = round(asind(vals));
end
function labels = fun2(vals)
labels = 180 - round(asind(vals));
end
function labels = fun3(vals)
labels = 360 - round(acosd(vals));
end
function labels = fun4(vals)
labels = round(acosd(vals));
end