From: Sam Moore Date: Mon, 20 Aug 2012 05:51:16 +0000 (+0800) Subject: Initial tests of processing (calculate dI/dE) X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=bb17b8b51e56de0189083afeb5db8b58b9e1f268;p=matches%2Fhonours.git Initial tests of processing (calculate dI/dE) Uncalibrated. You know what? These results look like *SHIT*. --- diff --git a/research/TCS/2012-08-20/processed.png b/research/TCS/2012-08-20/processed.png new file mode 100644 index 00000000..a0470c5a Binary files /dev/null and b/research/TCS/2012-08-20/processed.png differ diff --git a/research/TCS/process.py b/research/TCS/process.py new file mode 100755 index 00000000..c2797590 --- /dev/null +++ b/research/TCS/process.py @@ -0,0 +1,55 @@ +#!/usr/bin/python -u + +# +# @file process.py +# @purpose Process TCS data +# Takes S(E) = dI/dE +# @author Sam Moore +# @date August 2012 +# + +import sys +import os +import re # Regular expressions - for removing comments +import odict #ordered dictionary + +def main(): + + if (len(sys.argv) != 2): + sys.stderr.write(sys.argv[0] + " - Require 1 argument (filename)\n") + return 1 + + input_file = open(sys.argv[1], "r") + data = odict.odict([]) + for line in input_file: + line = re.sub("#.*", "", line).strip("\r\n ") + if len(line) == 0: + continue + line = line.split("\t") + #sys.stdout.write(str(line)) + if float(line[1]) in data: + data[float(line[1])].append(float(line[2])) + else: + data[float(line[1])] = [float(line[2])] + + + for dac in data.keys(): + avg = sum(data[dac], 0.0) / len(data[dac]) + data[dac] = avg + + + result = [] + for i in range(0, len(data.keys())-1): + dE = data.keys()[i+1] - data.keys()[i] + dI = data[data.keys()[i+1]] - data[data.keys()[i]] + result.append((data.keys()[i], dI/dE)) + sys.stdout.write(str(data.keys()[i]) + "\t" + str(data[data.keys()[i]]) + "\t" + str(dI/dE) + "\n") + + #for dac in data: + # sys.stdout.write(str(dac) + "\t" + str(data[dac]) + "\n") + + return 0 + + +if __name__ == "__main__": + sys.exit(main())