aboutsummaryrefslogtreecommitdiffstats
path: root/IC_Helpers/modic_cutmoons.py
blob: 8ef5c0c149efbe640a8b41ed46b12d51178d0b2e (plain)
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
"""
Remove moons from stdin (requires default Genga column ordering).
python killmoons2.py --ce 95000 < $output_to_change > $changed_output
"""

import numpy as np
import argparse
import sys

# Parse arguments
parser = argparse.ArgumentParser()
parser.add_argument('--ce', type=int, required=True, \
                    help="Number of close encounters required for removal")
args = parser.parse_args()

# Read lines from stdin
lines_in = sys.stdin.read().rstrip("\n").split("\n")

# Remove particles with too many CEs
lines_out = []; cce = 0
for line in lines_in:
    if not int(line.strip().split()[19]) >= args.ce:
        lines_out.append(line)
    else:
        sys.stderr.write("Removed Particle %i (%i CEs) \n" % \
            ( int(line.strip().split()[1]), int(line.strip().split()[19]) ) )
        cce += 1

# Removed Stats
sys.stderr.write("Removed %i Particles\n" % cce)

# Dump to stdout
for line in lines_out:
    print line