-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjects.sh
101 lines (100 loc) · 1.52 KB
/
objects.sh
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
#!/bin/sh
sed "1d" objects-raw.csv |
sort -t, -k "1,1" -k "2,2n" -k "3,3n" |
awk -F, '
function printobject() {
if (y == "~")
y = x;
if (pa == "~")
pa = 0;
printf("%s%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n", \
id1, id2, alpha, delta, psa, x, y, pa, type, \
cat_M, cat_C, cat_U, cat_NGC, cat_IC, cat_Mel, cat_Cr, name);
if (alpha == "~")
print("# alpha missing");
if (delta == "~")
print("# delta missing");
if (type == "")
print("# type missing");
if (x == "~" && type != "FC")
print("# x missing");
if (y == "~" && type == "GAL")
print("# y missing");
if (pa == "~" && type == "GAL")
print("# pa missing");
alpha = "~";
delta = "~";
x = "~";
y = "~";
pa = "~";
type = "";
cat_M = "";
cat_C = "";
cat_U = "";
cat_NGC = "";
cat_IC = "";
cat_Mel = "";
cat_Cr = "";
name = "";
}
BEGIN {
print("# id, alpha, delta, psa, x, y, pa, type, cat_M, cat_C, cat_U, cat_NGC, cat_IC, cat_Mel, cat_Cr, name");
}
NR > 1 {
if (id1 != $1 || id2 != $2) {
printobject()
}
}
END {
printobject();
}
{
id1 = $1;
id2 = $2;
}
$5 != "" {
alpha = $5;
}
$6 != "" {
delta = $6;
}
$7 != "" {
psa = $7;
}
$9 != "" {
x = $9;
}
$10 != "" {
y = $10;
}
$11 != "" {
pa = $11;
}
$12 != "" {
type = $12;
}
$13 != "" {
cat_M = $13;
}
$14 != "" {
cat_C = $14;
}
$15 != "" {
cat_U = $15;
}
$16 != "" {
cat_NGC = $16;
}
$17 != "" {
cat_IC = $17;
}
$18 != "" {
cat_Mel = $18;
}
$19 != "" {
cat_Cr = $19;
}
$20 != "" {
name = $20;
}
' >objects.csv