-
Notifications
You must be signed in to change notification settings - Fork 9
/
xyzf2vtk.awk
55 lines (52 loc) · 1.08 KB
/
xyzf2vtk.awk
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
#convert x y z time mag file to VTK format
BEGIN{
}
{
if((substr($1,1,1)!="#")&&(NF>=5)){
n++;
x[n]=$1;
y[n]=$2;
z[n]=$3;
time[n]=$4;
mag[n]=$5;
}
}
END{
print("# vtk DataFile Version 3.0");
printf("converted from %s\n",FILENAME);
if(binary)
print("BINARY")
else
print("ASCII");
print("DATASET POLYDATA");
printf("POINTS %i float\n",n);
if(binary){
for(i=1;i<=n;i++)
printf("%g %g %g\n",x[i],y[i],z[i]) | "asciifloat2bebin"
close("asciifloat2bebin")
}else{
for(i=1;i<=n;i++)
printf("%g %g %g\n",x[i],y[i],z[i]);
}
printf("POINT_DATA %i\n",n);
print("SCALARS time float 1");
print("LOOKUP_TABLE default");
if(binary){
for(i=1;i<=n;i++)
printf("%g ",time[i]) | "asciifloat2bebin"
close("asciifloat2bebin")
}else{
for(i=1;i<=n;i++)
printf("%g\n",time[i]);
}
print("SCALARS mag float 1");
print("LOOKUP_TABLE default");
if(binary){
for(i=1;i<=n;i++)
printf("%g ",mag[i]) | "asciifloat2bebin"
close("asciifloat2bebin")
}else{
for(i=1;i<=n;i++)
printf("%g\n",mag[i]);
}
}