forked from kodamail/gscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loglabel.gs
153 lines (134 loc) · 2.73 KB
/
loglabel.gs
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
*
* Help is in the end of this script.
*
function loglabel( args )
_version='0.04r3'
if( args = '-help' )
help()
return
endif
'q dims'
res = sublin(result,4)
levmin = subwrd(res,6)
levmax = subwrd(res,8)
fix = subwrd(res,3)
if( fix = 'fixed' )
return
endif
lnlevmin = math_log10(levmin)
lnlevmax = math_log10(levmax)
diff = lnlevmin-lnlevmax
***** set parameters *****
* rule: (diff * n) should be close to 10
* ex. 1000hPa - 100hPa
if( diff >= 0.5 & diff < 1.5 )
base.1 = 8.5
base.2 = 7.0
base.3 = 6.0
base.4 = 5.0
base.5 = 4.0
base.6 = 3.0
base.7 = 2.5
base.8 = 2.0
base.9 = 1.5
base.10= 1.0
n = 10
* loop = 2
endif
* ex. 100hPa - 1hPa
if( diff >= 1.5 & diff < 2.5 )
base.1 = 7.0
base.2 = 5.0
base.3 = 3.0
base.4 = 2.0
base.5 = 1.0
n = 5
* loop = 3
endif
* ex. 1000hPa - 1hPa
if( diff >= 2.5 & diff < 3.5 )
base.1 = 5.0
base.2 = 3.0
base.3 = 2.0
base.4 = 1.0
n = 4
* loop = 4
endif
** ex. 1000hPa - 0.1hPa
* if( diff >= 3.5 & diff < 4.5 )
* base.1 = 5.0
* base.2 = 2.0
* base.3 = 1.0
* n = 3
** loop = 5
* endif
*
** ex. 1000hPa - 0.01hPa
* if( diff >= 4.5 & diff < 5.5 )
* base.1 = 5.0
* base.2 = 2.0
* base.3 = 1.0
* n = 3
** loop = 6
* endif
* ex. 1000hPa - 0.1hPa
if( diff >= 3.5 & diff < 4.5 )
base.1 = 5.0
base.2 = 2.0
base.3 = 1.0
n = 3
endif
* ex. 1000hPa - 0.01hPa, 1000hPa - 0.001hPa, 1000hPa - 0.0001hPa,
if( diff >= 4.5 & diff < 7.5 )
base.1 = 3.0
base.2 = 1.0
n = 2
endif
* ex. 1000hPa - 0.01hPa, 1000hPa - 0.001hPa, 1000hPa - 0.0001hPa,
if( diff >= 7.5 )
base.1 = 1.0
n = 1
endif
* if( diff < 0.5 | diff >= 5.5 )
* if( diff < 0.5 | diff >= 6.5 )
* say 'loglabel : out of range'
* return
* endif
***** set ylevs *****
loop = math_int( diff + 1.5 )
fact = math_pow(10,math_int(math_log10(levmin)))
string = base.n * fact * 10 % ' '
j = 1
while( j <= loop )
div = math_pow(10,j-1)
i = 1
while ( i <= n )
string = string % fact*base.i/div % ' '
i = i + 1
endwhile
j = j + 1
endwhile
'set ylevs 'string
*say 'ylevs (loglabels) = ' % string
return
*
* help
*
function help()
say ' Name:'
say ' loglabel '_version' - set log-p label'
say ' '
say ' Usage:'
say ' loglabel [-help]'
say ''
say ' Note:'
say ' [arg-name] : specify if needed'
say ' (arg1 | arg2) : arg1 or arg2 must be specified'
say ''
say ' "set imprun loglabel" is useful'
say ' set level before running loglabel'
say ''
say ' Copyright (C) 2004-2011 Chihiro Kodama'
say ' Distributed under GNU GPL (http://www.gnu.org/licenses/gpl.html)'
say ''
return