-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclear_ms_flags.py
More file actions
44 lines (31 loc) · 975 Bytes
/
clear_ms_flags.py
File metadata and controls
44 lines (31 loc) · 975 Bytes
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
#!/usr/bin/env python3
"""
Clear all flags from a measurement set.
"""
import sys
from pathlib import Path
# Add src to path
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
from casatools import table
def clear_flags(ms_path):
"""Clear all flags in MS (set to False)."""
print(f"Clearing flags in {ms_path}...")
tb = table()
tb.open(ms_path, nomodify=False)
# Get FLAG column shape
flags = tb.getcol("FLAG")
print(f" FLAG shape: {flags.shape}")
print(f" Currently flagged: {flags.sum() / flags.size * 100:.2f}%")
# Set all to False
flags[:] = False
tb.putcol("FLAG", flags)
# Verify
flags_check = tb.getcol("FLAG")
print(f" After clearing: {flags_check.sum() / flags_check.size * 100:.2f}%")
tb.close()
print(" Done")
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python clear_ms_flags.py <ms_path>")
sys.exit(1)
clear_flags(sys.argv[1])