Example #1
0
def make_xs_1g(h5_file='nuc_data.h5', data_dir='xs_html/'):
    """Makes an atomic weight table and adds it to the hdf5 library.

    Keyword Args:
        * h5_file (str): path to hdf5 file.
        * data_dir (str): path to that holds nuclide html one group neutron 
          cross section files.
    """
    # Get nulcide list from directory
    nuclist = [nuc.partition('.html')[0] for nuc in os.listdir(data_dir)]
    nuclist_zz = isoname.LLAAAM_2_zzaaam_List(nuclist)
    nuclist_zz.sort()
    nuclist = isoname.zzaaam_2_LLAAAM_List(nuclist_zz)

    # Open the HDF5 File
    kdb = tb.openFile(h5_file, 'a')

    # Create neutron group
    if not hasattr(kdb.root, 'neutron'):
        neutron_group = kdb.createGroup('/', 'neutron', 'Neutron Cross Sections')

    # Create xs_1g Group
    xs_1g_group = kdb.createGroup("/neutron", "xs_1g", "One Group Neutron Cross Section Data")

    # Loop through all energy types
    for xsef in xs_1g_energy_flags:
        # Create table for this energy 
        xs_1g_table = kdb.createTable(xs_1g_group, xsef, xs_1g_desc, "({0}) [barns]".format(xs_1g_energy_flags[xsef]))
        nucrow = xs_1g_table.row

        for nuc in nuclist:
            iso_LL = isoname.mixed_2_LLAAAM(nuc)
            iso_zz = isoname.LLAAAM_2_zzaaam(iso_LL)

            nucrow['iso_LL'] = iso_LL
            nucrow['iso_zz'] = iso_zz

            for xstf in xs_1g_type_flags:
                nucrow[xstf] = get_xs_from_html_file(nuc, data_dir, xs_1g_type_flags[xstf], xs_1g_energy_flags[xsef])

            nucrow['sigma_s'] = nucrow['sigma_e'] + nucrow['sigma_i']

            nucrow['sigma_a'] = nucrow['sigma_gamma'] + nucrow['sigma_f'] + nucrow['sigma_alpha'] + \
                                nucrow['sigma_proton'] + nucrow['sigma_deut'] + nucrow['sigma_trit'] + \
                                nucrow['sigma_2n'] + nucrow['sigma_3n'] + nucrow['sigma_4n']

            # Write out this row 
            nucrow.append()

        # Writr out this table
        xs_1g_table.flush()

    # Close the hdf5 file
    kdb.close()
Example #2
0
 def test_zzaaam_2_LLAAAM_List(self):
     assert_equal(isoname.zzaaam_2_LLAAAM_List([942390, 80160]), 
         ["PU239", "O16"])