aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Hoffmann <volker@cheleb.net>2016-11-26 22:30:33 +0100
committerVolker Hoffmann <volker@cheleb.net>2016-11-26 22:30:33 +0100
commitcdf309df5f6a24e08122ca29e48df7c4596e7674 (patch)
tree907f21b2b9de8729d9f8bea397aa39b3825a44fd
parentc8f1fd5bcbc0d9fae66ddb01e178ad7661ded22a (diff)
brought in scripts to cut moons from G2 repoHEADmaster
-rw-r--r--IC_Helpers/modic_cutmoons.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/IC_Helpers/modic_cutmoons.py b/IC_Helpers/modic_cutmoons.py
new file mode 100644
index 0000000..5e5e5b7
--- /dev/null
+++ b/IC_Helpers/modic_cutmoons.py
@@ -0,0 +1,42 @@
+"""
+Remove moons from stdin (requires default Genga column ordering).
+
+Call Signature:
+$ python modic_cutmoons.py \
+ --minpid 5 \
+ --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")
+parser.add_argument('--minpid', type=int, default=1, \
+ help="Minimum PID that is cut.")
+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:
+ pid = int(line.strip().split()[1])
+ cnt = int(line.strip().split()[19])
+ if (cnt < args.ce) or (pid < args.minpid):
+ 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