def get_xs_from_file(filename, eng, chan): """Parses out a cross section from a KAERI file. Parameters ---------- filename : str Local path to a KAERI neutron cross section summary html file. eng : str Energy flag to find this cross section for. (Must be key of simple_xs_energy dictionary). chan : str Cross section (interaction channel) to find. (Must be key of simple_xs_channels dict). Returns ------- data : float Microscopic cross section in [barns]. """ with open(filename, 'r') as f: in_channel = False for line in f: if simple_xs_channels[chan] in line: in_channel = True if in_channel and ("<li>" + simple_xs_energy[eng] in line): du = line.partition("=")[2].split() data = float(du.pop(0)) unit = "" for u in du: unit = unit + u unit = unit.partition("\\")[0] data = to_barns(data, unit) return data elif in_channel and ("</ul>" in line): # XS not defined for this energy, returning zero return 0.0 # If the specific XS was not found in this file, return zero return 0.0
def get_xs_from_file(filename, eng, chan): """Parses out a cross section from a KAERI file. Parameters ---------- filename : str Local path to a KAERI neutron cross section summary html file. eng : str Energy flag to find this cross section for. (Must be key of simple_xs_energy dictionary). chan : str Cross section (interaction channel) to find. (Must be key of simple_xs_channels dict). Returns ------- data : float Microscopic cross section in [barns]. """ with open(filename, 'r') as f: in_channel = False for line in f: if simple_xs_channels[chan] in line: in_channel = True if in_channel and ("<li>"+simple_xs_energy[eng] in line): du = line.partition("=")[2].split() data = float(du.pop(0)) unit = "" for u in du: unit = unit + u unit = unit.partition("\\")[0] data = to_barns(data, unit) return data elif in_channel and ("</ul>" in line): # XS not defined for this energy, returning zero return 0.0 # If the specific XS was not found in this file, return zero return 0.0
def test_to_barns(): assert_equal(3E3, utils.to_barns(3, 'KB'))
def test_to_barns(): assert_equal(3e3, utils.to_barns(3, "KB"))