EGS Brachy
An egs++ user code for rapid brachytherapy calculations
Loading...
Searching...
No Matches
test.py
Go to the documentation of this file.
1"""
2
3A test to ensure egs_brachy superposition mode calculations match previous
4calculations when egs_brachy was in a known good state.
5
6"""
7import math
8import os
9import re
10
11from eb_tests.utils import (compare_3ddose_files, doses_approx_equal,
12 extract_all_doses, read3ddose)
13
14EGSINP = "tg43mode.egsinp"
15TIME_LIMIT_S_PER_MHZ = 2000/2993. # s / MHz
16NCOMPARE = 100
17
18def get_n_highest_dose_pairs(dose1, dose2, n=NCOMPARE):
19 return sorted(zip(dose1, dose2))[-NCOMPARE:]
20
21def compare_results(egslst, inp_name):
22
23 gold_standard = read3ddose(os.path.join(os.path.dirname(os.path.abspath(__file__)), "gold_standard.3ddose"))
24 run_doses = read3ddose(inp_name+".phantom.3ddose")
25
26 dose_pairs = get_n_highest_dose_pairs(gold_standard['doses'], run_doses['doses'])
27
28 dose_diff = [abs(a-b)/a for a, b in dose_pairs]
29
30 doses_close = max(dose_diff) < 0.01
31
32 rd, gs = list(zip(*dose_pairs))
33 return doses_close, rd, gs
34
get_n_highest_dose_pairs(dose1, dose2, n=NCOMPARE)
Definition test.py:18