Beispiel #1
0
 def test_hl_isotopes(self):
     res = [
         PQ.Time(12.33, 0., ureg.year),
         PQ.Time(5.271, 0., ureg.year),
         PQ.Time(1.265e+09, 0., ureg.year),
         PQ.Time(30.04, 0., ureg.year)
     ]
     values = [_dh._hl[isotope] for isotope in self.test_isotopes]
     self.assertEqual(values, res)
Beispiel #2
0
 def test_time_evolution_simple(self):
     isotope = PQ.Isotope(3, 1, 0)
     data = {
         "det1":
         OrderedDict([(isotope, StoredData(PQ.ProductionYield(10., 2.)))])
     }
     time_evo = TimeEvolution(**self.config)
     time_evo.invoke(data)
     res = (1 - exp(-log(2) * PQ.Time(1, unit=ureg.year) / _dh._hl[isotope])) \
           * exp(-log(2) * PQ.Time(1, unit=ureg.year)/ _dh._hl[isotope]) * PQ.ProductionYield(10., 2.)
     self.assertEqual(data["det1"][PQ.Isotope(3, 1, 0)]["ProductionYield"],
                      res)
 def test_parsing_const_val_with_unit_simple(self):
     config = {
         "type": "scalar",
         "multiplier": "DoseRate",
         "multiplicand": "const:100 hour",
         "product": "Dose"
     }
     mul_op = MultiplicationOperator(**config)
     self.assertEqual(mul_op.multiplicand, PQ.Time(100, unit=ureg.hour))
Beispiel #4
0
 def _parse_config(time):
     ts = time.split(" ")
     return PQ.Time(float(ts[0]), 0., PQ.Time._get_conversion_dict()[ts[1]])
Beispiel #5
0
half_life_vals = {}

str_to_unit = {
    "s": ureg.second,
    "h": ureg.hour,
    "d": ureg.day,
    "m": ureg.minute,
    "y": ureg.year
}
rg = re.compile("\d+\.?\d*[eE]?[+-]?\d*")
for line in f_raw.readlines()[3:]:
    if not re.match("^[A-Z]", line):
        continue
    line = line.replace('\n', '')
    sl = line.split(' ')
    if "None" not in sl[-1]:
        time = PQ.Time(
            map(float, rg.findall(sl[-1]))[0], 0., str_to_unit[sl[-1][-1]])
    else:
        #stable isotope
        time = PQ.Time(-1., -1., ureg.year)
    half_life_vals[PQ.Isotope(int(re.findall(r'\d+',
                                             sl[0])[0]), sl[0].split('-')[0],
                              1 if sl[0].endswith("M") else 0)] = time

f_raw.close()

f_pickle = open("../data/half_lifes.p", 'w')
pickle.dump(half_life_vals, f_pickle)
f_pickle.close()
Beispiel #6
0
 def test_config_parsing(self):
     time_evo = TimeEvolution(**self.config)
     self.assertEqual(time_evo.irr_time, PQ.Time(1., 0., ureg.year))
     self.assertEqual(time_evo.cool_time, PQ.Time(1., 0., ureg.year))