#!/usr/bin/python # get_wrong-meas.py # Jure Skvarc # Find files with incorrect measurements on the basis that 4th column in the # input file is bigger than 0.1 from string import * import fileinput import re import os class Star: pass # First read stars which have to be tested testfile = 'act150s-compare.dat' tstars = {} for line in fileinput.input(testfile): l = split(line) if float(l[3]) > 0.1 and float(l[2]) < 400000: ns = Star() ns.id = l[0] ns.int = float(l[2]) tstars[ns.id] = ns datfiles = '^H.*dat' datre = re.compile(datfiles) files = os.listdir('.') faults = {} for name in files: if datre.search(name) != None: if os.path.isfile(name): for line in fileinput.input(name): l = split(line) if len(l) > 8: intensity = float(l[3]) id = l[7] if tstars.has_key(id) and tstars[id].int == intensity: if faults.has_key(name): faults[name] = faults[name] + 1 else: faults[name] = 0 for a in faults.keys(): if faults[a] > 0: print a, faults[a]