forked from bolidozor/js9
-
Notifications
You must be signed in to change notification settings - Fork 0
/
funcnts2flot
executable file
·88 lines (85 loc) · 1.56 KB
/
funcnts2flot
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
#!/bin/sh
LC_NUMERIC=en_US.ISO8859-1
export LC_NUMERIC
files="None"
while [ x"$1" != x ]; do
case $1 in
-title)
title="$2"
shift
shift
continue;;
-file)
files="$2"
shift
shift
continue;;
*)
break;;
esac
done
awk -v title="$title" '
BEGIN{
mode=1
initparam=0
npts=0
xlabel="unknown"
ylabel="unknown"
}
mode==1{
if( initparam == 0 ){
if( files == "None" ){
files=""
dofile="true"
}
else{
dofile="false"
}
initparam=1
if( title == "" ){
title = "RadialProfile"
}
}
if( dofile == "true" && $1 == "#" && $2 == "data" && $3 == "file:" ){
if( files != "" ) files = files ","
files = files $4
}
else if( $1 == "#" && $2 == "radii:" ){
xlabel = $3
}
else if( $1 == "#" && $2 == "surf_bri:" ){
ylabel = $3
}
else if( $1 == "----" ){
gsub(/"/,"\\\"", files)
printf "{\042color\042: \042green\042, \042label\042 : \042surf_bri(%s) vs. avg_radius(%s)\042, \042points\042 : {\042errorbars\042 : \042y\042, \042yerr\042 : {\042show\042 : \042true\042, \042color\042 : \042red\042}}, ", ylabel, xlabel
mode = 2
next
}
}
mode==2{
if( NF == 12 ){
if( npts == 0 ){
printf "\042data\042 : ["
} else {
printf ","
}
npts = npts + 1
if( $9 != "NA" ){
printf "[%.2f, %s, %s]", ($9+$10)/2, $7, $8
}
else{
print "ERROR: annulus and circle regions only" > "/dev/stderr"
exit 1
}
}
else{
mode = 3
}
next
}
END{
printf "]}"
}
' files="$files"
exit 0