-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathformatcpt.awk
More file actions
74 lines (73 loc) · 1.34 KB
/
Copy pathformatcpt.awk
File metadata and controls
74 lines (73 loc) · 1.34 KB
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
#
# formats GMT makecpt cpt output such that boundaries of color boxes
# look nicer
#
# not quite there yet...
#
#
BEGIN{
line=0;
if(annotate_every==0)
annotate_every=4;
}
{
if($1 != "#" && $1 != "" && $5 != "" &&
$1 != "#COLOR_MODEL"){
line ++;
if(line == 1){
if($1=="nan0x7ffffe00")
x[1]=0;
else
x[1]=$1;
if($5=="nan0x7ffffe00")
x[2]=0;
else
x[2]=$5;
} else {
px[1]=px[2];
if($5=="nan0x7ffffe00")
x[2]=0;
else
x[2]=$5;
}
for(i=1;i<=2;i++){ # reformat limit to look nice
if((line != 1 ) && (i==1))
continue;
if(x[i] < 0){
sign= -1.0;
x[i] = -x[i];
}else{
sign=1.0;
}
f=1.0e-10;
j=-10;
while(x[i] > f){
j++;
f *= 10.0;
}
f /= 100.0;
g=0.0;
while(x[i] > g)
g += f;
if( g < 1e8 && g > 1.0e-8){
# j=(2-j > 0)?(2-j):(0);
# use this version for increased compatibility
#
j=2-j;
if(j <= 0)j=0;
formatstr=sprintf("%s10.%if","%",j);
}else
formatstr="%5.2e";
px[i]=sprintf(formatstr,g*sign);
if(sqrt(px[i]*px[i])<1.0e-8)px[i]=0.0;
}
if(px[1] != px[2]){
if(NR%annotate_every == 0)
printf("%s %3i %3i %3i %s %3i %3i %3i B\n",px[1],$2,$3,$4,px[2],$6,$7,$8);
else
printf("%s %3i %3i %3i %s %3i %3i %3i\n",px[1],$2,$3,$4,px[2],$6,$7,$8);
}
}else{
print($0);
}
}