From f67b43d57e5909de214ef47368be97de298ad476 Mon Sep 17 00:00:00 2001 From: Spect4tor <74201981+Spect4tor@users.noreply.github.com> Date: Mon, 15 Nov 2021 17:22:23 +0100 Subject: [PATCH 1/2] wrote function to extract spillover from out files --- grasp_out.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 grasp_out.py diff --git a/grasp_out.py b/grasp_out.py new file mode 100644 index 0000000..c07f5c9 --- /dev/null +++ b/grasp_out.py @@ -0,0 +1,18 @@ +import numpy as np + +def extract_spillover(fname): + """Takes a filename of an .out file and searches it for the "Relative Power hitting reflector" values, calculates the "spillover" value given in the line below and returns a dictionary with the PO-value pairs""" + spill_dict={} + names_PO=[] + values_spill=[] + f=open(fname,"r") + for num,line in enumerate(f.readlines()): + if "get_currents" in line: + name=line.split()[0] + names_PO.append(name) + if "Relative power" in line: + value=float(line.split()[4]) + values_spill.append([value,-10*np.log10(value)]) + for i in range(len(names_PO)): + spill_dict[names_PO[i]]=values_spill[i] + return spill_dict \ No newline at end of file From b1d623c018edb5f27714b083e967d924527b7509 Mon Sep 17 00:00:00 2001 From: Spect4tor <74201981+Spect4tor@users.noreply.github.com> Date: Mon, 15 Nov 2021 17:29:18 +0100 Subject: [PATCH 2/2] added newline at the bottom --- grasp_out.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grasp_out.py b/grasp_out.py index c07f5c9..27a8cb4 100644 --- a/grasp_out.py +++ b/grasp_out.py @@ -15,4 +15,4 @@ def extract_spillover(fname): values_spill.append([value,-10*np.log10(value)]) for i in range(len(names_PO)): spill_dict[names_PO[i]]=values_spill[i] - return spill_dict \ No newline at end of file + return spill_dict